7 ms·
Is the design better in some fundamental way, or is it just about equality comparison and other shallow "wtfs"?
by spion 7y ago
Is the design better in some fundamental way, or is it just about equality comparison and other shallow "wtfs"?
- blacksqr 7y agoI'm not a Node expert, but my understanding is that if any code throws an error, the server crashes and has to be restarted. That prompted a serious WTF from me when I read about it. While Tcl is running as a server in an event loop, if an error is thrown while processing an event it is reported via a background error API, and the server keeps going.
- spion 7y agoThat is true, and node's official advice in this regard is bad. It comes from previous bad designs of error handling and leaking resources (file descriptors mostly) caused by domains. However, modern node code typically uses promises and you can use slightly more old-fashioned methods of managing resources: https://stackoverflow.com/a/19540907/110271 https://stackoverflow.com/a/19540907/110271 You can go a step further and fully isolate "crash-assuming" code from "non-crash-assuming" (promise based code): https://gist.github.com/spion/ed8deb7a3b4add0a6d727dc78fe635d8 https://gist.github.com/spion/ed8deb7a3b4add0a6d727dc78fe635...
- lmm 7y agoI don't know what you consider a deep part of programming language design. E.g. I would consider prototypal inheritance and non-lexical scope to be deep language design mistakes in JavaScript. But even beyond that TCL is a particularly elegant design (rather lisplike in a way) - e.g. Guido van Rossum cites it as an inspiration.
- spion 7y agoWhy do you believe that JavaScript isn't lexical? My understanding is that it is. Do you mean the behavior of `this`? Its similar to Lua in that `this` is actually an implicit function argument (passed left of the dot) but thats definitely very different from say, dynamic scope Prototypical inheritance isn't a "deep" design mistake in so far that its not actually used as such (its mostly used as classical inheritance). Classical inheritance could be argued a design mistake, but one that most mainstream languages make, so I wouldn't go as far as to call it a deep one.
- lmm 7y ago> Why do you believe that JavaScript isn't lexical? My understanding is that it is. Do you mean the behavior of `this`? Its similar to Lua in that `this` is actually an implicit function argument (passed left of the dot) but thats definitely very different from say, dynamic scope `this` but also hoisting - variables get hoisted out of blocks where they are declared, so their scope is not what it looks like lexically. > Prototypical inheritance isn't a "deep" design mistake in so far that its not actually used as such (its mostly used as classical inheritance). I'd argue that even if it's not being used it still adds complexity when reading or debugging.
- spion 7y agoHoisting is still lexical, except the scope is function level. But the point is moot, since we have `let` which behaves "normally" now. `this` is not non-lexical scope, its argument passing. Its the most confusing wart in JS but its actually not a fundamental design flaw, just a syntactic wart: https://gist.github.com/spion/7180482 https://gist.github.com/spion/7180482 > I'd argue that even if it's not being used it still adds complexity when reading or debugging. I disagree, it barely adds a couple of bits of noise here and there. Definitely not a deep flaw. The worst JS flaws are in its anemic standard library and the pre-promises backend standard library included with node. They are overdue for a refresh.