HNHacker News
TopNewBestAskShowJobs

sold

367 karma · joined February 10, 2012

submissionscomments
sold··on Why I prefer scheme to Haskell
- I made many mistakes in the learning process. Monads should be done after you know core language (higher order functions, ADTs and pattern matching, typeclasses). I was attempting to learn many things at once and perfectly, instead of climbing Wittgenstein's ladders.

- Getting used to nested functions, \x -> f >>= (\y -> g >>= h x y) is not that easy.

- The type of bind, m a -> (a -> m b) -> m b is rather complex for a noob. You've got polymorphism, and m can be different depending on the monad. Monads form a higher-kinded typeclass * -> * , unlike most other typeclasses * . I discovered Functor rather late. You need to realize Reader r is a monad, not Reader, not Reader r a. Partial application on types.

- It took me some time to read and rederive all standard monads - [], Maybe, Reader, Writer, State, Cont. Those things enter the mind slowly, especially state and continuations. Now I can reimplement all of them given a scratch of paper.

- If you do not know IO, you can only use GHCi to test expressions. I thought I need to know monads very well to do IO. This is not true, but I survived a month by loading modules and interacting with GHCi only. On the other side, after all this trouble IO clicked immediately. Fortunately Haskell has enough concepts you can learn for a month without writing a complete interactive program. Look at http://www.haskell.org/haskellwiki/Blow_your_mind for example.

- After you know (>>=), return you need to learn standard library functions such as join, mapM, sequence, forever etc. Then transformers.

- When I was learning, there was no Learn You a Haskell or Typeclassopedia yet. I found sigfpe's famous http://blog.sigfpe.com/2006/08/you-could-have-invented-monad... very late. I found a lot of useless buzz and opinions but rarely with details or instructive code.

I am happy I had a good curious attitude and did not resign.

sold··on Why I prefer scheme to Haskell
It took me two months to really comprehend monads. Now I find them very intuitive and easy. However, they are definitely not easy to learn. It is like you are learning programming for the first time. Initially, they seem weird. Haskell requires patience. It is not a language where you can jump in and immediately see results, like jumping from C to Python. Someone who starts learning vi might be frustrated too. You need to learn ten keys before it becomes as productive as notepad.

> In Ruby or a similar object oriented language you expect to find three APIs/gems, all with a similar object oriented syntax, but for three Haskell DSLs designed for three different tasks to share syntax implies that their authors failed to optimise them for those tasks, hence instead of five minutes with API documentation you have hours of DSL tutorials ahead of you before you can begin work.

You need to learn monads only once. I can use new monads without any trouble.

sold··on How Not To Sort By Average Rating
Urban Dictionary no longer sorts by positive - negative, see e.g. http://www.urbandictionary.com/define.php?term=usa. I don't know what they use now.
sold··on Functional Programming For The Rest of Us
Is Prolog a functional language, as it avoids state manipulation but has no first-class functions? I think not. There are some characteristics of functional languages - including first class and higher order functions, relying on immutability, declarativity etc. Choosing just one of them to measure how much a language is "functional" is a mistake IMO.
sold··on Functional Programming For The Rest of Us
> wikipedia uses one definition

Let me repeat: you used an introductory sentence as a "definition" of FP and are overinterpreting it. If you read later you will see:

> Functional programming languages, especially purely functional ones...

So Wikipedia distinguishes functional programming and pure functional programming. In fact there is a separate article on pure functional programming, which says that destructive modifications are "excluded", not just "avoided".

Functional programming does not have clear boundaries. You can have advantages of functional programming even if you introduce _a bit_ of FP style in a very imperative program. Conversely, you can write in very imperative style in Haskell.

sold··on Functional Programming For The Rest of Us
This is a single introductory sentence. You should not reason that far with it.

With that reasoning you could claim addition is impure, because time() + 1 changes over time. map is definitely a pure function. If you apply it to impure arguments, of course the result will be impure. The point in FP is to avoid using 'time', not 'map'.

sold··on Defining Property
Music too, if someone in a train has loud headphones. Or, you could hear a band playing a show outside the venue. In a very resourceful world, you could always find a public place where you can overhear the track you want to listen.
sold··on Viral Video About Body Scanners
Sometimes YouTube comments give me also that feeling.
sold··on A beautiful algorithm that only a very few know of: In-Place Merge in O(n) time
I get 404 at this URL but google cache is available.
sold··on How Many C Programs Are There?
If you have printf, then "printf("long string")" where the string might be modified should give a good bound, say Omega(200^S). If you don't have it, what is the program allowed to do? Only return from main, without checking arguments? Then you have as many extensionally distinct programs as integers.
sold··on It’s Just Math
I think the poster is arguing against the conflation. Organic chemistry is not memorizing compounds; mathematics is not memorizing integrals; anatomy is not like memorizing colors. There is a great difference between understanding and memorizing.

I had a very bad history teacher. On most tests, he required the class to learn about 20 different dates (only) and some facts like where a peace treaty was signed. Nobody cared what those events meant, what were connections between the dates etc. Now, many years later, I don't recall anything. I learned nothing. Was I really learning history or just arbitrary numbers? You could claim that it was real history, and probably be technically correct, but I think that's silly. In my mind, the semantics of what I knew did not resemble history at all. In contrast, my chemistry teacher visibly required understanding, and till now I can discuss basic chemistry, even though I did not exercise my skills for a long time.

It's the same with mathematics, learning algorithms means essentially you are programmed to do mechanical work, just I like I was acting like a lookup table during history classes. "Real" mathematics starts when the problem you are doing is not directly amenable to a mechanical approach.

sold··on Simple SAT Solver in Haskell
clauseSat, simpClause and simplify functions do not need special case for []. You can remove the three lines. Even more, clauseSat s l = elem l s, simpClause c l = filter (/= -l) c.
sold··on So I started a blog ... about learning how to code
I also recommend following a tutorial, it's really hard to start coding on your own, you will definitely get bad habits or a very shallow, incorrect understanding. I know this from long experience.
← PreviousPage 5 of 5