Live data from Hacker News

JavaScript: It’s Not Just for Browsers Any More

pragprog.com

51–60 of 93 posts

Re: JavaScript: It’s Not Just for Browsers Any More

#51
post #45
post #37

Earlier quoted context omitted.

I'm really at a loss as to how people seem to just swallow this claim without question. What's so special about Javascript's closure support vs Perl, Python, Ruby, PHP, Lua, C#, Lisp, Erlang, or ${all other functional languages}? What's Node.js got over Twisted, POE, EventMachine, or every single thing ever written in Erlang? Most languages used in web development have closures. A large number of them have event-base…

JS has three epic wins going for it, that cannot be matched together by another language: * A shitton of people are already using it on the daily * All of the existing code written in it is event-driven * It's got prototypical inheritance, and some people actually use it instead of bludgeoning in classicism

Your second and third points have been matched by Erlang, and for longer too.

Re: JavaScript: It’s Not Just for Browsers Any More

#52
post #49

Earlier quoted context omitted.

If A, B, C, and D truly are asynchronous then I believe you're going to need condition variables and (at a lower level) locks. I agree that such syntax should be baked in and handled at a lower level. If you can guarantee that a given variable can only be modified by one process at a time, it is easy to do something to take care of this for individual processes, and wouldn't be hard to generalize. (note, I was last u…

Nope, no locks needed in Node. This is one of the little joys of javascript: no threading at all. None. With Web Workers you can have processes, but there isn't shared state; everything is done through message passing. All parallelism is cooperative in javascript, meaning that you don't have to worry about control flow switching out from under you at arbitrary points, just when you explicitly yield it by returning fr…

> Finally, to answer the grandparent question

I don't event have a kid! ;-)

Thank you, that was the thing I was looking for. My question now: What happens if one of the promises fails? Is a promise group disposed then? Solution offered by Periodic would wait forever.

Re: JavaScript: It’s Not Just for Browsers Any More

#55
post #39

Earlier quoted context omitted.

Well Python's lambda's kinna suck for one. As far as I know, Python, Ruby, and PHP all suffer from the fact that all functions are not first class. Also Javascript's prototypal inheritance is pretty neat. I'm not saying js is a "great" language, it's not with out it's crufty bits, but it's a nicer language than most people give it credit for.

"Well Python's lambda's kinna suck for one." Not really relevant in this context, as naming things isn't that big a deal. Lambdas are only needed for one-liners and they serve that purpose fine. "As far as I know, Python, Ruby, and PHP all suffer from the fact that all functions are not first class." Definitely false for Python, Ruby actually has multiple kinds of first-class functions (for better or for worse, I am…

Actually you could say that functions in C# have been first-class since version 2.0.

We of course need to define what first-class is ... if it's the ability to have higher-order functions, than 2.0 fits. C# 3.0 only adds a light-weight syntax for anonymous delegates plus the really kick-ass ability to get a syntax tree of that method instead of the method's reference (on which Linq is based) ... and I really wish other languages add this capability (it was possible in Ruby 1.8.x, but it's not anymore in Ruby 2.0).

Python kicks ass in regard to first-class functions ... and it leverages that ability with decorators. People using other languages go through great pain to have AOP capabilities (for example), but in Python it only takes like 10 minutes to add a couple of utilities to do whatever you want.

The only frustration I have with it is the lack of multi-line anonymous blocks, but Python is so flexible you can add that using "with" block hacks, like described here ... http://billmill.org/multi_line_lambdas.html

Also, once you understand dynamic-scoping ... it's really not that big of a deal to deal with the situation described above. It's just different.

I like the lexical-scoping in Perl as it prevents all kinds of errors ... but in Python I have real exception-handling, and a kick-ass debugger console just by adding "import ipdb; ipdb.set_trace()" anywhere I want.

Re: JavaScript: It’s Not Just for Browsers Any More

#56

Earlier quoted context omitted.

Here's Yegge on the topic: http://steve-yegge.blogspot.com/2007/02/next-big-language.ht... ... though he doesn't explicitly say he's talking about Javascript, it's pretty likely that he's talking about Javascript. 1) It's got C-like syntax. 2) It's got the dynamic- and functional-language features that make people happy. 3) We're stuck with it no matter what. Changing the world's installed base of web browsers takes…

When was "C-Like Syntax" ever a good reason? I want something I can read naturally, like Ruby or Python.

He means that there's a critical mass of developers who will take one look at a syntax and move on if it doesn't have curly braces and semicolons. It's not that they're enamored with having a needlessly awkward syntax for function pointers, it's just that a syntax that isn't 95% of the way to Java just looks freaky weird to them, end of story.

I don't disagree that syntax matters, but C's is hardly a shining example. There's a network effect with programming languages, though (libraries, documentation, community, etc.), and there's a certain amount of realpolitik in designing with "C-Like Syntax" in mind.

I'm more worried about languages with ugly semantics. Odd syntax is only skin deep, but bad design goes straight to the bone.

Re: JavaScript: It’s Not Just for Browsers Any More

#57
post #5

Why do we want javascript on the server side, when we already have so many other options? I'm not trying to imply something against this aproach, this really is a question.

Here's Yegge on the topic: http://steve-yegge.blogspot.com/2007/02/next-big-language.ht... ... though he doesn't explicitly say he's talking about Javascript, it's pretty likely that he's talking about Javascript. 1) It's got C-like syntax. 2) It's got the dynamic- and functional-language features that make people happy. 3) We're stuck with it no matter what. Changing the world's installed base of web browsers takes…

I don't think people should take Yegge seriously without a grain of salt.

Yeah, he's a good writer and I've read all of its blog-posts ... but he seems like the kind of programmer that's always discontented with the status-quo, always looking for that next big language, always relentlessly looking for tools that will make programming fun again ... and that particular article seems to me a lot like wishful thinking.

And guess what ... you won't find much happiness in switching languages, unless the culture around it favors simplicity and getting things done (and your previous community didn't). That's why Lisp is almost dead.

Also, Javascript may become popular on the server-side, but that's only because browsers are stuck in the past, while becoming more and more relevant to the future.

But give developers the choice of multiple languages ... and I'm pretty sure Javascript will fade away to a niche. Incidentally, you can play with Ruby and Python in the browser right now ... it requires Silverlight/Moonlight, but it's pretty cool and gives some glimpse in what the future should look like.

Re: JavaScript: It’s Not Just for Browsers Any More

#58
post #5

Why do we want javascript on the server side, when we already have so many other options? I'm not trying to imply something against this aproach, this really is a question.

Like others are mentioning, Javascript is clean, familiar, easy, and has some compelling language features to boot (closures, JSON, etc). Cultural norms and design patterns in Javascript Land increasingly orbit around projects like jQuery. This sort of influence works out spectacularly-well if you've spent the last several years working countless hours on browser-side code and suddenly stumble on nodejs and its event…

The people who claim JavaScript is fast because of V8 have probably never used a fast language and platform in a situation where speed is important. V8 is fast compared to other JavaScript engines. It's very slow compared to most other languages. PLT Scheme, a non-fast Scheme platform, averages half the time of V8 in the flawed benchmarks game (single core, JavaScript cannot multithread.) Lua, a fast non-broken dynamic language with first-class functions averages between 3x and 100x as fast as V8, the fastest JavaScript engine.

http://shootout.alioth.debian.org/u32/benchmark.php?test=all...

By definition they are flawed benchmarks, but you will have a hard time writing faster JavaScript code than equivalent code in most other platforms. In the case of Lua (and Python, and Perl, and many many others) the equivalent JavaScript code will also be as long or longer, and not as clean.

I'm not going to get mad at anyone for their choice to use JavaScript, but the uncritical repetition of sentences like "Thanks to V8 and other modern engines, JavaScript has become fast compared to optimized language/platform X" or "JavaScript offers these N features you won't find anywhere else" will not fly.

Re: JavaScript: It’s Not Just for Browsers Any More

#59

Earlier quoted context omitted.

Here's Yegge on the topic: http://steve-yegge.blogspot.com/2007/02/next-big-language.ht... ... though he doesn't explicitly say he's talking about Javascript, it's pretty likely that he's talking about Javascript. 1) It's got C-like syntax. 2) It's got the dynamic- and functional-language features that make people happy. 3) We're stuck with it no matter what. Changing the world's installed base of web browsers takes…

I don't think people should take Yegge seriously without a grain of salt. Yeah, he's a good writer and I've read all of its blog-posts ... but he seems like the kind of programmer that's always discontented with the status-quo, always looking for that next big language, always relentlessly looking for tools that will make programming fun again ... and that particular article seems to me a lot like wishful thinking. A…

I know that not a lot of people would agree with me on that one, but i'd argue that JavaScript is a better designed language than Python or Ruby on a lots of points.

It's simpler than both regarding the core language features, and is also the only one of the three to have real anonymous functions.

I'm not fond of C syntax, but i can live with it

Re: JavaScript: It’s Not Just for Browsers Any More

#60

Earlier quoted context omitted.

I don't think people should take Yegge seriously without a grain of salt. Yeah, he's a good writer and I've read all of its blog-posts ... but he seems like the kind of programmer that's always discontented with the status-quo, always looking for that next big language, always relentlessly looking for tools that will make programming fun again ... and that particular article seems to me a lot like wishful thinking. A…

I know that not a lot of people would agree with me on that one, but i'd argue that JavaScript is a better designed language than Python or Ruby on a lots of points. It's simpler than both regarding the core language features, and is also the only one of the three to have real anonymous functions. I'm not fond of C syntax, but i can live with it

> is also the only one of the three to have real anonymous functions

What are you talking about?

Post reply on HN