“The World’s Most Misunderstood Programming Language”; starting Javascript 101 at p2pu


So, out of curiosity, and in the thought that it’d be vaguely useful to the future direction in which I’d like to head, I’ve entered a basic Javascript course over at p2pu.org: a free online education project. Blogging the course and the homework assignments is an integral part of the course, and for lack of any better-seeming option, I’ll be posting those here- any regular readers, feel free to ignore them.

The course will be based on some lectures given by Douglas Crockford of Yahoo, the first one, that I’ll be blogging today available here

Based on a first viewing of this video, I clearly have my work cut out for me. While the course description said a “basic” understanding of programming concepts was required, Crockford is clearly speaking for an audience of experienced programmers. But in the age of wikipedia and instant expertise, supposedly nothing is more than a search away, so I’ll see how I go. Here’s hoping that other students are either as in the dark as I am for solidarity purposes, or both savvy and willing to give me a hand ;) 

So here’s a no-particular-order summary if what I gleaned from the video:

  • Javascript is “misunderstood” (for instance: it has almost nothing to do with the Java language, and is more than just a scripting language), 
  • Javascript is “typecast” - it’s viewed by most people as a language mostly for use in the browser), and it was apparently deliberately mispositioned by the companies that created it. 

In general, one gets the impression that Javascript is a useful, popular, imperfect programming language with a slightly complicated reputation and a slightly chequered history. 

The key ideas in Javascript:

  • Load & go delivery: “programs are delivered to the execution site as source-code/text.” I’ll be frank - I don’t understand the implications of this. I know source code (human readable code that gets compiled before it’s run or “interpreted” as it’s run) and I know machine code (the result of compilation - mostly NOT human readable code that’s executed by the machine), but this isn’t meaningful to me. Is Crockford just saying that Javascript is an interpreted language?
  • Loose typing: As far as I recall, this means that the type of each variable is not required to be specified when it’s declared?  Apparently it means any variable can receive any kind of value. Crockford seems to be saying this sacrifices speed - as strong-typing (?) languages apparently allow the compiler to do more of the heavy lifting during compilation, requiring less processing during run-time - but allows greater flexibility, “expressive power”, and ease in programming. At least that’s the impression I get. 
  • Objects as general containers: Not a clue. Whatever it is, Crockford approves. “the unification of objects and hash-tables” ???
    Seems to imply, to me, that objects are somehow used as versatile and generic building blocks of the program - maybe substituting for some other data structures?  
  • Prototypal inheritance: (as distinct from classical inheritance) “objects inherit directly from other objects… there are no classes” This would seem to imply that new objects, when instantiated, take on the characteristics of existing objects, initially? Again, not sure. Widely misunderstood idea, apparently.
  • Lambda: “allows the use of functions as first class objects” **Whoosh!** That’s the sound of this point going over my head.
  • Linkage through global variables: see above “whoosh”. Apparently a bad idea. Crockford disapproves.

Further selected points:

  • Values: Crockford says Javascript has a “small” set of values. I’ll take it on faith that he’s right. Don’t know enough other languages to compare. Only one number type, apparently, which is different to the other languages I’ve looked at (ie. Python) - no integers. Apparently runs counter to the common understanding of arithmetic, making some operations difficult for users to understand.
  • Strings: An older implementation of Unicode, apparently. What this means in practice, I’m not sure. No separate “character” type - a single character is just a short string. Strings are immutable, and can’t be modified once they’re made. There are a variety of string methods that can be used.
  • Boolean values: There are two: TRUE and FALSE. Apparently this differs from some other languages. 
  • Null: a value that “isn’t anything”, and Undefined “which isn’t even that (ie. null).” Not quite sure of the distinction there.
  • Javascript is a member of the C family, in terms of syntax. “Differs in its type system, which allows functions to be values” Crockford says this is a “big idea”, and it sounds like it. From my limited understanding, I’d imagine this to be quite powerful.
  • By convention all “variables, parameters, members and function names” start with lower case letters.
  • A heavy-handed “reserved word” policy. Ie. lots of words that you can’t use for variable names and other things.

Unfortunately, the above reads more like a listing of my non-comprehension than a “what I learned”. While the background on the language was interesting, it struck me that much of what Crockford was saying seemed like fine distinguishing details of the language that won’t be useful until later in the course - hence there’s a lot that I haven’t summarised here, as it seems a little pointless. Here’s hoping that more of the material going forward will be geared to a novice programmer.