Answer to what? What's wrong with Javascript in the first place?
http://johnkpaul.github.io/presentations/empirejs/javascript...
11–20 of 148 posts
Answer to what? What's wrong with Javascript in the first place?
http://johnkpaul.github.io/presentations/empirejs/javascript...
Answer to what? What's wrong with Javascript in the first place?
He covers that here: http://www.walkercoderanger.com/blog/2014/02/javascript-mine...
How is JavaScript a minefield? Well, JavaScript has all sorts of pitfalls lurking for the developer. Each pitfall is like a mine in the minefield, silently waiting for you to accidentally step on it. Just like the minefield, JavaScript’s mines are hidden in plain sight. Entire books have been written about all the mines present in JavaScript. Maybe I’ll get into what some of those are in future blog posts.
So then he goes into why Typescript/Coffeescript/Dart aren't the answer to the "Javascript minefield" though he doesn't actually describe the mine's he's trying to avoid. He's not even bothering to setup a strawman to knock down. Its kind of hard for any tool to solve an undefined problem.
delayed: () ->
-> this.model # isn't the class
Well, that isn't really fair now, is it? You could have used the fat arrow (`=>`) for binding `this` to the class.With that in mind, I agree with the author in that CoffeeScript isn't the answer, at least not exactly. With syntax this incredibly similar, how far are we from compiling python (with generators, with statements, imports, ...) to JavaScript?
Answer to what? What's wrong with Javascript in the first place?
People have documented this many times. It boils down to surprising features of the language. http://johnkpaul.github.io/presentations/empirejs/javascript... https://speakerdeck.com/felixge/javascript-the-bad-parts
delayed: () -> -> this.model # isn't the class Well, that isn't really fair now, is it? You could have used the fat arrow (`=>`) for binding `this` to the class. With that in mind, I agree with the author in that CoffeeScript isn't the answer, at least not exactly. With syntax this incredibly similar, how far are we from compiling python (with generators, with statements, imports, ...) to JavaScript?
Sometimes I think that most CoffeeScript, ClojureScript, etc. programmers are people who were advanced in other languages before they learned JavaScript. There are quite a few programmers who have no issues with these "bad parts" or "really bad parts" because they cut their teeth on them, and these numbers are growing: Most people now learn JavaScript as their first language. JavaScript already won, and things like C…
For years I avoided using javascript beyond wiring little bits of jQuery together because I hated the language but eventually I ran into a project where I could no longer do that and resolved to learn javascript properly.
Many wtf's where had but now looking back I realise that Javascript is a warty language (but then show me a widely used (top 10) language that isn't).
I still don't like it but I don't hate it and I just accept it for what it is.
# BROKEN
func 5, {
event: (e) ->
if e.something
36
else
45,
val: 10}
Anyone with more than a day's experience with CoffeeScript knows that it's much better to express this with the simpler: # far better
func 5,
event: (e) ->
if e.something
36
else
45
val: 10
Note how just dropping the excessive notation makes the intention clearer while also making the code cleaner.His example on variable capture neatly illustrates a few of the opinions of CoffeeScript that actually make it far easier to reason about code: don't use global variables, and if a variable has the same name, it should refer to the same thing. It's far more confusing to allow rampant variable shadowing. Code that relies on variable shadowing is simply broken.
His last example shows a fundamental misunderstanding of not just CoffeeScript, but JavaScript generally. Granted `this` binding can be sometimes confusing, which is why CoffeeScript has a fat arrow (`=>`) to automatically capture `this`.