Suppose a program was written in two distinct languages, let them be language X and language Y, if their compilers generate the same byte code, why I should use language X instead of the language Y? What defines that one language is faster than other?I ask this because often you see people say things like: C is the fastest language, ATS is a language fast as C. I was seeking to understand the definition of fast for programming languages.
What determines the speed of a programming language?
programming languages;compilers
There are many reasons that may be considered for choosing a languageX over a language Y. Program readability, ease of programming,portability to many platforms, existence of good programmingenvironments can be such reasons. However, I shall consider only thespeed of execution as requested in the question. The question does notseem to consider, for example, the speed of development.Two languages can compile to the same bytecode, but it does not meanthat the same code will be produced,Actually bytecode is only code for a specific virtual machine. It doeshave engineering advantages, but does not introduce fundamentaldifferences with compiling directly for a specific harware. So youmight as well consider comparing two languages compiled for directexecution on the same machine.This said, the issue of relative speed of languages is an old one,dating back to the first compilers.For many years, in those early times, professional considered thathand written code was faster than compiled code. In other words,machine language was considered faster than high level languages suchas Cobol or Fortran. And it was, both faster and usually smaller. Highlevel languages still developed because they were much easier to usefor many people who were not computer scientists. The cost of usinghigh level languages even had a name: the expansion ratio, which couldconcern the size of the generated code (a very important issue inthose times) or the number of instructions actually executed.  Theconcept was mainly experimental, but the ratio was greater than 1 atfirst, as compilers did a fairly simple minded job by today standards.Thus machine language was faster than say, Fortran.Of course, that changed over the years, as compilers became moresophisticated, to the point that programming in assembly language isnow very rare. For most applications, assembly language programscompete poorly with code generated by optimizing compilers.This shows that one major issue is the quality of the compilersavailable for the language considered, their ability to analyse the sourcecode, and to optimize it accordingly.This ability may depend to some extend on the features of the languageto emphasize the structural and mathematical properties of the sourcein order to make the work easier for the compiler. For example, alanguage could allow the inclusion of statements about the algebraicproperties of user defined functions, so as to allows the compiler touse these properties for optimization purposes.The compiling process may be easier, hence producing better code, whenthe programming paradigm of the language is closer to the features ofthe machines that will intepret the code, whether real or virtualmachine.Another point is whether the paradigms implemented in the language areclosed to the type of problem being programmed. It is to be expectedthat a programming language specialized for specific programmingparadigms will compile very efficiently features related to thatparadigm. Hence the choice of a programming language may depend, forclarity and for speed, of the choice of a programming languageadapted to the kind of problem being programmed.The popularity of C for system programming is probably due to the factthat C is close to the machine architecture, and that systemprogramming is directly related to that architecture too.Some other problem will be more easily programmed, with fasterexecution using logic programming and constraint resolution languages.Complex reactive systems can be very efficiently programmed with specialized synchronous programming languages like Esterel which embodies very specialized knowledge about such systems and generate very fast code.Or to take an extreme example, some languages are highly specialized,such as syntax description languages used to program parsers. A parsergenerator is nothing but a compiler for such languages. Of course, itis not Turing complete, but these compilers are extremely good fortheir specialty: producing efficient parsing programs. The domain ofknowledge being restricted, the optimization techniques can be veryspecialized and tuned very finely. These parser generators are usuallymuch better than what could be obtained by writing code in anotherlanguage. There are many highly specialized languages with compilers that produce excellent and fast code for a restricted class of problems.Hence, when writing a large system, it may be advisable not to rely ona single language, but to choose the best language for differentcomponents of the system.  This, of course, raises problems ofcompatibility.Another point that matters often is simply the existence of efficient libraries for the topics being programmed.Finally, speed is not the only criterion and may be in conflict withother criteria such as code safety (for exemple with respect to badinput, or resilience to system errors), memory use, ease ofprogramming (though paradigm compatibility may actually help that),object code size, program maintainability, etc.Speed is not always the most important parameter. Also it may take different guises, like complexity which may be average complexity or worse case complexity. Also, in a large system as in a smaller program, there are parts where speed is critical, and others where it matters little. And it s not always easy to determine that in advance.