I know there are many computer languages (C#, java, basic, etc) How are the languages themselves created?
This is not the kind of question that can be adequately answered in a forum post—there’s way too much stuff to cover. Numerous Computer Science grad courses are dedicated to language theory, compiler design, formal grammars, etc. One of my professors wrote his Ph.D thesis on something to do with lambda calculus (he was never more specific as to what, exactly, he did), which is a fairly indispensable tool in the study of languages. If you have some spare time and money and are serious about learning more about language design, I highly recommend Programming Language Pragmatics by the excellent Dr. Michael Scott. If, on the other hand, your interest doesn’t extend that far, you might be well-advised to ask a more specific question, because the field of language design is very broad.
Well, it sounds like the OP is just curious about the bootstrapping process for specifically creating the compiler/interpreter; what language is the C# compiler written in? And what language was the compiler for that language written in? And so on.
Well, often times, the Language X compiler is written in Language X itself.
How can that be? Well, it can work like this: Suppose you want to make a compiler for some spiffy new language Chris++. First, you write a compiler for it in some old, not-as-nice language of your choice. Then, once you have a working Chris++ compiler, you write the code for a new Chris++ compiler in Chris++, and then actually turn this code into an executable program using the old compiler. So now you end up with a Chris++ compiler which was also written in Chris++.
Great. Nice trick. But still, to get there, you had to originally start with some language at some point which wasn’t Chris++.
That’s true, but maybe the language you started with to write your original Chris++ compiler was a little bit simpler than Chris++. And accordingly, maybe its original compiler was written in a slightly simpler language. And so on. Going all the way back to a language which was so simple that its original compiler could be written manually in direct machine code.
That is to say, building up from just writing straight machine code, people kept incrementally designing compilers for more and more complex languages (it being easier and easier to write these as the languages got higher- and higher-level). It’s actually pretty straightforward, and not as magical as it at first seems it must be.
A CPU has, built into, the ability to perform various operations. These all basically consist of performing math or moving data from one location to another. An example of how a CPU can do this simply via hardware can be seen in this video.
The CPU is made to do these operations based on its reading through a list of commands. The ability to read and perform these commands are again done in hardware.
Say that we number commands for add, subtract, multiple, and divide as 1, 2, 3, and 4 respectively. The two numbers following are considered to be the values that we wish to perform the operation on.
1 100 300
4 64 42
That would be the commands to add 100 and 300, and to divide 42 into 64, respectively.
But so, if you can write the commands for the CPU into a place where the CPU will read it, it will perform those commands. And that’s what the first programmers did. They’d write commands onto punch cards, load those into the computer, and hit the big red “Execute” button.
But so then they wrote a simple program, on the punch cards, that would translate something like:
add 100 300
div 64 42
…into the CPU command version. This was the first Assembler. Assemblers are different from compilers in that they simply translate machine commands as written in human fonts into machine commands as written in some form of CPU understandable numeric data.
With a working Assembler, it was then easier to start writing the first Compiler. Once you have a working Compiler for your language, you can then rewrite your Compiler in your language. You can also write compilers for other languages in your language.
I had to hand input my first machine language interpreter in binary at the keyboard. It took a long time and just as long to find the typo that kept it from running. It took a couple weeks to find the typo.
ml = machine language
After I had the working ml interpreter I typed in a file for the ml interpreter program in ml. I could now compile this ml file to make a working ml interpreter. I modified the interpreter program’s file and compiled a new version of the interpreter every time I wanted it modified.
This is an example of machine language.
LDA #32
That is a simple load register A with the decimal number 32.
It’s much easier than writing the program in all numbers. I make the trouble i went through to type in a working ml interpreter worth it.
Like has been said you make or modify a new language the same way using what is available. I used to be very good at making text adventure interpreters.
From Zork:
West of House
You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.
Look mailbox
The first PC had no screen or keyboard or disk storage. It just had a row of red lights and switches. But they still wrote programs for it.
My first introduction to programming in college. Back in 1982. Fun times.
Those are high level languages and their compilers were probably written in something low level like assembly or machine language, which are just the operation codes for the CPU. Not to mention as someone wrote above, writing compilers in their own language via bootstrapping.
In school, I built one of those from raw chips and wire-wrap and a few other bits of hardware. To enter a program, I had to flip switches. But there was still a program in the machine which could interpret those switch-flips. That program was created on another computer. And so on…
There is a continuous chain of computer program creation tools, simpler and simpler as you go back through the years, until you get to the simplest machines and programs, ones that could be built entirely from non-computer parts using non-computer tools, and programmed from plans small enough to fit in peoples’ heads.
That’s assembly, not machine language.
Early versions of stuff like Lotus 123 were written in assembler which must not have been easy.
I’m far removed from the days when I studied and/or did this but the more conceptual view is that everything has to get translated to instructions for the CPU. People working on similar tasks find themselves using the same set of instructions over and over. They could create a language that puts blocks of machine instruction together to make it easier to write the code they need.
Any programmer who thinks “there should be an easier way to do this” has the first step to a new language. Most find the alternative is a library of re-usable code instead of a full fledged new language but that is the “why” that leads to the “how”.
Your right. I figured I goof something somewhere and get corrected. I never get through a complicated explanation and get it all right anymore. It’s not that I don’t look, I just don’t see it.
Well, the first computer to be called a PC certainly had a screen and a keyboard, but disk storage wasn’t standard. This was the IBM PC released in 1981.
The first microcomputer (a computer built around a microchip and, therefore, small enough to fit in a breadbox) didn’t come with a keyboard or screen. You had to buy a text terminal and hook it up to a serial port if you wanted one, but, as you said, it was possible to go without. This was the Micral-N from 1972.
However, the Micral’s software was largely written on a larger, more convenient computer and transferred over.
The earliest all-electronic, stored program computers, such as the Manchester Small-Scale Experimental Machine, were programmed using lights and switches. The SSEM was very similar to modern computers: It was all-electronic, unlike the Z1 which used switches, and it could be reprogrammed as opposed to rebuilt, unlike the Colossus which used patch cables and wasn’t a fully general computer even so.
This is the computer I was talking about, it came out in 75.
Most people say there were PCs before IBM , you had the Apple I and II, Commodore 64, etc.
I guess it depends on whether or not people actually used the term “PC” for those models. I certainly consider the Apple I a PC even if that term was not used.
The embedded computer I just now programmed doesn’t even have lights or switches, just a serial port. I write the code in C on a regular laptop, compile it with a cross-compiler, and load the resulting machine language into the embedded processor’ s onboard flash memory.
Bijou Drains: The Altair 8800 was the first really popular microcomputer, and I use the term because that’s what they were called until the IBM released the micro it branded as the PC. It might be a fine point and I’m not going to dispute that microcomputers were indeed personal computers, but if you look at the old documentation and advertising the terms ‘microcomputer’ and ‘micro’ predominate until IBM’s offering. Besides, the term is useful to distinguish these machines from even earlier small computers (such as the PDP-8) that could arguably have been personal for extremely rich persons as early as the 1960s.
Apple uses the term personal computer here in 1977, they also use the term home computer
http://blog.modernmechanix.com/mags/qf/c/ScientificAmerican/9-1977/appleII/med_appleII_1.jpg
We didn’t. They were called microcomputers. You could buy software or hardware that was sold as being for an Apple, a PC, a C64, etc. and if it said PC that meant an IBM compatible.