The following is a short interview with Succinctly series author Vassili Kaplan, whose latest book, Implementing a Custom Language Succinctly, was published recently. You can download the book here.
Implementing a Custom Language Succinctly
What should people know about the subject of your book? Why is it important?
If you know how a compiler works, you start programming differently and more efficiently. There are a few ways of implementing the same algorithm, but usually they are not equivalent and one of them will do its job more efficiently than another.
For instance, in C++ the prefix operator ++x is usually more efficient than the postfix one x++, when x is not a primitive type.
In CSCS, “for (element : array)” loop is more efficient than “for (i = 0; i < size(array); ++i)” for accessing all elements of an array.
The good thing about a custom language is precisely that it’s custom—you can easily change basic language features and their implementation. For instance, you can fine-tune the performance of “for (i = 0; i < size(array); ++i)” loop if this is the loop you want to use the most. You can add new operators and new programming rules, so you can start having even more fun when programming!
When did you first become interested in this subject?
A few years ago, I wrote a custom algorithm to parse a mathematical expression, Split-And-Merge. When I was publishing an article describing this algorithm in MSDN Magazine, I was asked by the editor to add a sentence on how this algorithm can be used in real life. So I added this sentence:
“With small adjustments you can also create your own C# compiler for your new scripting language”
(in https://msdn.microsoft.com/magazine/mt573716)
Only after the article was published, I started thinking: “And how do I actually do that?”
As a result, I published another article in MSDN (https://msdn.microsoft.com/magazine/mt632273) and this is how CSCS, Customizable Scripting in C#, was born.
Vassili Kaplan
By writing this e-book, did you learn anything new yourself?
I fixed a few bugs when describing the language and when running examples.
How will this subject change over the next few years?
I believe there are going to be more custom scripting languages for mobile development. More and more people are starting to program for mobile devices, and it appears that this niche is not taken by anyone yet.
Do you see the subject as part of a larger trend in software development?
I hope it will be a larger trend because it makes programming much more fun!
And having more fun means being more productive!
What other books or resources on this topic do you recommend?
I would strongly recommend Modern Operating Systems by Andrew S. Tanenbaum. (https://www.amazon.com/Modern-Operating-Systems-Andrew-Tanenbaum/dp/013359162X)
Even though it’s not about writing programming languages, it gives a very good idea of how operating systems work and can give a few clues on how to write the next programming language.