News for hackers. Stuff that matters.
Re:The switch: Python to Node.js by sneak on Sunday December 18, 2011 @09:53AM (#3366696)
Python is a programming language. Node.js is not. What you meant to say is that you switched from Python (presumably running on top of a Real Web Server) to javascript running on Node.

The argument could be made that they are both interpreters, but please, get it right - you are writing javascript, which is a pretty shitty language in which to develop apps these days. The only reason we use it is because it has near-universal browser support - and then only for UIs.

Also, not to parrot, but it's true - node is cancer. It's for fad chasers who have no idea how real servers manage to serve volume.

Fortunately, most people inexperienced enough to choose node are inexperienced enough to never need to scale, so it'll work out okay for them - for implementation-specific values of 'okay'. :)

Re:The switch: Python to Node.js by karterk on Sunday December 18, 2011 @10:30AM (#3366762)
> you are writing javascript, which is a pretty shitty language in which to develop apps these days.

Woah. I do both Python and JS, and guess what - there are a fair number of people who hate Python's significant whitespace. And to them, it's also a "hacky" language (with all kinds of __foo__ stuff). So, shitty-ness is in the eyes of the beholder.

> It's for fad chasers who have no idea how real servers manage to serve volume.

There are real world apps like Trello, which is on Node, and are scaling well. Get your facts right, or stop trolling.

Re:The switch: Python to Node.js by hello_moto on Sunday December 18, 2011 @10:48AM (#3366793)
I'm not going to argue too much between JS and Python.

But whitespace as debate topic over corner cases in JS language? really?

And also Trello is just launched and suddenly it scales off miles away? really?

Re:The switch: Python to Node.js by jQueryIsAwesome on Sunday December 18, 2011 @11:00AM (#3366820)
The have pagerank 6 and they "just launch"? ... that is weird.
Re:The switch: Python to Node.js by hello_moto on Sunday December 18, 2011 @11:24AM (#3366869)
They launched mid September 2011. 3 months and they are what people considered web-scale?

Pagerank 6 == webscale?

Those facts are weird...

Re:The switch: Python to Node.js by malandrew on Sunday December 18, 2011 @10:51AM (#3366800)
Yup, shitty-ness is in the eye of the beholder. I wish that every time a discussion of syntax came up, we'd be as quick to make reference to Wadler's law as we are to make reference to Godwin, when Nazi's are brought into the picture.

http://www.haskell.org/haskellwiki/Wadlers_Law

Arguing syntax is more often then not pretty absurd, unless you are arguing how the syntax actually changes semantics (like with S-expressions and overloaded parens).

Re:The switch: Python to Node.js by sneak on Sunday December 18, 2011 @12:14PM (#3366971)
I think it's amusing that when I claim that javascript is a shitty language, instead of trying to claim that javascript isn't shitty, you point out the shittier attributes of the language I was comparing it to.

Regardless of whether you like python or not, javascript pretty much sucks. Coffeescript helps a bit, but if you aren't running in browser, why hobble yourself like that?

Re:The switch: Python to Node.js by cm127 on Sunday December 18, 2011 @12:50PM (#3367055)
The "Javascript is a shitty language" argument is getting old. I feel like you're only admitting that you're too lazy to learn how to program with a prototype-based language. You even suggest Coffeescript which is big on making Javascript like an OOP language when it's really not.

As far as a reason why you might "hobble" yourself is because Javascript is great at asynchronous design. You should try checking it out for real instead of jumping on the opinion bandwagon.

Re:The switch: Python to Node.js by jashkenas on Sunday December 18, 2011 @03:03PM (#3367349)
Oh man oh man.

    > You even suggest Coffeescript which is big on making
    > Javascript like an OOP language when it's really not.
JavaScript is deeply object-oriented.
Re:The switch: Python to Node.js by rdtsc on Sunday December 18, 2011 @02:20PM (#3367260)
> argument is getting old.

How does the age of the argument impact its validity.

> you're only admitting that you're too lazy to learn how to program with a prototype-based language.

If you don't like Erlang you are just admitting you are too lazy to learn the actor model. See I'll just call you "lazy" it will validate my argument.

> because Javascript is great at asynchronous design.

Not disagreeing with you here, but it would help if you'd actually mention why. You said something about it being a prototype based language. Is that why you think it is great at asynchronous design?

Re:The switch: Python to Node.js by MatthewPhillips on Sunday December 18, 2011 @12:22PM (#3366984)
You expected a nuanced refutation when you yourself offered nothing of substance?
Re:The switch: Python to Node.js by david_a_r_kemp on Sunday December 18, 2011 @02:06PM (#3367223)
At least Javascript isn't having problems with incompatible language versions
Re:The switch: Python to Node.js by Tobu on Monday December 19, 2011 @03:44AM (#3368993)
The language is limited by IE dragging their feet on unbreaking their implementation or advancing standards, Webkit and V8 staying at a very conservative middle ground (Google pushing Dart and compilation as substitutes), and Mozilla being the only engine developer showing willingness to evolve the language, because they are the only ones using it to implement the rest of their browser. Node.js is held back by a language implementation they don't control and feels underpowered in the language department, indirectly being a victim of resistance to change in the browser landscape.

Python and other non-browser languages are far more powerful and expressive, and — since you refer to Python 3 — willing to further improve.

Re:The switch: Python to Node.js by StavrosK on Sunday December 18, 2011 @11:04AM (#3366826)
What __foo__ stuff?
Re:The switch: Python to Node.js by david_a_r_kemp on Sunday December 18, 2011 @02:05PM (#3367216)
__call__; __new__; __getattr__ and __getattribute__; and __metaclass__ - you can do some black magic in Python straight out of the box that takes a lot more work in statically typed languages.
Re:The switch: Python to Node.js by StavrosK on Sunday December 18, 2011 @02:45PM (#3367318)
Those are used for hacking, though, or for more advanced usage. The syntax is to discourage trivial use.
Re:The switch: Python to Node.js by bmelton on Sunday December 18, 2011 @11:14AM (#3366847)
I'm not the author, but I believe the classic example is:

if __name__ == "__main__":

Re:The switch: Python to Node.js by epidemian on Sunday December 18, 2011 @11:28AM (#3366875)
Or methods like __init__, __str__, __cmp__, etc. I know they are part of Python's protocols, which are basically a form of the template method pattern, and that they do make sense. But to some people they feel hackish; they woud prefer to have "normal" name methods for these protocols instead.
Re:The switch: Python to Node.js by mixmastamyk on Sunday December 18, 2011 @07:16PM (#3367919)
If they were normal they'd eat up your namespace.
Re:The switch: Python to Node.js by epidemian on Sunday December 18, 2011 @08:00PM (#3368020)
Yes. But, it that a bad thing?

For example, I think if you'd have to explain how to change the string representation of some kind of object, saying "just define the 'str' method and then call it, like 'something.str()'" is simpler than "define a '__str__' method -- don't worry about all the underscores -- but then don't call it directly; instead of that, use the global 'str' function".

I don't know if that extra indirection (i.e. calling 'str', which, in turn, calls '__str__'; or 'next', that calls '__next__' in Python 3) adds more value than the simplicity of not having that extra indirection in the first place.

Re:The switch: Python to Node.js by Tobu on Monday December 19, 2011 @01:56AM (#3368770)
If it used normal names, Python couldn't evolve new methods for its protocols with language support. It would need some kind of annotation saying “yes I really mean to get this method called by the language and didn't just happen to use the same name by coincidence”.
Re:The switch: Python to Node.js by ak217 on Sunday December 18, 2011 @02:55PM (#3367340)
You don't actually need that though - there is a completely obvious way to write stuff without having to use that line.

Just about the only underscore that you can't really avoid is the constructor syntax, "def __init__()". Which I guess is tolerable.

Re:The switch: Python to Node.js by cpenner461 on Sunday December 18, 2011 @03:33PM (#3367411)
> You don't actually need that though - there is a completely obvious way to write stuff without having to use that line.

Can you elaborate on that point? I thought that was the canonical way to do exactly that... http://docs.python.org/library/__main__.html. If there's an easier/less verbose method (pun not intended) I'd love to know about it.

Re:The switch: Python to Node.js by ak217 on Sunday December 18, 2011 @04:06PM (#3367462)
From your link:

It is this environment in which the idiomatic “conditional script” stanza causes a script to run

The conditional script stanza is optional, and intended to make a .py file function as both a script and a module (i.e. be importable). To me, it's unclear why you would want to do that. The only thing you have to do to avoid using __main__ is not require any file to be both a script and a module/library. Then just put any entry-point code at the top level of whatever script invokes your program. Unfortunately the __main__ stanza is pretty widely used though.

On the topic of modules, there is a wrinkle in requiring __init__.py to be present in any library subdirectory that you want to be part of the namespace. It would be nice to have a more intuitive way for that.

Re:The switch: Python to Node.js by bmelton on Monday December 19, 2011 @12:09AM (#3368586)
Oh, I do it all the time. It allows me to write a script that I can just run from the command line when I want, like 'fetch_new_images'.

I especially love it when I'm first coding, cause I like to test as I go. That allows me to run it to see what works and what doesn't.

When I'm finished, I know that I can just plop that file into a directory and use it as a library afterward. The majority of the code that I write implements that, and I find it a godsend, personally.

Re:The switch: Python to Node.js by rdtsc on Sunday December 18, 2011 @01:59PM (#3367205)
> fair number of people who hate Python's significant whitespace

if that is their only reason to claim JS is a better language, i wouldn't bother listening to their opinion too much.

Re:The switch: Python to Node.js by davidw on Sunday December 18, 2011 @10:56AM (#3366812)
> It's for fad chasers who have no idea how real servers manage to serve volume.

I think that pquerna has some pretty good ideas about how "real servers" work, but leaving that be, you could actually explain what's wrong with the system, rather than attack the people.

Having some Erlang experience myself, I can find plenty not to like about node.js. However, the Erlang guys have fired round after round into their own feet to the point where even if it's inferior, node.js has probably already surpassed Erlang for many server tasks.

Re:The switch: Python to Node.js by therockhead on Sunday December 18, 2011 @11:23AM (#3366862)
Would you mind explaining "the Erlang guys have fired round after round into their own feet"?
Re:The switch: Python to Node.js by davidw on Sunday December 18, 2011 @12:35PM (#3367015)
They had, years ago, a clearly superior platform for event-driven programming (none of these weird callbacks). They have more or less failed to capitalize on it in terms of getting mainstream traction.

Here's some of what I think is wrong with Erlang:

http://journal.dedasys.com/2007/09/22/erlang

Several years ago, it was getting some "early hype noises", but sort of sputtered and bounced and never got off the runway.

Re:The switch: Python to Node.js by simonw on Sunday December 18, 2011 @11:02AM (#3366823)
"It's for fad chasers who have no idea how real servers manage to serve volume"

If you look at who's building serious systems with Node.js, that statement doesn't hold up. CloudKick / the Rackspace monitoring team are hardly amateurs - neither are Joyent, LinkedIn, eBay or Yahoo.

Re:The switch: Python to Node.js by FraaJad on Sunday December 18, 2011 @11:33AM (#3366882)
Yes. Those teams have sharp people who can probably write good software using COBOL if they had to.

Also see facebook and PHP. Just because Facebook uses PHP, it doesn't mean that PHP is a good language.

Re:The switch: Python to Node.js by scorpion032 on Sunday December 18, 2011 @11:51AM (#3366927)
Facebook didn't choose PHP. They continued to use it, as there was a lot of legacy to port if they wanted to.

These people actively measured (using a spreadsheet at that) the various parameters of a programming language and settled the one that fits their requirements.

Re:The switch: Python to Node.js by FraaJad on Sunday December 18, 2011 @12:07PM (#3366959)
Exactly! Facebook continues to develop in PHP because throwing out your existing system and replacing it with new code base (and a new language!) is almost always fraught with risks.

That spreadsheet is not "science" even though it has numbers in it. I can put higher numbers for Python and arrive at a different answer.

I completely agree with this comment: http://news.ycombinator.com/item?id=3366883 elsewhere in the thread.

Re:The switch: Python to Node.js by rhizome on Sunday December 18, 2011 @04:17PM (#3367499)
Re:The switch: Python to Node.js by jalanco on Sunday December 18, 2011 @10:39AM (#3366773)
Wow. What are you so frightened of? It's obvious from your post that you have invested a great deal of time in python and you are terrified that Node is going to take away your livelihood. That is not going to happen. Python is here to stay, just as Javascript is. Both will continue to be improved over time, but there is no reason to freak out and lash out at other people. Relax.

And I'd like to see the results of your study where you have proven that "most people inexperienced enough to choose node are inexperienced enough to never need to scale". You should publish such a bombshell study.

But in truth, your fear is causing you to make nasty attacks and, well, just make shit up. Come on, just admit it, Sneak.

Re:The switch: Python to Node.js by sneak on Sunday December 18, 2011 @12:08PM (#3366963)
Were it that Python was my livelihood my life would be a lot simpler. Instead, my livelihood comes from unfucking bad decisions like "hey, let's use PHP!" or "hey, let's rewrite the whole thing in javascript and use node!" or "MongoDB seems great, let's switch from MySQL!"

It's not fear of new, it's fear of broken. I encourage you to use whatever shiny stack-of-the-month you enjoy, as it basically amounts to my competitive advantage over people like that. I'll be over here using Apache and nginx and MySQL and python and perl and other languages that don't make me write abominations like '==!', same way I have forever. Best of luck to you.

Re:The switch: Python to Node.js by dtf on Sunday December 18, 2011 @09:36PM (#3368231)
>>> a = 100; b = 100; print (a is b)

True

>>> a = 1000; b = 1000; print (a is b)

True

>>> a = 1000

>>> b = 1000

>>> print (a is b)

False

Python has its quirks too. Most people learn them and get over it.

Re:The switch: Python to Node.js by zeemonkee on Monday December 19, 2011 @03:44AM (#3368992)
This might be a good explanation for this behavior:

http://stackoverflow.com/questions/2858603/why-is-keyword-ha...

tl;dr; use "is" only with singetons (None etc)

Re:The switch: Python to Node.js by sneak on Monday December 19, 2011 @10:57AM (#3369976)
I have never once used the 'is' keyword in python.
Re:The switch: Python to Node.js by dtf on Monday December 19, 2011 @03:50PM (#3371084)
Have you ever tested for a None value?

    if foo is None:
      return

    if bar is not None:
      bar()
Re:The switch: Python to Node.js by adolfojp on Sunday December 18, 2011 @10:55AM (#3366811)
"It's obvious from your post that you have invested a great deal of time in python and you are terrified that Node is going to take away your livelihood."

No it's not. You're just making one hell of an assumption.

Re:The switch: Python to Node.js by jalanco on Sunday December 18, 2011 @12:30PM (#3367002)
You're right of course. I should have said "apparent" not "obvious".