Recommended Reading for Any Programmer

(Fletcher) #1

As the second oldest person I know of here (@Rhuagh is the first!) I thought I’d give a short list of books and tips I recommend to any programmer, especially ones just out college or high-school, that I’ve found useful in my career:

Books

  1. The Pragmatic Programmer - Every programmer should read this. No exceptions.
  2. Clean Code - More of a mid-boss book. Best to read after you’ve written some medium-scale projects so you can read this, and be properly horrified.
  3. Design Patterns - Yes, the focus is on OOP, but it still has a lot of useful insights
  4. The Art of Computer Programming - Consider this more of a…final boss. It is 4 massive books, but they are books that you will read and re-read throughout your career, and get something new each time.

Things to Learn

  1. A functional language. My recommendation is the following order.
    • Elixir
    • Erlang
    • Haskell
    • F# is in there somewhere, but I don’t know where
  2. The Actor Programming Paradigm
    • Erlang will cover this, but so will Akka if you want a JVM experience.
    • This architecture is key to building reliable, distributed systems

Harder Things to Learn/Read

  1. The Dragon Book if you want to know how compilers work
  2. The Design and Implementation of Operating Systems - Anything by Andrew Tanenbaum is worth reading
  3. TCP/IP Illustrated - If you want to know how networks work, so you can be properly horrified at how much money runs through something built to be inherently insecure 40 years ago.
9 Likes
(Simon Rönnberg) #2

I would add “Agile estimating and planning” if you are or are planning on working with any role in software development in the modern age.

1 Like
(Simon Rönnberg) #3

And you should read some kind of book on computer architecture (i.e. how does the cpu work internally? memory hierarchies? cache? etc).

2 Likes
(W. Brian Gourlie) #4

As for functional language recommendations, I would suggest Elm since it enforces purity (no escape hatches, unlike F#) and is presented in a far more user-friendly way than Haskell.

1 Like
(OvermindDL1) #5

Eh, I’d opt for OCaml over Haskell/F#/Elm for a variety of reasons.

#6

OCaml over Haskell/F#/Elm

Would you care to provide some details concerning why?

(Timon) #7

Amazing books, I have read all of those. Some not completed because I like starting with new book when others aren’t finished yet :persevere:

(OvermindDL1) #8

When people speak of Haskell they tend to refer to GHC since in ‘pure haskell’ it is quite hard to accomplish a lot of actual work, thus GHC’s extensions come out in full force, which is teaching you compiler quirks and workaround instead of proper patterns.

F# is OCaml without the module system, and OCaml’s higher typing power comes from its module system, without that you lose, dare I say, most of its extended capabilities.

Elm is similar to a pure haskell, hard to accomplish work in unless it fits into a very narrow subset.

As for why OCaml, quite a multitude of reasons:

  • It compiles faster than about any other language out, and certainly faster than any other optimizing compiler.
  • It focuses on purity and includes features of that which are not efficiently emulateable otherwise in the language.
  • The language came out and is used to do work in various industries (from heavy use at bloomberg to janestreet to even Facebook) and the features it has was for the purpose of getting work done, not for testing purity constructs as tends to be done with Haskell (hence why so many compiler extensions to work around faults in the language design).
  • It has a multitude of PP’s (preprocessors, such as Caml4p to ReasonML, essentially different syntax on the same OCaml), PPX’s (AST preprocessors, they can mutate the AST from one form to another), and backends (from a bytecode language to highly optimized native machine code to javascript and more).
  • It’s compiler is actually good to learn from, like I would say it has probably the only readable compiler code written in the language it compiles that is easy to understand, follow, and well worth learning from, especially if you are interested in optimizations.
  • It executes at around C/Rust speed in the majority of its constructs.
  • And of course the features of its typing system are simple and comprehensive (again, unlike haskell) from the usual things like records/sumtypes/prodtypes to GADT’s, Polymorphic Variants, and Row-Typed objects (think Elm records), to safe code modification via PPX’s to the Higher Polymorphic Type system that is its Module system.
  • The ecosystem is big on good documentation and easy to read code, you won’t find operator-hell ala Haskell in the OCaml ecosystem (even though its capable of it, kind of the difference between perl and python there).
  • EDIT: Oh and can’t forget that OCaml by default has an unambiguous syntax, easy to parse and read unlike most languages.

In addition, (I work at a college) both Haskell and OCaml have been taught here and OCaml always ends up being the preferred one by both instructors and students. It’s been described as kind of like a Strongly (full extended HM) Typed Python, can be as succinct as python but fully type safe.

And yes, OCaml does have an escape hatch, a single one, the magic function in the Obj module, it is typed 'a -> 'b and no one should ever use it. Even the compilers uses of it have near vanished (language features added over time like GADT’s and Polymorphic Variants) have made it unnecessary.

And of course OCaml has great interactions with native code, you can just external some_name: int -> float = "linker_name" and link it in at compile-time (static or dynamic), or you can use the FFI for more bit-specific interactions in a type safe way.

1 Like
(doomy) #9

All great resources! Thank you @OvermindDL1 for the reasoning. Ive dabbled in Elm and have been wanting to further my language knowledge.

(Fletcher) #10

@OvermindDL1 what’s the current state of OCaml and parallelization? I’ve struggled to find good info on this aspect of it

#11

I was wondering what language to learn next. Choices were (from most interesting to less):

  • Erlang/Elixir
  • Swift
  • Elm
  • Prolog
  • Scala
  • D language (after reading documentation today it is forever out of the list)

Sold. I’m learning OCaml :slight_smile:

(Khionu Sybiern) #12

Having tried it, I can tell you it’s unusable thanks to tooling. I got a compiler error that made no sense, and on top of that was pointing to the middle of a multi-line comment. The feature list is drool-worthy, which makes it depressing.

(Fletcher) #13

Nim is a decent alternative to D, I think.

#14

I did read a little about Nim but failed to see any strengths compared to Rust.

(OvermindDL1) #15

Think of it this way, the way Python/Crystal/Etc parallelization is is how OCaml’s is in it’s stock compiler. It has great concurrency, but no built-in parallelization due to a GIL.

However there is a multi-core ocaml compiler out (which you can install) that gets rid of the GIL and is experimenting with an Algebraic Effects system (hands down one of the best I’ve seen for a statically typed language out!) that will let you implement any form of concurrency and parallelization that you wish from both cooperative and preemptive multi-threading to Actor style systems to whatever else you can come up with. It will not be merged into OCaml’s core compiler until it is very well defined and set. OCaml seems slow moving at times but only because they exceedingly think through the design of features that are added to it now (it had issues at the start of some odd design choices that are hard to go back on now, specifically some of the standard library calls that they have better alternatives for now but they keep the old calls in for backwards compat).

However, like Python/Crystal/Etc… you can parallelize OCaml via starting multiple processes (this is how it’s web servers work for example, a set of worker processes to handle socket tasks).

Actually if you are going in to it for learning purposes I’d say learn a lisp’y language first, like https://racket-lang.org/ as it will teach you so much more. It even has a HM-style typed variant (typed-racket) built in! A Lispy language is so powerful that it can quite literally take any feature from any language anywhere and integrate it fully and easily. Learning this power is an amazing ‘opening’ of how to do things. I like OCaml because I use it like a faster and safer Python when I don’t need a python-specific library (and ocaml has a lot of libraries to choose from), plus easier C/C++/Rust integration.

Erlang/Elixir are interesting as they are a pure Actor model. Erlang is prolog’y and Elixir is Ruby’ish. One big thing Elixir has over Erlang is an almost lispy style macro support, which is quite nice to create DSEL’s with, though the underlying language hampers its full use.

No point learning swift/elm if you learn OCaml as OCaml will teach you the basics of better than either. Swift has a nicer syntax though, but not quite as powerful and safe.

Prolog is amazing, not something you’ll use but it is a fantastic thing to learn with how it kind of ‘inverts’ everything (this is where erlang/elixir got their Pattern matching idea from!).

Scala is basically a classful, JVM, Haskell, it’s awesome if you want to use the JVM, otherwise meh.

D was designed to be a better C++, and it really is, but it’s ecosystem is… a mess. ^.^;

Also add Forth to your list. Forth is one of the languages I have the most fun with. You can implement it in almost any language very easily (even implemented in assembly it’s only a couple thousand lines) and writing programs in it is like a puzzle, so succinct, readable, and easy to use, but crafting the ‘incantations’ to manage the stack right is a real brain teaser at times but SO nice when you figure it out. Forth is the unheralded champion of trivially embeddable languages used in places you wouldn’t expect (from water readers to NASA satellites) that works at dang near native speed with little work and is trivially implementable. :slight_smile:

Just started looking at Nim recently as well for a Learning purpose and it’s pretty interesting. I’d pick Rust for real work over it easily, but it is absolutely in the realm of speed of Rust and C/C++ with full parallelization and concurrency. Fascinating little language.

(Kae) #16

I only have Coders at Work to recommend. It was rather transformative for me because it offers something quite rare and difficult to find otherwise: a wide perspective on software development from the mouth of successful engineers. It’s like sitting down and having a chat with renowned people of our field. Other books may propose a certain way of working or recommended processes in a structured way, but those books don’t give you the same wider perspective on how some successful people think about the work.

3 Likes
(Max Yankov) #17

Great thread. I wanted to mention Game Programming Patterns — which may be a bit basic for Amethyst users (after all, it goes right into ECS straight from the tutorial), but still is one of the best resources about the topic.

1 Like
(Richard Dodd (Dodj)) #18

This is a great thread.

(Lokathor) #19

I’m going to pick something that isn’t a book: The Handmade Hero series is an amazing (and long!) series that gets right down to brass tacks about implementing a game. No vague programming patterns or abstract suggestions, just code on the screen. You see every line he types, there’s Q and A after each hour of work, and there’s a very well documented archive of all of the videos if you want to search through old episodes.

Days 1 - 25 are about building up a Win32 based platform layer to open a window with sound and graphics, and then after that is actual engine code for tile maps and collisions and so on and so forth.

1 Like
(Timon) #20

https://github.com/majikarp/awesome-programming-books/blob/master/README.md

List with awesome books sorted by category.