Earlier quoted context omitted.
Fair enough, but the examples I've seen look like continuation passing style ( http://en.wikipedia.org/wiki/Continuation-passing_style ), which is something we know how to abstract behind language syntax and semantics. In what way am I wrong?
Programming in an "event-based way" is a huge part of writing traditional JavaScript in the browser. You're handling user events, Ajax responses, the page load itself. And JavaScript's first-class functions and closures are extremely well-suited to the task.
Fogus: Node.js should become its own language
41–50 of 79 posts
Re: Fogus: Node.js should become its own language
#42As someone who has spent the last six months coding in Node.js, I completely disagree with this notion. One of my favorite advantages of Node is in fact that it is based on javascript. When building my application I can share code between client/sever side (string formatting methods for example) and don't need to do any mental context switching when it comes to languages. I've developed in javascript for years and al…
" The "faults" of javascript are primarily inexperience with event looped architectures that use callbacks " Maybe for a lot of people this is true, but for me the faults of javascript are ingrained language "features". Actually, I'm not the only one who thinks so, because theres a website dedicated to it[1]. [1] http://wtfjs.com/
Re: Fogus: Node.js should become its own language
#43Earlier quoted context omitted.
It's not deceptive if you have a preemptively multitasking runtime that you trust (like the Erlang VM); it's a much more natural way of writing code. Single-threaded, event-driven callback spaghetti makes code harder to read, and inherently means more code. If someone took v8, added lightweight coroutines, and wrote a preemptive scheduler for it, I bet you could massively reduce the SLOC count for large node.js apps.
> It's not deceptive if you have a preemptively multitasking runtime that you trust That may be so, but since Javascript is inherently single threaded _and_ this is about javascript I agree with Cushman that it is indeed deceptive.
Also, the reason you care about the "synchronicity" in the first place is because your environment forces you to care! When it all Just Works (TM), you don't care whether it's "synchronous" or not. That's a deficiency in your language, not a feature.
I'm not theorizing. I program in this sort of language all the time. You worry much more simply about how long something will take, which you can never not worry about, rather than how many bits are "synchronous".
Re: Fogus: Node.js should become its own language
#44"My problem with Javascript has always been that expertise is defined more in terms of understanding its faults rather than its features." That's mostly just true for browsers. Javascript itself has very few faults. My biggest annoyances with the language are: Lack of lexical scope, no trailing commas and semicolon usage that differs from C. I could complain all day about my annoyances with browsers (or just IE).
Javascript itself has very few faults. We disagree. Signed, Douglas Crockford, Jeremy Ashkenas, and Brendan Eich
Re: Fogus: Node.js should become its own language
#45Earlier quoted context omitted.
The good news for fogus is that everyone who prefers CoffeeScript validates the idea that an alternative syntax is enough of a win to be worth the adoption headaches.
It's not just syntax, but some semantics too. Last expression in a function is returned. This includes assignment statements which are in fact expressions. foo = () -> a = bar() z = () -> if a b = fu() else b = kar() Here, foo returns the function z, and z returns either fu() or kar() while assigning the value to b One could argue this is just syntax but I think this way beyond the kind of thing that comes to mind wh…
Re: Fogus: Node.js should become its own language
#46Earlier quoted context omitted.
Except that Javascript has lexical scope. Use the var keyword to define local variables. foo = function(){ var bar=0 return function(){ bar=bar+1 return bar } } baz=foo() baz() // => 1 baz() // => 2 baz() // => 3 bar; // => ERROR: bar is not defined
They're "hoisted" and only local to the function, though. I'd (personally) prefer it if it worked like C, and a variable was defined from the "var" statement until the next closing brace. Then you could have a variable local to one branch of an if statement, etc, without faking scopes by abusing closures (eg (function() { })(); ). And nested loops that both use "i" would work.
Re: Fogus: Node.js should become its own language
#47I prefer coffee-script. It also works in the browser. http://jashkenas.github.com/coffee-script/
Re: Fogus: Node.js should become its own language
#48Starting from scratch is going to be difficult at this point; by the time you even have a half-decent stack you're going to be way behind.
(At the very least... you do realize this has been done and you don't have to start from scratch, right? Rather a lot of Node.js users have exactly the cognitive holes I'd expect from not knowing that Node.js is at best "keeping up", rather than being anything like cutting edge. And I'd say this style of programming was actually on its way to the dust heap of history before being brushed off and gotten a shiny new coat of paint sprayed on... it really doesn't work very well....)
Re: Fogus: Node.js should become its own language
#49Edit: http://haxe.org/ is based on AS3
Re: Fogus: Node.js should become its own language
#50"My problem with Javascript has always been that expertise is defined more in terms of understanding its faults rather than its features." That's mostly just true for browsers. Javascript itself has very few faults. My biggest annoyances with the language are: Lack of lexical scope, no trailing commas and semicolon usage that differs from C. I could complain all day about my annoyances with browsers (or just IE).