4 ms·
previous discussion https://news.ycombinator.com/item?id=6068360 https://news.ycombinator.com/item?id=6068360 * I'd be curious to hear if @munificent has chang
by dahart 9y ago
previous discussion https://news.ycombinator.com/item?id=6068360 https://news.ycombinator.com/item?id=6068360
* I'd be curious to hear if @munificent has changed his mind about this article at all since it was written.
Since 2013, JS has added optional lexical scoping and continuations (promises). There is arguably a distaste for mutation in the community and among the major JS frameworks, not sure if that counts.
- mst 9y agoPromises and generators are both awesome, but they're both way more restrictive than call/cc. Now, I tend to the idea that that's usually a feature - and that at most strictly delimited continuations is more than sufficient in a normal language - but equating promises to continuations is ... not really accurate. (but oh gods 'let' makes me so happy, having to get sensible closure behaviour by typing out let-over-lambda shenanigans by hand was -ing horrible)
- dahart 9y ago> equating promises to continuations is ... not really accurate. That's fair, agreed, and I don't mean to imply equality. The argument was that JS doesn't have continuations at all though, which wasn't completely true in 2013, and is trending less true over time with promises and generators, right?
- Roboprog 9y agoRe: “let” Some might argue that a function which is so long that it needs block scoping, whether for visibility or storage lifetime management, is too long. I guess it’s at least “mostly harmless”, though :-) (“class” arguably sucks in ES2015)
- z3t4 9y agoI like the function scope as it encourages you to create functions. functions are great! Only time it gets confusing is in the for-loop where most people expect a closure. I tell them to just put the innards of the for-loop in a function. Also with function scope you don't have to worry about the blocks, you can declare variables everywhere and they'll be hoisted.
- mst 9y agoBeing able to write: for (let x in list) { callbacks.push(function () { x+3 }); } instead of: for (var x in list) { callbacks.push((function (x) { function () { x + 3 } })(x); } is a huge advantage to me. (yes, I know arrow function notation exists, but given I was explaining "why I love let" it would've been unfair to use it in the "good" example)
- Roboprog 9y agoOh. I guess I don’t use for...in much (at all). I see your point now, though. OTOH: list.forEach( function( x ) { callbacks.push( function () { return x + 3 } ) } I guess I tend to use forEach, or one of the Ramada.js operations, rather than for loops these days. EcmaScript isn’t Scheme, or Smalltalk/Self, or Ruby. But it sucks a lot less than the other language I’m allowed to use at work :-) (I pretend that ES is mostly Ruby)
- rachitnigam 9y agoBoth promises and generators can be used to implement delimited continuations. Furthermore, there is already a compiler that implements first class delimited continuations in JavaScript: http://stopify.org http://stopify.org The project implements the control operator (which can implement other operators like call/cc). The research paper linked on the website talks about how control is implemented.
- mst 9y agoI've implemented delimited continuations using both. But I don't disagree with any of your factual statements.
- munificent 9y agoI think I still mostly agree with it. let was on the way in when I wrote that, but that doesn't mean lexical scoping is a particularly interesting or defining trait of JS. Most languages today have pretty solid lexical block scoping, so that's more JS playing catch-up than anything else. I don't think of promises as being particularly close to continuations, not even one-shot continuations. I think it's more "If you use promises you have to manually turn your code into continuations." :) I wrote about my thoughts on that idea here: http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y... One thing that has changed in the past few years is I don't see people comparing JS to Scheme very much anymore. I don't know if it's because JS got big enough with ES6 that the comparison seems forced, or because Scheme doesn't have the cachet it had a few years ago, or what. Today, people who like JS seem to like it because they like JS — which usually means they like some combination of dynamic typing, JS's syntax, the platforms where JS runs, and the frameworks people built for it. I think those are all great reasons to prefer JS, much better than comparing it to some other language that it may or may not be similar to. (There are also a lot of people who like JS today because it's the only language they know. I don't think that's a super informed choice, but everyone goes through a first love in their life, and the object of that affection doesn't say much more about its subject than the moment in time that they happened to start programming. My first love was Apple BASIC, but I think I turned out OK.)
- DonHopkins 9y agoINTEGER BASIC or APPLESOFT? ;)
- munificent 9y agoFirst were Applesoft BASIC on my Apple IIe at home, and whatever weird BASIC ran on the TRS-80s at school. Then Microsoft QuickBASIC on an early Mac, followed by FutureBASIC, mostly on a Mac LC. There was a little RealBASIC near the end before I finally switched over to C. FutureBASIC was my jam. QuickBASIC was too slow so I tried to learn C, but it was brutal trying to learn that on my own. This was before the web and I knew zero people who knew any C. Something like a misplaced semicolon would get me stuck for weeks. But FutureBASIC was almost as easy as QuickBASIC, fast enough for games, gave full access to the Macintosh Toolbox (graphics), and had a really cool visual interface builder (PG PRO). I could make software in it that looked like "real" Mac applications (which felt amazingly legitimizing to teenage me) and ran fast enough for real games. It was really hard to make the switch to C because FutureBASIC was good enough for quite a long time. I wouldn't be where I am today without all the fun I had using it back then.
- ahazred8ta 9y agoThe OP has a lot to say https://news.ycombinator.com/from?site=stuffwithstuff.com https://news.ycombinator.com/from?site=stuffwithstuff.com -- https://github.com/munificent https://github.com/munificent -- http://stuffwithstuff.com http://stuffwithstuff.com