Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Programming Language

I was wondering how professional programmers create their own programming languages.
Do they only create a compiler which reads a text file and makes an executable out of it (considering there are no syntax errors etc)?

I'm not planning on creating my own programming language (I'm obviously too unexperienced for that) , I just wanna know how they do it.

like image 512
Normal People Scare Me Avatar asked Mar 10 '13 13:03

Normal People Scare Me


People also ask

Can I create my own programming language?

You can just take a subset of an existing language or come up with a simple variation of it and get started. However, if you have plans for creating your very own programming language, you will have to give it some thought. I think of designing a programming language as divided two phases: The big-picture phase.

How hard is it to create a new programming language?

It's really difficult and it takes a lot of time to do so. Many languages are written one on the other, like C++ is written on C, but every language comes back to one, Assembler.


2 Answers

If you're interested, there's a great free course you can take on Udacity that will give you a good idea: https://www.udacity.com/course/cs262 (Programming Languages - Building a Web Browser). I'm not halfway through the course yet, but we've learned some interesting concepts as well as the foundations of lexical analysis. You might think a web browser has nothing to do with a programming language (I did), but actually, they do pretty much the same things except for compiling the code to executable form. They both have to read, parse, and lex code, and interpret it according to the specification of the language. JavaScript is also a pretty powerful language built into every modern browser (and many other 'languages' are interpreted by browsers now as well).

To give you another example, the inaugural implementation of Python was implemented in the C programming language. This allows python programs to make use of C source code. There is also a Java take on Python (jython) that interoperates with Java programs. What makes Python Python (if you ignore the batteries-included aspect of it) is the language specification which includes things like what are the reserved words, how objects are stored in memory, what kind of expressions and control structures are valid, etc. etc. I'm by no means knowledgeable enough to develop a 'serious' language like Python. But someone who is would have to develop it in another language. Even if you did have the ability to develop another language, you would have to have something special for it to become widely used, as there are thousands of programming language, many of which are considered hobby languages (for example, there are languages designed so that their source code will resemble a Shakespeare play, or a recipe).

like image 173
Hart Simha Avatar answered Nov 07 '22 16:11

Hart Simha


You should read up on compiler construction. Some of the main areas include:

  • Lexical analysis
  • Syntax analysis
  • Semantic analysis
  • Code optimisation
like image 38
Darren Avatar answered Nov 07 '22 14:11

Darren