I'm novice programmer, learning C.
Something that's always confused me is how do people create new programming languages?
- What language do they write it in?
- Does the language have to be one that in between a high level language and machine code?
- What are the stages/elements of creating a programming language For example - C or C++(From my basic research I've realised that all programming languages either need a compiler or an interpreter but I don't really understand the difference between the two)
As I said, I'm a complete novice but I'm really intrigued by programming and really wanna learn more. I'm like a really crap tennis player who wants to know everything about tennis! I searched about it on Google but couldn't get satisfactory answer.
Best How To :
It will give you a good idea of where computers started and how they've progressed and how they progressed.
If you want to get into the history of computers I'd look at things such as the Jacquard loom and Babbage's difference engine. These two inventions probably had the greatest early influence on early modern computing. Usage of punch cards (Jacquard) and the mechanical 'calculation' (Babbage) provided a great foundation.
So lets start with how the computer works. At the heart of every computer is a Transistor (and before that vacuum tubes). The big thing behind a transistor is it can send electricity in two different ways, depending on it's state*. This allows for the creation of logical flows of electricity. With this we can create all sorts of wonderful things**: nand gates, and gates, half adders, multiplexes etc.
Now that we have these electronic building blocks in place there's essentially two types of signals that come into them. Signals that tell the electronics what to do, and actual data that the electronics compute with. So the command to add, might say take the data from register 1, and add it to the data in register 2, and store that information in register 3. What this command does, is sets the computer up in a state so that registers 1 and 2 behave as inputs to the adder, and register 3 stores the result. The same would be true for subtraction multiplication etc. There's also commands to say jump to a certain line, read information from memory etc.
The binary commands these binary commands are the machine code necessary to 'set the cpu.
To now I haven't really addressed your questions, but I've laid some of the framework to understand what's going on. (You said you wanted to learn everything =P)
So now we have a computer that runs on machine code. Nothing more nothing less. This is now a very hard to use, machine. So assembly is almost always one of the first languages that's created. To use assembly we need to create an assembler. An assembler is essentially a compiler, that turns assembly language into machine code. As a result assembly languages are 1 to 1 with the machine code commands. The idea being since we're coding this in binary, it's a good idea to keep it simple. So now we have something that can turn assembly language into machine code.
So now we have two levels of 'languages' 0 - Machine code: This is code that the cpu understands, it's in binary, and not very user friendly 1 - Assembly language: This uses some 'english like' terms, but is still relatively clunky, and 1 to 1 command wise with the machine code.
So let's add a third,
2- High level language.
A high level language is something that more closely resembles english, such as C. We have loops and data structures and other useful things. To use C we have to write a compiler. A compiler takes code written in the C language and creates object code (similar to assembly language). Then another program turns that object code into machine language. Anymore these two steps are usually combined into one for efficiency sake. Now we have your first definition. A compiler turns a high level language into object (or machine) code***.
Now that we have our first high level language (C) it probably seems foolish and painful to work with the assembly language again unless we have to. So now we can write new languages and compilers in C, or any other language we've now made****.
So now lets tear into an interpreter. An interpreter is a program that reads, and executes a program on it's own. Instead of turning a program that turns high level code into machine code, this reads the high level code, (usually a line at a time) and executes it.
Let's take java for example. Java is an interpreted language, basically that means someone has made a program (in say C) This C program, reads the java and executes it. So there's another layer between the computer and the code.
There's a lot of stuff this response kind of glazes over, how to build a cpu, the considerations into making a language, how the same language can run on different cpus. The advantages of interpreters over compilers etc. But hopefully it gives a good amount of background and information that you can read up and research more on your own.