Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This question already has an answer here:

my question is this; How do I start making a programming language? By this I mean not an interpreted language, but I want to know how do I start from the machine code and work up, like the first programming languages, as in I want to build something entirely new. I should make it clear i'm not asking for a guide because I'm sure one doesn't exist; I'm asking for pointers, tips, advice, things like that. This is not for any purpose other than solely that I want to learn, and it interests me greatly, but I'm not sure where to start, I've looked around online and I cant find an answer. I'm sorry if this is too vague, but I didn't know where else to ask this question and I'm not sure how to make it less vague.

share|improve this question

marked as duplicate by Michael Durrant, MainMa, Kirk Broadhurst, James McLeod, gnat Oct 15 '14 at 3:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4  
You could start by taking a compilers course or working out how compilers work. :) –  Vaughan Hilts Oct 15 '14 at 1:04
1  
Start here: nathansuniversity.com. –  davidk01 Oct 15 '14 at 1:56
    
recommended reading: Where to start? –  gnat Oct 15 '14 at 3:45
    
Guides do exist. But you could start by learning what programming languages are, what concepts they use and how they are designed. –  babou Oct 15 '14 at 10:22

1 Answer 1

If you want to learn, you shouldn't start by re-inventing the wheel, this is the hard way. There are two interrelated subjects you should study to learn how to do this:

  • The Theory of Computing (sometimes called automata theory)
  • Compiler design, theory, and implementation.

There are many math text books you can find on automata theory, and compiler theory is built on top automata theory.

To build your own language you will need, at minimum, to understand:

  • Context Free Grammers (CFG)
  • Lexical analyasis
  • Various Forms of parsing: LL(k), LR(k), LALR(k) (k=1 is the most common)
  • Code Generation

Not to mention, optimization, internal representation (intermediate formats), etc.

If you want to learn this the best way is to get the "dragon book" (aka http://www.amazon.com/Compilers-Principles-Techniques-Tools-Edition/dp/0321486811) Most serious compiler courses will use some edition of this as their textbook, it should contain the necessary theory of computing that the book utilizes.

share|improve this answer
2  
3 out of 4 items in your list are about syntax. That is absurd as it is the part you can get from the shelf. You can actually implement a compiler with only rudimentary knowledge of syntax analysis. What is first needed is to understand programming paradigms, structures and concepts. Implementation expertise will get you nowhere if you cannot design properly what you intend to implement. –  babou Oct 15 '14 at 10:19
    
Thanks for the answer and I'll look into all the things your brought up. –  user3550574 Oct 15 '14 at 19:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.