Co-routines (as of JavaScript 1.7)
So I was playing around with some of the new features in JavaScript 1.7 - not a lot of discussion about them in the Firefox 2.0/IE 7 release brouhaha, but definitely really useful improvements there for developers.
In particular, co-routines (in the form of the "yield" operator) are the key big improvement (IMHO). The rest is mostly syntactic sugar - and in fact, most of those are indeed enabled by co-routines (which they label as "Generators").
I have to admit, though, to being a little disappointed with trying to use them in practice, for "programming in the large" with JS type things. As always, I might be missing something - but what I'm finding is that most of the time I don't want to necessarily yield to just the calling function; I want to yield waaaay up the stack. I think what I'm really looking for is a "resumable" exception of sorts- where I can yield all the way up somewhere, take some action, and then continue execution back to the yield - ALMOST there with JS 1.7 generators - but the implementation seems to be more about keeping up with Python superficially... ah, well.
Still - it does simplify A LOT of real world design patterns, so I can't complain. No denying that co-routines are a powerful programming paradigm, which I first saw in Ruby, then Python, and now JavaScript. There are even a few attempts to bring them to C - but I guess the interesting question will be how much browser adoption (in a fragmented market) of these features affects their real world utility and use.
Adobe has much less of that particular adoption problem - being a single vendor monopoly for core technology has its advantages.
In particular, co-routines (in the form of the "yield" operator) are the key big improvement (IMHO). The rest is mostly syntactic sugar - and in fact, most of those are indeed enabled by co-routines (which they label as "Generators").
I have to admit, though, to being a little disappointed with trying to use them in practice, for "programming in the large" with JS type things. As always, I might be missing something - but what I'm finding is that most of the time I don't want to necessarily yield to just the calling function; I want to yield waaaay up the stack. I think what I'm really looking for is a "resumable" exception of sorts- where I can yield all the way up somewhere, take some action, and then continue execution back to the yield - ALMOST there with JS 1.7 generators - but the implementation seems to be more about keeping up with Python superficially... ah, well.
Still - it does simplify A LOT of real world design patterns, so I can't complain. No denying that co-routines are a powerful programming paradigm, which I first saw in Ruby, then Python, and now JavaScript. There are even a few attempts to bring them to C - but I guess the interesting question will be how much browser adoption (in a fragmented market) of these features affects their real world utility and use.
Adobe has much less of that particular adoption problem - being a single vendor monopoly for core technology has its advantages.
2 Comments:
If you want "resumable exceptions" as you call them, look for languages supporting continuations, like any modern Scheme implementation. Mozilla's Java implementation of JavaScript (Rhino) also supports continuations in interpreted code.
runescape money runescape gold runescape money runescape gold wow power leveling wow powerleveling Warcraft Power Leveling Warcraft PowerLeveling buy runescape gold buy runescape money runescape items runescape gold runescape accounts runescape gp dofus kamas buy dofus kamas Guild Wars Gold buy Guild Wars Gold runescape accounts buy runescape accounts runescape lotro gold buy lotro gold lotro gold buy lotro gold lotro gold buy lotro gold lotro gold buy lotro gold runescape money runescape power leveling runescape money runescape gold dofus kamas cheap runescape money cheap runescape gold Hellgate Palladium Hellgate London Palladium Hellgate money Tabula Rasa gold tabula rasa money 陈楚生 压力开关 压力传感器 流量开关 流量计 液位计 液位开关 温湿度记录仪 风速仪 差压开关 可燃气体检测仪 过滤器 强磁水处理器 自清洗过滤器 自动反冲洗过滤器 保鲜棕榈树 棕榈树
Post a Comment
Links to this post:
Create a Link
<< Home