Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ TOOL_SOURCES := tool/pubspec.lock $(shell find tool -name '*.dart')
BUILD_SNAPSHOT := $(BUILD_DIR)/build.dart.snapshot
TEST_SNAPSHOT := $(BUILD_DIR)/test.dart.snapshot

DART_FLAGS := --old_gen_heap_size=1024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On an early version of dart3, it will build fine without this. Prior to pushing this, I updated to a more recent dart 3, and the build started hanging with an OOM error. Adding this flag allowed it to once again build successfully. You could try with DART_FLAGS := "" and see if you can replicate it, or if it is needed. I don't use dart a whole lot, so I'm not sure if this was maybe something transient introduce in one version and then fixed, or if it will carry forward to future versions.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it thanks, can we add 1-line code comment so this is easier for people in future to know why it was set?


default: book clox jlox

# Run dart pub get on tool directory.
get:
@ cd ./tool; dart pub get
@ cd ./tool; dart $(DART_FLAGS) pub get

# Remove all build outputs and intermediate files.
clean:
Expand All @@ -16,46 +18,46 @@ clean:

# Build the site.
book: $(BUILD_SNAPSHOT)
@ dart $(BUILD_SNAPSHOT)
@ dart $(DART_FLAGS) $(BUILD_SNAPSHOT)

# Run a local development server for the site that rebuilds automatically.
serve: $(BUILD_SNAPSHOT)
@ dart $(BUILD_SNAPSHOT) --serve
@ dart $(DART_FLAGS) $(BUILD_SNAPSHOT) --serve

$(BUILD_SNAPSHOT): $(TOOL_SOURCES)
@ mkdir -p build
@ echo "Compiling Dart snapshot..."
@ dart --snapshot=$@ --snapshot-kind=app-jit tool/bin/build.dart >/dev/null
@ dart $(DART_FLAGS) --snapshot=$@ --snapshot-kind=app-jit tool/bin/build.dart >/dev/null

# Run the tests for the final versions of clox and jlox.
test: debug jlox $(TEST_SNAPSHOT)
@- dart $(TEST_SNAPSHOT) clox
@ dart $(TEST_SNAPSHOT) jlox
@- dart $(DART_FLAGS) $(TEST_SNAPSHOT) clox
@ dart $(DART_FLAGS) $(TEST_SNAPSHOT) jlox

# Run the tests for the final version of clox.
test_clox: debug $(TEST_SNAPSHOT)
@ dart $(TEST_SNAPSHOT) clox
@ dart $(DART_FLAGS) $(TEST_SNAPSHOT) clox

# Run the tests for the final version of jlox.
test_jlox: jlox $(TEST_SNAPSHOT)
@ dart $(TEST_SNAPSHOT) jlox
@ dart $(DART_FLAGS) $(TEST_SNAPSHOT) jlox

# Run the tests for every chapter's version of clox.
test_c: debug c_chapters $(TEST_SNAPSHOT)
@ dart $(TEST_SNAPSHOT) c
@ dart $(DART_FLAGS) $(TEST_SNAPSHOT) c

# Run the tests for every chapter's version of jlox.
test_java: jlox java_chapters $(TEST_SNAPSHOT)
@ dart $(TEST_SNAPSHOT) java
@ dart $(DART_FLAGS) $(TEST_SNAPSHOT) java

# Run the tests for every chapter's version of clox and jlox.
test_all: debug jlox c_chapters java_chapters compile_snippets $(TEST_SNAPSHOT)
@ dart $(TEST_SNAPSHOT) all
@ dart $(DART_FLAGS) $(TEST_SNAPSHOT) all

$(TEST_SNAPSHOT): $(TOOL_SOURCES)
@ mkdir -p build
@ echo "Compiling Dart snapshot..."
@ dart --snapshot=$@ --snapshot-kind=app-jit tool/bin/test.dart clox >/dev/null
@ dart $(DART_FLAGS) --snapshot=$@ --snapshot-kind=app-jit tool/bin/test.dart clox >/dev/null

# Compile a debug build of clox.
debug:
Expand Down Expand Up @@ -193,14 +195,14 @@ diffs: split_chapters java_chapters
@ -diff --new-file gen/chap29_superclasses/ gen/chap30_optimization/ > build/diffs/chap30_optimization.diff

split_chapters:
@ dart tool/bin/split_chapters.dart
@ dart $(DART_FLAGS) tool/bin/split_chapters.dart

compile_snippets:
@ dart tool/bin/compile_snippets.dart
@ dart $(DART_FLAGS) tool/bin/compile_snippets.dart

# Generate the XML for importing into InDesign.
xml: $(TOOL_SOURCES)
@ dart --enable-asserts tool/bin/build_xml.dart
@ dart $(DART_FLAGS) --enable-asserts tool/bin/build_xml.dart

.PHONY: book c_chapters clean clox compile_snippets debug default diffs \
get java_chapters jlox serve split_chapters test test_all test_c test_java
2 changes: 1 addition & 1 deletion asset/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ a.action {
small {
font-size: 14px;
padding: 4px;
color: hsla(0, 0, 100%, 0.7);
color: hsla(0, 0%, 100%, 0.7);
transition: color 0.2s ease;
}
}
Expand Down
6 changes: 4 additions & 2 deletions asset/sass/chapter.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "sass:math";

article.chapter {
h2 {
font: 600 30px/24px $serif;
Expand Down Expand Up @@ -192,8 +194,8 @@ article.chapter {
@media only screen and (max-width: 630px) {
article.chapter {
h2 a::before, h3 a::before {
left: -($col / 2);
width: $col / 2;
left: -(math.div($col, 2));
width: math.div($col, 2);
Comment on lines +197 to +198

@rossdancraig rossdancraig May 25, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if possible, would prefer this PR to have been split into multiple parts instead of all boilerplate in 1 (thought not sure if that's possible). Ex:

  1. migration to @use "sass:math";
  2. CSS hexcodes --> hsl
  3. Non functional formatting changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I kind of felt the same way about this one. It was mixed. I can work on splitting this up into the dart pacakges as one update, and the dart 3 in another. I can't remember if I started getting errors on one of the packages and that is why I went ahead and updated them, or if this just started to feel like a modernization story to me and I updated the packages. These were just warnings that they would break in the future at any rate. I try not to have warnings emitted with a build. But this isn't really related to the nullability safety at all.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for context. I feel you, thanks for fixing them. Since I've already begun reviewing I'm cool with continuing, just a heads up for future reference!

}
}
}
Expand Down
10 changes: 6 additions & 4 deletions asset/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "sass:math";

@import 'sass/shared';
@import 'sass/chapter';
@import 'sass/contents';
Expand Down Expand Up @@ -210,7 +212,7 @@ nav.floating {
}

img {
padding: 110px $col/2 23px $col/2;
padding: 110px math.div($col, 2) 23px math.div($col, 2);
}
}

Expand Down Expand Up @@ -332,7 +334,7 @@ pre {

// If the chapter ends with code, don't overlap the challenges box.
div.codehilite + div.challenges {
margin-top: $col / 2;
margin-top: math.div($col, 2);
}

article {
Expand Down Expand Up @@ -751,13 +753,13 @@ footer {
// The cut-off sizes here are based on trying to get 72 columns of code to fit.
@media only screen and (max-width: 630px) {
.page {
margin: 0 $col / 2;
margin: 0 math.div($col, 2);
width: inherit;
}

nav.narrow {
.prev, .next {
padding: 0 $col / 2;
padding: 0 math.div($col, 2);
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions shell.nix

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not required to unblock the main issue (Dart 3 dep), this should be in it's own separate PR. Being able to run this requires installing nix package manager. While this can be helpful, it also adds more steps for getting started, so tradeoffs for that can be discussed separately

@DewJunkie DewJunkie Jun 1, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I based this PR onto my other PR which pinned the dart version at dart 2. Being able to have a locked down version of DART was kind of key to being able to validate this migration, because I could then compare the output of the dart2 to the output of dart3, and make sure I didn't accidentally introduce a regression. I know a lot of folks don't use nix, but this is why it was there. I had made the prior PR, because it would only build under dart2, and I had to spend a bit of time figuring out how to get an old version up and going. nix package manager is supported on many distros. Using a dockerfile could get a similar experience, and maybe be useful to more people. But I use nix.
#1199 // Dart 2 shell.nix PR

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for context, sure I'm ok with adding it since it's additive

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Using the NixOS 25.11 stable release for a consistent Dart 3 environment.
{ pkgs ? import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/nixos-25.11.tar.gz";
sha256 = "1hp1ddh41wrqxgrnfa79nsv7gzlbpwcqsijx7jw5b33wvk5ah5gb";
}) {} }:

pkgs.mkShell {
buildInputs = [
pkgs.dart
pkgs.zulu
pkgs.gcc
pkgs.gnumake
pkgs.git
pkgs.glibcLocales
];

shellHook = ''
export LANG=en_US.UTF-8
'';
}
50 changes: 19 additions & 31 deletions site/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ body {
.sign-up {
padding: 12px;
margin: 24px 0 24px 0;
background: #fcf6e8;
color: #bf9540;
background: hsl(40, 80%, 95%);
color: hsl(40, 50%, 50%);
border-radius: 3px;
}
.sign-up form {
Expand All @@ -68,8 +68,8 @@ body {
font: 16px "Source Sans Pro", sans-serif;
outline: none;
border-radius: 3px;
border: solid 2px #ffd580;
color: #825e17;
border: solid 2px hsl(40, 100%, 75%);
color: hsl(40, 70%, 30%);
height: 32px;
}
.sign-up input.email {
Expand All @@ -83,36 +83,36 @@ body {
font: 600 13px "Source Sans Pro", sans-serif;
text-transform: uppercase;
letter-spacing: 1px;
background: #ffbb33;
background: hsl(40, 100%, 60%);
border: none;
transition: background-color 0.2s ease;
}
.sign-up input.button:hover {
background: #ffd580;
background: hsl(40, 100%, 75%);
}
.sign-up input:focus {
border-color: #ffaa00;
border-color: hsl(40, 100%, 50%);
}

body, h1, h2, h3, h4, p, blockquote, code, ul, ol, dl, dd, img {
margin: 0;
}

body {
background: #29313d url("image/background.png") top center/100% auto no-repeat;
background: hsl(215, 20%, 20%) url("image/background.png") top center/100% auto no-repeat;
color: #222;
font: normal 16px/24px "Crimson", Georgia, serif;
}

a {
color: #1481b8;
color: hsl(200, 80%, 40%);
text-decoration: none;
border-bottom: solid 1px rgba(222, 233, 237, 0);
transition: color 0.2s ease, border-color 0.4s ease;
}

a:hover {
color: #1481b8;
color: hsl(200, 80%, 40%);
border-bottom: solid 1px #dee9ed;
}

Expand All @@ -125,8 +125,8 @@ article {

header {
margin: 0 0 48px 0;
color: #595959;
background: #f5f3f0;
color: hsl(40, 0%, 35%);
background: hsl(40, 20%, 95%);
border-bottom: solid 1px #dad8d6;
}

Expand Down Expand Up @@ -165,7 +165,7 @@ p + p {
padding: 12px 12px 8px 12px;
height: 244px;
box-sizing: border-box;
background: #eef4f7;
background: hsl(195, 35%, 95%);
background-size: cover;
background-position: left;
color: #444;
Expand Down Expand Up @@ -223,20 +223,20 @@ a.action {
padding: 4px 0;
text-align: center;
border-radius: 3px;
background: #1481b8;
background: hsl(200, 80%, 40%);
transition: background-color 0.2s ease, color 0.2s ease;
font: 400 17px/24px "Source Sans Pro", sans-serif;
color: white;
}
a.action small {
font-size: 14px;
padding: 4px;
color: rgba(255, 255, 255, 0.7);
color: hsla(0, 0%, 100%, 0.7);
transition: color 0.2s ease;
}

a.action:hover {
background-color: #2badee;
background-color: hsl(200, 85%, 55%);
}
a.action:hover small {
color: white;
Expand All @@ -252,7 +252,7 @@ img.author {
width: 240px;
margin: 0 12px 0 -12px;
padding: 12px;
background: #f5f3f0;
background: hsl(40, 20%, 95%);
border-radius: 3px;
}

Expand All @@ -263,8 +263,8 @@ div.author {

footer {
position: relative;
border-top: solid 1px #dee9ed;
color: #7aa0b8;
border-top: solid 1px hsl(195, 30%, 90%);
color: hsl(203, 30%, 60%);
font: 400 15px "Source Sans Pro", sans-serif;
text-align: center;
margin: 12px 0 36px 0;
Expand All @@ -278,19 +278,15 @@ footer a, footer a:hover {
main {
margin: 0 24px;
}

header {
margin-bottom: 24px;
}

img.big {
display: none;
}

img.small {
display: block;
}

div.intro {
display: block;
}
Expand All @@ -302,38 +298,30 @@ footer a, footer a:hover {
display: block;
margin: 24px 0 24px 0;
}

.format {
margin-bottom: 12px;
height: auto;
background-blend-mode: lighten;
}

.format-info {
display: block;
width: 100%;
}

.format.print {
background-color: #a6a29f;
}

.format.ebook {
background-color: #97a2aa;
}

.format.pdf {
background-color: #cfccca;
}

.format.web {
background-color: #d6dbd3;
}

img.author {
float: none;
}

div.author {
margin: 0 0 0 0;
}
Expand Down
Loading