Live data from Hacker News

Elements of Programming (2019)

elementsofprogramming.com

11–13 of 13 posts

Re: Elements of Programming (2019)

#11

This is a great book. This wasn't mentioned in the past thread. Alex presents his ideas in my forms. This one happens to be the most terse and mathematical. That can be good, but I think "From Mathematics to Generic Programming" is much more generally approachable. One practical skill that's shown well in this book is writing functions that solve the easiest or special cases, and then layering those into general func…

> writing functions that solve the easiest or special cases, and then layering those into general functions

This is something I've been getting the hang of in my recent playing around with Elixir. In Elixir, you can eliminate a lot of conditional logic by utilizing pattern matching in function signatures. Often, though not always, it's possible to write each of your edge cases with a single function head. In practice this usually looks like a few 1 or 2 line functions for simple cases, and then one gnarly one that does whatever checking you need to assure the right result.

It's also a great way to write recursive functions. You can pattern match on the base case - say, an empty list - and then put the recursive case or cases under separate function head.

It's a wonderfully fun and expressive language, although I have been missing static types here and there, which counterintuitively seem like they might eliminate a lot of boilerplate from my code.

Highly recommended playground for the language geek.

Re: Elements of Programming (2019)

#12
post #7

Earlier quoted context omitted.

I was a bit put off by the introductory chapter where he is using a lot of nonstandard terms such as "abstract species/genus" rather than the usual type theoretic treatment. However, take that as the remark of an ignoramus.

Can you say more about why that put you off? There are many different backgrounds from which to explore these topics, and type theory is just one way. Also the introduction isn't really trying to formalize computation itself, but give mathematical tools for talking about algorithms. The abstract species/genus is probably inspired more by Aristotle than CS topics.

I don't think the terms "Abstract species/genus" ever came up, but it makes me think of Introductory course to Object-Oriented Programming (Java), lecture 5: Inheritance

Re: Elements of Programming (2019)

#13
post #12

Earlier quoted context omitted.

Can you say more about why that put you off? There are many different backgrounds from which to explore these topics, and type theory is just one way. Also the introduction isn't really trying to formalize computation itself, but give mathematical tools for talking about algorithms. The abstract species/genus is probably inspired more by Aristotle than CS topics.

I don't think the terms "Abstract species/genus" ever came up, but it makes me think of Introductory course to Object-Oriented Programming (Java), lecture 5: Inheritance

You might be happy to know there is no inheritance in these books.
Post reply on HN