Learn to Program
If you wish so, this collection of topics intends to take you from a state where you have no idea that software could even be written by humans to a state where you stand out as an autonomous developer with decent programming skills.
Topic 1: Demystify
- Setup your machine.
- Your first program:
- R/Python/Julia: what is an interpreter.
- Rust: what is a compiler.
- Variables: the machine's memory.
- Operators/Functions: the machine computes.
- Outputs: the machine serves you.
- Inputs: feed the machine data.
- Branches (if/else): you make decisions.
- Discuss simple exercises.
- Share resources to get further on your own.
Topic 2: Native Types
- From ones and zeros to integers: decimal vs. binary encoding.
- Signed integers.
- Text characters.
- Floating-point numbers and IEEE754.
- R/Python:
- Compound types: vectors, strings, lists, dicts, matrices, dataframes.
- Julia/Rust:
- References and pointers.
- Compound types: arrays, vectors, maps, dicts.
- Loops: the machine does not get tired.
- Introduction to algorithmic complexity.
Topic 3: Code Semantics
- Functions: your code is meaningful and reusable.
- Aliases and Copies: there is more to computer memory than meets the eye.
What does
a = b
really means? What doesf(a)
really means?- R: copies by default.
- Python/Julia: aliases by default.
- Rust: the move semantics, shared references and mutability.
- Discuss simple exercises, possibly from exercism.
Topic 4: Get organized
- Split your work into multiple files.
- R: the package structure.
- Python: packages and modules.
- Julia: environment, packages and modules.
- Rust: cargo, crates and modules.
- Test your project.
- R: testthat.
- Python/Julia: native doctests.
- Rust: native test modules and functions.
- Document your project.
Topic 5: Creating your own types
By creating your custom types, you make your program more meaningful to humans: easier to understand, easier to modify without introducing bugs.
- Python:
- Classes and methods.
- Object-oriented programming.
- Inheritance and associated pitfalls/good practices.
- Julia:
- Structs.
- Multiple dispatch.
- Type parameters and generic programming.
- Rust:
- Struct and enums: sum types and union types.
- Methods and traits: composition.
- Type parameters, trait bounds, and generic programming.
Creating custom types in R is overly complicated. R is a niche software to do statistics. If you need custom types in your program, then you have left the original scope of R and you probably need another language.
Topic 6: Metaprogramming
Machines can write code. Programs can write programs. This is very powerful, although you should mostly use this to alleviate boilerplate and ease readability.
- Python:
- Decorators.
- Metaclasses.
- The
eval
function and associated pitfalls.
- Julia/Rust:
- Compile time vs. runtime.
- The Abstract Syntaxic Tree (AST).
- Macros and expansion.
- Quoting and interpolation.
- Hygiene and escaping/bending hygiene.
— Wait.. 6 topics and that's it: I am an "autonomous programmer with decent programming skills" already? õ.Ô
— Of course not: you need to practice a lot first, right? You had a science project when you first came: embrace it now, write code and code and code again to make it work. Have your code reviewed by peers. Learn cool things this way. Then eventually, yes, you'll become that for sure ;)