Question

I'm getting introduced to declarative languages and am beginning to love them. In particular Haskell, a functional language, is very expressive, easy to debug. But my question has to do with execution. Are such languages compiled or interpreted? If it is the latter then I would have to choose conventional languages like C++ or Java for performance reasons. But I would love to use declarative languages for their increased productivity and ease of maintenance. Eager to hear from the esteemed members of this community.

Was it helpful?

Solution

There's no universal answer for all languages; it just depends on what's been implemented for a particular language. Haskell, in particular, can be either compiled or interpreted. Some declarative languages may only have interpreters currently, but a compiler could be written in the future.

Also, don't assume that just because a language implementation is interpreted, it's unusable "for performance reasons". Depending on the application, interpreted code may still be fast enough.

OTHER TIPS

By definition of declarative languages, they cannot be executed in their purely declarative form; see e.g. the An intelligent system can and must use declarative knowledge efficiently paper of J.Pitrat, or several entries of his blog e.g. "stop programming!", "CAIA, my colleague", "know thyself", etc...

So a declarative system is transforming the declarative knowledge into executable procedures, or interpreting it procedurally, or often a mix of both approaches.

J.Pitrat's mentra is that such work on declarative knowledge can and should be expressed in a declarative way (thru declarative meta-knowledge able to be applied to itself), with a bootstrapped system.

BTW, his CAIA system has lot of declarative knowledge and is bootstrapped, so translated itself into hundreds of thousands of lines of C.

You could follow his example and work on a declarative system which generates Java code, but it is a long journey... Your system will then have a "compiler" part, that is something which contextually translates some declarative knowledge into executable Java code.

Likewise, Haskell may transform (i.e. compile) some expression into several forms of code, depending upon the context, etc...

Licensed under: CC-BY-SA with attribution
scroll top