开发者

Good cross platform functional language for library use in a C++ application?

What are my options in terms of a fast functional language for library use in a cross-platform Qt C++ application?

It seems almost all languages (functional or not) have some way of calling C/C++ code in an easy manner. I'd like to go the other way around - write an application in Qt using C++ for stateful business logic, GUIs and stuff but drop down and use a functional 开发者_JAVA技巧language for the core calculation library.

Which ones are easy to use in this manner? Can for instance OCaml code be compiled into a static library and then consumed by a C++ app?

Thanks, Rickard


Haskell has this capability, though the interaction with Qt/qmake and your build process with ghc may take a little trickery to get working:

http://www.haskell.org/haskellwiki/Calling_Haskell_from_C

There is also a project called HaskellDirect which seems similar to your purpose as well:

http://www.haskell.org/hdirect/


AutoCAD uses AutoLisp so my suggestion would be Lisp.


I'd be tempted to check out qtHaskell and to do the whole thing in Haskell. My opinion is based on Don Stewart's remarkable success doing xmonad in Haskell.


Lisp and Haskell are excellent functional languages but if we consider the ease of binding C/C++ code along with the language, I'd recommend lua.

It is extremely straightforward to bind C functions to lua right off the bat, the interpreter is super compact and easy library to build, it's among the fastest scripting languages out there, and, with luabind, you can easily bind C++ classes, template instantiations, etc. I've had to do bindings for numerous scripting languages in the past and I've never found one that's quite as straightforward as lua. It's also supported with swig if you prefer to bind things through swig which will allow your application to support multiple scripting languages.

From a pure language point of view, the meta-feature/metaprogramming aspect of lua (comparable to lisp) makes it very easy to support all kinds of programming paradigms, though I personally find it best suited for functional programming. It's extremely customizable and well-suited for embedded use.

However, since you are already using qt, qtHaskell might be a nice choice to consider as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜