-
Notifications
You must be signed in to change notification settings - Fork 18
A Misunderstood Language?
As you might know the first version of JavaScript was developed in mere two weeks at 1995 by a fellow named Brendan Eich over at Netscape Corporation. Mozilla can be considered a successor of it. You most likely recognize the name. Yes, they are behind the web browser. In fact they built that on the remains of Netscape.
Initially the language was known as LiveScript but the marketing men decided JavaScript sounds more convincing. After all it was the decade of Java so anything with Java in it must have felt like a killer product. And in a way the legacy of Java still lives on although not in the way envisioned. On retrospect it wasn't a good choice to name the language as JavaScript and a lot of confusion has ensued. Java is to JavaScript as ham is to hamster. Keep that in mind!
So how would you characterize JavaScript? Even though it looks a bit like Java or C due to bracing there it is actually an implementation of a couple of powerful languages in disguise. These languages are a variant of Lisp known as Scheme and Self. From former JavaScript inherited some of its functional programming capabilities whereas latter gave it prototypal inheritance system which in some ways can be considered superior to classical one used by languages such as Java.
It is possible to mimic the more commonly used one with a little effort, though. As a result there are dozens of implementations around. It doesn't take a genius to realize that this isn't particularly nice. ES6 aims to various implementations and will provide a single pattern to use.
Particularly JavaScript's functional capabilities make it in some ways an exceptional language. For a long while this power was well hidden, or at least not that well recognized. The language was improved in this regard in well supported ES4 (there are shims for older browsers). ES6 will take this a notch further.
Of course JavaScript comes with the usual imperative programming constructs (for, while, if, etc.) you might expect. There is also some legacy in form of Date and Math modules inherited from Java 1.0. There are some custom features even (with
comes to mind) though it is better to avoid some of those and just to stick to a solid subset.
You can get plenty of things done even with a well selected subset of the language. You will avoid some pitfalls and keep your code readable even for less superior programmers as you. Granted it is perhaps a bit more verbose than some might like.
As a result various people have implemented languages that compile to JavaScript. Usually these languages provide some constructs not found in the core language. You may gain better type checking or some syntactical sugar.
altJS lists many of these languages. If you have time, go and check out a few. Personal recommendations: CoffeeScript, Dart, TypeScript, Elm.
Speaking of typing, JavaScript has been typed very loosely. Functions are treated as first class citizen. And everything is an object of course. It will take some getting used to. It isn't as bad as it might sound. Although it is one of those features that makes it very easy to shoot oneself into a foot. As you probably want to avoid that fate, read on. It will be hopefully a little less painful that way.
Created by @bebraw. If you have ideas or happened to find some bugs, let me know over at issue tracker.