Is there a technical limitation preventing functional programming on the EVM? For instance the cost of computation?

I have heard that FP is "too costly". Is that correct? If it is, why?

Because "functional programming" is a broad category, this is a bit of a broad question. But knowing if FP is possible could inspire people to explore either creating a functional language or even integrating some functional programming concepts into Solidity.

up vote 10 down vote accepted

There are some aspects of functional programming that can cause slowdowns on common hardware and VMs; for a discussion see Wikipedia's section on efficiency issues. This arises because some mutable data types, like arrays, have natural mappings to hardware, where equivalent immutable constructs in functional languages don't.

Still, with a good compiler, these slowdowns can be minimal, and it's not clear that the typical workload of an EVM contract is one that would suffer overly from the issue. In my opinion, at least, it would be entirely practical to develop a functional language for the EVM.

The only thing preventing this, really, is that compilers for functional languages tend to be more difficult to write well: they require good knowledge of compiler theory and design in order to produce efficient code, and the computation model they use is significantly different from what they're being asked to produce code for, making more work for the compiler.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.