> Why the choice of java as introductory level?It was a hard choice. I wanted a language that was:
1. Fairly high level with garbage colleciton so users didn't have to worry about pointers and stuff while they were trying to learn basic concepts.
2. Object-oriented, since that's familiar territory for many programmers and because I wanted to show some techniques around working with programming languages in an object-oriented language, like the visitor pattern.
3. Widely known and not mostly confined to a single platform or domain.
4. Statically typed, since I think it makes it much easier to see what types are flowing through the code when it's on paper and you don't have a debugger to help you.
There isn't much in the intersection of that set. Functional languages like SML and Haskell are great for writing compilers and interpreters, but now readers have to learn two things at the same time. C++ is a reasonable widely known typed OOP language, but is a nightmare of complexity. JavaScript is a good OOP linqua franca but the lack of types is a drag. TypeScript is maybe a good choice, but it's type system is so complex and JavaScript has so much weird baggage that I didn't want to go there. C#, Swift, and Kotlin are all nice languages but hew mostly to specific platforms.
Java was the least bad lingua franca I could find. I also don't mind it as a language.
> It’s just that Java is so longform.
My experience is that Java isn't particularly verbose as long as you don't program in a 90's Enterprise Java style.
> as the low-level code is simpler and smaller.
The C bytecode VM is quite compact, but it is so because it deliberately discards a bunch of things like an AST, simple environment representation, or separate resolution pass. It is designed to be implemented in C.
But I also want to teach users those other concepts. If I'd written the tree-walk interpreter that you do first also in C, it would end up a huge sprawling C program. Just dealing with allocating and freeing the AST nodes at the right time would have been miserable.
Not to mention, it means you would have to implement a garbage collector very early on since Lox relies on it but C doesn't have it.