Live data from Hacker News

Show HN: I built a poker site with Haskell

github.com

91–100 of 121 posts

Re: Show HN: I built a poker site with Haskell

#91
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

> So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence.

Then perhaps you should fix these before indicting the code?

Haskell isn't just a different language to learn because it's different, it's also a different language because it has a community that values math-driven models of things. As such, you're going to end up at a disadvantage trying to understand every aspect of it without any prior consideration.

Sorta like how templates often baffle new programmers but are considered absolutely essential by folks who get a year or three of C++ experience.

Re: Show HN: I built a poker site with Haskell

#92

Earlier quoted context omitted.

Well, non-programmers are even more helpless in understanding the code, but that's just not the point I'm making. Let's not require everyone to couch every statement in disclaimers, especially such an ancillary one. And you surely can understand that code is trying to read a port or use a default one.

> And you surely can understand that code is trying to read a port or use a default one. In programming languages which use paradigms I'm more familiar with, yes. In Haskell, not so much, which is the entire point of this thread.

Weird, I thought the point of this thread was how to bikeshed looking up environment variables while folks look at the proverbial camera and appeal to the hypothetical audience that `if x == null: ` would surely be morally superior.

Re: Show HN: I built a poker site with Haskell

#93
post #75

Earlier quoted context omitted.

Closer, but int can throw a ValueError. The original Haskell code defaulted to the defaultPort if the specified port could not be cast to an int.

I see. Though I think it's better to throw an error. I wouldn't want my app just coming up on default port if I had configured it incorrectly.

It might be in Python, but it's sorta oranges to apples for you to just not do the same thing your Rosetta code is supposed to do.

What's the value of your exercise if you just redefine the problem to get rid of the tricky part?

Re: Show HN: I built a poker site with Haskell

#94
post #49

Earlier quoted context omitted.

Haskell is not a difficult language to learn, but unlike imperative languages, you can't just start reading the code if you "know literally nothing about Haskell". One thing to keep in mind is that every other line in Haskell is basically just composing functions together, but you need to know how all those weird >>= and and effect code/composition flow

> is not a difficult language to learn People say this about every single programming language.

Probably because they're all right.

Re: Show HN: I built a poker site with Haskell

#95
post #46

Earlier quoted context omitted.

Unfortunately, a lot of work there is done by the Haskell community having utterly absurd standards for those things. I work in a different functional programming language, and you would not believe the amount of time I spend convincing new hires with Haskell backgrounds to spend the extra few characters to expand out the unreadable point-free/single-character-names style that Haskell folks prefer.

Oh believe me, I’d believe. My Haskell background comes from building upon academic proofs of concept during a stint at CSAIL. Never again.

That world has very little to do with commerical Haskell though, now does it? Why, we even discourage the use of Singletons and if you import a unification library everyone will immediately demand to know why.

Re: Show HN: I built a poker site with Haskell

#96
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

One problem is very generic tooling in Haskell. In many languages, you'll have a library that might provide a function like "iteratePokerGameStep." In the haskell community, the author is more likely to realize that this could just be implemented via "BiApplicativeProfuctorCategory.map." So instead of writing a 6 line "iteratePokerGameStep" which gets its own name, you're more likely to see someone just call "map." M…

"BiApplicativeProfuctorCategory".

Please don't just make things up.

Re: Show HN: I built a poker site with Haskell

#97
post #80

Earlier quoted context omitted.

Game servers aren’t typical. Texas Hold’Em especially. Like a chat application is also multi-user real-time. It’s obvious that when a chat participant disconnects you hold onto the messages to deliver to them for later. When you disconnect from a Texas Hold’em online and you were small blind, what should you do? Wait? Shift the blinds over? The next player in line gets big or small? Copy the leading product’s behavio…

Our ways to hide that logic has been building libraries that handle nearly all of it. But since Haskell's ecosystem is small by comparison a lot of that logic leaks to your own application code. Especially when dealing with something like stateful websocket applications.

A general-purpose library able to hide the necessarily specific logic of how network events and a poker game should interact seems... unlikely?

Re: Show HN: I built a poker site with Haskell

#98
post #77
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

> Is it just me[?] It's not just you, I came here to say the same thing. I just feel dumb when I try to read Haskell, though I've been using Clojure in production for over 5 years.

While I feel like writing Clojure for 5 years would improve one's ability to /write/ Haskell, I feel it'd have almost no impact on one's ability to read Haskell.

With all pros (e.g. local reasoning, referential transparency, no destructive updates) and all cons (e.g. tons of marshalling/converting, piles of imports, shitty records) aside for a moment, I think you learn to read Haskell like you learn to read any other programming language: by writing a lot of it.

Re: Show HN: I built a poker site with Haskell

#99
post #80

Earlier quoted context omitted.

Our ways to hide that logic has been building libraries that handle nearly all of it. But since Haskell's ecosystem is small by comparison a lot of that logic leaks to your own application code. Especially when dealing with something like stateful websocket applications.

A general-purpose library able to hide the necessarily specific logic of how network events and a poker game should interact seems... unlikely?

Sure, but the original argument was: > raw connection state, timers, transient and long-term persistent state

Much of this surely can be abstracted away to 3rd party libraries/frameworks. Haskell, even though a higher level language than most out there, lacks the ecosystem support for a lot of things that are handled by some library in lower level languages.

Re: Show HN: I built a poker site with Haskell

#100

Earlier quoted context omitted.

I see. Though I think it's better to throw an error. I wouldn't want my app just coming up on default port if I had configured it incorrectly.

It might be in Python, but it's sorta oranges to apples for you to just not do the same thing your Rosetta code is supposed to do. What's the value of your exercise if you just redefine the problem to get rid of the tricky part?

I’d say the original code was wrong. anyway catching an exception isn’t tricky.
Post reply on HN