How To Get Started Making a Programming Language

Hey guys I was wondering how programming languages are made and how I could make one?

Java was made cause the other tools didn't work. Forget who the guy was or his company, read about it 20 years back. The guy locked himself away for a few days and created what was called C minus. I know this doesn't answer your question but if I knew more I probably wouldn't be driving a truck fer a livin:) . C++ came about to take advantage of the then new L1 and L2 cache.

I'll chime in on the second part of your post; unfortunately, the answer there is probably something like "read a book or twenty..." You'll want to look for books on compiler/interpreter design, in addition to just finding ones on the design of programming languages in general.

This blog series (wip) goes through making a Pascal interpreter in Python:

https://ruslanspivak.com/lsbasi-part1/

Personally, I've found it quite useful for learning more about the internals of compilers and interpreters. He's also got a recommended reading list at the bottom, if you want to check those out too.

Learn about how compilers and interpeters work, then learn assembly and machine code.

1 Like

The better option I think would be to contribute to an already existing language that you enjoy, try to find things that would be useful and add the functionality so that you can share it with the rest of the world.

Find an open source language, dig in and start getting your hands dirty with it, see what you can create. If you come up with something good, send the changes back to the master.

1 Like

11 days late, but, to start with, I find old, and old-school books on compiler construction to be better at presenting actual examples of hands-on how-to. Most modern books on interpreters and compilers are too focused on cutting edge stuff, parsing theory, etc., when you actually only need something to get your juices flowing. To feel the progression of getting something done.

So, I would first have a look at how BASIC programming language worked way back in the 80's, on 8-bit computers. Oh yes, that's right :) .

That used to be a very simple interpreter, often contained within a few 1000 bytes of code, thus easy to grasp in entirety. I'm pretty sure you can find manuals for the old computers such as C64 and ZX Spectrum 48. How would you implement that?

Then I would have a look at how assembly language works on the CPU:s of those two computers. Again, because it is simple to grasp in entirety.

Then I would also look at how 8-bit and 16-bit emulators are implemented (mostly look-up-tables). This will give you an idea of how a limited virtual machine can work out, and what it may need to be able to deliver.

By now you would have covered interpreted languages and virtual machines.

These are the basic concepts that you probably can imitate on your own with most ease - very low complexity. If you play around in Java, C, C++, or whatever language trying to implement these (Java might get you faster through a prototype), you should find that you can end up with a working simple programming language quite quickly and easily, and start asking yourself what you would like to have it actually achieve.


For a possibly next step:

As for compilation to native code (ARM, x86/64, etc), that will take considerably more time, because documentation on how to create binary executables for specific operating systems will be either difficult to obtain, or obscure to read. If you anyway choose to go that way, it may be easier to start by compiling to assembly language (or intermediate language like LLVM or RTL), and then use an actual end-assembler/compiler to create an exe, but you will probably also need to create some kind of runtime to link with, so I would suggest starting with an interpreter, or a byte-code compiler and interpreter before going for a full-on native-compilation.


If you decide to spend some money on it, check at least this one:

But do also consider this one:

These two books are a fantastic read on the subject of programming language and virtual machine implementation.

Also, do not forget to check how Lua and Ruby are made to interop with C. In fact, you can run (interpret) both from within a C/C++-program. I think Ruby can also run within Java, but it's been a while I checked on that.

And, yes. I did roll out my own. It is a private pet project (one of many that will never be truly finished, because you can always add to it).

  1. install gentoo
  2. ???
  3. Profit

Well if you want to dive in, perhaps start looking into assembly (machine code) its the lowest point between hardware and software.