
John Resig: JavaScript as a First Language - fogus
http://ejohn.org/blog/javascript-as-a-first-language/
======
jashkenas
For the interested (and with the caveat that I definitely would not suggest it
for the Khan Academy's purposes), CoffeeScript does try to address all of the
issues that John raises in his post.

Type Coercion: There is no `==` in CoffeeScript. You usually write `if x is y`
in order to be particularly clear, but if you're in the mode of most other
scripting languages, and you write `if x == y`, it will compile to `if (x ===
y) {` in JavaScript.

John's note about `x == null` being the only useful application of double
equals is quite true, and something that CoffeeScript provides in the
existential operator: `if x?`

Falsy Values: The existential operator helps you ask the question "Does this
value exist?" (Is this value not either null of undefined?) ... which covers
many of the use cases for having saner falsy values in JavaScript. For
example, instead of JS' `if (string) {` ... where the string may be the empty
string, you have `if string?`

Function Declarations: JavaScript having function declarations, function
expressions, and named function expressions as three functionally different
things is indeed a wart on the language. Especially so because JavaScript
having a single type of function is one of the beautiful aspects that shines
in comparison to languages like Ruby, where you have methods, blocks, procs,
lamdas, and unbound methods -- all of which behave in slightly different ways.
CoffeeScript only provides JS's function expressions.

Block Scope: This is a tricky one, because unfortunately it can't be emulated
in a performant way in JavaScript. So all that CoffeeScript can provide is the
"do" keyword, which immediately invokes the following function, forwarding
arguments. So, if a regular "for" loop looks like this:

    
    
        for item, index in list
          ...
    

A faux-block-scoped "for" loop would look like this:

    
    
        for item, index in list
          do (item, index) ->
            ...

~~~
gnaritas
And made the mistake of making whitespace significant thereby driving off
people in droves.

~~~
dextorious
It's 2011. We love significant whitespace now, get on with the times...

~~~
malandrew
Assume you've never programmed before. Would you want to debug a program that
has a significant whitespace bug? It's much easier for the average person to
spot an unbalanced parenthesis that an incorrectly sized whitespace.

Getting stuck and being frustrated hurts motivation a lot.

Now curly brackets and syntax may be seen by a person as an irritation or
inconvenience compared to whitespace, but I'd say it's better to use a
language with an inconvenience than one which is more likely to leave you
stuck.

You, I and others used to programming with insignificant whitespace have
developed and eye for detail and can rapidly spot a whitespace but. The
general population with no programming experience can't consistently space
most of the documents in their life, but they can typically place periods
correctly.

~~~
dextorious
"""Assume you've never programmed before. Would you want to debug a program
that has a significant whitespace bug? It's much easier for the average person
to spot an unbalanced parenthesis that an incorrectly sized whitespace."""

I'd argue that for a beginner it's equally difficult.

And how about this equally difficult to spot classic bug:

if (f==x)

    
    
      do_something()
    
      and_also_do_this() //oops!
    

a language with significant whitespace does not permit it. It gets people
using the correct indentation levels from the start, whay they _should_ have
used anyway in any language, even one where whitespace doesn't matter.

I propose we don't talk about languages with "significant whitespace", but
instead about "languages with proper indentation enforced".

~~~
melling
Why is this hard to catch? Format your code and the incorrect indentation goes
away. A beginner should be taught to run the formatter to keep the code neat.

------
absconditus
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...](http://stackoverflow.com/questions/1995113/strangest-language-
feature?tab=votes&page=1)

~~~
maximusprime
Disagree... for example from the link:

    
    
      In JavaScript:
    
      '5' + 3 gives '53'
      Whereas
    
      '5' - 3 gives 2
    

That's just logical and obvious, since "+" is both numerical addition, and
string concatenation, but "-" is only numerical subtraction, and the '5'
starts out as a string.

Every language has 'gotchas'. Doesn't really matter which you pick to learn
first at all. The more important thing is that you don't give up. _possibly_
there are languages that just make people want to give up, but I'd say perhaps
they're not motivated enough to learn if that's the case.

I started out on BASIC, and after a while I decided it was a piece of shit
language and learnt assembly. But it taught me programming which is what I
wanted to learn. I'm really glad I learnt BASIC first... essentially I learnt
to swim really fast through syrup, and then switched to swimming in water.

The good thing about javascript as a first language is that people can be
programming in it immediately, in their browser. They have a built in REPL to
help them, as well as a debugger, profiler, etc. They have numerous docs to
look at, and if they go to any website they can check the source to see how it
works. That's a big win.

~~~
kevingadd
Calling your example logical and obvious is only logical and obvious if you're
completely trapped within the JS mindset. It's the same as how people defend
the absurd semantics of Visual Basic and PHP. It's fine if you like it, but to
claim that it's objectively okay is just not supported by fact.

It's also worth considering that even if every language has 'gotchas', some of
them have far worse gotchas than others. It is worthwhile to choose a starting
language that teaches the fewest bad habits and the fewest bizarre rules so
that people can easily learn new languages.

~~~
maximusprime
See my comment below. It's not about being trapped in any mindset. It's about
thinking logically.

Either '5' - 3 results in an error of some kind, or it evaluates to 2. There
is no other logical outcome. Javascript chooses to do the latter.

I also disagree that starting language matters. It's like saying you need to
have a steinway grand to learn the piano properly.

Learning is about learning what not to do just as much, if not more, than what
to do.

Also if you learn to swim through syrup, imagine how fast you'll be when you
try swimming through water...

~~~
mquander
Your ideas about what is "logical" are completely arbitrary. Look, I can make
up rules too:

* '5' - 3 should return '5', since it's the string '5' minus all the instances of the character '3' in it. There is no other logical outcome!

* '5' - 3 should return an empty string, since it's the string '5' with the last three characters removed. There is no other logical outcome!

* '5' - 3 should return '2' -- since we started with a string, the result should turn back into a string. There is no other logical outcome!

* '5' - 3 should return 50, since the only logical way to do math on a character is to take the UTF-8/ASCII value of it and then do the math. There is no other logical outcome!

* '5' - 3 should return undefined, since subtracting from a string typically doesn't produce a reasonable result. There is no other logical outcome!

You have provided absolutely no rational basis for discriminating between the
merits of these choices, so your claim that Javascript's choice is one of
exactly two "logical" ones is bizarre. If you think Javascript's choice is
better, give a _reason_ why it's better, don't just say that it's better.

------
laconian
I'm a fairly experienced programmer and JS still drives me up the wall. The
implicit casting and inconsistent operator overloads have led to many unhappy
visits to Stack Overflow to see just WTF my browser is doing. I can't imagine
the experience being any better for newbie programmers! Even simple things,
like bitwise operators, are basically broken unless you take care to ensure
that your variables are coerced to whole numbers, because all numerics are
f%!#^&ing floating point numbers...

Given that the language is such a mess, I think it would induce a new
programmer to compartmentalize their JS learnings as a bunch of special case
hacks instead of discovering broad language principles that are applied
consistently across the language.

~~~
cageface
Python seems to me like an infinitely better choice. Every language has its
warts but bringing up a new generation on a language that even the author
admits was a quick and dirty hack takes "worse is better" cynicism way too
far.

~~~
showell30
I like Python too, and the current CS curriculum on Khan is mostly, if not
completely, based on Python.

------
IanMechura
I have argued JS as an intro language for years. My main argument has been not
based on language features which I feel are unimportant in forming a young
programmers mind but rather in the complete lack of barriers to getting
started.

Take for instance python( my personal language). At a minimum you need python
installed on the computer. Then you need to deal with issues such as the PATH
and PYTHON_PATH. Also you have to understand package naming and import scheme.

With JS you only need a .html text file on the desktop.

Write code, save, double click, results. It is something that anyone who has
even seen a computer can understand.

Particularly if the student has not had much experience in computers in
general, things like paths, imports, file system knowledge and command line
interfaces can be a barrier to learning code. You will eventually need to
learn all of the things above to be a programmer but why bore a child or
teenager with the details of a file system or command line when you could be
showing them how to code animations on a web page.

I will admit, that struggling with run time environment, compilers and class
path issues made me into better engineer sooner, but I already had a passion
for what I was doing.

~~~
pbsd
In the particular case of python, I see none of the problems you mention. In
pretty much all Linux distros, it already comes installed and ready to use
(i.e., just execute it, no need to know paths or anything).

The same happens on Windows, once you run the installer; there you can, too,
just edit and double click it. All you need is a .py file on the desktop.

------
extension
Yeah, JavaScript will break their impressionable young minds. But you know
what? Programming in general will break their minds. Programming is fucked up
from any perspective. If they learn a good language first, they will go crazy
trying to figure out why nobody is using it. Might as well teach them a
language that lets them get stuff done in the real world, while preparing them
for the ugliness ahead. They can learn the good language later.

------
sirchristian
I support using JavaScript as a first language. If for nothing else there are
millions of code snippets just a short "right click -> view source" away.
Granted these may not be the most ideal examples, but it enables tinkering.
One thing that always frustrated me about the "easy" languages to learn
(Python, Ruby, etc) is you still have to figure out how to download something
and then the first programs just write out text to a console window. It's hard
to see at first how learning one of the "easy" languages translates into
building cool stuff.

Having access to such a vast array of samples, plus something like Khan
Acadamy teaching the "right way" is just awesome to me.

------
noelwelsh
Reading this I reminded of the saying "when you have a hammer everything looks
like a nail". It's not surprising to see John Resig leaning towards using
Javascript. There is a lot of research into teaching introductory programming.
It would be nice to see some of that referenced in making the decision. You
know, base it at least in part on science rather than just opinion.

------
angelbob
I am _so_ looking forward to a huge army of newly-trained programmers who view
_prototype-based_ inheritance as the default and classical inheritance as
weird.

Similarly, I look forward to a whole set of various modules and libraries to
graft prototype-based inheritance onto existing languages like Ruby...

 _cackle_

~~~
kenjackson
Unfortunately I think that class-based inheritence is more general in concept.
That is, people who understand class-based inheritence have a very small leap
to get prototypal inheritence. You can pretty much just say, "Inheritence
works on the instances/objects, not on the class."

Explaining class based inheritence to people who only know prototypal seems
trickier. You have to explain the concept of classes and then build from
there.

BTW, are there any prototypal languages that support multiple inheritence --
you can create an object from a set of an arbitrary number of objects?

~~~
anon1385
In Io you can add as many objects as you like to the protos list of an object:
[http://www.iolanguage.com/scm/io/docs/IoGuide.html#Objects-I...](http://www.iolanguage.com/scm/io/docs/IoGuide.html#Objects-
Inheritance)

~~~
kenjackson
Nice. Thanks. How is it that I've never looked at the IO language before? Some
reading for tonight.

------
agentultra
I think it'd be more apt to choose something like Racket. It has all the
desirable characteristics the author finds attractive in Javascript. It is an
integrated environment and includes libraries and extensions for teaching
basic programming. Unlike Javascript it isn't married to the browser (and by
extension, the DOM) and doesn't suffer from a variety of syntactical
discrepancies. It even comes with a free book for teaching the fundamentals of
computer programming and computation.

<http://docs.racket-lang.org/quick/>

 _Update_ : All of the desire-able characteristics except for being a resume-
search keyword with a high hit frequency. IMO, learning how to program and
getting a job are orthogonal.

------
yuvadam
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)?

~~~
catshirt
for new programmers, the entry barrier for those languages is significantly
greater than javascript. people don't quit learning programming because
they're not learning OOP- they quit because it's inaccessible.

~~~
hello_moto
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.

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

~~~
hello_moto
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...

------
njonsson
All decent suggestions. I quibble with this, though:

    
    
      // Don't do this:
      function getData() { }
      // Do this instead:
      var getData = function() { };
    

The assignment is righteous, but by omitting the function’s name, you make
stack traces more difficult to follow. Better this instead:

    
    
      var getData = function getData() { };

~~~
apalmblad
I definitely agree with your point about stack traces - I've used var x =
function(){} for some projects, but have found in practice that named
functions are very much worthwhile when dealing with stack traces?

What's the benefit of var x = function x(){}? Is it just illustration that
functions can be assigned to variables?

------
edtechdev
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 to teach kids programming and computer science
concepts. <http://csunplugged.org/> doesn't use any software at all to teach
concepts like binary numbers, sorting, etc.

~~~
arctangent
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 :-)

------
firefoxman1
Before I even read the article, I was pretty sure that with a title like that
there is going to be lots of debate from the CS people. They do raise some
good points, but here's my 2 cents.

Besides a little bit of VB in highschool, JavaScript was my first language. I
mainly learned through two books: "The Good Parts" which was a nice overview,
and "Object-Oriented JavaScript" a really underrated book that covered every
little piece of the language, even those weird parts like block scoping and
falsy types.

Having never learned anything about classes or inheritance, prototypal
inheritance was kinda hard to grasp, but I eventually found it pretty amazing.
I think a loosely typed language is much better to learn on too. That way you
can learn the big pieces of the language then later get into the little things
like typing. That's just my experience, but I'm really glad JS was my first
language.

------
olov
I want to take this further still. Most JavaScript programmers already use a
subset of the language and I believe that there is quite a broad union of
those subsets that should resonate with the majority of us. Excluding certain
parts of the language will lead to more robust code that is easier to reason
about (and more fun to write), I claim. My attempt to formalize it is called
"restrict mode for JavaScript" <http://restrictmode.org> and I laid my case
here: <http://blog.lassus.se/2011/03/case-for-restrict-mode.html> . Would be
curious to hear other thoughts about it.

~~~
tikhonj
I think Resig means to use JSLint throughout, which does something similar.
Additionally, browsers already support "use strict" which is also a restricted
mode. In short, plenty of people share your views on the matter (me included).
The whole thesis of _JavaScript: The Good Parts_ was basically that, and the
book is one of the best on the language.

~~~
olov
The major difference is that JSLint as well as "the good parts" focus on a
subset that can be verified statically (before running the program) while
restrict mode sanitizes operator semantics that must be verified dynamically
(when running the program). I like the few changes strict mode did except for
one thing that breaks compatibility in an unfortunate way (this is bound to
the primitive, not the boxed number). But we should take all this much
further.

More important than anything I'd like us to start talking about sane subsets
of JS more, and stop limiting ourselves to what one author considers "good"
because quite frankly, _that_ subsets still contains a whole lot of awful
stuff.

------
kls
One thing that I have not seen covered that is worth mentioning, is that
JavaScript for the most part embraces an event based development model. While
it is not unique to JavaScript it certainly is heavily reinforced by
JavaScript and JavaScript developers. In other languages it can be fairly
underrepresented, that being said, it is worth learning JavaScript due to the
fact that it helps developers think of execution as events. One can go their
whole life in other language and not deal with events, with JavaScript you
will be hard pressed to get to intermediate tutorials without fairly good
coverage of events and event syndication.

------
arctangent
If you want to teach computer science to people then a good first language for
them to learn is C, because it will help them think about and understand what
the computer is actually doing.

~~~
danenania
That's an argument for learning C, but not for learning C as a first language.
Studying assembler or chip design or even particle physics will also help you
understand what the computer is 'actually doing', but it doesn't mean that's
the best place to start learning how to program.

~~~
arctangent
I didn't claim that C was the best language for learning how to program.

John Resig's article above is about "teaching Computer Science" rather than
teaching students how to program. These are very different things.

That's why I recommended C - because it is very much a language that will
teach the theory about how computers work.

I agree that there are other languages better suited for learning how to
program.

~~~
danenania
Ok, I see your point. But perhaps one can learn Computer Science much more
efficiently after already knowing how to program? It doesn't seem likely that
you'll be very open to learning data structure design and asymptotic
complexity when you're still wrestling with for loop syntax, the difference
between assignment and reference, what the hell recursion is, etc. You have to
learn to walk before you can learn to run, and while jumping in the deep end
may work for some, I'd guess most would find a more programmer-friendly
introductory language a quicker path to comprehending basic CS concepts and
would subsequently be in a much stronger position to tackle C.

------
city41
On a similar note, I've been in the process of creating a JavaScript
library[0] that is strongly inspired by _why's Shoes. My intent for doing this
was to create a DSL where one can whip up webapps very quickly. But I'm also
now looking into essentially recreating Hackety Hack on the web, and maybe
having a simple way for very young people to get a taste of programming. Sadly
JS isn't as DSL friendly as Ruby.

[0] <https://github.com/city41/Joeys>

------
glenjamin
Am I the only one who thinks that lack of block scope is only confusing for
people who are used to it?

I don't think it'll affect JS-as-a-first-language people.

------
j45
Interesting Idea.

I know for me the way I learnt programming made me quite flexible and happy.

Working the entire scale from functional to OO languages gave me a really good
perspective for anything I face.

I've learnt all the web stuff I use today completely on my own, but I use the
foundation I learnt below. The "classic" academic programming languages I've
learnt happened in this order.

Basic -> VB -> Pascal (High school/first year Uni) --> C --> C++ --> Java

Too much code out there rarely exists entirely on the OO or functional end and
projects are often heading towards one or the other.

Once I had traversed this, I was easily able to pick up .NET, whether any one
of the .NET languages was OO or functionally based (Foxpro, or whatever).
Javascript was interesting because it extended from Java for me.

I really do feel that programming needs to be learnt at the
mathematical/computational level of functions for clear process/analytics and
then learn the benefits of using functions in an OO world.

Be interested to hear what order others learnt

~~~
tikhonj
I'm curious: which of the languages you listed do you consider "functional"?

~~~
j45
Pascal was procedural, so was VB.. (pre .NET) even though it shared so much
with COM/DCOM :)

------
malandrew
I'm a full-time javascript developer and entrepreneur myself, but I'm
wondering why you don't consider Scheme instead, basing the course on the How
to Design Programs v2 curriculum?

The people behind that book have spent a lot of time thinking about how you
teach programs to people.

More importantly, they focus on problem decomposition and concepts that
provide a great foundation for growing.

The reasons I can see for using Javascript first is because everyone has a
runtime available at their fingertips (M. Haverbeke's approach of including
the console was great.) and because people can immediately see the utility of
the language to real world needs.

But does Javascript provide the best foundation for future concepts? Does it
teach good habits both mental and in practice?

Ref: The Structure and Interpretation of the Computer Science Curriculum
<http://www.ccs.neu.edu/racket/pubs/jfp2004-fffk.pdf>

------
captainaj
I parted away with CS to major in biochem thinking it wasn't as fascinating
(first course was in C++). This is definitely not a bad idea and also already
implemented. Stanford has CS101 in entirely Javascript:
<http://www.stanford.edu/class/cs101/>

------
tantalor
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.

~~~
danmaz74
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.

~~~
tantalor
With a standard prompt, you can see the previous output from the program and
user input. But a popup window has no context, no history.

Of course that's just my opinion. If it could help teach kids good programming
skills then it should be used used.

~~~
peterbraden
Chrome, Firefox and Safari all have built in REPLs

~~~
tantalor
REPL is not the same as standard streams (STDIN, STDOUT).

You can build a REPL with standard streams, but you can't use a REPL like the
WebKit console as standard streams. Where is your STDIN?

------
mycodebreaks
Well, I would like to teach kids assembly language first. That's how my
generation did it. Second language should be C. That's how you know how your
program actually runs on a computer. You know what memory is, and how it is
used.

------
jhuni
Its pretty easy to criticise, so instead I will discuss the steps I would take
to a student CS principles from my own experiences. I find graphs to be
fundamental, so I would start the student out with them.

1\. Teach the student basic concepts in graph theory such as nodes, edges,
walks, paths, cycles, and structures such as trees, and linked lists.

2\. Introduce the student to syntax trees as a means of representing
mathematical equations, and the representation of them used in Lisp: (+ (* a x
x) (* b x) c).

3\. Describe dataflow graphs to the student. For example, loops are cycles in
the dataflow graph, and infinite loops occur when the cycle is endless.

------
potch
The hopeful part of me loves this because I truly believe the web stack is a
truly democratizing technology, and has tremendous accessibility.

The cynical side of me also loves this because I like watching PL bikeshedders
rage.

------
Stormbringer
I loved this comment:

 _"The policy when I went to school was to start everyone with LISP. That way,
if they never got past CompSci 101, they wouldn’t be capable of impersonating
a real programmer. "_ \-- Dave Edelhart

------
olivier1664
I've learn programming to create small 2D games: Turtle at 8, TI-82 at 16,
Pascal at 18, C with Allegro at 22, android-java at 30. It was some "Snake" or
"Tron" or "Bomberman" kind of games.

Seems obvious for me that children motivation can be creating game.

So, in my opinion, an ideal first language should be a sandbox language that
have C syntax style without pointer stuff and can easily: \- Read keyboard()
\- DrawPixel() \- DrawImage() \- PlaySound()

Bonus if there is no install. Bonus if created games can be send by email to
friends.

------
_THE_PLAGUE
I have commented (at length) on this earlier, so don't have much to add. But a
further thought did occur to me: JavaScript has "loose typing", that is, one
is not taught the difference between say, an int, and a double, or even a
char, and the fact that there is no such thing (really) as a string -
"strings" are just a lazy shorthand for a char array. Loose typing is not just
incorrect - on some level, it is immoral, IMO.

------
ZenPsycho
Someone is teaching JavaScript to other people? This is nothing less than /The
Downfall of Civilisation As We Know It!/. Quick everyone, get your pitchforks!

------
neduma
Io will do.

I do not think this would be optimum for new comers even thought i’m a die
hard fan of JavaScript. You can teach ‘Io’ language instead of JavaScript
which has all kind advantages you have mentioned and which has few set of
parser rules that would be easier for new comers.

JavaScript can be a icing on the cake.

------
tingletech
JavaScript was my first language. I made web applications using Netscape
Enterprise Server which had server side javascript, and I worked on a signed
javascript kiosk application that ran in Netscape and had javascript menus
that would side off the screen.

------
capex
To introduce kids to programming, there is nothing better than Javascript.
Instant gratification & no installations. It'll be an easy entry into harder
concepts. But the way you enter does matter.

------
tolmasky
Anyone else taught Karel++? In high school they taught us: Pascal -> Karel++
-> C++

Then the new AP tests came in and the switched to C++ -> Java, which seemed
very silly to me (C++ as a first language???)

~~~
showell30
My intro CS class in college started with a week of Karel. It was incredibly
fun for me, but I can't vouch for it as a first language, since I had already
learned Basic and Pascal in high school. (Yep, I'm old). Karel variants are
actually very challenging in a way--the syntax is dead simple, but its lack of
constructs forces you to be fairly clever.

------
jebblue
>> a function is actually an object and can be manipulated as such

A function is an object? I also read down the comments and saw something like
'1' + 2 prints '12'. ROFL

------
bdfh42
Only thing I am not sure about is the focus on "===" - I think it is a pain
and fails in too many instances to do what the programmer would expect.

~~~
OriginalSyn
Strict Equals Operator (===) does exactly what I expect and that is no funny
coercion or guessing, two objects I'm evaluating have a 1 for 1 likeness, no
more no less. How is that confusing?

~~~
ryanbraganza
NaN !== NaN

Apart from that, I agree.

~~~
tikhonj
That's not really language dependent--that's how floating point numbers always
work. And with good reason--there are actually a ton of different NaN bit
patterns in the floating point standard. I think anything where the exponent
is all 1 is an NaN (except maybe for infinity--I don't remember the exact
details). The point is that two completely different patterns of bits can be
NaN.

------
_THE_PLAGUE
My response: [http://blogkinnetic.blogspot.com/2011/12/on-civic-decay-
of-u...](http://blogkinnetic.blogspot.com/2011/12/on-civic-decay-of-us-
computer-science.html)

------
_THE_PLAGUE
Here is my blog article I wrote on this travesty. (Available here:
[http://blogkinnetic.blogspot.com/2011/12/on-civic-decay-
of-u...](http://blogkinnetic.blogspot.com/2011/12/on-civic-decay-of-us-
computer-science.html)) I am not a pugilist for the sake of it, but when I see
abominations like this, well, somebody has to take a stand for whatever real
programmers are actually left out there. :-)
=================================================== When I saw the above
article I could only be reminded of H.P. Lovecraft's description of the
Massachusetts seaport town of Innsmouth, a great fishing community before the
American Revolution, but which by the early 1900's had become a classic case
of civic decay, with bootleg liquor becoming its primary occupation, and the
general cultural or educational status descending to the level of the
primitive. This is because the approach the article advocates for teaching
computer science can only end in one place: the primitive, and by that I do
not mean the C primitive variable types of char, float, double, and int, but I
mean primitive as in stone-age. :-)

I learned programming a bit ass-backwards. I got a "teach yourself Java" kind
of book, went through that, and generally learned things "on the fly" as it
were, and, in so doing, in time, eventually was comfortable with the "Java
world" of Java SDK (basic Java), XML, XSLT, and some DOS / UNIX scripting
skills as well. Still to this day, Java is a language I feel very "at home"
in, and would choose if I had to build something up really fast. It is my
"GOTO" or "default" language if you will.

Later, though, I started to study C++ and C, first for a job that required me
to write unit tests using CPPUnit (the C++ port of Java's JUnit) and just sort
of "learning on the fly" began to be able to understand and edit C++ code,
though I was not then (or now) as proficient there as in Java. Still later, I
studied C proper and read Kernighan and Richie's classic book, "The C
programming Language". I think it was then, and only then, that I really
understood the fundamentals of programming, by which I mean the principles of
it, not just memorizing syntax to get stuff done, but rather having a deep
understanding of things like memory allocation, processes, stacks, etc.

The thrill of creating dynamic (re-sizable) arrays using C-style pointers is
something that still gives me a bit of a high, because there are many
situations in which resizable arrays are needed or desirable, and doing this
via C-style pointers is the most efficient way of doing it.

I can say that while today I still would choose Java if I were doing a
personal project of some size or complexity just for expediancy's sake, I love
C the most, for it is the most efficient (fast, using less memory, etc.).

To make a comparison to poetry: Java is Ginsberg and C is Eliot. Both of whom
I love, but they are different styles. Ginsberg is the Jazz musician of poetry
- creating crazy yet haunting melodies by going "off the map" if one wills in
terms of traditional styles. Eliot is the baroque musician of poetry - using
the fewest notes to create the greatest effect - precision is the key word
here - no room for an off-note here or there but every note having a purpose.
Both have their place. I love Jazz. But in terms of aesthetic efficiency,
baroque has something to be said for it. Ginsberg is poetry's Jazz - wild,
haunting, all over-the-place in a good way. Eliot is poetry's baroque -
precise, haunting as well if more in a subtle way, and always having a precise
direction or purpose.

Well, Java is the Ginsberg / Jazz of this analogy. It is easier / quicker to
mess around and improvise and come up with a Jazz tune. It takes longer and it
is more painstaking to come up with a baroque melody. Both are great and have
their place. However, while I would use the quicker thing to come up with
something on a deadline (Java / Jazz) there is a certain satisfaction to be
had with taking longer and having to put more effort in order to produce
precise, efficient, parsimonious code, and by parsimonious I mean not wasting
any memory or CPU cycles, but having each bit of memory serve a purpose, just
like each note of a baroque piece or each line of an Eliot poem has a precise
purpose and taking one line out or one note out would ruin the whole thing.

So, while I still would use Java probably the most, I find a certain nobility
in C, much as while I might probably listen to Jazz (or its descendants) the
most, I find a certain nobility in baroque, and whereas I love and relate very
much to Ginsberg, there is a certain appeal in Eliot's ability to say so much
with so little that will always hold an attraction for me.

This is why the above article I came across, in which a computer science
professor is talking about using, not even Java, but JavaScript for goodness
sake, as the first language to teach students, is so tragic. Like I intimated
before, if I had to do it all over again, I would have studied C before I even
got into Java. That would have taught me correct principles and just a better
"philosophy" of programming. As it was though, I was lucky. I worked with a
math PhD who was a C++ whiz, a guy named Dr. Mark T. Lane, Chief Scientist at
what is now mobi (mobicorp.com) who imparted to me the basic concepts of
efficiency and attention to detail that I could never have gotten from the
Java world, so, although it was later that I seriously began to study C, even
early on I had some of those benefits, for which I will always count myself
lucky and grateful.

But not everyone is going to luck out like me and get to work with such
brilliant folks. I can only feel sorry for those aspiring computer scientists
who go to a computer science program and get freaking JavaScript as the
opening silo in their introduction to the world of programming, and I can only
feel contempt for those professors who would advocate such a fool's errand.

When I was a kid, I loved this old 1950's teen sci-fi novel called "The
Forgotten Star" featuring a character named Digby Allen who travels to the
50's version of a moon base and a Mars base, and eventually lands on Eros, an
asteroid. Turns out in the book the asteroid is a space ship and inside are
people from another planet (from a "forgotten star") who long ago have
forgotten the knowledge that propelled them into space in the first place. The
interior of the ship has a simulated earth-like environment, with a sky,
fields, etc., and these people live like primitive savages, in huts, etc. not
knowing there is a world outside the interior of their space ship, not even
knowing, for that matter, what a space ship even is. They have a cool
contraption which can convert atoms into anything asked for, so they get their
food from that. The contraption (as near as I can recall) would basically take
atoms from space and convert them into the molecules for whatever the user
requested, so I could say ask it for bread and it would give me bread. To
these inhabitants it was like a magic thing, for they had lost the knowledge
that went into producing that contraption to begin with. And I suppose the
young space adventurer Digby Allen saves the day and brings them into the
modern age, though now I forget just how that ended. But I will never forget
the impression which the book had upon me - the concept, the very sad concept,
of a people once-advanced who through laziness had allowed themselves to
descend into ignorance and dependency upon technologies they could no longer
understand.

I was reminded of this tragedy when I saw the above article. Already I had
read essays about computer science professors lamenting that C / C++ is no
longer at some schools taught, Java being the preferred language. And now, it
seems we are descending yet another rung, with JavaScript now being the
preferred language. What is next? HTML? How about just forget about teaching
kids how to write code and teach them how to use point-and-click tools like
say WordPress which does not require any code skills at all to at least be
able to use the basics thereof.

If we go down this road enough, we will be in the "Forgotten Star" situation -
able to use tools built in the past but not having the knowledge anymore to
build those tools again. Because you can only create great Jazz if you also
know how to play baroque. You can create mediocre jazz I am sure - hell, a
chimpanzee, given enough time, also could. But you cannot play great jazz
without the underlying principles that led to it. Neither can we expect great
code to be developed without the understanding of the underlying principles
which led to our current languages (like JavaScript) in the first place.

Oh, and one more thing, subverting a function into an "object" has its
purposes in terms of being able to code things up faster, more easily
understanding the architecture, etc., but here is a dirty secret that
apparently contemporary self-styled computer science professors won't tell
you: a mathematical function is not an "object", sweetheart. Because "objects"
belong to "sets" which may describe computational functions, but are not the
functions themselves.

Deal with it, Java cultists. :-)

~~~
pdenya
Your comment is heavy with comparisons that don't really apply while still not
making much of a point. Javascript isn't as low level as other languages but
HTML is no more the next step than XML is the next rung down from java.

If you hadn't linked the blog post in your comment I would have thought tl;dr
but since you did I tried to wade through all the flowerly language. Your
whole post can be summed up as "People who learn javascript first will never
learn CS fundamentals" which is unfair and untrue.

------
jaequery
john, just teach them jQuery!

------
more_original
Nooooo!

------
its_so_on
wat. This is like teaching postscript as a first language.

almost literally.

~~~
its_so_on
this was downvoted. Let me make the analogy clear.

Javascript is sent by a server to a rendering engine (your web browser),
usually a part of displaying a page, though of course also as part of
interacting with it.

Postscript is sent by a (print) server to a rendering engine (in a printer),
as part of typseting a page. It is a Turing-complete programming language, but
that's no guarantee it won't make your eyes bleed.

The existence of things like jquery "on top of" javascript are really no
different form having Microsoft Word or Open Office / Libre Office there to
'print' your postscript file.

Like it or not, neither javascript nor postscript are:

\- Systems languages.

\- Desktop application languages. (As Java can be).

\- Low-level language suitable for writing drivers.

\- Low-level languages suitable for writing network protocols.

\- High-level languages suitable for prototyping very large, complex data
structures and relationships

\- High-level scripting languages suitable for abstracting away incredible
sophistication and power and letting the user program in a very high level
mode.

\- Robust and scalable applications languags, suitable for putting in a
version control system and having a team of fifty iterate on it

They're niche, domain-specific languages, like a Perl regex. Would you suggest
anyone's first language be the regex Perl uses? Obviously not.

Appropriate first languages are anything from:

* A fake language like Turtle Logo

* An almost-fake academic language like Pascale

* An "electrical engineer" approach nuts and bolts introduction: assembly.

* A low-level systems language, C, or C++

* A high-level scripting language: Ruby, Python, Perl

* An interpreted systems language: Java.

* A markup language: HTML and CSS

* No language. Configuration files for nginx and other things.

etc etc.

Very, very low on the list would be something like Javascript. This would be
akin to editing Adobe Illustrator files in a hex editor. Sure you could end up
with an image and an understanding of vector art, but, why in the name of God
would you try to learn those concepts in that way?

~~~
jerhewet
Upvote from me. It's a sad day when Kiddiescript is somehow magically elevated
to the status of a _real_ programming language.

~~~
Apocryphon
JavaScript is Lisp in C's clothing.
<http://javascript.crockford.com/javascript.html>

Also this: <http://gigaom.com/cloud/node-js-and-the-javascript-age/>

~~~
silentOpen
If this were actually true, JavaScript would have TCO by now.

