I somewhat regret starting this discussion here and apologise for accidentally hijacking the thread.
IMO, your last statement, "it suddenly becomes decent language (at least for frontend)" is key - yes, if you are just doing inversion of control, and just wiring simple actions off elements, then JS is fine. As soon as you start doing anything heavier, it becomes horrific. However, it's not clear to me where the problems are JS's own fault and where they're library/implementation issues. For example, the CPS mess that results due to a lack of threading: as soon as you start doing any real IO, any semblance of control flow you thought you had has rendered your code to a mess of spaghetti. But the ECMAScript 5 spec is, IIRC, silent on the issue of threading and IO in general. The many definitions of bottom (false, undefined, null), the endless variations of implementations, the endless duck typing and random heuristics and general lack of any degree of confidence that different libs will actually work together - there is no static way of validating that one library will not do things that are thoroughly incompatible with other libraries. NodeJS certainly exacerbates these problems to the Nth degree, but they're there in the browser too.
The issue about learning the language "properly" is that it's difficult to when certain aspects of the language (e.g. the "new" operator) were put there deliberately to "lower the learning curve" but serve merely to confuse. As you say, if you know what to stay away from then it perfectly fine, but then the same is said of Perl. And complex Perl might actually be more readable than complex JS! Once you have learnt the language properly, you realise how significant the lack of sensible language features really is; the threading issues in particular. Promises and friends help to a degree, but really you just can't write large maintainable code bases that do anything particularly complex. Now if you thus treat JS as a DSL for the browser, that might be ok, provided you don't try and do anything too complex in the browser (though the C-like webGL is clearly complex from the exact opposite end of the spectrum!). But firstly people want to do more and more in the browser, and secondly, JS keeps being used as a more general purpose language outside of the browser, which just strikes me as odd.
HTML is fine as a document structuring DSL when you actually get to use it for that, but most new single-page-apps start with a blank HTML file just loading scripts, and all DOM elements are constructed programmatically from the JS. Programmatic construction of GUIs is (IMO) a poor idea at best because it tends to put off anyone with any actual design skills from being involved. Graphical design of GUIs makes a whole lot more sense, at least to me, though I'm aware this is another can of worms that I don't really want to open! I remember in the 1990s writing applications under RISC OS. The graphical GUI designer, !WinEd (http://www.riscos.info/index.php/WinEd) was superb and I have not worked with anything that makes GUI design so intuitive and simple since (having done bits or more from ncurses, Java Swing/AWT and Java SWT, and HTML/CSS/JS amongst others).
Posted Oct 17, 2012 12:39 UTC (Wed) by drag (subscriber, #31333)
[Link]
All languages are terrible and have warts. I don't think worrying about multithreaded heavy I/O is going to be a big deal for moving windows around on a desktop.
Wayland and Weston 0.99.0 snapshots released
Posted Oct 17, 2012 12:50 UTC (Wed) by ms (subscriber, #41272)
[Link]
Mmm, true. I genuinely find it fascinating that a technology that had so little going for it (other than it was the only game in town) grows to a point where it has the properties you described in your other posting, and then manages to spread because of its ubiquity etc and possibly actually finds uses to which it is better suited. It's not so much that I want to beat JS with a big stick, it's more I'm finding its spread genuinely interesting: many finer languages have failed spectacularly and trying to understand the whys is important I feel.
Wayland and Weston 0.99.0 snapshots released
Posted Oct 17, 2012 12:56 UTC (Wed) by Cyberax (✭ supporter ✭, #52523)
[Link]
JS is warty indeed, but it's built on solid and well-known principles - it's just a Scheme in disguise. So once you get past idiosyncrasies of JS it's actually quite pleasant to work with.
Wayland and Weston 0.99.0 snapshots released
Posted Oct 17, 2012 13:01 UTC (Wed) by drag (subscriber, #31333)
[Link]
Oh. That's easy to understand:
Worse is better.
Why is windows dominate on the desktop? Why did Unix beat out other much better optimized systems? Why did Linux become the most popular posix-y system when it's full of so many idiosyncrasies and the BSD OSes were technically superior for many years early on and were just as free?
etc etc.
The answer is that implementation differences in technology pale in importance when compared to external factors and realities.
:)
The corollary to this is that technical superiority isn't going to do much for you in terms of marketability nor usefulness for your target users and developers. Ignore external realities at your peril.