|
|
|
|
|
by vivzkestrel
17 days ago
|
|
- stupid question: how do you make a programming language like this from scratch? - what is the thought process that goes into making a programming language - what is this field of study or discipline called? - why do we have so many programming languages? what purpose do they intend to solve and how do we know what purpose a programming language was made for? - for example, why was swift made if objective c exists and why was objective c made if c++ exists? |
|
Write a parser from your language’s syntax to an AST (Abstract Syntax Tree) which is the representation of the code in memory. Now write a function from the AST to the compiler output format. That can be some executable binary format (see https://en.wikipedia.org/wiki/Comparison_of_executable_file_...) or some other language, like C (a common target) or something made exactly for that like LLVM (used by clang and Rust), Java or C# bytecode if you don’t mind requiring a VM to run the application. I’ve written Java bytecode generators and it’s surprisingly easy! Getting a simple language off the ground is a lot of fun and not a huge challenge.