News for hackers. Stuff that matters.
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.