Writing your own programming language with the DLR (Dynamic Language Runtime) 30. March 2009 Reviews Comment (3) Image stolen from this great article In accordance to the very good blog with many useful links for IronPython at ironpython-urls.blogspot.com I will also try to post some useful links about my recent DLR (Dynamic Language Runtime for .NET) research. I have been working a bit on the DLR before, mostly together with Silverlight, which was cool, but Silverlight was way too hard to work with and I still think it is not distributed enough. On that note if you are interested in Silverlight, check out the . And even before that quite a bit with the Visual Studio SDK, early IronPython versions and other language implementations in .NET and even with native c code (but usually I just modified existing samples). I have also modified Lua for my own needs recently and made it run on the Xbox 360 and PS3 and modified some behaviour for my projects, since we use it for our upcoming game and I use it quite a lot together with IronPython on the tools I write at work.` But my overall goal remains: Writing my own language, preferbly running on .NET and the DLR seems to be a good fit. Today after we finished the latest demo of our game for the GDC next week, I had finally some time and motivation to get this thing started again :) I probably should do some more XNA projects since I'm a DirectX/XNA MVP and I have still something I work on from time to time, but it is still a long way to go until this project is completely done. Okay, to get things started again I searched for some new DLR information and samples on the net and here are some helpful links: The Tools: DLR - Dynamic Language Runtime, which runs on top of the CLR in .NET (even in Silverlight) ANTLR v3 - The best tool ever for constructing your own interpreter/compiler/parser, etc. And these are the most useful links to get started (and other links that interested me): Five minute introduction to ANTLR 3 ANTLR 3 - FAQ - Getting Started Test-Driven Development with ANTLR Quick Starter on Parser Grammars - No Past Experience Required How do I get case insensitivity? Learning the basics and also some good blog posts: Create your own language on top of the DLR - Detailed article about creating a language with the DLR DLR - Build Your Own Language (without tears). Kinda fast paced article that skips a lot of steps, but at least it got me motivated. Part 2, Part 3, Extra Tips CLR Inside Out - IronPython and the Dynamic Language Runtime - Good article about the DLR, IronPython and DLR ASTs Generate AST for the DLR (Code Project). Nicely written, easy to understand and gives a good overview of writing your own custom AST for the DLR. The sample itself is kinda useless because it always generates the same AST, but you will at least understand how code should be parsed and passed to the DLR as an AST. In this tutorial there is no parser or lexer, the generated AST is just static code, but at least the source code is easy to understand :) The article will also explain all the basics you need to understand ASTs and how the DLR uses them. Building a DLR Language - Answering Some Questions - Also a very helpful blog. Goes into detail about whats going on under the hoods, investigates with Reflector. Be sure to also read the other posts of Martin Maly. How to write a simple DLR host in C# using Hosting API Building a DLR Language - ToyScript (Martin Maly's blog) Jim Hugunin's Thinking Dynamic blog - The One True Object articles are interesting, also links to a lot of good DLR talks DevHawk - Blog by Harry Pierson, one of the main guys behind IronPython Martin Maly - Building a DLR Language (more general, see above for more comments) Sapphire Steel blog: Antlr 3 and the Dynamic Language Runtime DLR Hosting and related stuff... Knowing .NET blog about IronPython and .NET The .Net DLR makes building a new language implementation ridiculously easy Building On The DLR - by Tomas Restrepo - An approach to create a simple language with the DLR I still have a problem with the DLR - by mithrandir (Incanus On Rails) - A critice on how the DLR beta was written. I think most of the issues have been solved or not as bad as portraied there. Darrell Hawley's blog, mostly about IronPython integration. Has some cool "Note to self" posts on there. Another critice about the DLR, this time about the fact that it is not really open source since no contributions are accepted. Little bit too harsch. The Weekly Source Code 11 - LOLCode DLR Edition (from 2007) - by Scott Hanselman's ComputerZen.com - fun read. Another post like this from a year ago with helpful DLR links: Adventures in Compilers - Building on the DLR Embedding the Dynamic Language Runtime - IronPython & .NET Applications - A nice tutorial by Michael J. Foord (at voidspace.org.uk) Compiler Books: Basics of Compiler Design by Torben Ægidius Mogensen - Free eBook - Easy and enjoyable read about a hard topic! Compiler Construction by Niklaus Wirth - Also a free eBook (about Oberon) Compiler Design and Implementation - Free eBook about some guy writing his own compiler - step by step Compilers: Principles, Techniques, and Tools (2nd Edition) - A heavy 1000+ pages and kinda expensive book about a heavy topic, was written in 1986, but is still very useful and recommended The Definitive ANTLR Reference: Building Domain-Specific Languages by Terence Parr - This is the book you should read when using ANTLR seriously. Very nice book; I plan to read it when I use ANTLR more. Lots more Free Compiler Design / Construction Ebooks And even more Free Compiler Books (newer) Other useful DLR links: Homepage of IronPython - The main usecase for DLR - quite a lot of releases, performance comparisons and a small, but active community DLR Pad, a very simple app that lets you write and test code with a simple XAML WPF app using IronPython and IronRuby IronPython and the Dynamic Language Runtime Make Your Application Extendable Using the DLR - simple example on how to use IronRuby or IronPython in a little app. Boo also uses ANTLR and is a very interesting project overall (mixture of C# and Python). I used it a bit 2 years ago, but I stopped because of the lack of a decent IDE (yes, I know about SharpDevelop, but that is not decent enough for me). IronPython (and DLR) nightly builds. In case you want to be on the bleeding edge. Silverlight Dynamic Languages SDK Okay, back to improving my lexer and parser. I think I got the research aspect covered for now.