Learn How to Program Using Any Web Browser
The language is suitably light and simple, the book well-structured and broken down into easily digested chunks. The order in which concepts are introduced is fairly traditional for a language tutorial: first we get types, variables and statements, before moving on to conditionals, loops, and functions, followed by arrays and objects before finishing with event-driven programming. Davis' decision to leave string handling till last seems a little perverse and personally I would have introduced functions earlier.
My real complaints about this book centre on the abstract nature of the discussion. There are very few real world examples that could be useful to anyone. The best you get is a version of "Rock, Paper, Scissors" in Chapter 3, and an 'auction' application. The book would have been improved dramatically if the end result of your study was a few things you could actually point to.
I also have a complaint about the target audience for this book. The web page for the book at the publishers states that "The target reader is likely a twelve- or thirteen-year-old, who is just starting to get curious about what makes a computer work -- or an office worker who has been using computer applications for years, and would like to spend some time delving deeper into what makes them tick." Most adults and even teenagers don't want to 'learn how to program' as much as they want to learn how to use a tool to perform a task. If your tool is JavaScript, then it's almost certain your task is related to building web pages, but this gets little real attention from Davis. For even younger students, this book totally lacks anything to hold their attention -- the lack of real-world examples hurts here.
I also take issue with the title: this book doesn't really teach 'programming' much at all. It certainly teaches you to write JavaScript, but where are the sections about the real lessons of programming, such as top-down vs. bottom-up design, or breaking a task up into chunks? Even debugging has little coverage -- a single thirty-page chapter, half of which is specific to JavaScript or the throwing and handling of exceptions. Since the work of Papert and others at MIT twenty-five years ago, we've learned a great deal about how to teach programming concepts in a simple manner, but Davis appears to have ignored all this and given us a language tutorial. The publisher's web page for the book says "very emphatically, this is not a book about programming JavaScript." If that's so then I'd argue that it isn't a book about learning the principles of programming either.
It is obvious from this book that Davis is an excellent writer; if he had tried to write a book to teach JavaScript and had focused on the tasks for which it is often used this, volume may have been superb. As it is, he has shot for a higher goal and fallen far too short.
If you would like to check it out for yourself, you can go to the web page for the book where there is sample chapter, the Table of Contents (though they call it a "Detailed TOC" as distinct from the 'Table of Contents,' which is just a list of 11 chapter titles) and index, all in PDF format.
I went looking for a book that I could give to my 11-year-old daughter now that she has become interested in "what Daddy does." I'm still looking, I'm certain that this one isn't it.
You can purchase Learn How to Program Using Any Web Browser from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Why this:
Harold Davis has started with a marvelous idea, teaching programming using a language available on all platforms, JavaScript
Why not this:
Harold Davis has started with a marvelous idea, teaching programming using a language available on all platforms, Java
Maybe because that book has already been written?
The best way to learn how to program is to sit down in front of a computer with a reference handy and dive in!
geeky shirts.. funny shirts
The web browser is *not* an IDE. You do the programming in vim/gedit/notepad. (emacs is a bit much for javascript IMO)
I know this was meant as funny, but Java is a normal accepted language. Because it is more structured then Perl or other languages, I highly reccomend Java to beginners.
Javascript, or ECMA script, is a terrible non-standardized (despite being created by a standards board) peice of junk.
I'm a good cook. I'm a fantastic eater. - Steven Brust
5/5? 5/10?
useless
I'd have to disagree with you. The syntax is very similar to C/C++/Java - (don't flame me because its not *EXACTLY* the same - and it is more limited) - and secondly, "but it's full of exploits" - Maybe the interpretter on some platforms gives it power outside the boundries of the language but that is *NOT* the language's fault. Javascript is a tool and has its place and usefulness just like any other tool.
If the book's actual target audience is 12ish, I don't really see JS keeping the attention of children.
I also don't think most 12-14 year olds really want an in-depth discussion of programming principals, like the review suggest. I think they'd rather it be fun. That could just be me...
Though it's not free and only works on a couple of platforms, I think Flash and ActionScript are a great way to introduce people, especially young people, to programming. A few simple lines of code can replace the timeline based motion tweening and is a great, visual way to see how your code works. From there kids can add a few lines of code to make sound and images work interactively.
True, it might not turn them into kernel hackers, but most kids would probably more interested in learning to program if it kept their attention. Action script can be very easy with many neat things taking only a few lines of codes but it can grow as your young programmer learns more and seeks more challenging projects.
- It has to be easy to learn and use. In order to build the novice's confidence, it should encourage early successes. It should be easy to debug.
- The tools have to be accessable to the student. Ideally, you want to use a language which is already installed on their computer, or at worse be a free download which will run on all major platforms.
- It has to be practical. If the student can't use it to do something which is useful TO THEM fairly early on in the learning process, they probably won't stick with it.
- It has to provide a good foundation for future learning. This means that it should support all the standard code constructs and have a syntax similar to other more advanced languages. It also means that it shouldn't teach them any bad habits they'll have to unlearn later.
I'm sure there are other qualities, but this is a pretty good starting list. On the basis of this simple list we can eliminate a lot of potential candidates as first language.Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
The reviewer makes an excellent point. Programming is a *means to an end*. People don't learn how to program just so they can say they program. To not put the art of learning programming into the context of real-world applications is counterproductive.
Then again, pardon me for being cynical, but this seems reflective of the new type of motivation we have these days behind people choosing vocations. People go to law school, not because they have any interest in law, but because they're under the impression they can make money if they're a lawyer. The bottom line is that if you get into any vocation without having any passion or interest, you'll never be any good at it.
This reminds me of the arguments over which programming language is best. It's moot. The application and environment should dictate which tools be used. Likewise, if you want to learn to program, and don't know for what platform or application you're interested, you're on the wrong track... figure that out before you buy any books.
Yes, that's just what we need - every Joe, Shmoe, and Harry that surfs the web to start thinking he's hot shit on Sunday because he's a "programmer", and now he can go out and grab one of those elite tech jobs!
Of course, knowing the stupidity of HR, they'll likely get hired.
~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
But Python is free and available on nearly all OSs. And a decent language. And it comes with a development environment (not a great one, but it works!). And it has a sensible structure (similar to many other languages). And it comes with complete documentation. And....
... well, it's available everywhere, and you can find help. But you need to deal with pointers and casts, and the warnings when you mishandle them are obscure. And then there's the gruesome things that you can get used to doing with the preprocessor...that make your code unreadable.
Now many of the same things could be said for Java, but I think that Python makes a better first language. In fact, the only competition that I see is Ruby and Lisp. But if you speak English, you'll probably find more help for Python. (And Ruby diagnostics need work!)
Java is a popular first language in an academic setting, and in that setting it makes sense. But for learning on your own I feel that Python is a better choice.
C
C++....that's an unmentionable monstrosity. Sorry, but I'd sooner start a beginner with Ada. OTOH, most of the advantages of C++ can be captured in a more reasonable way with D (from Digital Mars). It's also available for free, but it's not available at all for the Mac. Even so, I thing even D is too complex for a first language (besides, it's still beta, or possibly alpha [it's gotten up to around version 0.8 over the last couple of years]).
I think we've pushed this "anyone can grow up to be president" thing too far.
Here is a course I helped design to teach Javascript programming to CS170 students-- pre-business majors.
Javascript was our idea of a language replacement for what we were using True Basic. The idea was to have a language where the students wouldn't constantly question why they were learning it, and to pretend like we were doing some level of web enabled e-commerce site programming.
The problems we have found come from the lack of structure of the language, and combined with the browser's desire to fix as much as it can. While this is a nice feature for a real developer, it sucks when you have to tell a student "I know it works on the browser, but it's still wrong."
The other issue is trying to keep to a small set of structures for programming, and making sure the TAs for the course don't get too ambitious with teaching dozens of alternative ways to accomplish the same thing. For students at this level, they just get confused.
But it does work well, and it is nice not having to ask students to buy another piece of software to program with at home. (Unlike True Basic.)
I demand a million helicopters and a DOLLAR!
VB is actually a non-sucky choice as a teaching language. It's pretty beginner-friendly, has practical applicability, and (in the form of VBA) is already available on most computers. Most importantly, you can use the same language to teach both procedural and object-oriented concepts, something that you can't do in Java. VB/VBA is far from perfect but there are far worse languages to chose as a teaching tool.
Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
FYI, neither C or c++ have a built-in output function. printf() comes from #include'ing stdio, and even then it's optional.
Prototype OOP is weird at first, but amazingly powerful.
Also, javascript support's eval's and even closures: ( pardon slashdot's indenting, or lack therof )
Why aren't you encrypting your e-mail?
I began teaching my brother programming with Javascript. I also recommended to my department head that they use Java as a beginning programming introduction.
You need to learn the fundamentals of programming - not necessarily Assembly-level, but something that, upon completion of a beginning course, will be useful and applicable to other languages.
We spent three weeks learning conditionals, loops and case - in my Java course (specifically did not use the word "class" there, for anti-pun reasons...). The prerequisite courses were "intro programming" and another, such as VB. But all but three of students came into the class unable to understand an if-else. My time was wasted, my prof was furious and most students gave up.
You know what they learn in the intro programming class? QBASIC. You know how many people had a clue coming into Java or VB or C++? Two of us. We'd both been programming for ten years (and we were 20) and could teach the class. It was a req. for the major, so we had to take it.
Programming is best learned in front of a computer, with a task to do and a good reference to rely on. If that reference is a book, another programmer or freakin' Google, you can still learn the basics from there. I liked the idea of teaching my brother using Javascript because I could 1 - look at his code, 2 - point him at countless resources, examples, etc. and 3 - demonstrate that even if your code follows the rules, works on your machine and is well commented/indented, it won't work on everyone else's machine.
It won't teach you the inner workings of a machine (previous Slashdot post on Assembly as an intro language) but it will help prepare you for a real internship or at least for a class that will teach you more.
1) You have three options as you said but there are others as well. document.title = 'str' or window.status = 'str'. I think it is a wonderful way to start. First time I saw printf() I was really lost.
:
// your document title will change to "Beer"
:
// You could then check to see if an array contains something with a simple method :
// shorthand array definition
// of course this one is alerted.
2) the prototype is only there if you want to add a function after you instantiated an object. There are much better ways to add a method to an object since javascript 1.0.
If you were to build a function with a method you can do it very easily without using the prototype construct (ie inside the class definition)
function MyClass(str)
{
this.name = str || null;
this.changeDocTitle = function()
{
document.title = this.name;
}
}
var myObj = new MyClass('Beer');
myObj.changeDocTitle()
Now the Array object is a great example of when you should use the prototype construct. Say you wanted to add a method to all array objects to check if it contains an item. Here is how you would do it
Array.prototype.contains = function (obj)
{
for (var i = 0; i < this.length; i++)
{
if (this[i] == obj) return true;
}
return false;
}
var myArray = [1,2,3,4,5,6,7,8]
if (myArray.contains(3))
{
alert("My array contains 3")
}
else
{
alert("My array doesn't contain 3")
}
The prototype construct is actually really handy here for objects which have already been defined. Using it in any other circumstances is still possible but it isn't a good way to program IMHO.
3) nope JS wasn't designed for that but for people to learn for, switch, do and while loops it is very handy. You cannot expect someone just wanting to learn a bit about programming to directly dive into a Java/Swing/SQL environment, there needs to be stepping stones to get there. ECMAScript (Javascript) does that quite well.
Although it's a very valuable motivator to have a learner able to create GUIs just like they use everyday with a few clicks, I fear for the long term education of the individual.
Someone who cut their teeth on VB is likely to look at the first steps into C and think "What? I don't want to write command-line programs!". They're not even going to learn what compilation is. I'd say that VB misrepresents computer programming in general to a beginner.
VB is okay for what it's designed for: quick 'n' dirty win32 RAD, but I would question the wisdom of its use as a stepping stone to any other programming. Better to start with real basics and build from there.
Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
1) No print() or echo() function.
...] functions are actually defined INSIDE the class
...if that's what you like, use it. You can also put the methods outside of the constructor if you want to. Or, you can use function() and create lambda functions if that tickles your fancy.
function print()
{
var i;
for (i=0; i 2) Weird OOP syntax [... in normal languages
function point(x,y)
{
this.x = x;
this.y = y;
function mPoint_toString()
{
return '(' + this.x + ',' + this.y + ')';
}
this.toString = mPoint_toString;
}
alert(new point(3,4));
The only wierd thing with JavaScript OOP is the lack of meaningful automatic inheritance. You have to pretty much do that yourself.
> 3) No file/database support.
C doesn't include file support natively. Neither does C++. I don't know about Java (I'm a C guy), but I suspect it's imported from a class. This goes doubly for database support! BASIC, Pascal, and any other real language I can think of require add-ons for Database support!
The author of the book *could have* written a class to support file *reading* easily enough, in a *completely* DOM-portable format (by retrieving "files" which are stored on a webserver instead of a local disc.. or they could even be in file://). Writing files is non-portable, but if you chose a specific JavaScript implementation, it's very possible. Two specific ones I'm thinking of are NJS JavaScript (hell, I write shell scripts in it sometimes, it's quite handy) and Microsoft's Windows Scripting Host... as long as you're not running JScript inside the web-browser sandbox, it can do full File IO.
Somebody else pointed out using ADO for Database access. That's pretty reasonable, you have to do the same thing in C++. You could also [read-only] use the Tabular Data Control (which has shipped as an OCX with every version of IE since 4.0) to read CSV files and interact with them pretty much the same way you can interact with an RDF.
The list goes on.
The problem you are having is that you cannot see JavaScript as a real programming language for two reasons:
1) It has been horribly, horribly abused in the past
2) There is not a great deal of aftermarket libraries available for the non-Microsoft version of the language. (Whose fault is that? Yours!)
It is entirely possible to write Good Code in JavaScript, although (like any language) it might not meet your needs. The criticisms you make of JavaScript could be made of LISP as well, and I think emacs has proven the point that you can use LISP to write real, non-AI-field programs.. That do I/O an' ever-thing! [albeit in an incredibly bloated manner].
In fact, I would argue that with proper "setup" [include files], JavaScript in the Microsoft environment would be a *far better* tool for teaching programming than, say, GW-Basic. Or possibly even VB (although that tenous at best). Certainly as good as Object-Oriented Turing and other educators' pets.
Getting it to work as well (file io, db access) in the non-MS environment merely requires somebody who cares about these things to write appropriate class libraries for the NJS interpreter. Or the right plug-ins for Mozilla. Etc.
Do daemons dream of electric sleep()?
If you're using VB as an instructional tool, you don't have to teach the student drag-and-drop programming; you teach them the features you want them to learn. VB programs do not have to have to use forms, you know.
Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
i'd have to disagree and say that VB is probably one of the worst languages to start off with. Yes, it's easy...the problem is that from then on, if you get really good at VB, then you'll ALWAYS be struggling to learn a new language. Most languages i've come across that are any good have more of a C++ syntax. Once you learn C++ decently (I don't think anyone ever masters it...but hey...i'm probably wrong), then everything is a step down in difficulty. With VB, everything is stepping up... 1st choice, i'd chose c++, even if you never use it, 2nd probably java, that way you don't really have to teach pointer arithmetic (PITA) or memory management.
> And lastly the first timer's language needs to be useful for large scale projects
Huh? Why? It's not like the language they use to learn basic concepts is going to be the language they use as a professional programmer.
Hmmm, I assumed that this would be a person who had not done ANY programming.
I too just jump right into a new language. It is mostly just a different syntax. Actually I try to find out what you cannot do in a new language.
Mind you, I had to take a course to learn OO. And I found out that I had been doing OO anyway, just not in a formal sense. Now I find it hard to do non-OO stuff.
- - - - - - - - - - -
I am a programmer. I am paid to produce syntax not grammar. Deal with it.
The most you can do is help a student develop their skill. Skill is something that comes from the way your brain is wired. If you don't have it, no amount of learning will give it to you.
There are a lot of people with advanced degrees and little skill.
Bruce
Bruce Perens.
Anyone who actually suggests that learning programming should be made more difficult to prevent irresponsible use has got to take the cake for elitest bullshit.
Yes, Python and a host of other languages can be downloaded for no cost, BUT none of them are provided ready-installed along with the OS on 99.8% of all new desktop/laptop computers today, and with 90%+ of desktop/laptop computers sold over the last 5 years.
With this book and a computer running Win98 or later (can't remember if IE on 95 has JS), or OS X (dunno about earlier versions), the user has all they need to start writing code of their own. No downloads required - hell, they don;t even have to be on-line!
Never mind the 12-13 age group - I'll be giving this to a few 7-8 year olds for birthday and/or christmas prezzies...
This sig left unintentionally blank.
Pretty good book. Covers the C++ language, though it talks an awful lot about UML flowcharts and the like -- okay if that's your style, but for my purposes, farting about with pseudocode and flowcharts is more difficult than writing the damn code in a real language -- at least Applescript, and usually C++.
Where are these stupid HR people you refer to? If some JS weenie can get a job due to their stupidity, surely I can.
I want my Cowboyneal
Now some of those points are very subjective and bullshit, but cost and portability are very real concerns when learning a language. It shouldn't cost really anything to learn basic programing techniques I think.
Now as far as what I'd suggest for a learning language I'd suggest what everyone else is throwing out (python, ruby, etc). One that I haven't seen anyone else mention yet is HTML. Ok, ok, it isn't a programming language, but writing webpages actually tends to be a good place to start when you want to start making things happen on the computer.
that takes nothing away from the fact that javascript is a very good language to learn programming on. i learned how to use loops and functions in javascript way before i knew what a compiler was. i say 'YAY!' to the author for an interesting and effective thought.
I write code.