Live data from Hacker News

The New Haskell Homepage

new-www.haskell.org

181–190 of 258 posts

Re: The New Haskell Homepage

#181

I get paid to write C++ code. I'm pretty good at it. I understand it's normal usage syntax very well. I don't fucking know what a god damn thing means in Haskell. λ 5 + 7 12 :: Num a => a What the christ? The 12 I get. Got it. The colons? Not sure. I think it's just a dumb separator. Num is type! What the hell is a => a? I have no idea. In the top they have an example. primes = sieve[2..] where sieve (p:xs) = p : sie…

Yours isn't an uncommon reaction, don't sweat it. I remember being thoroughly confused by what I was reading back when I started learning Clojure, after years in C# and ruby. At first I thought no normal human being could understand just what the heck was happening amongst all of those parentheses, but eventually it became second nature. Now I've probably written a good 50KLOC in the language and to me it feels seman…

Out of curiosity, was there a specific reason you went from Clojure to Haskell or was it more about exploring a new language?

I ask because I am currently learning Clojure, but wonder if there is something unique that Haskell offers.

Re: The New Haskell Homepage

#182

I get paid to write C++ code. I'm pretty good at it. I understand it's normal usage syntax very well. I don't fucking know what a god damn thing means in Haskell. λ 5 + 7 12 :: Num a => a What the christ? The 12 I get. Got it. The colons? Not sure. I think it's just a dumb separator. Num is type! What the hell is a => a? I have no idea. In the top they have an example. primes = sieve[2..] where sieve (p:xs) = p : sie…

> I guess primes is a thing (function?) that takes 2 or more things?

Primes is an infinite list of integers containing all prime numbers. It's not a function, it's a value just like any other list of integers.

You obviously can't do something like that in C++ or most other languages. I think that's a pretty good example to demonstrate the difference between a pure and lazy language like Haskell and the more mainstream kind of languages.

If you're primarily a C++ programmer, Haskell should feel alien to you. It's a good thing. The differences in syntax are only skin deep, the differences in the semantics is what is interesting.

Re: The New Haskell Homepage

#183
post #59

Earlier quoted context omitted.

Could you suggest a simpler example? Finding primes is something that is taught in the first programming class in Indian high schools. I guess I've never thought of it as something hard. I looked at nodejs.org, and their first example is a web server! Python has the Fibonacci as it's second example (the first one show's numeric operations). Ruby does simple string operations on it's home page. While I think that is i…

Fibonacci sounds perfect! fibonacci :: Integer -> Integer fibonacci 0 = 0 fibonacci 1 = 1 fibonacci n = fibonacci (n - 1) + fibonacci (n - 2) Arguments for this: * "Find the Nth Fibonacci Number" is among the most universally known programming tasks, so visitors are far more likely to immediately pick up the example than they are with sieve. * It shows off a bit of Haskell syntax that (A) can be learned just by looki…

Your example doesnt highlight lazyness like the sieve one does. I would expect to see something like this instead:

    fibonacci :: [Integer]
    fibonacci = 1 : 1 : zipWith (+) fibonacci (tail fibonacci)

Re: The New Haskell Homepage

#184
post #94

Well, it sure looks nicer, I'll give you that. I'm more interested in the content, though. I was just trying here and there over the last week or so to learn some Haskell - people always seem to be raving about how cool it is. I found my way to the CIS 194 class link, the first one on the page, and I find that it really isn't very good for learning. I went through the first page, trying to run some of the stuff. I fi…

I too dislike tutorials focused around the REPL, because it's rarely how you write code in practice. The REPL is more of a debugging tool for quickly testing and manipulating code you've already written. I'd jump directly into creating code files/modules - begin by creating simple programs using `main` as you would in other languages. Create a file with ".hs" extension, (Haskell filenames start with capital letters b…

> I too dislike tutorials focused around the REPL, because it's rarely how you write code in practice....

> The preferred tool for writing Haskell though is emacs...

I understand, but if your goal is to pull in new Haskell programmers you want to grab them as quickly as possible. You want them to try something immediately, not force them to invest in a toolset from the get-go.

I wasn't interested in Haskell until I used the REPL. It allowed me to get immediate feedback on how Haskell works. The tutorial got me engaged quickly.

Re: The New Haskell Homepage

#185
post #182

I get paid to write C++ code. I'm pretty good at it. I understand it's normal usage syntax very well. I don't fucking know what a god damn thing means in Haskell. λ 5 + 7 12 :: Num a => a What the christ? The 12 I get. Got it. The colons? Not sure. I think it's just a dumb separator. Num is type! What the hell is a => a? I have no idea. In the top they have an example. primes = sieve[2..] where sieve (p:xs) = p : sie…

> I guess primes is a thing (function?) that takes 2 or more things? Primes is an infinite list of integers containing all prime numbers. It's not a function, it's a value just like any other list of integers. You obviously can't do something like that in C++ or most other languages. I think that's a pretty good example to demonstrate the difference between a pure and lazy language like Haskell and the more mainstrea…

> Primes is an infinite list of integers containing all prime numbers. It's not a function, it's a value just like any other list of integers.

> You obviously can't do something like that in C++ or most other languages.

While the syntax is different, you can create a value just like any other iterable sequence that happens to be a generator for the infinite series of integers resulting from filtering another infinite series of integers by a particular function (which depends on the previous values of the series) in many, and possibly most, modern languages. (And the example here -- primes -- is pretty much the canonical example for every language.)

Definitely in most of the popular dynamic languages (Ruby, Python, etc.). And plenty of popular static OO languages, too. (Pretty sure both Java and C#, and definitely sure that Scala and other JVM and .NET static languages can.)

Re: The New Haskell Homepage

#186
post #111

Earlier quoted context omitted.

> I understand it's normal usage syntax very well. You understand C++ syntax because you're familiar with it, not because it is "normal" in any way.

Very true, but helpfully many other languages have a similar syntax (C, Java, JavaScript, even PHP's OOP system looks like Java) so it is easy to move between them. This looks very alien. Is there any language with a similar syntax?

The syntax should not really be a primary concern when evaluating a new language. It is easy enough to pick up if you understand the concepts behind the language. Haskell has not all that many keywords and a lot of syntactic sugar, there are no public final static member variables and no insane *((&a)++)++.

Re: The New Haskell Homepage

#187

I get paid to write C++ code. I'm pretty good at it. I understand it's normal usage syntax very well. I don't fucking know what a god damn thing means in Haskell. λ 5 + 7 12 :: Num a => a What the christ? The 12 I get. Got it. The colons? Not sure. I think it's just a dumb separator. Num is type! What the hell is a => a? I have no idea. In the top they have an example. primes = sieve[2..] where sieve (p:xs) = p : sie…

To complement some of the great answers here, I would like to point out that in Haskell, instead of objects carrying around a vtable pointer, the typeclass dictionaries get passed arount as extra implicit arguments to the functions.

This is important when you have binary operations like `+`. In haskell both operands must be the same type while with OO interfaces the operands can have different concrete implementations.

Re: The New Haskell Homepage

#189
> How often do programs crash because of an unexpected null value? Haskell programs never do!

    > head []
    error "Prelude.head: empty list"
Ok, so you don't call it `null`, but it still crashes the program. Its deceptive to claim null isn't present because it's conventional to avoid using "error" in favor of Maybe, but it's still there, and used throughout Prelude. The REPL on the site hides these errors too, which is going to be pretty confusing to a newcomer who takes the head of the empty list and gets back "null" (the absence of a value) of type a.

    > (head x) + (head (head x))
      :: Num a => a
Hiding errors makes it hard for a beginner to see what went wrong, although perhaps not in this trivial example.

Re: The New Haskell Homepage

#190

> How often do programs crash because of an unexpected null value? Haskell programs never do! > head [] error "Prelude.head: empty list" Ok, so you don't call it `null`, but it still crashes the program. Its deceptive to claim null isn't present because it's conventional to avoid using "error" in favor of Maybe, but it's still there, and used throughout Prelude. The REPL on the site hides these errors too, which is g…

There's a difference between crashing and returning null. If head returned null on an empty list, that null could be passed around to different places in the program before it crashed from a null pointer exception.

There can be unexpected crashes in Haskell, but not because of null.

Post reply on HN