DEV Community

Discussion on: Creating a new programming language

Collapse
 
gtanyware profile image
Graham Trott

Congratulations, Sajjad. What I find most interesting is the curiosity-driven mindset that motivates someone to write a new language.

There are about 6500 human languages in the world, which is all the richer for them. And this ignores dialects or variants used by specific interest groups.

So we can well afford a few more computer languages. Writing one is a mind-broadening job with unpredictable spin-offs. To anyone wanting an interesting project, I'd say "write a new language" and then "use it for something" (the only true test of value). You may be surprised how much you learn, you'll have a lot of fun and you never know where it might lead. Just remember, many of today's best computer languages started that way.

Collapse
 
mcsh profile image
Sajjad Heydari

Thank you for your kind words!

I want to write this language, and then write the compiler within itself. Which will probably take longer than I like to admit, but I'm up for the challenge!

Collapse
 
gtanyware profile image
Graham Trott • Edited

It may depend on how close your language is to the one it's currently written in. Could be a lot of it is a relatively simple substitution exercise. Or not. I did this back in about 1985. I originally wrote my compiler (a variant of PL/M) in assembly-language then rewrote it in itself. High-level languages look nothing like assembler so the new version was structurally very different from the old. However, much of the time in developing the original had been spent designing the syntax and figuring out what it should do, so little of this effort was needed the second time around. I think the second iteration actually took a lot less time than the first.

If you're going for self-compilation you can limit the scope of the initial product to the minimum needed to compile itself. All other features can wait until you have self-compilation working, after which you're operating entirely in your own code. This should flush out errors very quickly and your debugging takes place in a simpler environment than if you wait for everything to be in place. Well, that was my experience, at least.