Live data from Hacker News

Does anybody find this Scheme code readable?

raw.githubusercontent.com

1–10 of 23 posts

Re: Does anybody find this Scheme code readable?

#3

I want to learn scheme but that is too much for me. So either 1. That is badly written code. 2. I'm a bad programmer. 3. Scheme's syntax is ugly. What do you think?

I'd probably start by putting this in an editor with syntax highlighting, which should make things a bit clearer. I'm from the C world myself, but I could mostly follow along the code. It's s-expressions of course though, which take some getting used to. Personally I hate them, so I stay away!

Re: Does anybody find this Scheme code readable?

#7

I want to learn scheme but that is too much for me. So either 1. That is badly written code. 2. I'm a bad programmer. 3. Scheme's syntax is ugly. What do you think?

I think "it's hard to read code in a language you don't know."

You're fooled on this because so many languages are so similar -- if you know C++, you can trivially read Java and C# and Python, and even languages that are a bit further afield like Javascript and Perl still are heavily influenced by C, so don't seem too odd.

But Scheme is a whole new family of languages. It's like being an English reader and looking at Greek text as opposed to Spanish. It's not that Greek is harder than Spanish, it's that Spanish is closer to what you already know.

Re: Does anybody find this Scheme code readable?

#8

I want to learn scheme but that is too much for me. So either 1. That is badly written code. 2. I'm a bad programmer. 3. Scheme's syntax is ugly. What do you think?

4. You best read code by trying it out and seeing what pieces of it do.

Try it with an interpreter running.

Re: Does anybody find this Scheme code readable?

#9

I want to learn scheme but that is too much for me. So either 1. That is badly written code. 2. I'm a bad programmer. 3. Scheme's syntax is ugly. What do you think?

Perhaps this is (at least) a 4th possibility, which is that it would take you time to get used to, but once you had it would not be too much for you. Even Paul Graham (enthusiastic Lisp advocate) once said "I suppose I should learn Lisp, but it seems so foreign" [1]

I found it reasonably readable. The only criticism I had, offhand, was that the predicates like 'is-piece-knight?' were a bit verbose: the query mark at the end is understood to label a predicate, so the 'is-piece-' was redundant. I'd have written 'knight?' instead. That's pretty nit-picky though, and I don't think the current convention really detracts from its readability.

[1] If Lisp is So Great: http://paulgraham.com/iflisp.html

Re: Does anybody find this Scheme code readable?

#10
It's been about 15 years[1] since I last spent a lot of time with Scheme, but yes. As others have mentioned, the author could've done a better job with variable names, and syntax highlighting would do a world of good, but the code itself looks pretty understandable.

If you're not using DrRacket, then please start using it. I learned what was then Scheme from SICP[2], but I've heard that the Little Schemer is perhaps a bit more approachable. Try starting with it[3].

[1] That moment when you realize it's been over fifteen years since you started college...Yeesh.

[2] https://en.wikipedia.org/wiki/Structure_and_Interpretation_o...

[3] http://stackoverflow.com/questions/13003850/little-schemer-a...

Post reply on HN