Building a hand-rolled simulation environment to demonstrate the classic consensus protocol (Paxos) with the goal of hearing the OCaml compiler "sing" to me; a step towards making my learning visible.
I picked up some OCaml recently. At the start of my challenge (see âSongs of the OCaml Compilerâ), I read through most of âReal World OCaml â Functional programming for the masses; 2nd Edition (Oct 2022)â by Anil Madhavapeddy and Yaron Minsky. OCamlâs type system was fresh for me, Iâve never used anything like it. I see its appeal.
...
My unedited org-noter notes from the classic book âFluent Python â Clear, Concise, and Effective Programmingâ by Luciano Ramalho.
The notes for this are messy, sorry about that. There are some chapters I could not get time to finish so they are left as TODOs for now.
...
Chapter 1: Guided Tour Tooling the book is going to prefer using Base over the standard library that OCaml has. Checks out because one of the authors is a Jane Street senior (Yaron Minsky) and Base is from Jane Street. utop is an improvement from the older ocaml shell Basic Language Syntax operators = can be used for let-binding, can also be used for equality testing, they can be used in the same sentence like so:
...
Chapter 11: First-Class Modules Working with First-Class Modules Creating First-Class Modules (packaging) Inference and Anonymous Modules Unpacking first-class modules Functions for Manipulating First-Class Modules Richer First-Class Modules Exposing Types Example: A Query-handling framework Implementing a query handler Dispatching to Multiple Query Handlers Loading and Unloading Query Handlers Living without First-Class Modules OCaml essentially has 2 parts to the language:
a core language that is concerned with values and types
...
TODO Chapter 16: Concurrent Programming with Async Async Basics Using Let Syntax Ivars and Upon Example: An Echo Server Initial helpers Tail-Calls and Chain of Deferreds Functions that Never Return Improving the Echo Server Example: Searching Definitions with DuckDuckGo Setup URI Handling Parsing JSON Strings Executing an HTTP Client Query Dispatching multiple searches in parallel Exception Handling Monitors Example: Handling exceptions with DuckDuckGo Timeouts, Cancellation, and Choices Working with System Threads Multicore OCaml Thread-Safety and Locking The book introduces us to concurrent programming by talking about the problems of waiting on blocked processes on some sort of IO.
...
Chapter 6: Variants Basics: Variants, Tuples and Parens Catch-All Cases & Refactoring Combining Records and Variants Embedded Records Variants & Recursive Data Structures Polymorphic Variants Polymorphic variants and Catch-all Cases Use case of using polymorphic variants: Terminal Colors Redux Packaging the code up When to Use Polymorphic Variants Variants are sum types of multiple forms of data, all of them are tagged explicitly. The value this gives is that we can represent complex data and organise the case-analysis of that information.
...