12
votes

I'm starting a new project and don't know which language to use.

My 'must have' requirements are:

  1. Be able to run on Windows/LinuxMacOs natively (native executable) – user should be able to just run the .exe (when on Windows, for example) and see the results.
  2. No runtimes/interpreters (no JVM, CLR etc.) – one file download should be enough to run the application.
  3. Full Unicode support.
  4. Be able to manipulate OS threads (create them, run multiple tasks in parallel on multi-core CPUs, etc.)
  5. Be reasonably fast (Python level performance and better).
  6. To have some kind of standard library that does low-level, mundane tasks.
  7. Not very niche and have some community behind it to be able to ask questions.

My 'nice to have' requirements are:

  1. Language should be functional.
  2. It should have good string manipulation capabilities (not necessarily regex).
  3. Not extremely hard to learn.

I'm thinking about Haskell now, but keeping in mind OCaml as well.

Update: This application is intended to be a simple language parsing and manipulation utility.

Please advice, if my choice is correct.

4
How good are you at programming in either language and what algorithms do you intend to use? Implementing some algorithms optimally in Haskell can be hard (such as any algo that requires, or may benefit from, a hash table).Fred Foo
Either language is new to me, but I have some experience with F#, which is close to OCaml and vast experience with imperative languages.Narzanka
I'm not giving a formal answer since if I've never built large projects in either language, but I getting it done is more important than learning, I recommend OCaml. It is very similar to F#. If you want to learn a new language, go with Haskell. It's beautiful and quite good for numeric tasks and parsing.Fred Foo
Yep, checkmark on every point. Except perhaps "not extremely hard to learn" depending on your background. But since you are looking for a functional language, I suspect you have some background in functional programming, so Haskell shouldn't be hard to learn.luqui

4 Answers

14
votes

Haskell:

1: It runs on Linux, Windows and OS X, in many cases without changes to source code.

2: Native binaries generated. No VM.

3: Full Unicode support. All UTF variants supported.

4: Full threading support, plus if you only want parallelisation then you can use "par" with a 100% guarantee that it only affects the time taken rather than the semantics.

5: As fast as C, although some tweaking can be required, the skills required are currently rather obscure, and apparently minor tweaks can have multiple orders of magnitude impact.

6: Standard library included, and "Hackage" has lots more packages including a range of parser libraries.

7: Friendly community on IRC (#haskell) and here.

Edit: On the "nice to have" points:

1: Haskell is an uncompromisingly pure functional language.

2: It has generally good string manipulation, with regexes if you want them. As someone said in a later comment, beware the efficiency of the built-in "String" type (it represents a string as a linked list of characters), but the ByteString and Text libraries will solve that for you.

3: Is it hard to learn? Its nowhere near as complicated as C++, and probably a lot simpler than Java or even maybe Python. But its pure functional nature means that it is very different to imperative languages. The problem is not so much learning Haskell as unlearning imperative thought patterns.

4
votes

Haskell sounds like it fits the bill perfectly. GHC produces native code on OS X, linux and windows just fine, and in general has performance that is much better than Python (for many things, not everything).

The only strange request is the need for OS threads. Programs produced by GHC use lightweight threads, which perform much better than OS threads, and much easier to work with than pthreads.

Haskell is also excellent for language parsing, using libraries like Parsec.

We're also quite well known for how string and helpful the community is around Haskell.

2
votes

To your third nice to have: Have a look at Real World Haskell, it's free and a very good introduction, including an introduction to all the points you need. (Such as parallel computing, string parsing, etc).

1
votes

Maybe 'nice to have':

  1. yes pure functional and lazy evaluation.
  2. yes (as said before).
  3. depends on you, I think it's hard to learn, but gives you some great benefits.