News for hackers. Stuff that matters.
Re:Letter to a Young Haskell Enthusiast by innguest on Friday August 01, 2014 @09:31AM (#8119666)
Haskell just clicked for me not long ago after 4 years of revisiting it periodically, writing one-liners and small programs, and reading tons of material on it. All the tutorials in the world weren't helping it click for me.

But then somehow I finally understood that Haskell is (trying its best to be) Math. I had a deeply mistaken idea of what math is and I thought I "hated" it and that any kind of advanced math is too hard for me. I have failed Calculus before, though I've always done well in discrete math.

It was only when I realized that math begins (or does it?) with what you have (objects, sheep, anything you want to count) and what you can do with them (group, make a set, join two sets, etc). Then I went into a reading spree about all ofthose very basic and foundational aspects of pure math (pure as in "look around you, you can count things, you can group them based on some trait, you can do operations based on groups, you can now think of those groups as the entities to focus on, you can prove certain properties about those groups, etc") and I found it amazing that so much can be known and discovered from starting with just what you see around you.

When I understood that math starts with just looking around you then I finally made peace with math, and I saw that it was good, that it was here to help me. Then I looked at Haskell again, and suddenly Void, Unit, Either, Maybe, they all made perfect sense. Maybe is a function that takes your set and gives you a new set that looks the same, but has a special entity that means "the lack of an entity in this set"; in other words, Maybe adds a zero to a type. It's simple and easy for me when I choose to see it that way. Everything is a lot more concrete and I have even drawn all these concepts and they map very well to visual ideas. So many things in Haskell are recurring themes (like adding a zero, starting things with a "one" entity, etc) that if you have a good relationship with math, many things fall into place just nicely.

But I started Haskell hating math and that has held me back so much. So my advice would be to never deny that Haskell is math, but to explain what's so awesome about math, how it gives us so much certainty even if we only assume very basic and seemingly obvious statements. I could have used some rough advice like "listen, stop whining about math, you're wrong about what you think math is, it's much more fundamental and it's a tool to help you organize any set of ideas you have, so why would you not apply that to programming?"

Re:Letter to a Young Haskell Enthusiast by pavlov on Friday August 01, 2014 @11:52AM (#8120719)
It was only when I realized that math begins (or does it?) with what you have (objects, sheep, anything you want to count) and what you can do with them (group, make a set, join two sets, etc). Then I went into a reading spree about all ofthose very basic and foundational aspects of pure math (pure as in "look around you, you can count things, you can group them based on some trait, you can do operations based on groups, you can now think of those groups as the entities to focus on, you can prove certain properties about those groups, etc") and I found it amazing that so much can be known and discovered from starting with just what you see around you.

In the early '70s, there was a global movement in math pedagogy that took this angle to elementary learning.

Instead of arithmetic, first graders were taught set theory. Elements and unions became the first mathematical concepts introduced to 6-year-olds.

In the US, I think they called it "New Math". Here in Finland, set theory was included in the national educational system's grand redesign. Regardless of country, set theory as elementary math seems to have gone out of fashion as quickly as it gained traction, and by the early '80s was out everywhere.

Maybe, if they had stuck with it, we would all be using Haskell now as a side effect :)

(Here's a picture of a very '70s styled Finnish math teacher doing set theory: http://1.bp.blogspot.com/-vWW22FRIdfc/TobxIw3xF3I/AAAAAAAAHa... -- "Now tell me children, what is the union of green swans and red bears?")

Re:Letter to a Young Haskell Enthusiast by t-ob on Friday August 01, 2014 @12:44PM (#8121299)
I took a History of Mathematics module as an undergrad and remember our lecturer telling us the main reason "New Math" never stuck was because parents were no longer able to help their kids with their homework.
Re:Letter to a Young Haskell Enthusiast by judk on Friday August 01, 2014 @01:20PM (#8121573)
This issue comes up every time new ideas enter education. This roadblock will never be overcome, unless parents try to learn math as well.
Re:Letter to a Young Haskell Enthusiast by emotionalcode on Friday August 01, 2014 @12:24PM (#8121123)
On a very abstract level, I don't really think it makes a difference. If you start from one sub-domain as a primary foundation in mathematics, you eventually wind up realizing you can define that sub-domain easily, using different sub-domains of math. Realizing that is I think, where category theory sprang from. That last bit, I could be totally wrong on - I tried to teach myself category theory and wound up building webs using abstract algebra and formal logic.

That's obvious if you program, though (to me). What you can do in one language, you can do faster, slower, more concise, more verbose, more symbolic, more literal, and so on, in another. You can build constructions and you can break them apart, depending on what layer of abstraction you can get to. You can call it by it's specific name and functionality, in how the part interacts in relation to the parts around it, or you can call it objects and morphisms.

I might be totally wrong, again, or using the wrong words and confusing everyone including myself (which is why I like to study formal languages, too). But I think that no matter where you start from, you will eventually find yourself in a place where you are scratching your head, confused about what you know, what you don't know, what everyone knows, and what everyone doesn't know.

Oh, and it's probably totally obvious if write proofs, believe in induction, and get very philosophical.

Re:Letter to a Young Haskell Enthusiast by euid on Saturday August 02, 2014 @03:52PM (#8125784)
> believe in induction

Does it even make sense for someone to not believe in induction? It's a perfectly valid logical rule.

Re:Letter to a Young Haskell Enthusiast by emotionalcode on Thursday August 07, 2014 @08:16AM (#8147281)
On some layers of logic, I agree. On some layers of meta-logic, I don't know.
Re:Letter to a Young Haskell Enthusiast by zingermc on Friday August 01, 2014 @11:55AM (#8120754)

  using Haskell now as a side effect
Very clever.
Re:Letter to a Young Haskell Enthusiast by rfrey on Friday August 01, 2014 @03:48PM (#8122413)
On the off chance there's a person who hasn't heard Tom Lehrer's explanation of the New Math:

https://www.youtube.com/watch?v=Vetg7vWitTU

(In case you don't know Lehrer, he did PhD studies in math at Harvard, and taught at Harvard and MIT, often performing his songs during his lectures (or composing songs FOR his lectures.))

Re:Letter to a Young Haskell Enthusiast by dllthomas on Friday August 01, 2014 @06:05PM (#8123093)
"taught at Harvard and MIT"

... and Santa Cruz! I was one course shy of taking his last course (Infinity) before he retired.

Re:Letter to a Young Haskell Enthusiast by svachalek on Friday August 01, 2014 @01:20PM (#8121575)
Pretty interesting history of math education in the U.S.: http://www.nytimes.com/2014/07/27/magazine/why-do-americans-...
Re:Letter to a Young Haskell Enthusiast by rjsw on Friday August 01, 2014 @01:56PM (#8121800)
I'm the right age to have done this when I started school. My memory is of it is playing with lots of wooden bricks that were marked with lines to show their length. It felt well taught but I'm not sure how well the rest of the class picked it up.
Re:Letter to a Young Haskell Enthusiast by virtualwhys on Friday August 01, 2014 @11:31AM (#8120525)
Interesting, I have no background in higher level math at all (stopped after high school calculus), yet still am able to grok Either, Maybe, Unit, etc., as I'm sure is the case with any non-math head that happens to be a programmer.

The difficulty I find with Haskell itself (setting aside FP basics that exist in many languages these days), is the math requirement. Why requirement? Well, it may be possible to use Haskell in isolation without knowing category theory and higher level math in general, but in the real world, Haskell libraries are in fact based on and assume a foundation in category theory and general understanding of higher level math (see the uber popular Lens library, Yesod, Conduit, or really any non-trivial library implemented in Haskell).

Hand wavy stuff like, "oh, you don't need to know that, it's all just simple building blocks", mixed with, "go read this paper [filled with unicode symbols that have no meaning whatsoever to someone without a background in higher level math]" creates a split message, on the one hand Haskell is simple; on the other, beyond complex.

I'd say that F#, OCaml, and Scala are all more accessible than Haskell just due to their placing less of a cognitive burden on the beginner. Learning Haskell feels like reverse engineering my mind.

Will be interesting to see how things play out, Haskell is moving fast and is clearly ultra popular here on HN, perhaps startups are already using Haskell in anger (i.e. over Rails, Play et al).

Re:Letter to a Young Haskell Enthusiast by dragonwriter on Friday August 01, 2014 @03:29PM (#8122330)
> I'd say that F#, OCaml, and Scala are all more accessible than Haskell just due to their placing less of a cognitive burden on the beginner.

I think that this is largely a documentation issue rather than a language issue; that is, while certainly its a language issue -- a strength -- that implementing things with a strong basis in (e.g.) category theory is facilitated in Haskell, its a documentation issue that many things implemented in Haskell libraries are not explained in a manner accessible to programmers who don't have that kind of background.

Re:Letter to a Young Haskell Enthusiast by judk on Friday August 01, 2014 @11:37AM (#8120578)
There is also the amazing and bewilderig Java Generics FAQ.

Lens actually has a great tutorial in its standard documentation. You aren't required to read all the theoretical foundations. Trying to explain the logic under JS truthiness will make your head just as spinny.

Re:Letter to a Young Haskell Enthusiast by tel on Friday August 01, 2014 @10:17AM (#8119915)
For those looking for book recommendations, I personally found Aluffi's "Algebra: Chapter 0" quite wonderful. It's available online.
Re:Letter to a Young Haskell Enthusiast by j2kun on Friday August 01, 2014 @02:10PM (#8121884)
This book is what finally demystified category theory for me.

But as a fair warning it's role is as a synthesizing text for first-year PhD students in pure mathematics. The author's goal is essentially to prepare students to study algebraic geometry, which is one of the most obscure areas of contemporary mathematics research. That doesn't make it any less enjoyable of a book, and it has a lot of topics that are mostly unrelated to algebraic geometry. The point is it's not an easy book by HN standards.

Re:Letter to a Young Haskell Enthusiast by tel on Friday August 01, 2014 @02:29PM (#8122012)
While I know what you're getting at, I think of it as pretty accessible. It assumes a little familiarity with terminology, but since the goal is to use CT as a tool to "see" the structure of various mathematical objects it doesn't demand a whole lot of the reader in terms of background knowledge.

I suppose I should have begun by stating that CT is a new lens on the world and any reader interested in understanding it needs to have the, typically mathematics-derived, patience to really slow down and re-evaluate the way they view some friendly concepts. But I think even with that the "Socratic" rhetoric employed is helpful.

So, I totally agree but even if it's a bit off a waterfall it's not one that I feel too bad about encouraging people to jump off of.

Re:Letter to a Young Haskell Enthusiast by j2kun on Friday August 01, 2014 @06:11PM (#8123109)
> it's not one that I feel too bad about encouraging people to jump off of

I agree :)

Re:Letter to a Young Haskell Enthusiast by waffle_ss on Friday August 01, 2014 @11:08AM (#8120328)
Here's a curated list of Haskell-related books from Rein Henrichs: http://reinh.com/notes/posts/2014-07-25-recommended-reading-...

I've seen "Conceptual Mathematics" recommended by several people for learning Category Theory.

Re:Letter to a Young Haskell Enthusiast by rrradical on Friday August 01, 2014 @11:17AM (#8120400)
I'm reading that right now. It's a very gentle introduction, and I do recommend it. I looked at some other books but they were very dense with notation that I hadn't seen since college. Conceptual Mathematics doesn't really presume any prior knowledge, so even if it's a little slow in some parts, it's helping me get back up to speed.
Re:Letter to a Young Haskell Enthusiast by tel on Friday August 01, 2014 @11:56AM (#8120760)
I was quite possibly one of them! I recommend Conceptual Mathematics at every opportunity. It's a wonderful first CT book. Aluffi is a bit more ambitious in scope—you leave with a broader understanding of abstract algebra at large as interpreted through CT when useful.
Re:Letter to a Young Haskell Enthusiast by yawn on Friday August 01, 2014 @09:54AM (#8119784)
I agree with Jonnie...what books did you read? Your comment does a great job presenting math in a way that I would like to experience. What books/videos/materials did you discover that enhanced this?
Re:Letter to a Young Haskell Enthusiast by innguest on Friday August 01, 2014 @10:31AM (#8119998)
Unfortunately there isn't a single publication that does justice to what I've pieced together. By that I mean, because I had such a poor understanding of math, every little bit of knowledge and intuition that most people learn implicitly, I had to learn explicitly. The downside is that it took me all this time to realize how useful math is, but the upside is that I now have created several explanations (both in text and video format) where I explain all of these intuitions in a piecemeal way, slowly building up a model of the world, but without any math notation and without ever talking about numbers, just objects in general and relationships between them. You can go from scratch (things you see around you) all the way to category theory without realizing you got there, all without notation, just building intuitions. That's what I do in the videos, I use the idea of a caveman looking around and starting to discover these relationships, and building on top of them.

I must have more than 15 hours of material that I recorded as I was piecing together what I was (and am) learning. I should put them online - I haven't done it yet because I think it drags on for too long, but maybe I should put up one or two and judge from the comments and go from there.

Mostly I gathered these ideas by first finding out that Set Theory is at the beginning of math. Then I found out how categories and types and sets are all equivalent. Then I read some papers that explained that and for that they needed to step back and give some intuition of each and how they relate to each other. I explored so many links, but the knowledge is scattered.

I will publish some of the stuff I made, now that I know there's interest, when I'm back home on Monday. If you want to know about it, send me an email (it's in my profile page) and I'll let you know.

Re:Letter to a Young Haskell Enthusiast by charlieflowers on Friday August 01, 2014 @10:52AM (#8120142)
Publish it. Don't get caught up in perfectionism. This would be highly valued by me and many others even if it does "drag on" at times or lacks polish in certain areas. You have just recently bridged a gap that many would like to bridge, so it is still fresh in your mind what it is like to be on both sides of that gap. It's that freshness that lends unique value to your material. A 20 year professor might be an expert, but she has lost that freshness.

So publish it! Please!

Re:Letter to a Young Haskell Enthusiast by JonnieCache on Friday August 01, 2014 @10:56AM (#8120170)
Seconding this. Publish it, even if its a mess. Just make it CC, other people will clean it up if they think it's worth doing. If they don't, no loss to you.
Re:Letter to a Young Haskell Enthusiast by willismichael on Friday August 01, 2014 @11:25AM (#8120476)
As somebody who is looking for engaging ways to teach my young children math, I will also ask you to please please make this available. (And I can fully agree with previous comments regarding perfectionism and creative commons).
Re:Letter to a Young Haskell Enthusiast by innguest on Friday August 01, 2014 @12:04PM (#8120850)
Wow, thanks for the interest :) I will definitely publish it this weekend on Youtube (I'm not home right now so I don't have access to the files). If you'd like to be notified about it, ping me on my email; I would love to have feedback on them!
Re:Letter to a Young Haskell Enthusiast by a-saleh on Friday August 01, 2014 @11:02AM (#8120252)
If you are interested in math in relation with programming, I really like blog at http://jeremykun.com

If you feel your math is too rusty to follow along, http://jeremykun.com/primers/ should get you started, and then just choose the topic in http://jeremykun.com/main-content/ ... or maybe the other way around :)

Re:Letter to a Young Haskell Enthusiast by Ixiaus on Friday August 01, 2014 @02:16PM (#8121914)
Mathematics for non-mathematicians, Foundations of Arithmetic were the books that did it for me. Amazing books.
Re:Letter to a Young Haskell Enthusiast by JonnieCache on Friday August 01, 2014 @09:35AM (#8119684)
Nice comment. What books did you read?
Re:Letter to a Young Haskell Enthusiast by methodology on Friday August 01, 2014 @02:15PM (#8121909)
How did learning how Algebraic Data Types are algebraic make you "get" Haskell?

When I learned Haskell, I just read Learn You A Hasekell in a few days, and immediately understood the practical value of Algebraic Data Types. They simply are like the types in C,Java,etc but more general because unions can have "fields". This alone means you can represent things like Maybe without any trouble, whereas in C/Java, you'd have to use casting, explicit tagged unions, or the visitor pattern. ML has largely the exact same features as Haskell, except you have to explicitly say which module you're using, instead of the typeclass system doing it for you. Do you also "get" ML? It sounds more like you are claiming to "get" some sort of theory, rather than Haskell or ML, which are trivial, but you make it sound like you need to be somehow enlightened to understand.

The only hard part I ever found in Haskell is lazy evaluation, which to me is just another type of magic which nobody gets, just like the Java Memory Model. The other hard part of Haskell are the extensions to type classes, which make you start thinking about open research problems.

edit: Which part of the above is downvoting material? Please explain so I can avoid being downvoted in the future.

Re:Letter to a Young Haskell Enthusiast by tel on Friday August 01, 2014 @02:30PM (#8122020)
I think there's reason to believe that ADTs are both a major component of "getting" Haskell and a major topic in their own right of significant size beyond Haskell itself.

I've been plugging it a lot lately, but here's a post I wrote trying to emphasize this: http://tel.github.io/2014/07/23/types_of_data/