Better HN
topnewbestaskshowjobs
Log inSign up

substack

1,135 karma · joined Mar 22, 2009 (17y ago) · 212 submissions

Whatever.
Submissions

comment 15y ago · link · parent

I gave haskell a shot as some of my earlier github repos indicate: https://github.com/substack. I even wrote my blog in haskell with happstack, since snap hadn't gotten popular yet.

Haskell is very hard, but even after 3 years of pretty intensive use, I never really felt productive with haskell in the same way that I've felt in other languages. Anything I did in haskell required a lot of thinking up-front and tinkering in the REPL to make sure the types all agreed and it was rather time-consuming to assemble a selection of data types and functions that mapped adequately onto the problem I was trying to solve. More often than not, the result was something of an unsightly jumble that would take a long time to convert into nicer-looking code or to make an API less terrible to use.

I built an underwater ROV control system in haskell in 2010 which went well enough, but I had to tinker with the RTS scheduling constantly to keep the more processor-hungry threads from starving out the other ones for CPU. The system worked, but I had no idea what horrors GHC was performing on my behalf.

Later I built the first prototype of my startup with haskell, but the sheer volume of things that I didn't know kept getting in the way of getting stuff done in a reasonable time frame. Then we started to incrementally phase out haskell in favor of node.

I write a lot of node.js now and it's really nice. The whole runtime system easily fits into my head all at once and the execution model is simple and predictable. I can also spend more time writing and testing software and less time learning obscure theories so that the libraries and abstractions I use make sense.

The point in the article about haskell being "too clever for this benchmark" sums up haskell generally in my experience.

comment 15y ago · link · parent

Reading the section on ruby reminds me of the things that I take for granted in node.js right now owing to the long history of package management and module systems that it builds upon.

It's super nice having the dependencies specified by semvers in a package.json and installed locally in a project node_modules directory so that libraries can't step on each others toes.

The "Don’t use Bundler version X with RVM version Y" can be specified directly in the package.json and concurrent versions of module dependencies even work without incident in the same project.

comment 15y ago · link · parent

Presumably by modifying `require_paths` and therefore changing how `require` behaves.

comment 15y ago · link · parent

Native apps in webOS are written in node.js:

https://developer.palm.com/content/resources/intro_to_hp_web...

comment 15y ago · link · parent

I don't see how it's specious to prefer javascript syntax over python syntax for asynchronous code. It's an aesthetic consideration and so it's less about the fact that you can have the same sorts of functionality and structures in both environments and more about which style people prefer.

I really don't understand why whenever somebody switches to node from python people pounce on them like this, as if people aren't allowed to find a particular syntax annoying?

comment 15y ago · link · parent

There's a link to heatmap.js in the article.

127.

Heatmaps for node.js and the browser(substack.net ↗)

56 points · by substack · 15y ago · 3 comments

comment 15y ago · link · parent

It's handy for whipping out gdb to investigate segfaults at least.

comment 15y ago · link · parent

For context, see http://blog.nodejs.org/2011/07/11/evolving-the-node-js-brand...

comment 15y ago · link · parent

Oh I forgot to mention in the article, but I'm also using burrito for node-detective (https://github.com/substack/node-detective) to find all the require()s in a javascript file. Using detective made browserify (https://github.com/substack/node-browserify) much easier to use.

131.

Javascript AST trickery with burrito(substack.net ↗)

64 points · by substack · 15y ago · 6 comments

comment 15y ago · link · parent

> To do that the dependency module IDs must be extracted from the module text via static analysis, but that's fairly easy since module IDs are specified to be string literals. A simple regex is usually good enough, but using one of the many JavaScript parsers is safer.

I did exactly this for browserify, yet another node-based browser-side require() bundling system. Another benefit of this approach is that you can use modules made for node just by require()ing them in your browser-side javascript, so long as your static analysis bundling is recursive and the modules can be `require.resolve()`'d by node.

133.

Node.js: batteries not included(github.com ↗)

2 points · by substack · 15y ago · discuss

comment 15y ago · link · parent

Actually in node at least modules can export functions directly, just assign a function to `module.exports` and when you require() that module you'll get a function back. Plus you can add attributes to that function since functions are also objects.

comment 15y ago · link · parent

And the nodeconf slides are at https://gist.github.com/958556

comment 15y ago · link · parent

Javascript compressors can intelligently remove blocks that general purpose stream compressors can't, like dead code or comments. Also because they understand the AST they can move code around to a limited extent to make the final output shorter.

comment 15y ago · link · parent

Automatic compression isn't in there yet but you can compress the bundles using the "filter" option, which just takes a function that transforms the bundled source.

138.

Browserify: browser-side require() for your node.js(substack.net ↗)

40 points · by substack · 15y ago · 9 comments

139.

Salvador Dali, spatial frequency, and Lincoln(scottmcd.net ↗)

2 points · by substack · 15y ago · discuss

comment 15y ago · link · parent

Isn't this what perl6 grammars set out to solve?

comment 15y ago · link · parent

I suspect that previous attempts haven't been successful for a number of reasons but especially because they tend to be synchronous. Node is a great platform for asynchronous rpc because the asynchronous character is already designed to make the programmer have to think about where the high-latency barriers are. I ran into this problem with drb in ruby for a job queuing system and had to write my own thread pool and polling system to compensate for it. Handing a callback off to your remote method does seem to work reasonably well at addressing these common rpc pitfalls.

comment 15y ago · link · parent

Nowjs seems to have a replication system baked in with harmony proxies so when you update data structures these changes get pushed out to the clients. I chose to have dnode just make copies but I do plan on writing a replication middleware at some point with the .use() functionality that landed in dnode v0.5 so I'm interested to see how well this replication approach turns out with nowjs.

comment 15y ago · link · parent

And in the next release of Socket.IO Guillermo has promised us multiple channels, so projects like nowjs should get channels for free!

comment 15y ago · link · parent

On that note, (browserify author here) I would love to see projects like nowjs start to abuse the "browserify" field in the package.json for client distribution like dnode v0.6 does (presently in staging until socket.io-node v0.7 lands). With this field you can `require('pkgname')` in your browser-side code just by specifying 'pkgname' in your require list, even though pkgname might have both server and browser-side components.

comment 15y ago · link · parent

The solution I settled on for dnode is that a deep traversal finds all the functions in your argument list, pulls them out, and wraps them. This part of the protocol is a reusable module if you want to go with it:

https://github.com/substack/dnode-protocol

It's written for continuation-passing style but it shouldn't be too hard to retrofit it for other call styles if you want to preserve explicit returns for instance.

comment 15y ago · link · parent

Rival node.js RPC project (dnode) author chiming in here.

This is pretty neat and I like the emphasis on getting stuff going in as few lines as possible but I'm not convinced that return values and implicit result callbacks are the way to go for asynchronous requests, which is how I understand this project to work. Often when you want to make a remote call you'll be doing some I/O on the server side, which in node is asynchronous so you can't return right away. Passing along a callback from the client side works much better when the I/O actions have some values to call the client back with.

comment 15y ago · link · parent

Ah, your point makes much more sense now. Yes, the author had some overly complex examples, but I'm optimistic about using user-space libraries to handle flow control without having to add new language primitives.

comment 15y ago · link · parent

First, why wrap your second example in try {} catch {} but not the first? The second example (final example from the article) seems like it was intentionally made more complicated to prove its point, but it could just be unfamiliarity. Node idioms are just different from other environments and it takes time to get a good feel for them.

(Edit: noticed that the article does it this way.)

How about just:

    function insertCollection(collection, cb) {
        if (collection.length === 0) cb(null);
        else db.insert(collection[0], function (err) {
            if (err) cb(err)
            else insertCollection(collection.slice(1), cb)
        }
    }
That's hardly much more complex, and as a bonus won't lock up your whole program while db.insert() is working. You could use something like my own library Seq() too:

    var Seq = require('seq');
    function insertCollection (collection, cb) {
        Seq.ap(collection).seqEach(function () {
            db.insert(c, this);
        }).seq(cb).catch(cb)
    }
That is, if you actually want the inserts to go sequentially. Usually you want them to go in parallel with say a maximum of 10 pending requests:

    var Seq = require('seq');
    function insertCollection (collection, cb) {
        Seq.ap(collection).parEach(10, function () {
            db.insert(c, this);
        }).seq(cb).catch(cb)
    }
I don't see any "fundamental issue" with node here. It's just a very new ecosystem and the idioms and libraries are rapidly evolving.
1
45678