How I want to write Node: Stream all the things
91–100 of 118 posts
Re: How I want to write Node: Stream all the things
#92This 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');
Re: How I want to write Node: Stream all the things
#93Earlier 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…
Re: How I want to write Node: Stream all the things
#94Earlier 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...
Re: How I want to write Node: Stream all the things
#95Earlier 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.
Re: How I want to write Node: Stream all the things
#96Earlier 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…
Re: How I want to write Node: Stream all the things
#97Earlier 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.
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
#98Earlier 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`?
Re: How I want to write Node: Stream all the things
#99Earlier 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`?
(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
#100It 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.