Question

What real programming languages are easy to write interpreters for?

"Real" languages for me, are languages you can actually write a small project with, not one of the easy Esoteric programming languages.

(I'm asking because I want to do some hobby project.)

Was it helpful?

Solution

The Metacircular Evaluator in SICP is an exercise for writing a Scheme interpreter in Scheme. It's a common first-year CS project.

OTHER TIPS

It is very easy to write an interpreter for the programming language Forth (once you know how - but it is well documented). Forth has been in use for real-world problems for more than 40 years.

Perhaps it is too easy, but you will learn a lot in the process.

A light-hearted (online) introduction is in chapter 9 of Leo Brodie's "Starting FORTH".

The original Wirth's Pascal is a good candidate, and often used as a demo in parser generators. Its grammar is LL(1), and otherwise fairly strict, so it's easy to parse. Feature-wise it's pretty limited as well.

You might want to fiddle with it a bit a bit, though - e.g. you might want to ignore pointers, but support first-class strings.

Forth. Okay, now I'm only typing this because I need at least 15 characters in the answer, but the smallest Forth implementations are a couple of KB. It's hard to think of any other language that could have such a small core. Maybe the original McCarthy 1958 Lisp, where the functions were hand compiled.

Scheme, or any lisp variant.

In my college operating systems class we wrote an interpreter for Db (D-flat). It was very simple and well-defined.

I would think a markup syntax language, Liran. The syntax structure makes for easy parsing since code blocks are clearly delineated between begin and end tags. You could theoretically easily build a level 1 interpreter that parses and runs the code directly.

That said there aren't any markup languages out there that do meaningful things in the context I seem you are aiming at (you may want to write your own). Next best choice would probably languages with minimum functionality and preferably not supporting procedural programming. A language like BASIC should be easy to build a level 1 interpreter for.

Next best thing perhaps is early script languages which didn't offer many syntactic elements and were rather short in complexity. I fail to think of any though.

But perhaps the best option of all is for you to design your own language. The interpreter becomes easier to build because you have a deep knowledge of the language syntax and can rule your own language structure and semantics in the interpreter.

...

The insistence on level 1 interpreter is because you did mention you want it easy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top