1312: "Haskell"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

prosfilaes
Posts: 31
Joined: Tue Jan 15, 2008 2:21 am UTC

Re: 1312: "Haskell"

Postby prosfilaes » Thu Jan 09, 2014 9:36 am UTC

Kit. wrote:
prosfilaes wrote:
carlt wrote:...and other semantically irrelevant lines of code.

The problem is, I get all of that with Scala,

One example from my link above:

Code: Select all

fac 0 = 1
fac n = n * fac (n-1)

Can you show us the equivalent code in Scala?


Code: Select all

def fac (x : Int): Int = if (x == 0) 1 else x * fac (x - 1)


The Int being there because the Scala type system, unlike the Haskell type system, is too powerful for Hindley–Milner type inference. I'm not sure where you were hoping to squeeze lines of code out of that.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Thu Jan 09, 2014 11:47 am UTC

prosfilaes wrote:
Kit. wrote:
prosfilaes wrote:
carlt wrote:...and other semantically irrelevant lines of code.

The problem is, I get all of that with Scala,

One example from my link above:

Code: Select all

fac 0 = 1
fac n = n * fac (n-1)

Can you show us the equivalent code in Scala?

Code: Select all

def fac (x : Int): Int = if (x == 0) 1 else x * fac (x - 1)

So, worse pattern matching, less helpful type semantics, and uglier and more wasteful syntax.

Not the best at problem solving.

prosfilaes wrote:The Int being there because the Scala type system, unlike the Haskell type system, is too powerful for Hindley–Milner type inference.

And how is it supposed to be a good thing? Type system needs to be helpful, not "powerful". If I want an overcomplicated type system to fight, I have C++.

prosfilaes
Posts: 31
Joined: Tue Jan 15, 2008 2:21 am UTC

Re: 1312: "Haskell"

Postby prosfilaes » Fri Jan 10, 2014 4:25 am UTC

Kit. wrote:So, worse pattern matching, less helpful type semantics, and uglier and more wasteful syntax.


I could have used pattern matching, but I felt it was a bit overkill. With pattern matching it would be:

Code: Select all

def fac (x:Int): Int = x match {
case 0 => 1;
case _ => x * fac (x - 1)
}


As for syntax, that's up to taste, but I think Lispers will talk about how wasteful Haskell is with grammar productions and APLers will make that claim and also point out that ! is much better syntax for the problem.

And how is it supposed to be a good thing? Type system needs to be helpful, not "powerful". If I want an overcomplicated type system to fight, I have C++.


If you want to know how it's supposed to be a good thing, look up "object orientation". Like or hate it, it's silly to ask why it supposed to be a good thing. After working with Scala, going back to a system with less rich types is less then attractive to me. Also, being able to transparently use all of Java's libraries is incredibly useful in real world programming. (Haskell has to mess with interfacing with C, and that's never transparent if you're not C, C++ or Objective C.)

I'm not saying that you shouldn't use Haskell, or that Scala is the answer for everyone. My point was really that bringing up "introducing loop counters" was like listening, in 1999, to the Amiga guy talking about how his system had dynamically linked libraries. Modern versions of Java have constructs to avoid needing loop counters and so do many if not most of the languages programmers would choose to use.

(I do find it funny that your example used a loop counter, just in a recursive loop instead of iterative. "factorial n = foldl (*) 1 [1..n]" or better yet "factorial n = product [1..n]" would be examples without loop counters.)

User avatar
sford
Posts: 75
Joined: Sun Oct 22, 2006 6:50 pm UTC

Re: 1312: "Haskell"

Postby sford » Sun Jan 12, 2014 2:32 am UTC

FWIW, I have zero previous exposure to Haskell or functional programming in general. I just went through http://learnyouahaskell.com and I had no trouble. I'll have to admit that after 30+ years of C programming (not C++, good old ANSII C), I find that I'm excited to try out some of my new-found Haskell skills.

I recommend "Learn You a Haskell" for accomplished imperative programmers who don't need to learn how to program but want to learn them a Haskell.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Sun Jan 12, 2014 7:25 pm UTC

prosfilaes wrote:
Kit. wrote:So, worse pattern matching, less helpful type semantics, and uglier and more wasteful syntax.

I could have used pattern matching, but I felt it was a bit overkill. With pattern matching it would be:

Code: Select all

def fac (x:Int): Int = x match {
case 0 => 1;
case _ => x * fac (x - 1)
}

As for syntax, that's up to taste, but I think Lispers will talk about how wasteful Haskell is with grammar productions and APLers will make that claim and also point out that ! is much better syntax for the problem.

Neither Lisp nor APL provide the solution written so close to the problem domain language itself. Your Scala solutions don't do it either.

prosfilaes wrote:
And how is it supposed to be a good thing? Type system needs to be helpful, not "powerful". If I want an overcomplicated type system to fight, I have C++.

If you want to know how it's supposed to be a good thing, look up "object orientation". Like or hate it, it's silly to ask why it supposed to be a good thing.

My 20+ years of using OO in software development tell me that OO is about as good for your type system as goto is good for your control flow. Don't get me wrong, I can use goto virtuously if needed, but....

OO is a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem. That's how it gained its popularity (mostly due to the dot-com bubble economics requiring lots of such prototypes), and that's why the industry is still stuck with the OO even when better approaches (such as type classes) exist.

OO hierarchy is an ad-hoc exclusive rigid hierarchy over your solution domain anchored in every type introduced by you and coercing you into unnecessary coupling your data type hierarchies with your action type hierarchies. It kinda works when your problem domain doesn't evolve, but it's pain in the ass once you try to cover a problem that lies slightly beyond the scope of your hierarchy. That's usually leads to extensive redesign of the OO hierarchy during the life of your project, which (redesign) eventually stops not because a final solution was found, but because future redesigns become too costly and you need to stick to workarounds instead of fixing the root causes of the rigidity of your existing solution.

As an example, you can look at the evolution of the various C++ container libraries. It was a total mess until the attempts at the OO solutions died out, losing to the parametric polymorphism solution (STL).

prosfilaes wrote:I'm not saying that you shouldn't use Haskell, or that Scala is the answer for everyone. My point was really that bringing up "introducing loop counters" was like listening, in 1999, to the Amiga guy talking about how his system had dynamically linked libraries.

I believe "loop counters" was just an example of a construct that does not belong to the problem domain but needs to be introduced into the solution domain if the solution is written in particular languages. The percentage of useful problems that can be solved (but still not solved yet) using only constructs from their problem domains is not big, but when you need to handle such a problem, Haskell seems to be the best language for it.

prosfilaes wrote:(I do find it funny that your example used a loop counter, just in a recursive loop instead of iterative. "factorial n = foldl (*) 1 [1..n]" or better yet "factorial n = product [1..n]" would be examples without loop counters.)

First, it's not "a loop counter", it's an inductive step. It's a part of the problem domain, and you don't really need to care (so far) how exactly the compiler is going to implement it.

Second, your alternative solutions introduce the concept of folding a list. While the idea of a list and the idea of a fold can be described using Peano arithmetic, isn't it an overkill to use them to define a factorial?

And third, now you are stepping into the area where the language semantics may complicate your solution (like the Scala type semantics complicates your Scala solutions). For example, can you explain why you are choosing foldl and not foldl'?
Last edited by Kit. on Mon Jan 13, 2014 10:33 am UTC, edited 1 time in total.

User avatar
Negrebskoh
Posts: 139
Joined: Fri Mar 01, 2013 11:49 pm UTC
Location: The Netherlands

Re: 1312: "Haskell"

Postby Negrebskoh » Sun Jan 12, 2014 9:55 pm UTC

Can I still like Haskell without shitting on everyone else's favorite programming language?

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: 1312: "Haskell"

Postby jestingrabbit » Mon Jan 13, 2014 9:56 am UTC

Negrebskoh wrote:Can I still like Haskell without shitting on everyone else's favorite programming language?


Seems not.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Mon Jan 13, 2014 10:33 am UTC

You can if it's your fetish.

However, if your preference is rational, you need to be able to explain it, and some people might be offended by your explanation.

User avatar
Klear
Posts: 1965
Joined: Sun Jun 13, 2010 8:43 am UTC
Location: Prague

Re: 1312: "Haskell"

Postby Klear » Mon Jan 13, 2014 10:36 am UTC

Kit. wrote:However, if your preference is rational, you need to be able to explain it, and some people might be offended by your explanation.


Why would you need to explain why you like something? Sure, there are people who have to explain everything, but still...

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Mon Jan 13, 2014 11:12 am UTC

Languages are good for their network effect, and rational explanations of their benefits are good to increase the number of their users.

But technically you are correct, you can rationally choose a language to do the task, and then irrationally (or mistakenly) decide that you don't want the language to be more popular.

User avatar
Klear
Posts: 1965
Joined: Sun Jun 13, 2010 8:43 am UTC
Location: Prague

Re: 1312: "Haskell"

Postby Klear » Mon Jan 13, 2014 11:55 am UTC

I meant that I for example like Roland Emmerich, and I have no intention to explain that... wait, you said rational? Nevermind then.

kchaloux
Posts: 2
Joined: Thu Jan 09, 2014 1:57 pm UTC

Re: 1312: "Haskell"

Postby kchaloux » Mon Jan 13, 2014 2:11 pm UTC

At the moment, Scala is probably my favorite programming language, but Haskell is right up there.

Haskell is more elegant at working with functions, especially function composition. While Scala provides functions like 'compose' and 'andThen' it simply can't match the simplicity or usability of the '(.)' function in Haskell:

Code: Select all

-- Haskell
let reverseEach = unWords . map reverse . words

// Scala
def reverseEach(str: String) = str.split("\\s").map(_.reverse).mkString(" ")


It's hard to beat Haskell when it comes to code that's free of clutter and noise.

I also happen to rather like how Haskell handles side effects and I/O. After having played with it a bunch, it's actually very nice to have a very clear way to mark data that was obtained via I/O separately from data give to the program in source. As I explore more and more programming languages, I find it's better to have the language be as safe and restrictive as it can be by default, and allow the user to opt out of safety if need be. I prefer having a 'mutable' keyword (see: F#) to having a 'const' keyword.

That being said, I prefer to spend my time in Scala, because I find it to be a more flexible, albeit less elegant language than Haskell. I work in a job doing C#, so I can't distance myself too much from the OO paradigm, and Scala excels at object oriented code.

    * Scala is a sublime Object Oriented language, enhanced greatly with functional features.
    * Haskell is a masterfully designed Functional Programming Language, with a strong emphasis on managing side effects.

It's foolish to fight over which one is better - they don't occupy the same niche. There is some overlap, but they choose to focus on different things, and they both do their own things very well.

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: 1312: "Haskell"

Postby jestingrabbit » Mon Jan 13, 2014 4:01 pm UTC

Kit. wrote:Languages are good for their network effect, and rational explanations of their benefits are good to increase the number of their users.

But technically you are correct, you can rationally choose a language to do the task, and then irrationally (or mistakenly) decide that you don't want the language to be more popular.


The idea that talking about the traits or properties of one language or another, especially when it so frequently is done in a manner that is condescending, dismissive and elitist, isn't going to encourage anyone to change their programming habits.

If you want to get people to use a language, write stuff in that language. Make projects that use that language and get people on board. People still use and learn fortran because there are still fortran programs being run. You want haskell to have a following, make the haskell codebase bigger. Talking about it isn't making that happen.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Mon Jan 13, 2014 4:36 pm UTC

Why would you need to do it in a "condescending, dismissive and elitist" manner, and why can't you discuss the language properties and use the language itself if you find the language useful?

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: 1312: "Haskell"

Postby jestingrabbit » Mon Jan 13, 2014 7:06 pm UTC

Kit. wrote:Why would you need to do it in a "condescending, dismissive and elitist" manner, and why can't you discuss the language properties and use the language itself if you find the language useful?


I think you should address the first query to BAReFOOt, and the many other people of his ilk. They really stand out in these sorts of conversations. Your own dismissal of object oriented programming, widely regarded as helpful and sensible, is I think, particularly bizarre when you consider that Haskell implements classes and OO.

Feel free to fill up the internet with talk about languages, but no matter what people say, there are webpages that are being served up by php as we speak, and all the talk doesn't change that.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Mon Jan 13, 2014 9:11 pm UTC

jestingrabbit wrote:
Kit. wrote:Why would you need to do it in a "condescending, dismissive and elitist" manner, and why can't you discuss the language properties and use the language itself if you find the language useful?

I think you should address the first query to BAReFOOt, and the many other people of his ilk.

Why should I feed an obvious troll?

jestingrabbit wrote:Your own dismissal of object oriented programming, widely regarded as helpful and sensible, is I think, particularly bizarre when you consider

Let me guess: you take it as a dismissal and not frustration because...

jestingrabbit wrote:that Haskell implements classes and OO.

...because you haven't actually read our conversation, right?

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: 1312: "Haskell"

Postby jestingrabbit » Mon Jan 13, 2014 10:09 pm UTC

Kit. wrote:
jestingrabbit wrote:Your own dismissal of object oriented programming, widely regarded as helpful and sensible, is I think, particularly bizarre when you consider

Let me guess: you take it as a dismissal and not frustration because...

jestingrabbit wrote:that Haskell implements classes and OO.

...because you haven't actually read our conversation, right?


You said

OO is a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem.


In what way is that not a dismissal?
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Mon Jan 13, 2014 10:13 pm UTC

Are you claiming that you have never used kludges or that you will never use them again?

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: 1312: "Haskell"

Postby jestingrabbit » Tue Jan 14, 2014 2:06 pm UTC

Kit. wrote:Are you claiming that you have never used kludges or that you will never use them again?


No, I'm claiming that describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Tue Jan 14, 2014 4:42 pm UTC

jestingrabbit wrote:
Kit. wrote:Are you claiming that you have never used kludges or that you will never use them again?

No, I'm claiming that describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive.

And I'm claiming that your claiming that 'describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive' is dismissive. Now what?

And I can and do substantiate my claims. Can you?

User avatar
Klear
Posts: 1965
Joined: Sun Jun 13, 2010 8:43 am UTC
Location: Prague

Re: 1312: "Haskell"

Postby Klear » Tue Jan 14, 2014 4:53 pm UTC

Kit. wrote:
jestingrabbit wrote:
Kit. wrote:Are you claiming that you have never used kludges or that you will never use them again?

No, I'm claiming that describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive.

And I'm claiming that your claiming that 'describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive' is dismissive. Now what?

And I can and do substantiate my claims. Can you?


Please do. So far it looks like a childish repeating.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Tue Jan 14, 2014 8:24 pm UTC

Klear wrote:
Kit. wrote:
jestingrabbit wrote:
Kit. wrote:Are you claiming that you have never used kludges or that you will never use them again?

No, I'm claiming that describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive.

And I'm claiming that your claiming that 'describing probably the central programming technique of the last decade as "a kludge that allows you to hack a quick and dirty prototype of a solution of a slightly non-trivial problem" is dismissive' is dismissive. Now what?

And I can and do substantiate my claims. Can you?

Please do.

With pleasure.

For me, "dismissive" means "rejecting consideration". If you have a similar but different definition, feel free to adapt my line of thought to it.

I started to critique the technique (OO) by saying for how many years I'm actually working with it.
Then I proceeded with a detailed explanation what my experience tells me about the deficiencies of the technique.

Neither of this is compatible with the idea that I'm rejecting consideration of the technique... except for people that are rejecting consideration of my argument.

I could go on and show how not only the idea of my opponent, but the further behavior in this thread as well, is dismissive of my argument, but, luckily for the opponent, it seems that I have no time to do it today. If you insist, we may continue having this fun tomorrow.

Klear wrote:So far it looks like a childish repeating.

Be careful. You are stepping onto a dangerous and unrewarding path here.

blowfishhootie
Posts: 486
Joined: Wed Sep 21, 2011 11:13 pm UTC

Re: 1312: "Haskell"

Postby blowfishhootie » Wed Jan 15, 2014 1:48 am UTC

Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Wed Jan 15, 2014 11:38 am UTC

blowfishhootie wrote:Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

Please elaborate.

User avatar
orthogon
Posts: 3082
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1312: "Haskell"

Postby orthogon » Wed Jan 15, 2014 11:45 am UTC

Kit. wrote:
blowfishhootie wrote:Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

Please elaborate.

You should use "interlocutor" instead. Just because it's a cool word. (I am most definitely not engaging with the discussion itself.)
xtifr wrote:... and orthogon merely sounds undecided.

blowfishhootie
Posts: 486
Joined: Wed Sep 21, 2011 11:13 pm UTC

Re: 1312: "Haskell"

Postby blowfishhootie » Wed Jan 15, 2014 12:59 pm UTC

Kit. wrote:
blowfishhootie wrote:Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

Please elaborate.


No.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Wed Jan 15, 2014 3:26 pm UTC

blowfishhootie wrote:
Kit. wrote:
blowfishhootie wrote:Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

Please elaborate.

No.

Why? It would be easy. Look:

It doesn't support the claim you've made up for me,
it doesn't support the claims I've actually made,
and it doesn't really need to support any of them.

Claims are supported by arguments, and not by descriptions.

rmsgrey
Posts: 3634
Joined: Wed Nov 16, 2011 6:35 pm UTC

Re: 1312: "Haskell"

Postby rmsgrey » Wed Jan 15, 2014 5:44 pm UTC

Kit. wrote:
blowfishhootie wrote:
Kit. wrote:
blowfishhootie wrote:Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

Please elaborate.

No.

Why? It would be easy. Look:

It doesn't support the claim you've made up for me,
it doesn't support the claims I've actually made,
and it doesn't really need to support any of them.

Claims are supported by arguments, and not by descriptions.

Describing someone as an opponent puts you in an adversarial relationship to them, and suggests that your goals are incompatible with theirs. An adversarial debate is more concerned with establishing your own opinion as the accepted truth than with arriving at the actual truth.

If both you and the person with whom you are having a discussion are aiming either to achieve a consensus, or to uncover an actual truth, then describing them as your opponent is a poor choice of word...

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1312: "Haskell"

Postby Kit. » Wed Jan 15, 2014 7:15 pm UTC

rmsgrey wrote:
Kit. wrote:
blowfishhootie wrote:
Kit. wrote:
blowfishhootie wrote:Referring to a person you are having a discussion with as an "opponent" doesn't support your claim that you are considering any opinion other than your own.

...

Describing someone as an opponent puts you in an adversarial relationship to them, and suggests that your goals are incompatible with theirs. An adversarial debate

I see the fallacy of equivocacy at this point.

rmsgrey wrote:If both you and the person with whom you are having a discussion are aiming either to achieve a consensus, or to uncover an actual truth, then describing them as your opponent is a poor choice of word...

Now, a situation: you have a discussion with two persons. One is Klear, who asks you for details of your argument, and another one tries to blame you for something that only exists in their head. How would you describe the second person so that Klear doesn't fit?

User avatar
Klear
Posts: 1965
Joined: Sun Jun 13, 2010 8:43 am UTC
Location: Prague

Re: 1312: "Haskell"

Postby Klear » Thu Jan 16, 2014 1:36 pm UTC

Kit. wrote:Now, a situation: you have a discussion with two persons. One is Klear, who asks you for details of your argument, and another one tries to blame you for something that only exists in their head. How would you describe the second person so that Klear doesn't fit?


Asshole?

jpk
Posts: 607
Joined: Sat Nov 13, 2010 7:33 am UTC

Re: 1312: "Haskell"

Postby jpk » Wed Jan 22, 2014 6:57 am UTC

DR6 wrote: Learn You a Haskell's code should totally work, except a few parts which are slightly outdated.


The "Learn you a haskell" book is one of the reasons I've never yet felt any temptation to try the language. The language's users, as a group, constitute another reason. Life's too short to spend any of it with people who think that's a good title, or who think that evangelizing their language constitutes conversation. (they really are the Jehovah's Witnesses of the programming world... I swear there were two of them on my porch the other morning wanting to talk about functional programming - they wouldn't piss off until I agreed to take a pamphlet)


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: No registered users and 47 guests