Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

61–70 of 228 posts

Re: John Resig: JavaScript as a First Language

#61

Earlier quoted context omitted.

That would be ridiculous because then what would 'hello' + 1 equal? Everyone would expect it to equal 'hello1'.

Except, not "everyone" would expect that. I'd expect "hello" - 1 to return NaN, since you can't perform numerical subtraction on something that isn't a number. That's exactly what Javascript does. In the same way, I'd expect "hello" + 1 to return Nan, since you can't perform string concatenation on something that isn't a string, and you can't perform numerical addition on something that isn't a number. Edited for cla…

"hello" - 1 doesn't return NaN out of some sense of exception to trying to subtract from a string.

It returns it because parseFloat("hello") = NaN, and NaN - 1 = NaN.

Re: John Resig: JavaScript as a First Language

#62
post #8

Javascript is an absolutely horrible language to use for such purposes. There are far too many gotchas. See the following for numerous examples: http://stackoverflow.com/questions/1995113/strangest-languag...

Every language has its gotchas. Even assignment operators are kind of a gotcha. If you're coming from a basic math background, and have no programming experience, then the expression "a = 15; a = a + 1;" would be confusing in any mutable language, because assigning a value to a variable is not equivalent to stating the equality (identity) of both sides.

You're right in that even Scheme, which evolved with teaching in mind, has gotchas. However, the Racket folks made "student languages" that specifically exclude gotchas, so DrRacket is as close as a student can get to a gotcha-free environment.

Re: John Resig: JavaScript as a First Language

#63
post #30

Javascript is an absolutely horrible language to use for such purposes. There are far too many gotchas. See the following for numerous examples: http://stackoverflow.com/questions/1995113/strangest-languag...

I have to agree. BASIC is a far better option. It will obviously never be used for anything, but it will teach the student basic concepts like output, input, variables, etc. These are not simple concepts for somebody starting from zero!

But, but, but, Dijkstra!

In all honestly, I started out learning BASIC on Apple IIe's, and have managed to become an okay programmer. I would support it as a learning language.

That said, I don't know that BASIC's syntax is that much easier for beginners than javascript. I mean, there's no braces or semicolons, but a lot of the control structures are basically the same.

Re: John Resig: JavaScript as a First Language

#64

Javascript is an absolutely horrible language to use for such purposes. There are far too many gotchas. See the following for numerous examples: http://stackoverflow.com/questions/1995113/strangest-languag...

Whenever I see a post about what to use as a first language I always think about how I learned, and am learning, how to program. Warning: long-ish story/rant ahead.

My first class in high school was the basic Java 101. The teacher did not know anything more than how to draw UML diagrams and tell us to use for loops. He had been teaching the class for years and had no industry experience. I imagine 10 years ago he figured out all the questions he was going to ask and learned just enough to explain the really difficult ones. He was not a zen master LISP programmer who had glided down from the plane of Forms to enlighten us.

But I started to learn programming because of him. He knew what he knew and he had his presentation down. I didn't know how to program so anything was better than what I was going with. He explained terms and ideas in the most stereotypical of ways. But they made sense. In a way, he passed off his framework of knowledge to those who cared to take it. It was incredibly mind expanding at the time.

And so I had this little ball of specific domain knowledge. I wanted to be able to do cool stuff though on my website though. Java wasn't quite there yet, couldn't do all the things I wanted it to do. So I picked up Javascript from W3 schools online. It was terrible, awful Javascript that I have purposefully forgotten. But I could make my pages interactive, I could impress my friends. My little ball of know how was growing and expanding. I kept at it and started seeing how Java "sucked" and why Javascript was the One True Language. New ideas like functions as variables, easy to run scripts, interactive webpages, they all got added on and replaced old less useful ideas from Java.

Pretty soon after that I started actively learning Mathematica in college. The whole IDE is just lisp with some mathematical lipstick, but I didn't know that at the time. I started thinking of how to solve problems with lists, how to use IDE's, and reading and writing to files so I wouldn't have to redo everything each time. I had programs that wouldn't run in less than a second which made me really aware of what I was writing and how to optimize things.

And the story just keeps going and going on like that. Common lisp with Emacs last winter because of PG. More Mathematica and jQuery during last spring and summer because of an Internship. Node, Haskell, Clojure, Python during this past fall for enlightenment. And now R and, maybe, Ruby/Rails during the winter because I have ideas I want to make happen. I'm by no means a professional, but I know enough to shoot the shit with the CS majors and randomly drop into tech meetups (What up Cinci.rb!)

All that sprung from a high school class taught by a standard teacher on a shitty language that I don't ever want to touch again. And so when people talk about first languages and why X will be an absolutely horrible language to use to learn, I zone out. Every language is going to be a horrible first language. All of them. I don't care what arguments you make about js gotchas or Python's batteries included or why scheme is more beautifuller than common. If you don't know how to program, learning how to program is going to suck. Period. Maybe learning C++ first isn't the hottest idea, but at some point you have to grit your teeth and go "Programming is hard."

So I applaud Resig's and Khan Academy's use of javascript. Not because I love javascript, but because I know they are going to doing an amazing job presenting the tiny balls of programming knowledge to kids across the world. They could have picked most any mainstream language they want to present these ideas with and I would still be excited by their ideas. All that matters is how they plant the seeds. If they can stir up a kid's desire enough to get over the "ARRAYS SUCK. FOR LOOPS SUCK. WHY WON'T MY PROGRAM COMPILEEEE." and learn the next language or build the next project, then they have done an amazing job and good for the world.

tl;dr Programming is hard, every language has it's own use, waffling about the choice of languages isn't going to teach you what you need to know any faster.

Re: John Resig: JavaScript as a First Language

#65
post #4

tl;dr - they picked JS due to its "ubiquity, desirability in the larger workforce, lack of prior installation requirements, and ability to create something that's easy to share with friends" I find that explanation disturbing. Why not start from a language that teaches the basics of the common programming paradigms, such as OOP (Java) or FP (Scheme)?

You may have a different perspective, but if I wanted to teach OOP to new programmers, Java would be the last language I would consider, not the first. It’s a fine language in a vocational setting where the objective is to graduate people for employment as Java programmers, of course. Scheme is elegant and small, and a traditional choice for teaching programming where functions are first-class objects. If you conside…

Agree with your opinion on Java/OOP. There do seem to be better places to start IMHO.

If you had to pick one language to teach people who had never programmed before and you wanted to be able to demonstrate the basics of OOP, FP and other styles, then Python would be a good choice.

(Disclaimer: I like Python quite a lot.)

Re: John Resig: JavaScript as a First Language

#66

The language picked doesn't matter as much as what you can (quickly) do with it. But personally, for high schoolers, I would start with Scratch ( http://scratch.mit.edu - scratch 2 will work in the browser) and then perhaps Processing.js or a game development site/tool like http://html5.yoyogames.com/ http://www.scirra.com/construct2 http://www.playmycode.com/ http://pixieengine.com/ There is actual research on how t…

Any languages which people unfamiliar with programming can get immediate (hopefully positive!) feedback with in under 5 minutes is ideal. Some languages do not pass this test :-)

Re: John Resig: JavaScript as a First Language

#67

Earlier quoted context omitted.

While that may be true (it's definitely take more steps to get your feet wet in Java), my experience with JS is otherwise until Node.JS arrives. I just don't have time to twiddle with document object (DOM API) just to see results.

Some people dont have time to twiddle with a crapload of OO abstractions/interfaces just to see results either.

Some people don't use that at all with Java for a simple academic assignment.

Some people don't have time either to deal with scoping or the right way to do prototype in JS.

We all should use QBasic...

Re: John Resig: JavaScript as a First Language

#68

Earlier quoted context omitted.

The claim that everyone has a profiler, debugger and REPL is blatantly false. Only a subset of commonly available desktop browsers include those features, and out of those, only recent versions do. Mobile web browsers don't include any development or debugging tools. The cost of installing Visual Studio or Eclipse is pretty small considering that you only have to do it once. Compare that with the cost a newbie progra…

> Mobile web browsers don't include any development or debugging tools. LOL. Great point. /sarcasm > The cost of installing Visual Studio or Eclipse is pretty small considering that you only have to do it once. Boom. That's all it takes to create a barrier of entry. Not everyone has permissions to install whatever they want on the computer they're using. Then you get into issues with multiple operating systems. Windo…

Boom. That's all it takes to create a barrier of entry. Not everyone has permissions to install whatever they want on the computer they're using.

Then you get into issues with multiple operating systems. Windows does it one way and Linux and OSX does it another way. Also, the tools you've mentioned are always changing. Will it be the same in a year or two?

But won't they need to install an editor anyways? Or are they just going to use notepad? That will be a horrible experience.

And JS is changing too. None of the languages change so drastically that it's not just something simple to incrementally learn. And I think getting students used to the fact that things change isn't a bad thing. But also let them know that typically backwards compat isn't broken with these changes.

With that said I'm a big fan of JS as a first language. I'd probably spend the first day with them using notepad or vi (or whatever is natively installed on the system) -- and then have them install some nice IDE of my choosing.

Re: John Resig: JavaScript as a First Language

#69

I once considered teaching JavaScript as a first language, but the absence of synchronous user input made me reconsider. For example, there is no way to do this in JavaScript, > var line = read_line(); Of course you could use the prompt() function, but that only works in the browser, and it's an ugly hack.

Why is prompt() ugly? On the contrary, I think that for kids who grew up in GUIs, it is much more familiar and less intimidating than a prompt.
Post reply on HN