Live data from Hacker News

Fogus: Node.js should become its own language

blog.fogus.me

41–50 of 79 posts

Re: Fogus: Node.js should become its own language

#41
post #36

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.

Ah, yes, you are correct. Then consider for the sake of discussion that I said "asynchronous."

Re: Fogus: Node.js should become its own language

#42

As 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/

The latest example on that blog (from Feb. 5th) examines the unexpected effects of type coercion when using double-equals for comparison. That's fine, as far as it goes, but, like most of these examples, it's a WTF that experienced JavaScript developers know how to mitigate (triple-equals) and not that big of a problem in practice. I'm trying to think of a time that JavaScript's wacky coercion rules actually bit me and I can't.

Re: Fogus: Node.js should become its own language

#43
post #26

Earlier 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.

But we aren't talking about Javascript. It's about a theoretical replacement language.

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
post #37

"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

Could you elaborate?

Re: Fogus: Node.js should become its own language

#45
post #27

Earlier 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…

Despite all of the weirdness of JavaScript, the lack of implicit return is it's biggest design flaw imho. The functional/scheme-like virtues of JS are well touted, but this small missing feature means implementing them always requires the slight but constant overhead of ending every expression with 'return', which then means that programming in a way which should be natural to javascript, isn't.

Re: Fogus: Node.js should become its own language

#46
post #10
post #9

Earlier 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.

[deleted]

Re: Fogus: Node.js should become its own language

#48
Since fogus is responding here: Other than hitching your wagon onto the fantastic hype storm that Node.js has generated, which I must say is a good move overall, reading your target description, why not start with Haskell or Erlang? You could start from there and mutate out but actually have a library base to start from. Or one of the languages sitting on top of Erlang like Reia. (Or discover that you don't need to mutate away after all.)

Starting 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

#49
How about Node.as? Flash doesn't get much love these days but I've always thought ActionScript 3 would make a great server side language. It's more like other OOP languages, has an event model like JavaScript (sync or async), and doesn't have many of JS's idiosyncrasies.

Edit: 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).

I think maybe you mean to say that you wish JavaScript had block scope. Lexical scope, it has.
Post reply on HN