typestar

Language basics

27 steps in 9 sets of Julia.

Julia is the language built on a refusal: that scientists should not have to prototype in one language and rewrite in another for speed. Born at MIT in 2012, it JIT-compiles dynamic, math-first code to machine speed, and its signature idea — multiple dispatch, where every argument's type picks the method — turns out to be how scientific libraries compose so well. It runs climate models, drug trials, and half of quantitative astronomy.

This tour types the core: bindings and interpolation, ranges and comprehensions, one-line function definitions and multiple dispatch, do blocks, varargs and keyword arguments, 1-indexed vectors with bang-marked mutation, Dicts and named tuples, the broadcasting dot that vectorizes anything, built-in matrices, immutable and parametric structs with abstract-type dispatch, pipes, error handling, and the everyday macros from @show to @printf. The Encore is the cross-language script trio in numeric-flavored Julia — argmin, diff, and Printf columns.

Start this tour

Values

  • The script shapeThe smallest Julia: bindings and println, no ceremony at all.
  • Variables and typesBindings need no keyword; the value carries the type.
  • StringsInterpolation with $, concatenation with *, repetition with ^.

Control flow

Functions

Collections

Broadcasting

Types

  • StructsImmutable by default; mutable is a separate promise.
  • Abstract typesName the family, dispatch on it, override per concrete type.
  • Parametric typesThe T in braces is chosen per use and bounded by <:.

Idioms

  • Pipes|> feeds left to right; dotted pipes broadcast the chain.
  • Varargs and keywords... collects arguments; keywords live after the semicolon.
  • Errorstryparse for expected failure, throw/try/catch for the rest.

Macros & formatting

  • Macros@show, @assert and @time — the everyday three.
  • PrintfC-style formatting from the standard library.
  • Sortingby= picks the key, rev= the direction, sortperm the indices.

Encore

  • word_freq.jlA word-frequency table from split, a Dict tally, and one sort key.
  • grade_report.jlReport cards from a struct roster, guard-clause grading, and vcat.
  • temp_stats.jlA week of temperatures: argmin/argmax, a bar chart, and diff.

The other Julia tours