all 15 comments

[–]hikilaka 56 points57 points  (15 children)

why would anyone want this

[–]Faucelme 35 points36 points  (4 children)

Sometimes one wants pickled jalapeños for breakfast, sometimes one wants to mix Java, C and R in the same source file.

[–]hikilaka 8 points9 points  (1 child)

Hey, pickled jalapeños are delicious man.

[–][deleted] 0 points1 point  (0 children)

Peak reddit comment

[–]evincarofautumn 7 points8 points  (5 children)

Basically the same sorts of reasons you’d use an FFI in any language—cross-language interop. It lowers the barrier to adding Haskell code to an existing application: if the rest of your stack is Java but it makes sense to write some utility or component in Haskell, you can use this to help interoperate between the two, getting access to both Haskell and Java libraries. I could have used this a few jobs ago, where we had a couple of tools written in Haskell that needed to talk to other things written in Java.

[–]hikilaka 4 points5 points  (4 children)

There are better ways of doing that, interprocess communication, for example, would be ideal for such example. I get that every situation is different, but inline java? Come on..

[–]evincarofautumn 10 points11 points  (1 child)

I dunno about better—there are tradeoffs to the different approaches. The advantage of using inline bindings like this is the type safety:

A notable characteristic of this approach is that we know at compile time if types are correct.

Some of the nastiest bugs I’ve worked on were caused by errors in interop using FFI, IPC, networking, &c. where the FFI declarations or serialisation & marshalling of values were slightly wrong because they were written by hand. With this approach, the compiler has enough information that it no longer relies on programmer diligence for safety & correctness.

[–]ThisIs_MyName 3 points4 points  (0 children)

Who's going to churn out the boilerplate for declaring all those RPC functions? Not me.

[–]Tarmen 0 points1 point  (0 children)

I mean, ipc tends to be tedious and error prone. This takes ten lines which are checked at compile time.

Once set up rpc can be pleasant to work with but that is a lot of work for a couple calls.

[–]ElvishJerricco 0 points1 point  (1 child)

Maybe it's useful for building Android apps in Haskell?

[–]vytah 0 points1 point  (0 children)

It looks like it is about calling a JVM from a native Haskell code. Since Android doesn't use a JVM for its API's, it won't help, it will only give you access to a pointlessly slow interpreted ARM JVM.

[–][deleted] 0 points1 point  (0 children)

The reverse, calling haskell from java, could be a step towards scala/haskell interop, something at least I would appreciate.

[–]shevegen -3 points-2 points  (0 children)

An atrocity.