5 reasons to create your own programming language

  • 1. its easier than you think

mostly its about chopping a file up into lines, then reading the lines and doing stuff based on what words are found. a couple loops and a lot of if-then statements are all you technically need.

  • 2. its fun and rewarding

even if the only language you ever make is a “toy” language, you can always joke that you wrote a toy programming language, which is a real accomplishment for anyone.

  • 3. it will help you understand how programming really works

even though serious languages have a lot more expertise go into their designs, the fundamentals are general enough that writing nearly any language will teach you more than it misleads you (unless youre really fishing for ways to be wrong.) languages differ in incredible ways, but they all have a fair amount in common.

  • 4. it will help you appreciate programming and language developers more

just as nothing will give you more insight into applications than writing them, nothing will give you better insight into what language developers go through than becoming one; particularly if youre still tweaking things half a year later. the first month i worked on my language a lot, and less than a year later i only work on it occasionally. theres no vantage like first person.

  • 5. you can write a useful language if you dont make it too general-purpose

general purpose languages are fantastic, but its incredibly difficult to design one with merits that anyone would want to use. far better to think about one or two things your favorite languages cant do, and focus on those as problems to solve. reinventing the wheel for a red wagon is a lot easier than reinventing the landing gear for an airplane, or even a spare for a minivan. try writing a language that makes just one job easier– or, take an app youve written and bolt on a way to automate it using a text file.


note: the difference between a lexer and a parser

a lexer takes your program source and separates it into tokens.

the parser figures out what to do with the tokens.

these are often separate things, and if you can code in c (i dont) there are even projects to generate a custom lexer/parser for you.

its increasingly common (though not necessarily more common) to see hand-written parsers, and combined lexer/parsers, so dont think you cant do that.

and if all that sounds too complicated, just follow these steps to a ridiculously simple toy language:

    1. loop through lines

        2. loop through space-separated words in each line

            3. if you see a word that is contained in an array (or dict) of keywords:

                4. get the next word and do a predefined action in response to that

thats a cheap way to do it, but its enough to get started. the experience you get making the simplest of languages will assist you in any future projects to extend or re/design that language, or develop an improved design.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s