Why are we bothering to write an interpreter for JavaScript that just runs Python in the end anyway?
Shouldn't we just write our code in Python directly and skip the middle step?
That's an interesting idea and one that I think gets to the heart of language design.
Programming languages, as we know them, are actually
relatively old in the history of computer science.
John Bacchus starting with speed coding, perhaps the first interpreted language, in 1953
and moved on to FORTRAN, which is still alive and going well, in around 1957.
Around the same time Admiral Grace Hopper made the first compiler around 1952
and started really promulgating languages like FLOW-MATIC in 1957.
Let's imagine that we transplant this question back in time.
You're in the '60s saying, "You know? If I write this program in FORTRAN,
ultimately it gets interpreted in assembly language and machine code.
Why should I bother with FORTRAN? Why not write it all in assembly language?"
Or these days more modern languages like Java were initially implemented in
languages like C. Why bother with Java, if we could write everything in C?
It turns out that all of the modern programming languages that we are considering--
Java, C++, C#, F# --
are all Turing completed, a term I won't define in this class explicitly,
but it deals with Turing and models of computations--they're all equally powerful.
Anything I could do in one language, I could do in another.
Now it's a matter of choice and expediency.
Some languages make it easier to write somethings or say some thoughts than others,
and some make it easier to do it with fewer errors,
and that's where I think the key motivations for modern languages really come from.
I think in the future, we're going to see an explosion, a proliferation, a profusion
of domain-specific languages--languages that aren't trying to be C or Java
but are trying to solve a very particular problem and do it quite well.
There are already a number of languages out there for dealing with mathematics,
things like MATLAB or Maple or Mathematica.
There are a number of ones out there for describing graphics.
Game design actually has a history of using a number of domain-specific languages
going all the way back to QuakeC from John Carmack.
Even more modern at the time of this writing,
modern games like Skyrim feature their own languages for describing events and quests--
Papyrus--check it out. Although they're based on relatively old programming language concepts.
Another more modern example is there are a number of hardware definition languages--
VHDL and Veralog.
Whenever Intel to some degree decides to design a new chip,
they use a hardware definition language rather than C or Java or Python to describe it.
These domain-specific languages hold out the promise of having higher-level operations
and of helping you catch common mistakes.
That's really important in economic terms for saving money in software engineering.
I want to make it take less time for you to write the program,
and I want to reduce the number of faults that we're going to find in it later.
I think one of the advantages of more modern languages over something like C
is that they feature higher order datatypes.
In Python if you want a list or a dictionary it's easy to write it with just a little bit of syntax.
In C you'd need to have those datatypes prepared or do all of the allocation yourself.
It just takes longer, and it's easier for errors to creep in.
I think one of the things that's been driving changes in programming languages over time
is that we're recognizing that correctness is often more important than speed
for many applications. Speed is still critical, but bugs can be really expensive.
Especially in the financial district or in mission-critical applications.
If you're making an airplane autopilot or an artificial heart pump.
Languages where one line of code creates a dictionary and initializes it with some value
save you a lot of work. You don't have to write out all of the lines to create that dictionary.
As a result, you don't have to write out any lines with bugs in them.
The fewer lines you can write, the more you can just declare your will and have the compiler
fill it in, the happier I am.
I think that there is a real reason to keep designing new languages,
even if we bootstrap them on top of the old ones,
because it might be easier or more concise to think a thought in the new language
or because the new language might help us reduce errors or software engineering defects.
Even thought our simple JavaScript interpreter is ultimately written in Python,
webpages typically include JavaScript rather than Python, it's handy.
People find it easier to write in one of these languages rather than the other,
even though they're all Turing complete and can express the same computations.
It's kind of a deep question and one that gets to personal choice and creativity.
Sometimes we just prefer one language over another, even if they're all ultimately the same.