Creating a new programming language from scratch?
-
I'd like to know if anyone has any suggestions regarding how someone would go about writing a new language from scratch, then using this language to create its own compiler. I've been entertaining the idea of writing my own language, mainly because I find pretty much every other language unreadable in terms of syntax choices, and overall visual representation of the code. My own experience with coding is limited, with most of my experience being in GML (GameMaker Language), and I've started picking up on Java. I was really impressed with GML's syntax and loose variable declaration, but to my knowledge it cant be used to create general computer software. When I started Java, however, I was completely turned off to its formatting requirements and syntax. Basically, I would like to create an easily read all-purpose language, and I'd like to try to combine all of the "pros" of the most popular languages, while eliminating as many of the "cons" as possible.
-
I'd like to know if anyone has any suggestions regarding how someone would go about writing a new language from scratch, then using this language to create its own compiler. I've been entertaining the idea of writing my own language, mainly because I find pretty much every other language unreadable in terms of syntax choices, and overall visual representation of the code. My own experience with coding is limited, with most of my experience being in GML (GameMaker Language), and I've started picking up on Java. I was really impressed with GML's syntax and loose variable declaration, but to my knowledge it cant be used to create general computer software. When I started Java, however, I was completely turned off to its formatting requirements and syntax. Basically, I would like to create an easily read all-purpose language, and I'd like to try to combine all of the "pros" of the most popular languages, while eliminating as many of the "cons" as possible.
For a self compiling compiler, you should have your compiler: A: LLVM (seems to be the easiest for machine code right now) for a backend B: Target a virtual machine (e.g. JVM or .NET) that has the features you need C: Translate code to an existing language that runs on platforms you care about (Like the first C++ compiler generated C code) For any programming language, you will need to write a parser. I prefer inline PEG parsers (like Boost Spirit and Parslet) over parser generators. Having a lexical analyzer can make parsing a lot easier when, but it is not required. If you are planning on making a serious language that you want other people to use, read this article. Popular languages that are not aiming to be a C/C++ replacement tend to converge to a hybrid of Lisp and Smalltalk but with a better syntax. So look those up to get good foundation, and while researching Lisp you may also want to look at Scheme and Kernel. Maybe Prologue as well, since it is so different and therefore might help with inspiration. Finally, lambda-the-ultimate.org is a good place to look for stuff on programming language theory and design. P.S. Making a language is a long and involved process if you want to make a good one.
-
For a self compiling compiler, you should have your compiler: A: LLVM (seems to be the easiest for machine code right now) for a backend B: Target a virtual machine (e.g. JVM or .NET) that has the features you need C: Translate code to an existing language that runs on platforms you care about (Like the first C++ compiler generated C code) For any programming language, you will need to write a parser. I prefer inline PEG parsers (like Boost Spirit and Parslet) over parser generators. Having a lexical analyzer can make parsing a lot easier when, but it is not required. If you are planning on making a serious language that you want other people to use, read this article. Popular languages that are not aiming to be a C/C++ replacement tend to converge to a hybrid of Lisp and Smalltalk but with a better syntax. So look those up to get good foundation, and while researching Lisp you may also want to look at Scheme and Kernel. Maybe Prologue as well, since it is so different and therefore might help with inspiration. Finally, lambda-the-ultimate.org is a good place to look for stuff on programming language theory and design. P.S. Making a language is a long and involved process if you want to make a good one.
This is not the right forum, but once this topic is here already, I would suggest you to read the dragon book: Compilers: Principles, Techniques, and Tools[^]. It will point you in the right direction and give solid base for your effort.