Programming Languages that are Both Interpretable and Compilable?

shx
2020-04-14T03:35:39Z

I've been thinking about the feasibility of defining a language spec that can both be compiled and interpreted lately. I first thought about it while writing code in crystal, which, for the unfamiliar, is a compiled language based heavily off the syntax of an interpreted language (ruby).

Here are a couple reasons I find the idea interesting:

It effectively neuters the interpreted/compiled language debates. Why just choose one, when both have such big upsides?

You could develop a program in the interpreter with the same playfulness as you get in a shell, and then compile it into a speedy 'lil thing!

It would be wonderful for metaprogramming! From my experience, languages usually define a little janked together syntax for compile-time execution. If the language had an interpreter for itself within the compiler, you could metaprogram and program in the exact same language.

I'm curious if any languages like this exist, or if you can think of more benefits.

Edit:
I just want to mention that my reference to 'feasibility' earlier is not born of disbelief - you can write a compiler or interpreter for any (to the best of my knowledge!) well defined formal grammar with enough effort. I suppose I left that word there to account for the fact that I might have unknown unknowns here.

Comments URL: https://tildes.net/~comp/nto/programming_languages_that_are_both_interpretable_and_compilable

Votes: 14

Comments: 25