Live data from Hacker News

Why I'm Learning Node

rdegges.com

31–40 of 65 posts

Re: Why I'm Learning Node

#31
post #29
post #23

Earlier quoted context omitted.

You may see some very nice libraries/tools coming out around node.js, like jade, coffeescript, and stylus. These are all nice and good, and they do increase your productivity, but, only on the client side. I disagree. Firstly, CoffeScript is not confined to the client-side. Besides, there are some modules like socket.io for which you will hardly find any substitues in other eco-systems. You're also discounting the ef…

The decrease in productivity with node comes from having to write everything with callbacks. Programming asynchronously is crazy, it makes very simple algorithms very annoying to write. I'd say it's almost like writing in assembly. You have to write your code in some pseudo code first, synchronously, then translate that into the asynchronous callback spaghetti than node requires. > Lastly, I would like to know what y…

It cracks me up that you haven't tried Go but you're still recommending it, is there a web framework?

Edit: Found web.go. Screw it it's a long weekend, I'll give learning Go a go.

Re: Why I'm Learning Node

#32
post #31
post #29

Earlier quoted context omitted.

The decrease in productivity with node comes from having to write everything with callbacks. Programming asynchronously is crazy, it makes very simple algorithms very annoying to write. I'd say it's almost like writing in assembly. You have to write your code in some pseudo code first, synchronously, then translate that into the asynchronous callback spaghetti than node requires. > Lastly, I would like to know what y…

It cracks me up that you haven't tried Go but you're still recommending it, is there a web framework? Edit: Found web.go. Screw it it's a long weekend, I'll give learning Go a go.

I haven't had a pressing need for using it, and I'm considering it as something I want to learn on the side for now.

As for frameworks, it seems the http package comes builtin with a server and a url router. Also, Google's AppEngine supports Go.

Re: Why I'm Learning Node

#33
post #21
post #16

As noted somewhere else learning node is not learning front-end. Something that bothered me recently is that on the back-end we are used to big oop frameworks when in fact the stateless nature of http do not match oop so well. On the front end however we have a gui so oop is a good paradigm.

Huh? What does the statelessness of HTTP have to do with OOP, particularly on the server, but not the client?

Because most server side languages take a "throw away the world" approach to web programming; none of your objects persist in memory through requests, which means every time a request comes in you have to reload a part of the user's world from the db, service the request, and then destroy the world you've just created. For structural things like MVC, objects are great, but you really don't see much of the "object as vehicle for data encapsulation" that's drilled into every new programmer when they're first taught OOP.

The client, on the other hand, can persist data and objects through requests, and the only time it needs to be fully refreshed is on a full reload.

Re: Why I'm Learning Node

#34
post #23
post #19

The problem with node is it decreases your productivity tremendously. The most important thing about the choice of programming tools is productivity. Node.JS does not promise you any productivity gains. Node sells itself as a solution to "slowness" caused by "blocking IO". What's the solution? All I/O is evented! This means you have to write everything with callbacks. You may see some very nice libraries/tools coming…

You may see some very nice libraries/tools coming out around node.js, like jade, coffeescript, and stylus. These are all nice and good, and they do increase your productivity, but, only on the client side. I disagree. Firstly, CoffeScript is not confined to the client-side. Besides, there are some modules like socket.io for which you will hardly find any substitues in other eco-systems. You're also discounting the ef…

> The decrease in productivity with node comes from having to write everything with callbacks. Programming asynchronously is crazy, it makes very simple algorithms very annoying to write.

I know exactly what you mean, because that's what I thought a year ago. I was going on and on about this to everyone. Mea culpa.

Then I actually tried node and learned the functional side of JavaScript (I don't mean the semantics, which are very simple; I mean powerful LISPish design patterns). Now I don't think about callbacks anymore, because I have a functional toolkit that mostly hides them.

You say asynchronous coding makes simple algorithms annoying to write. So let's have an example. Read two files -- in parallel -- trap I/O errors and warn about them, otherwise merge and sort the files by line, write the result to a third file, and warn about I/O errors there as well. Simple enough?

My solution is 8 lines, formatted. It was very pleasant to write.

  fork(
    ['lines.txt', 'lines2.txt'].map(function(name) {
      return fs.readFile.bind(fs, name);
    }),
    check(console.warn.bind(console), function(a) {
      fs.writeFile('linesOut.txt', a.sum().split('\n').sort().join('\n'), check(console.warn.bind(console)));
    })
  )
If you've seen enough JS to deduce what the lib definitions for fork() and check() might be, then this code will seem obvious -- almost trivial. Otherwise, you will probably claim shenanigans or 'spaghetti' because it doesn't look like insert favorite programming language/framework here.

So it saddens me to hear people whining about this aspect of node -- partly because it recalls my own naivety, and partly because I know from experience that they're missing out on something great.

Re: Why I'm Learning Node

#36
Starting with Node is a very poor choice if you want to learn front-end. But you can't go wrong with The Good Parts and you at least now know what's all the fuss about Node. But now let's really start learning front-end.

Begin with semantic HTML. It's really the basis. The best front-enders I know first write all the HTML for a project, and only then start adding CSS and JS. Learn why is wrong and isn't. Make sure you're HTML validates.

Now go to CSS. It's really easy to add some colours or fonts. You learn CSS as you go. But there is one hurdle here: the box model. Learn about float:left, position:absolute, display:block and how they entangle.

This will be harder than you think. You will need to learn some tools to debug this. Install Firebug and the Webdevelopers Toolbar in Firefox and see how you can fix your layout. Browsers aren't that scary.

We're only learning here, so skip IE for now. That one is actually kinda scary. Though if you really want to learn front-end, it's all about browser differences.

And then Javascript. Now it will be easy. Stick with jQuery and connect with your Node instance with socket.io. Learn Backbone if you want to make snappy web apps. There's a lot to learn in this 'grey field' between back-end and front-end. But at least you now know front-end.

Re: Why I'm Learning Node

#37
If you're an experienced programmer looking to learn Javascript, you probably can't do any better than reading Javascript: The Good Parts. It's extremely short, concise, and enjoyable to read. Highly recommended.

Any experienced programmer should definitely start elsewhere so he can make up his own mind about Crockfords ideas about how programming should be. While the book is ok-ish almost half of the material is about Crockfords personal preferences for coding style and can be applied to any language.

JavaScript - The Definite Guide by David Flanagan is in my opinion the best book on the subject. No other JS book comes even close in clarity and thoroughness.

http://www.amazon.com/JavaScript-Definitive-Guide-Activate-G...

Re: Why I'm Learning Node

#38

Starting with Node is a very poor choice if you want to learn front-end. But you can't go wrong with The Good Parts and you at least now know what's all the fuss about Node. But now let's really start learning front-end. Begin with semantic HTML. It's really the basis. The best front-enders I know first write all the HTML for a project, and only then start adding CSS and JS. Learn why is wrong and isn't. Make sure yo…

> And then Javascript. Now it will be easy.

Famous last words.

Re: Why I'm Learning Node

#40
post #34
post #23

Earlier quoted context omitted.

You may see some very nice libraries/tools coming out around node.js, like jade, coffeescript, and stylus. These are all nice and good, and they do increase your productivity, but, only on the client side. I disagree. Firstly, CoffeScript is not confined to the client-side. Besides, there are some modules like socket.io for which you will hardly find any substitues in other eco-systems. You're also discounting the ef…

> The decrease in productivity with node comes from having to write everything with callbacks. Programming asynchronously is crazy, it makes very simple algorithms very annoying to write. I know exactly what you mean, because that's what I thought a year ago. I was going on and on about this to everyone. Mea culpa. Then I actually tried node and learned the functional side of JavaScript (I don't mean the semantics, w…

So your point is that it's hard until you spend a year working with callback-based JavaScript, and then it becomes easy and intuitive? A year of investment may as well be an eternity for most.
Post reply on HN