Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to start writing a very simple programming language [duplicate]

Recently, I was going around looking for ideas on what I can build using C this summer and I came across this post: Interesting project to learn C?

Implement a programming language. This doesn't have to be terribly hard - I did the language that must not be named - but it will force you to learn a lot of the important parts of C. If you don't want to write a lexer and/or parser yourself, you can use lex/flex and yacc/bison, but if you plan on that you might want to start with a somewhat smaller project.

I was kinda intrigued about the implementing a programming language answer and I'm wondering how do I go about starting this? I've gone through the whole K&R book and I've done some of the exercises as well. I also have a bit of experience in C++ and Java if that matters. Any tips? Thanks!

like image 222
Rex Homming Avatar asked Jun 09 '10 17:06

Rex Homming


People also ask

Can I use 2 programming languages at once?

You can learn two programming languages at once but it is not advised for beginner developers. For anyone who hasn't learned and mastered their first language avoids learning two at the same time. If you have professional experience then learning two languages side-by-side shouldn't be too difficult.

Can I learn coding on my own?

But yes, it is entirely possible that you can be a self-taught programmer. However, it will be a long, tedious process. There's a saying that it takes roughly 10,000 hours of practice to achieve mastery in a field.


2 Answers

I'd start with a simple desk calculator program that can read things like:

5 + 10 * 3

and print the answer. Then you can progress it to add variables, control flow, even functions.

like image 101
Walter Bright Avatar answered Oct 05 '22 00:10

Walter Bright


Can I just say, I have seen many people asking questions like "How do I make a programming language?" or "How hard is it to make a programming language" and most of the answers just tell them that you have to go through years of university and read books that are 1000 pages long. I am here to tell everyone that you may post those answers, but it doesn't help them at all in their journey to make a programming language. I am 16 and have been doing programming for almost 2 years and I write programming languages. Quite advanced object orientated ones as well, but I haven't read any books, no have I done 8 years of university. To get people started, here's a simple programming language written in C#:

string code = "print Hello World";
foreach (string a in code.Split('\n'))
{
    if (a.StartsWith("print "))
    {
        Console.WriteLine(a.Substring(6));
    }
}

anyone who knows basic C# should be able to understand this. You can't start making programming languages without having some programming experience. Make sure you learn a programming language and make sure you know a lot about it, then just start writing simple little bits of code, like I've posted, and with experimentation and practice, you'll start writing some complex programming languages in no time :)

like image 21
Fletcher Cutting Avatar answered Oct 05 '22 02:10

Fletcher Cutting