4 ms·
Ok, I'm going to seem incredibly blunt and perhaps ignorant here. Hopefully someone can help me understand. I don't understand Node.js. Why do I care about b
by coherentpony 13y ago
Ok, I'm going to seem incredibly blunt and perhaps ignorant here. Hopefully someone can help me understand. I don't understand Node.js. Why do I care about being able to write javascript on the server? I can just as easily write a python script which, in my humble opinion, is much easier to read than javascript. I don't want to turn this into a language bashing session as I realise the argument can somewhat become a religous one. Is Node.js faster? Is it easier to hook into a web server? Why?
Apologies in advance for any trodden toes.
- prezjordan 13y agoNode's package manager is very, very good - which I attribute to the fact that it's been able to learn from the mistakes of those before it. Also the whole streaming/evented approach to web development is really cool. I know it's nothing new, but being able to require() a few modules and write a file upload component in 10 lines is pretty nifty.
- coherentpony 13y agoThat's interesting. I've used gem, npm, pip and luarocks. With my limited experience I'd say they're all pretty similar and all have their pros and cons. I usually resort to my OS's package manager instead. Is there a specific reason people think npm shines over the others?
- rpedela 13y agoCan't speak for all package managers, but I know that some do not handle multiple versions of the same package well. In contrast, NPM handles this very well. Publishing packages is also much easier than pip or Packagist (PHP) in my opinion.
- coherentpony 13y agoDownvotes for an honest call for understanding and self-improvement? Really, HN?
- nanidin 13y agoI don't have the ability to downvote, but this type of meta/complaining is exactly what I would downvote.
- untog 13y agoWell, the answers for this are easily google-able. At a certain point it just seems like laziness to ask in an HN thread.
- girvo 13y agoHN readers often give insight that is beyond what a simple Google search will give you. Hence the existence of "Ask HN".
- hibbelig 13y agoMy take on this: - If you're building a web app (perhaps a single page web app), it might be useful that you can share client side code and server side code. Take input validation as an example -- you can use the same `validateEmailAddress` function on the server and on the client -- guaranteed to be consistent. - Javascript is a fascinating language. - Maybe others can contribute some performance numbers? My impression is that V8 is very fast -- can JS outperform other scripting languages? - The whole Node.js approach to concurrency is very different than using threads -- it's fascinating, as well.
- girvo 13y agoIIRC, V8 is the fastest engine for scripting languages out there, with perhaps the exception of LuaJIT and PyPy, but I'm unsure about those two. If you just compare it to canonical scripting language implementations then yeah, it's definitely faster -- some of that is down to the really advanced JIT, some of it is down to the async-everywhere design and culture.
- iends 13y agoNode is faster than python, ruby, and php frameworks. Source: http://www.techempower.com/benchmarks/ http://www.techempower.com/benchmarks/ It's also javascript, (which has some really nice properties, and a few bad ones) and ubiquitous in web development already. The real reason for it's popularity is that a lot of the ruby guys seemed to have jumped to Node.js :)
- adamors 13y ago> The real reason for it's popularity is that a lot of the ruby guys seemed to have jumped to Node.js :) I think it's because a lot of front-end developers jumped to Node.
- Flenser 13y agoAnd those benchmarks are against Node.js v0.10.0 [1]. It will be interesting to see what difference switching to v0.12 makes to the benchmark results. [1] https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/nodejs#infrastructure-software-versions https://github.com/TechEmpower/FrameworkBenchmarks/tree/mast...
- ak217 13y agoNo toes trodden on! Advantages of node.js as I see them: - Provides npm (a state-of-the-art package manager which introduced a number of innovations) - Built on V8, which is possibly the best dynamic language compiler made to date, in terms of performance - Provides a well-done streaming I/O and event model, which many languages fail at - Provides an extremely powerful and high performance async/concurrency model, which is set to improve as promises and other concurrency patterns mature - Has a well-tested, high-performance, properly layered standard library (most of the time) - Has a nice C++ extension framework - Has a very active (though sometimes rough around the edges) developer community The downsides are: - It's Javascript, which has some serious design issues as a language - Currently still suffers from callback spaghetti, which is set to improve as per point 4 above - Can be very hard to debug in the face of its async model because of insufficient built-in debug facilities
- zackbloom 13y agoI have to disagree with the Javascript design issues. I've used both Python and Javascript for years, and the more I use Javascript the more I realize how ad hoc Python really is. So many of it's features (metaclasses, raising an exception to break iteration, the MRO, the import behavior, etc.) seem to be hacky solutions to problems of it's own making. Javascript is a much smaller, and therefore simpler language.
- ak217 13y agoTo each their own. I really dislike Javascript, and while Python is not perfect, at least it has the right set of core values and a community process that results in tangible improvement. I mean, you're complaining about the finer points of Python OOP - to me, Javascript OOP is broken, and there is no community standard to fix it. What's wrong with raising exceptions to break iteration or with the import behavior?
- est 13y ago> raising an exception to break iteration You don't have to. def mygen(): yield 1 yield 2 return print "never been here" >>> list(mygen()) [1, 2] I agree some parts of python are hackish though. Maybe because of legacy reasons. And py3k didn't fix all of them
- Skinney 13y agoIn my oppinion, one of the coolest things about Node is the ability to share code between server and client. Especially for validation, this is awesome.
- morganherlocker 13y agoAs someone who switched from python to node.js, I can give a few reasons. 1. npm is extremely easy to use and has a lot of traction. Language X is going to be a tough sell if it lacks good libraries. 2. node.js devs tend to be religiously adherent to the idea of small modules. While not everyone like this, and some would prefer large frameworks, it is definitely a more flexible model. 3. Speed. I happen to write mapping and geospatial analysis software. Most of the existing solutions are python based. I spent months optimizing one particular algorithm in python and was able to get processing time down to 70 seconds. This was not acceptable for a web app, so I wrote a new geostatistical engine from scratch in node.js. New operating time: 35ms. Sure, there were probably ways to optimize the python code further, but it was never going to touch the node implementation. https://github.com/morganherlocker/turf https://github.com/morganherlocker/turf 4. In data analysis type applications like this, async IO is a huge help. More connections with less servers means huge cost savings. 5. Syntax is just syntax. When I was a python dev I would look at javascript and cringe, now I find myself doing the reverse. I fully expect to look back at both and cringe when I am a few years into my next language. We all experience that feeling when we see something different than we are used to.
- camus2 13y agoNodeJS is usefully to write tiny servers working together for specific purposes (nodes). It was never designed to replace rails or django in what they do best : classic web apps with a lot of static pages served from server-side templates. So if you are designing an online news paper, a blog or e-shop ,you shouldnt be using it. However,you might want to send 100000 mails to your customers each week. Node can help you with that.You might want to fetch loads of data from a 3rd party api, Node can help you with that, or add real time functionalities... Node can be a component of your setup(like a RDBMS,a proxy,...),it doesnt have to be the core. The real issue is not Node,it's all the craze around it that makes people give up solutions that work for the new hotness,so you get people trying to port rails or django to node, which is stupid. So please dont bash Node because of the way some people try to sell it to everybody for everything. These people will go away soon and jump in the next bandwagon,but NodeJS is here to stay.
- diroussel 13y agoMy understanding, as an outsider, was that the birth of node went like this: "Evented, async, processing is faster than threads in many cases. What if you had a platform/language that you could only do async IO in? Well we could take an existing language and replace the IO layer, or we could just take javascript that has no-IO layer and add it in. Thus in node it's impossible to write blocking code. (Let me knoe if I'm wrong on that last bit)." Then it went from interesting experiment to useful, and thus to popular very quickly. Either because V8 is so very fast, or because lots of people know and like javascript, or because callbacks are not that bad :-). Not sure which.