Search code examples
compiler-constructionprogramming-languagescomputer-science

How is a new programming language actually formed/created?


Fortran->Algol->Cpl->Bcpl->C->C++->Java .....

Seems like every language is built upon an ancestor language. My question : New languages extend parent ones or there is some kind of a trick?

e.g. System.out.print() in Java ; is it actually printf() in C, and so on (printf is actually .. in Cpl)?

If so, doesn't this make every further language be slower and need more memory? What separates a new language from a framework?


Solution

  • Each language builds on the concepts of another (language design). Each new language learns what worked in previous languages and what did not work. Also languages are targeted at different groups. If you write a language for long-term maintainability and reliability, that language will probably not be appropriate for shell scripts.

    Many languages are testing beds for features or concepts. These are usually extremely flexible and fun and can be very quick to code in. Basic was one of these, as are Perl, Ruby, ...

    Other languages are reduced to a bear minimum and rarely change--they focus on backwards compatibility and consistency. New features would be avoided and, when they are added, would be tested in-depth before being added to the standard (Yeah, they tend to be standards based more than the previous group). C, Java, Ada and C++ were designed to fit here. C# is possibly a crossover with more features being added than these others, but more stability than the previous group.

    Now, besides what drives language features, there is how the language is built. Lanuages are often initially written in another language, however not in the way you are assuming. Java is mostly written in Java now, but the JVM is probably mostly hand-coded assembly, however you can be SURE that C's printf is nowhere to be found in Java.

    A compiled language generally consists of your program reduced to a certain set of codes (machine language or bytecode) and is then packaged with a set of routines (like System.out.println). However, println doesn't just call C's println, instead a library is created (written in some combination of Java, C, assembly) that knows how to do the output itself.

    In C the library would be generated the same way, a combination of C and assembly that generates the assembly code that can execute "printf"