Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are some Functional Programming languages syntactically geared for better performance?

I hear about the manifold increase in productivity, while using certain languages (RoR). I have also heard about some VMs being more optimal than others (GHC?). Yet others are trying to optimize their language of choice by improving the underlying architecture (Unladen Swallow)

However, while reading a paper ("SSA is functional programming"), I had a question on whether a particular language, by the virtue of its syntax , can (someday) be the language with the best performance.

I guess what I am asking is that, whether a particular syntax, is THEORETICALLY the best geared one to produce the best machine code. I would be very interested in the underlying theory for any opinions - I was discussing this with some friends and we were knocking about ideas about the information content of a particular syntax.

Please do note I am talking about languages which have atleast first class functions - no ASM please.

like image 404
Sandeep Avatar asked May 25 '09 11:05

Sandeep


1 Answers

This is highly subjective

The syntax of a language is just a method of expressing desired semantics. It is the semantics that drive performance. The 'performance implications of syntax' is equal to the performance implications of semantics given that past syntax analysis the syntax is often irrelevant.

The performance implication of semantics comes down to the environment that those semantics are being run in. This is why we have a CPU and a GPU, because they each can perform the semantics of a given low-level language quicker.

There is not really an answer to this without explicitly stating the target environment. A cluster of machines will deal better with concurrent programs, and there are syntax that express concurrency such as Erlang.

What you should be focusing on perhaps is how a generalized virtual machine or environment can provide the best performance for a wide range of semantics. For example, if you ported the Erlang syntax to JVM, could the virtual machine recognize that the language was single-assignment and concurrent without the requirement of locks? Could it optimize for this? Stackless virtual-machines are a good example of attempts to make efficient a generalized environment dependent on required semantics.

Really the question is: can the environment be optimized for a class or constrained set of semantics, when the environment is by definition, general?

I would recommend learning a bit about compilers (and where syntax stops mattering) and then look at something like LLVM, then re-ask yourself the question. As to if function languages are more suited to performance depends on the environment the translation is being executed in (multi-core, distributed, small-embedded device).

like image 112
Aiden Bell Avatar answered Sep 16 '22 22:09

Aiden Bell