Home:ALL Converter>Python and functional language interop

Python and functional language interop

Ask Time:2013-04-13T07:20:01         Author:Eelco Hoogendoorn

Json Formatter

My current primary programming language is python. There are lots of things I like about it, but I also like functional languages. Not enough to do an entire program in them, but definitely for certain functionality, that fits the functional mould well.

Of course .NET is amazing in this regard, having both ironpython and F#. But considering the ironpython support for the scientific python ecosystem is still dodgy last time I checked, .NET is not much of an option for me. I am a bit shocked at the apparent lack of tools to facilitate interop between cpython and say, Haskell. They are both mature languages with large communities, that seem like such a nice match to me.

Is there something about their architecture that makes them ill-compatible that im missing, or is this just something awesome that is still waiting to happen?

To clarify; there are some half-baked projects out there, but I am thinking of something that parallels the awesomeness of Weave, pycuda, or boost. Something that automates all the plumbing inherent in interop with just a few annotations.

Author:Eelco Hoogendoorn,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15982362/python-and-functional-language-interop
Theo Belaire :

Another approach is to use unix pipes, and just write a Haskell program, and also write a Python program, and have them communicate over text. Haskell and Python even share the same syntax for lists, so it's really easy to pipe data from one to the other.",
2013-07-25T17:28:32
User :

Referring to:\n\nIs there something about their architecture that makes them\nill-compatible that im missing, or is this just something awesome that\nis still waiting to happen?\n\nI think it is about the people doing these languages:\nThere are not much people who want to do Haskell and Python at the same time.\n\nto make use of both languages (liek Haskell and Python) at the same time you either could go via the C-Interface or create a protocol both languages speak.\nBoth are fairly advanced, limiting the number of people who could do it. Sure there would be also tradeoffs which make it difficult to use the full power of both languages.\n\nI am using Python and although I know some Haskell, I do not program it. I am a bit stuck in object-orientation, telling me that some day a problem will decide for me that it can better be solved in Haskell than python. That problem did not yet occur because my first thought is: I know how to do it in Python. I think other 'experts' face that problem, too.\n\nYou start thinking in a language. I think that Haskell has a totally different way of thinking with its functional style, no side-effects. To get into this thinking I need to forget or not use my Python knowledge. Switching between these two ways of thinking requires some strength.\n\n\nWrapping it up: because that two languages are not so close they stay apart. It is hard to do both and there are not many or easy ways to practice doing both.",
2013-04-13T18:39:46
vrume21 :

I think that any answer to this question would be remiss without considering the inertia of object-oriented and imperative languages relative to functional ones. Consider the following situation, beginning with the fact that functional languages are not taught at nearly the frequency that object-oriented or imperative languages are at the secondary, university, or graduate level. As User mentions, there is significant momentum involved as a programmer concerning one's choice of language. For example, during the course of a typical CS degree at a four year University, one may learn a handful of languages and more than likely, not one of them is a functional language. This typical graduate will then proceed to work in industry, where, after programming for 40+ hours per week for one's job, it is very difficult to then take time to, not only learn an entirely new language, but to learn a language that operates completely differently from the one's one already knows. On top of all of this, there is the drawback that functional languages are not nearly as useful in industry as object-oriented or imperative one's are. One can see that given this current state, it is understandable that the interoperability between Python and Haskell is not what some programmers would like it to be. ",
2013-04-14T00:30:57
yy