1

Recently I started looking at functional languages to make some algorithmic parts of my application more reliable. Of course I bumped into Haskell. But it prepared too many surprises for me with its laziness. Sometimes simple things become very and very slow.

So I'm wondering is there a language I can use to write small algorithms in functional style but without unnecessary laziness which causes more problems then helps.

The program should be compiled into Win32/64 native code (preferably dll) and have comparable performance with C++.

Alexandr
  • 100
  • 1
  • 9
  • do you know about bang patterns in haskell? http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/bang-patterns.html – MaksymB Apr 01 '13 at 13:40
  • 1
    Yes, but I find it difficult to use. I tried to place them in different places to make application use less memory but still did not win. Usually the most problems I have with lists. – Alexandr Apr 01 '13 at 13:43
  • Indeed lists is something difficult to make strict in Haskell – MaksymB Apr 01 '13 at 13:45
  • 1
    @Maxym: bang patterns only evaluate to WHNF, no? I'd recommend deepseq when you really need strictness. – amindfv Apr 01 '13 at 13:45
  • @amindfv yes, you are right. That's why it doesn't really work with lists – MaksymB Apr 01 '13 at 13:46
  • 1
    this was discussed here http://stackoverflow.com/questions/5558043/forced-strictness-for-lists-in-haskell – MaksymB Apr 01 '13 at 14:31

1 Answers1

2

OCaml is probably the closest to Haskell, but it's strict and impure. It's a successor to ML.

OCaml, ML, and Haskell can all be compiled to machine code on any common platform.

In my experience, though, laziness is usually a great feature once you get a sense for how it works.

amindfv
  • 8,438
  • 5
  • 36
  • 58
  • didn't look at that language yet. Does it integrate well with C++ code? – Alexandr Apr 01 '13 at 13:50
  • @Alexandr: O'Caml has an FFI, but I haven't used it. – amindfv Apr 01 '13 at 13:53
  • 1
    I see that Wondows Distribution is for the port based on the MinGW toolchain. Will it work well if I'll try to link resulting library with Visual Studio binaries? – Alexandr Apr 01 '13 at 14:00
  • @Alexandr good question. I didn't use OCaml but I think that in the output library there will not be any classes, only functions. And for functions export it should be more or less compatible on binary level. – MaksymB Apr 01 '13 at 14:03
  • @amindfv, upvoting because now I've started thinking of learning a bit of OCaml too :) – MaksymB Apr 01 '13 at 14:08
  • I will hope it's easy to integrate, I'll try OCaml – Alexandr Apr 01 '13 at 14:10