Haskell vs. procedural programming in the real world [closed]
Asked Answered
L

13

48

These days I'm getting seriously into functional programming.

While I'm really excited about Haskell and the possibilities it seems to offer, I can also see now that it is going to take me a while to learn. In an SO question on How to learn Haskell an answer states that it'll take months if not years to actually "master" it.

Now, I know C, PHP, some object oriented stuff, etc. And having been told that Haskell isn't much used out there in "the real world", will I be better off improving my skills in the regular languages I know? Is Haskell worth the struggle?

In this question on Why people think functional programming will catch on the conclusion seems to be that functional programming will "catch on". But surely procedural programming will stay on top, right?

EDIT: keparo nicely clarifies my question to: As opposed to procedural languages, will it be valuable for me to study Haskell and functional programming paradigms?

Lyingin answered 21/6, 2009 at 19:24 Comment(3)
What's the real question? If it's worth learning the functional programming paradigm? If it's worth learning Haskell and thus the functional programming paradigm?Girovard
Primarily Haskell but also the purely functional paradigm as I think they seem to be closely related.Lyingin
Running a start-up on Haskell: youtube.com/watch?v=ZR3Jirqk6W8Ingham
O
56

Haskell isn't as hard as people like to make out to learn. Haskell opens up a new world that you never knew existed for you. It's as valuable to learn as any other language. You might not find a job requiring you to do Haskell programming, but does that really mean a language isn't valuable?

Haskell will teach you a lot of new stuff, and it will show you how to program even better in the languages you /do/ work with. You can do your own personal projects in your spare time with it.

Haskell isn't really used much in the "real world" if you define "real world" as "cash generator". So if that is your objective, then you might have to rethink objectives :p

Also, I don't really like that part of chosen "how to learn haskell" answer. It takes months to years to master any language, not just Haskell. Depending on how you define "master". I can use Haskell to a pretty good degree of efficiency and I've only been learning it for a month, and I've been taking it slow even.

Oldfashioned answered 22/6, 2009 at 4:56 Comment(5)
+1 I think C++ basics (which includes efficient usage of the STL) are even harder to master than Haskell basics.Menswear
Many good answers. Thank you all so far. I'm accepting this one because I think it is the most general and non-subjective answer to my specific question.Lyingin
"takes years", It depends if the language your moving across to is of the same paradigm. OOP to OOP matches, just learning syntax. OOP to FOP learning syntax, mindset and paradigm shift.Usquebaugh
+1 for "isn't as hard as people say". Sometimes it sounds like nobody could understand Haskell if he has not at least a degree in category theory, but it's simply not true. And then, come on, let's be honest: many of the category things are actually fairly easy (but basic) concepts. It's just that they have complicated names.Refractive
@WeNeedAnswers: if you're coming from Java or Python etc OO, moving to C++ with templates isn't going to be "just learning syntax" because there can be some serious higher-order stuff in C++ templates, more reminiscent of types in Haskell or Scala.Ingham
R
20

If nothing else, the change in mindset that learning Haskell provides will help you when you have to go back to using those procedural languages that still are used in the workplace.

The functional paradigm is beginning to make it's way into various mainstream applications and languages - Even C++ is going to be adding a (crippled) lambda in C++0x.

You may also want to look at some of the hybrid languages like Scala or OCaml. Scala is being used at Twitter, and OCaml is being used at Jane's Street in a financial trading platform.

Ragman answered 21/6, 2009 at 19:37 Comment(1)
In C++, Meta Template Programming is a pure functional language, that's what enticed me to go toward Haskell in the first place.Guileful
R
11

I learned Haskell because it was by far the best functional language that I tried out of Scala, Clojure, OCaml and Scheme but I didn't seriously expect to use it for work.

As it turns out, it is perfect for those sorts of odd jobs that are too small for a team and would be just too time consuming in Java. So far, I've used it for ad-hoc data migrations i.e. mangling CSV exports into another format, batch conversions of XML (HXT is more concise and more powerful than XSLT), screen-scraping off the internet and software project estimating including modelling risk using the probability monad and producing optimum gantt charts using backtracking. This is all real work that needed doing, that I wouldn't have even bothered to try and do in Java as it would be a multi-day undertaking.

I now use it instead of Excel for anything vaguely mathematical as it is little more effort to create a list of values in haskell source in a text editor than it is to type them into Excel. Once in haskell, I can then do all sorts of magic like backtracking, probability distributions etc. that Excel can't do. If I need a graph then I spit the values out as CSV (2 lines of code) and load them into Excel.

The only downside is that it does take several months to get proficient, but worth the effort IMHO.

Ranaerancagua answered 14/2, 2011 at 22:7 Comment(1)
I also used Haskell for one such tool: I had to extract and analyse error message from our application logs and produce statistics to be loaded into Excel (output was CSV). It took me one or two days to write. In Java or C++ it would have taken at least three or four days. I haven't tried Haskell on larger projects, but I would like to give it a chance some time.Adiathermancy
Z
10

You probably shouldn't expect to use Haskell anywhere nearly as often as a C family language in professional settings. If the question is whether it will be valuable for you to study Haskell and functional programming paradigms, the answer is yes. You can apply your enriched understanding of programming to all of your work.

Zetes answered 21/6, 2009 at 19:34 Comment(0)
T
7

As opposed to procedural languages, will it be valuable for me to study Haskell and functional programming paradigms?

If having an expanded skill set is valuable, then: yes.

One advantage you might pick up: parallel and concurrent programming. Procedural languages of the past tend to have no clear notion of side effects, as a result writing parallel programs in them is difficult to do correctly. Functional languages (in particular, ones that limit side effects like Haskell) have a lot more to say about productive parallel programming.

Having that skill up your sleeve can't hurt.

Tabernacle answered 21/6, 2009 at 20:37 Comment(0)
S
6

As opposed to procedural languages, will it be valuable for me to study Haskell and functional programming paradigms?

Not unless you want to be miserable. Luke Plant says, in Why learning Haskell/Python makes you a worse programmer:

So, learning Python and Haskell has demoralised me and encouraged me to write code that is bizarre and difficult to understand...

(This is not entirely a joke.)

Salter answered 24/6, 2009 at 19:15 Comment(0)
I
5

I can see that functional programming can be a plus in a production environment if it's very easy to use by non functional code. MS could see that too when they came up with F# I guess.

Since they both compile to IL, you can handle problems that ask for a functional approach functional and use those solutions very easily in your procedural code.

In that way functional code can easily find its way in a production environment a bit at a time

Therefore, and since the userbase of MS is that big, my guess is that if F# will not catch on in the very near future, that Haskell won't either.

Involved answered 21/6, 2009 at 19:40 Comment(0)
M
4

I think it's worth the struggle. It will help you to understand how problems are solved and not only how a computer works.

Maybe one particular problem is Haskell itself - As a purely functional language, it's kinda "hardcore" which may on the other hand even complicate things.

Functional programming instead may be extremely useful in a very pragmatic manner - Many OO/imperative languages have now included functional elements for this reason (Linq, anonymous functions, readonly values, function pointers/delegates, type-inference): You can concentrate on what should be done which allows you to express more in less code (that is even less error-prone).

Non-purely functional languages (standard functional languages) like Scala or F# can be integrated easily into existing Java or .NET-projects, so you can combine the benefits of both paradigms where they are needed. For typical advantages of functional languages, see this thread. Just think of extremely powerful parsing (Monadic parser combinators / Parsec) or concurrent programming that is possible with functional languages and you'll see how useful they are.

Menswear answered 24/6, 2009 at 19:30 Comment(0)
Q
2

Broadening your horizons helps you be a better programmer no matter what language you happen to be using at the moment. You'll never look at programming the same way after you've written Lisp macros, for instance. After you begin to think in Haskell terms, you'll find yourself composing functions and wishing for closures in less advanced languages.

Judging from goodies in C# such as lambdas, type inference, closures, and so on, learning Haskell will give you a leg up on tomorrow's cutting edge in mainstream languages.

Quickie answered 21/6, 2009 at 19:37 Comment(0)
D
2

Some people enjoy programming in Haskell. If you can choose your environment, and enjoyment is a consideration, then maybe you should hop in.

Many programmers are not in position to choose their tools and enjoyment is not a factor for their choices. Many of them get to use C/Java/etc at their workplace for the "core project source", but then also choose or need to use Python for "scripts" such as build-scripts with SCons, other scripts that generate Java/etc code, testing systems, proofs-of-concepts, etc.. And in other places Python is also used in the "core project".

In 8 years, it will be Haskell, not Python, which will be "coming to you". But you can come to it sooner.

Disposed answered 21/6, 2009 at 19:49 Comment(0)
K
1

You can combine the use of functional programming and be pragmatic about the language.

All modern scripting languages s.a. JavaScript or Lua allow use of the functional paradigm.

Kirwan answered 30/6, 2009 at 11:27 Comment(0)
J
1

The functional concept is coming on strong. Note the flurry of activity and interest around Ruby. I've also noticed a bit more interest in JavaScript beyond a mere browser scripting language lately. You can get ahead of the game by diving in now, though the time invested might not pay off this year or next.

It depends on your general game plan. Are you into programming as an end in itself or as a means to an end? If it's the former, go nuts with Haskell. If the latter, stick with mainstream, "employable" languages. Wait for Haskell to take off and then pounce.

Jedda answered 5/7, 2009 at 20:38 Comment(1)
knowing Haskell (or FP in general), both because of its FP as well as type system capabilities, while actually working in more mainstream languages can be a very practical combination.Ingham
U
0

Why procedural and not Object Oriented, not seen procedural being used for many years apart from C.

Commercially speaking. I would go with Java or C#. Doesn't really matter which they both pay well and the skills are interchangeable with other like minded languages such as python, Ruby and JavaScript.

Haskell is worth the time and effort, although it is very academic, some banks use it, although many in Europe and the UK are moving the code base over to F#.

I don't think FOP will be moving at great speeds commercially speaking. But the techniques are definitely making an appearance in the main stay languages. Especially with Multi-Core chip designs and making code run parallel on them.

Usquebaugh answered 25/10, 2010 at 2:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.