Live data from Hacker News

How I want to write Node: Stream all the things

caolanmcmahon.com

91–100 of 118 posts

Re: How I want to write Node: Stream all the things

#92

This is highly intriguing, but I must ask why the JS community has this fascination with obscure identifiers like "_". It decreases readability when what should be a logically-chosen descriptive identifier for your class is replaced with a single character that visually recedes into the language syntax. Edit: I've grudgingly given jquery a pass on this because of its ubiquity, but come on, a stream library? Not to me…

var Highland = require('highland');

var ‾ = require('highland'); // Meet overline, the new underscore

Re: How I want to write Node: Stream all the things

#93
post #90

Earlier quoted context omitted.

It doesn't do anything about thrown exceptions. The correct way to deal with an error in asynchronous code is to pass an object describing the error as the first argument to the callback. Any code that takes a callback is expected to know this and not throw exceptions. From a practical perspective, it doesn't make sense to try to catch exceptions in asynchronous code, anyway. Once you do something asynchronous, you l…

The correct way to deal with an error in asynchronous code is to pass an object describing the error as the first argument to the callback. Sure, but what if the error is thrown at you as an exception in the first place—which happens a fair amount, because that's how the JS runtime tells you when something is wrong? How do you get from there to the callback way? What the Lisp macro I mentioned does is generate a sepa…

http://github.com/CrabDude/trycatch

Re: How I want to write Node: Stream all the things

#94
post #63
post #35

Earlier quoted context omitted.

Streams are being used in node.js already with a lot of success. Both basic byte chunk streams and object streams. As long as components are well behaved and only emit uniform data (everything they emit is of the same type), it's not better or worse than any function call.

Right, but the burden is on the programmer to ensure those types. If the stream composition is of simple things, like: cat some.txt | sort | uniq > yay.txt Then it isn't a problem - it's obvious and simple, but I think there will be difficulties as the programs get larger and type-level awareness occupies more space in the programmer's brain vs. it being handled by the compiler...

interesting example. the fact you know you have to call sort before uniq already shows that even with plain gnu unix util the user must know what he is doing.

Re: How I want to write Node: Stream all the things

#95
post #45
post #37

Earlier quoted context omitted.

async: async.waterfall([ fn1, fn2, fn3 ], function(err, result) { }); Q: resultP = [ fn1, fn2, fn3 ].reduce(Q.when, void 0); resultP .then(function(result) {}); .catch(function(err) {}); If you chain thens in Q, you are not doing it right (imho).

Q docs show both. Either way: .waterfall() is still simpler.

It would be trivial to create a q.series or q.waterfall abstraction. The real benefits of promises are that we get back `return`, `throw`, `try` and `catch`, not that it makes our code 'look' more sequential, which is totally possible using callbacks and async.js.

Re: How I want to write Node: Stream all the things

#96
post #43

Earlier quoted context omitted.

- Why BlueBird? What's wrong with Q? - Isn't data a scope down? - https://github.com/petkaantonov/bluebird/blob/master/API.md is API based, not task based. async is API based too, but the API has names like 'waterfall' and 'parallel'. I can click them because I know what they mean. Promises just makes me feel like I'm reading about and endless series of abstractions.

Native Promises already landed Chrome 32 and Q still does not support native promises. Bluebird delegate to native if supported. Promises can be used as flow control, but more importantly, it's an object that encapsulates asynchronous mechanics. I like to see how async can launch an asynchronous operation, then allow listeners to be attached later to capture the result. Now, you may say that if you want to attach lis…

This is false. Bluebird does not and never will delegate to native promises.

Re: How I want to write Node: Stream all the things

#97
post #70

Earlier quoted context omitted.

> JS's lack of strong typing limits your ability to reason about streams (a lot more than just streams, too) and further limits your ability to write performant stream computing software I think you missed my point so I'll restate: in practice you don't reason about streams in Node, because the community (a product of the simplicity of the streams API) has a packaged solution to your problem. It plugs right in. And t…

Can you qualify "Haskell doesn't have anything close to the plug-and-playability of npm modules" because I don't quite get what you mean? Maybe it is because I can't think of anything plug-and-play in node that isn't plug-and-play in Haskell.

Sure. I want a git server with push notifications. Two lines with the pushover module in node.

I would be pleasantly surprised if this existed at all in the Haskell community. Even more so with two lines of my own code.

Re: How I want to write Node: Stream all the things

#98
post #88
post #84

Earlier quoted context omitted.

sane has nothing to do with static typing. Python is a language which is dynamic and has a sane semantics. e.g. in JS {} + {} is NaN and many other examples.

There's a language where `{} + {}` does something useful? Or is the complaint that it should `TypeError`?

If it does anything at all, it certainly shouldn't generate NaN

Re: How I want to write Node: Stream all the things

#99
post #88
post #84

Earlier quoted context omitted.

sane has nothing to do with static typing. Python is a language which is dynamic and has a sane semantics. e.g. in JS {} + {} is NaN and many other examples.

There's a language where `{} + {}` does something useful? Or is the complaint that it should `TypeError`?

It's obviously {}, duh! ;)

(In one of the ways of constructing the natural numbers within ZFC set theory in mathematics, one identifies 0 with the empty set {}, 1 with {{}}={0}, 2 with { {}, {{}}} = {0,1}, and so on.)

Re: How I want to write Node: Stream all the things

#100
post #73

It looks like this whole notion of 'stream' is just a syntactic sugar for javascript guys who lost themselves in a bunch of nested stupid callbacks, which is worse than lisp parens. Instead of nesting whole callbacks, create a stream in the middle; execute first half of callback chain and dump the result into the stream so that next half of callback chain can be executed later. Why is this so an enlightenment for nod…

Wise words of wisdom from kimjotki2, the only real programmer on the internet. Bow down, bitches.

This is not reddit.
Post reply on HN