Fast as C, slick as Ruby

Exploring & Learning Crystal Language with code examples and augment the documentation.

1. Installation

On MacOS - use:

$ brew install crystal

For all other systems see: https://crystal-lang.org/install/

2. Crystal CLI

  • Useful commands when using crystal

  • My most useful command while developing is:

crystal run src/file_name.cr

3. Blocks

4. Macros (Sort-of Meta-Code)

5. Data Structures

5.1. Structs

  • Structs (& Records) are immutable data structures - these are safe when used in a concurrent/parallel context.

5.2. Records

  • Structs (& Records) are immutable data structures - these are safe when used in a concurrent/parallel context.

5.3. JSON Data

6. Code Patterns

6.1. Decorator

6.2. Value Object

6.3. East Oriented (Fluent Interface)

6.4. HTTP (Server and Client)

Non-stateful - short-term connections over TCP.

6.5. HTTP (Server and Client)

Encrypted HTTP Interactions

6.6. WebSockets (Server and Client)

Long-lived client-server connections over TCP.

6.6.1. WebSockets

6.6.2. WebSockets with SSL

6.6.3. WebSockets with Named Channels

7. Concurrency & Parallelism

An intro into the basics of how things like websockets work

TODO

Augment and adapt content using inspiration from: https://blog.golang.org/pipelines

7.1. Concurrency Basics

  • Basics on starting processes concurrently

7.2. Concurrent Objects

  • Examples of using concurrency with objects

7.3. Channels (Async Messaging)

  • Channels allow us to safely communicate between concurrent processes.

  • To safely share data/state send immutable data only (Structs are a good option).

7.4. Channel Buffers

  • What to do when messages come faster than collected

7.5. Channel Callbacks

  • Safely share state information when its available

7.8. Parallelism

  • Compiling to use multiple CPUs (add -Dpreview_mt) to the compile command

7.9. Actor Model

  • Using macros to build async message sending, callbacks and state sharing.

8. Making Shards

9. Mini-Projects

9.1. Game of Life

9.2. Chat Room

10. Resources

Note
Crystal Lang Gitter is a great group of people willing to help. (special mention to: @stnluu_twitter, @watzon, @repomaa, @randiaz95, @straight-shoota & @paulcsmith)

11. Generating these Docs

$ asciidoctor -D docs/crystal code/crystal/adoc/*