A Language a Day
A Language a Day
A brief introduction to 21 programming languages: C++, Clojure, Crystal, D, Dart, Elixir, Factor, Go, Hack, Hy, Io, Julia, Kotlin, Lua, Mercury, Nim, OCaml, Raku, Rust, Scala, and TypeScript
About the Book
This book provides a concise overview of 21 different programming languages. Each language is introduced using the same approach: solving several programming problems to showcase its features and capabilities. Languages covered in the book: C++, Clojure, Crystal, D, Dart, Elixir, Factor, Go, Hack, Hy, Io, Julia, Kotlin, Lua, Mercury, Nim, OCaml, Raku, Rust, Scala, and TypeScript.
Each chapter covers the essentials of a different programming language. To make the content more consistent and comparable, I use the same structure for each language, focusing on the following mini projects:
1. Creating a ‘Hello, World!’ program.
2. Implementing a Factorial function using recursion or a functional-style approach.
3. Creating a polymorphic array of objects (a ‘zoo’ of cats and dogs) and calling methods on them.
4. Implementing the Sleep Sort algorithm—while impractical for real-word use, it’s a playful demonstration of language’s concurrency capabilities.
Each language description follows—where applicable—this pattern:
1. Installing a command-line compiler and running a program.
2. Creating and using variables.
3. Defining and using functions.
4. Exploring object-oriented features.
5. Handling exception.
6. Introducing basic concurrency and parallelism.
You can find all the code examples in this book on GitHub: github.com/ash/a-language-a-day.
Table of Contents
C++
- Facts about the language
- Installing and running C++
- Hello, World!
- Variables
- Functions
- Lambdas
- Containers
- Classes
- A Polymorphic example
- Concurrency and threads
- Sleep Sort
- Thread-safety
- Get more!
Clojure
- Facts about the language
- Installing and running Clojure
- Hello, World!
- Variables
- Lists and vectors
- Functions
- Lambdas
- Factorial, solution 1
- Factorial, solution 2
- Multimethods
- A polymorphic example
- Concurrent computing
- Sleep Sort
- Get more!
Crystal
- Facts about the language
- Installing and running Crystal
- Hello, World!
- Variables
- Functions
- A Factorial example
- Proc
- Classes
- Getters and setters
- Class variables
- Inheritance
- A Polymorphic example
- Concurrent computation
- Sleep Sort
- Get more!
D
- Facts about the language
- Installing and running D
- Hello, World!
- Variables
- Functions
- A Factorial example
- A word on functional programming
- Unicode support
- Classes
- A Polymorphic example
- Concurrency
- Messages
- Sleep Sort
- Get more!
Dart
- Facts about the language
- Installing and running Dart
- Compiling
- Hello, World!
- Variables
- Functions
- A Factorial example
- Optional parameters
- Named parameters
- Lambdas
- Classes
- Cascade notation
- Factory constructors
- A Polymorphic example
- Asynchronous programming
- The Sleep Sort example
- Get more!
Elixir
- Facts about the language
- Installing and running Elixir
- Hello, World!
- Variables
- Lists
- Functions
- Named functions
- Multiple bodies
- A Factorial example
- A Polymorphic example
- Concurrency
- Sleep Sort
- Get more!
Factor
- Facts about the language
- Installing and running Factor
- Hello, World!
- Output
- Stack
- Variables
- Defining words
- A Factorial example
- Object-oriented programming
- Inheritance
- Sleep Sort
- Get more!
Go
- Facts about the language
- Installing and running Go
- Hello, World!
- The standard formatter
- Variables
- Constants
- Functions
- Function return options
- A Factorial example
- Closures
- Structs and methods
- A Polymorphic example
- Concurrency
- Sleep Sort
- Get more!
Hack
- Facts about the language
- Installing and running Hack
- Static checker
- Hello, World!
- Variables
- Functions
- A Factorial example
- Lambdas
- Classes
- Static members
- Inheritance
- A Polymorphic example
- Asynchronous programming
- The Sleep Sort example
- Get More!
Hy
- Facts about the language
- Installing and running Hy
- Hello, World!
- Looking at the Python code
- Variables
- Functions
- Calling a method
- A Factorial example
- Classes
- A Polymorphic example
- Using modules
- Sleep Sort
- Get more!
Io
- Facts about the language
- Installing and running Io
- Hello, World!
- Variables
- Functions
- A Factorial example
- Objects
- Inheritance
- A Polymorphic example
- Concurrency
- Sleep Sort
- Get more!
Julia
- Facts about the language
- Installing and running Julia
- Hello, World!
- Variables
- Identifiers
- String interpolation
- A note about numbers
- Functions
- Type annotation
- Lambdas
- Multiple dispatch
- A Factorial example
- Functions modifying their arguments
- Composite types
- A Polymorphic example
- Concurrency and parallelism
- Channels
- Sleep Sort
- Get more!
Kotlin
- Facts about the language
- Installing and running Kotlin
- Hello, World!
- Variables
- Functions
- A Factorial example
- Lambdas
- Classes
- Objects
- Getters and setters
- Inheritance
- An example of inheritance and polymorphism
- Coroutines
- Sleep Sort using coroutines
- Get more!
Lua
- Facts about the language
- Installing and running Lua
- Hello, World!
- Comments in Lua
- Variables
- Tables
- Functions
- A Factorial example
- Multiple results and variadic parameters
- Lambdas
- Object-oriented facilities
- Metatables
- Classes
- A Polymorphic example
- Coroutines
- Sleep Sort
- Get more!
Mercury
- Facts about the language
- Installing and running Mercury
- Hello, World!
- What all those :- and . are about
- Variables
- Functions and predicates
- A Factorial example 1
- A Factorial example 2
- What unification is
- Creating and using your own types
- A Polymorphic example
- Get more!
Nim
- Facts about the language
- Installing and running Nim
- Hello, World!
- Variables
- Identifier names
- Indentation
- Procedures
- Overloading
- Factorial
- Mutable function arguments
- Object-oriented programming
- A Polymorphic example
- Concurrency
- Sleep Sort
- Get more!
OCaml
- Facts about the language
- Installing and running OCaml
- Hello, World!
- Variables
- ;; vs ; vs in
- Functions
- A Factorial example
- Anonymous functions
- Lists
- Object-oriented programming
- Objects
- Classes
- A Polymorphic example
- Concurrency
- Sleep Sort
- Get more!
Raku
- Facts about the language
- Installing and running Raku
- Hello, World!
- Variables
- Aggregate types
- Functions
- Default and optional parameters
- Type constraints
- A Factorial example
- Lambdas
- Classes
- Class-level data members
- Hierarchy
- A Polymorphic example
- Concurrent computing
- Sleep Sort
- Grammars
- Get more!
Rust
- Facts about the language
- Installing and Running Rust
- Hello, World!
- Variables
- Types
- Functions
- A Factorial example
- Macros
- Object-oriented features
- A polymorphic example
- Error handling
- Concurrency
- Sleep Sort
- Get more!
Scala
- Facts about the language
- Installing and running Scala
- Hello, World!
- Variables
- Functions
- A Factorial example
- Classes
- Class methods
- Singleton objects
- A polymorphic example
- Concurrency
- Sleep Sort
- Get more!
TypeScript
- Facts about the language
- Installing and running TypeScript
- Hello, World!
- Variables
- Functions
- Optional and defaults parameters
- A Factorial example
- Lambdas
- Classes
- Inheritance and polymorphism
- Interfaces
- Error handling
- Asynchronous computing
- Sleep Sort
- Get more!
Other books by this author
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them