4 ms·
Good question. You can write a language in any other language. Say you create a language called LASERD and chose to write it in C: You write a program in C tha
by dazzawazza 14y ago
Good question. You can write a language in any other language. Say you create a language called LASERD and chose to write it in C:
You write a program in C that is able to transform LASERD source files in to a form that it can interpret and then execute.
One way to do this is to create a simple virtual machine as part of your C program that is sort of like a virtual CPU (with registers, pretend memory and simple opcodes like ADD, SUBtract, MOVe etc.
The C program takes the LASERD source file interprets the syntax and generates code that can 'run' on the virtual CPU.
This is basically how Lua, Python, Ruby, Java etc work.
Does that make sense?
- dovyski 14y agoIt makes sense to me. Even though this is the "right" way of creating an "interpreted" language, the assignment I asked my students was way more simple: they had to interpret the source code and react to it immediately. There was no intermediate instructions (such as Java byte-code).
- laserDinosaur 14y agoAwesome, thanks for the explanation :)