5 ms·
Bootstrapping a prototype-based object-oriented language in 44 lines of code.
- aarongough 16y agoFeedback is warmly welcomed as always. If any of the HN crowd sees issues with this approach I would love to hear about them before I commit to building this into my final language...
- eterps 16y agoI'd love to see an example of such a protoype based object oriented language in x86 Assembly language.
- aarongough 16y agoHaha, well it wouldn't be easy, but it is certainly possible. A good tool to mess with something like that would be 'EaRing', the dynamic assembler by Zed Shaw: http://www.zedshaw.com/blog/2009-08-21.html http://www.zedshaw.com/blog/2009-08-21.html
- petercooper 16y agoSeeing OOP implemented in "raw" C is similarly eye opening. As with this example, you have to do a bit of caretaking, but even the most complex structures are built from simple ones that nearly all languages support. Added: This isn't a particularly simple example, but I just found a good looking PDF on OOP in C that seems worth sharing: http://www.planetpdf.com/codecuts/pdfs/ooc.pdf http://www.planetpdf.com/codecuts/pdfs/ooc.pdf
- aarongough 16y agoThat was my thought when I saw it done too... The PDF I linked to at the bottom of the article shows a full implementation in C which is pretty awesome. If I remember correctly it's only a couple of hundred lines long. At the moment I am in the process of writing a VM which provides basic functions tailor-made for implementing a language this way. Should be interesting to see how it turns out...
- ekiru 16y agoThe send macro is a particularly clever bit of the C implementation. It uses GCC ({ }) compound statement-as-expression macros and static variables to insert an inline method cache at every place that you send a message to cache the result of lookup.
- deleted 16y ago[deleted]
- aarongough 16y agoI have to admit some confusion. Where are you seeing the Hello World code?
- mkramlich 16y agooops, you're right. i got it mixed up with another "new language" post I saw today. deleting my comments...
- aarongough 16y agoI thought it might be something like that :-p
- deleted 16y ago[deleted]