Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

If you have experience with both Ruby and Haskell, which of the following best describes the applicability and comparative power of the two languages?

  1. The two languages better suit different kinds of programs, i.e. Ruby is better for x and Haskell is better for y.
  2. They are both general-purpose, and one language better for almost all applications than the other.
  3. They are both general-purpose, and whether one language is better than the other is mostly just a matter of personal preference.

Or feel free to add your own conclusion. I know Ruby well, and have been studying Haskell for a few weeks without having written any serious applications with it. I primarily want to know which bits of my production Ruby applications I should try rewriting in Haskell, and also what future applications (not toy applications, but real production applications) I ought to consider writing in Haskell rather than Ruby.

share|improve this question
3  
"They are both general-purpose, and whether one language is better than the other is mostly just a matter of personal preference." Correct. Given that you've already figured out the essence, what more do you need to know? –  S.Lott Dec 27 '11 at 16:35
    
Isn't this is an open ended question and has to be closed? –  Chiron Dec 27 '11 at 21:41
1  
The question police are gonna crack down hard on this question. Get your answers in fast! –  Lord Tydus Dec 30 '11 at 3:46
1  
There is no such a thing as a "general purpose" programming language. –  SK-logic Dec 30 '11 at 8:48
1  
I think StackOverflow needs a less restrictive competitor site. –  dan Dec 30 '11 at 14:51
add comment

closed as not constructive by Oded, Yannis Rizos, Jarrod Roberson, Tom Squires, ChrisF Dec 30 '11 at 12:25

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

I feel qualified to answer this. I'm writing a database, Siege; I wrote the initial prototype in Ruby, but now it's entirely Haskell. Here are some conclusions I've drawn:

  • Haskell is not just some academic toy, you can use it effectively for real world things,
  • Haskell is more terse and expressive than Ruby,
  • Haskell has methods of composition and abstraction that Ruby could only dream of,
  • Haskell's type system is it's greatest asset,
  • Being productive in Haskell is a lot of fun,
  • For simple things Ruby requires less brain work to write,
  • Ruby is a much better scripting language,
  • Ruby's library support is far superior,
  • Ruby is easier to learn and to become productive in,
  • Ruby is more straight forward,
share|improve this answer
1  
+1: @dan_waterworth: Great answer! Very honest and very balanced. I think comparing languages should not be about "which is better, which is worse" but "what is X strong at?", "what is Y strong at"? –  Giorgio Apr 6 '12 at 9:37
1  
@Giorgio, I agree. Did you know you're allowed to like more than one language btw? –  dan_waterworth Apr 6 '12 at 14:03
    
Of course :-) I think it is a bit too restrictive to be fixated on one language only. I like Pascal, C, Java, C++, Scala, Haskell, ML, Scheme, Ruby, Ada, Python, ... :-) –  Giorgio Apr 6 '12 at 16:59
add comment

which bits of my production Ruby applications I should try rewriting in Haskell?

What problems are you solving by rewriting your production Ruby application in Haskell? If you're just rewriting it for the sake of learning, then write everything you can in Haskell, the more you write the more you will learn. Haskell is a tool just like every other language, you shouldn't be deploying "real production applications" in Haskell unless you understand Haskell well enough to identify when it's the appropriate tool for the job.

share|improve this answer
    
+1 Good answer. Also worth adding that if your doing it for a reason other than learning then its probably a bad idea. I cant think of one situation other than to learn that you would ever rewrite working code to a language you don't know. –  Tom Squires Dec 29 '11 at 22:53
    
Your answer do not address the problem. I think the question author sees huge effort that he need to put into learning haskell and he wants to know if it worth the effort (e.i. if he will get remarkable benefit from learning it). Though I would agree with you that rewriting an application to another language is generally a waste of effort –  Alexey Jul 14 '12 at 12:30
add comment

The main difference is: Ruby is a "scripting language" and haskell is not.

The focus and strength of a scripting language is different.

Scripting languages are very good for rapid prototyping. Further, they are good for gluing together different components or library functions.

For instance, python has the the sage library. There is a list of libraries available within sage, see: http://www.sagemath.org/links-components.html With Python and Sage it is easy "glue" together the functionality of the libraries and write a program.

Scripting languages are also suitable for parts of a program that change often.

Libraries (often called system libraries) are better programmed in programming languages like Haskell. For instance, a fast web server implementation is better done in Haskell, e.g. haskell wrap, see: http://hackage.haskell.org/package/warp-0.3.2.3

There are further specific strengths of (pure) functional programming languages like haskell. Haskell is very suited for parallel programming.

Haskell + parallel:
http://stackoverflow.com/questions/8582580/why-is-concurrent-haskell-non-deterministic-while-parallel-haskell-primitives-p
http://stackoverflow.com/questions/3011668/how-difficult-is-haskell-multi-threading

Areas where haskell is a good option:
http://stackoverflow.com/questions/1604790/what-is-haskell-actually-useful-for/1605155#1605155

share|improve this answer
add comment

In general, a Haskell program will run faster than an equivalent Ruby program, a fact which shouldn't be too surprising. If you need to do something where efficiency is important, Haskell would be better. On the other hand, writing the performance critical bits in something like C and calling that from either Haskell or Ruby would likely be faster still.

Both languages expect you to adopt their preferred paradigm to a significant extent, so really it's a matter of which approach you prefer.

That said, if you've only spent a few weeks with Haskell, I doubt you have enough feel for the language yet to decide whether you like it. If you really want to make the Right Choice (tm) I'd suggest spending a few months experimenting with Haskell and writing at least one non-toy application in it. After that, then decide.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.