4 ms·
I just finished hand converting ~1k lines of js to cl. I’ve been using lisp for multiple decades, and every time I have to use another language it’s so painful,
by abrax3141 3y ago
I just finished hand converting ~1k lines of js to cl. I’ve been using lisp for multiple decades, and every time I have to use another language it’s so painful, either per syntax or speed, that if I want to extend the code, it’s often worth the time to convert it. (In this case, I wanted to wrap the core algorithm in an mcmc optimizer, but the js was entangled in its ui, so it had to be untangled anyway so I got both the de-tangled algorithm, and it running over 200x faster by the conversion!) I’ve done this sort of thing before - quite a lot, actually - and macros are very very useful in this setting because you can make lisp do whatever random thing your source language syntax does quite naturally. The other thing that drives me f’ing nuts about almost every other language than lisp is that there’s always some aspect of the (non-lisp) language that fails to have syntactic scoping. Python is, of course, the worst case of this (at least among common languages) - white space is just an insane way to scope because you literally cannot see certain bugs. The one that kept making me crazy in js is the waterfall if-elses they use as case statements. It’s essentially impossible to figure out the scoping of complex nested ifs, except by tracking back every subclause. (Or putting it in a js-smart editor and using the auto-indent, and hoping that the author put line-turns in relevant places, which is what I ended up doing.) This is yet another often unrecognized advantage of the somewhat verbose but highly uniform lisp syntax (or lack of syntax!); Yeah, okay, you do end up with lots of irritating strings of parens at the end of some long code blocks, but you can absolutely always tell in any case by the same uniform operation the scope of every code block and sub block, and better still, reorg them as needed by just grabbing everything in the relevant parens, and blasting it where you want it, and 9 times out of 10 that’s all you need to do for most local refactoring.))))) :-)