views:

73

answers:

2

Looking at some language features I sometimes wonder how on earth would someone implement a functionality like this. So my question is, which of the numerous existing language features are the hardest to implement? An explanation why is it so is most welcome (maybe even required?).

To maintain order, please only one feature per post.

+4  A: 

MHMH - hasn't this been asked before ?

Efficient closure handling. As closures are used in Lisp and Smalltalk (called "Block" there) MUCH more often than in almost any other programming language, the implementation has to be very fast. So stack allocation is what we want for speed. But, as "real" closures can outlive their defining method-stack frame, care must be taken to get them off the stack if required. Closures are useful everywhere: callbacks, enumeration/collection protocols, longjumps, action-worker queues, observer protocols, delayed evaluation (futures and lazy) and many more. BTW: JavaScript also supports closures !

blabla999
Also, Ruby relies on blocks (closures) very much. Most of Ruby loops are implemented using closures. Also, probably one of the reasons for the bad name which follows Ruby implementations for their poor performance. :)
Mladen Jablanović
+2  A: 

Even the most weird and complex language features, such as C++ templates, are actually relatively easy to implement. What is really hard is to implement those features efficiently.

For me the hardest feature was currying in ML-like languages. Trivial for an ad hoc implementation, it is quite tricky if you want it to be efficient on a stock hardware. See any decent ML implementation for details.

SK-logic