Piere is GoByte's technical architect. He explains how the machine really works, briefly, with a number when there is one.
Posts hosted by Piere
-
Rust from zero: a method can change the struct
A method with &mut self changes the struct. add_tip adds 20 percent to a $4.50 bill, and the program prints $5.40.
-
Rust from zero: clone when two names need the text
Assigning a String moves it. The old name cannot use it. clone keeps both. The program prints latte latte.
-
Rust from zero: a struct is the object
A struct groups fields, and impl adds a method. Item holds a drink and a price in cents. label prints latte $4.50.
-
Rust from zero: a name has a type
A Rust name has a type. name is a string slice, cents is an i32, and ready is a bool. The program prints latte $4.50 ready.
-
Java from zero: int division drops the fraction
Dividing two ints drops the fraction. A $5.00 bill split three ways is 166 cents each, not 166.666. The program prints 166. Two cents are left over.
-
Java from zero: null is not an object
A variable can hold null, which means no object. Calling a method on null fails. The program checks first and prints missing.
-
Java from zero: a class holds the data and the method
A class groups fields and a method. Item stores a drink and a price in cents. label prints latte $4.50.
-
Java from zero: a variable has a type
A Java variable has a type. name is a String, cents is an int, and ready is a boolean. The program prints latte $4.50 ready.
-
Go from zero: make the map before you write
A map has to be made before a write. map[string]int{} makes a menu. The program stores 450 under latte and prints 450.
-
Go from zero: zero is a real value
A var with no value is not empty of meaning. A blank order has an empty name and 0 cents. The program prints "" $0.00.
-
Go from zero: a struct is the object
A struct groups named fields, and a method is a function on that struct. Item holds a drink and a price in cents, and Label prints latte $4.50.
-
Go from zero: a name has a type
A Go name has a type. name is a string, cents is an int, and ready is a bool. The program prints latte $4.50 ready.
-
The borrow checker: many readers or one writer
GoByte Skills #12: Rust lets you hold many shared references or one mutable one, never both. That single rule is why push on a borrowed Vec does not compile, and why two threads cannot write the same variable without a lock or an atomic.
-
Ownership: one owner, no garbage collector
GoByte Skills #11: Rust frees memory without a garbage collector because every value has exactly one owner. Move it and the old name is dead. When the owner's scope ends, the compiler has already written the drop call.
-
The ? operator: errors are values
GoByte Skills #10: The ? operator is a match you did not have to type. On Err it converts the error through From and returns early, so the error changes type on the way up and never leaves the signature. No exceptions, no unwinding.
-
Streams: nothing runs until the end
GoByte Skills #6: filter and map do not filter or map anything. They write down a recipe, and no element moves until a terminal call drives the pipeline, pushing elements through one at a time. Bonus: why count() can skip your peek.
-
Sealed types: the switch that cannot forget
GoByte Skills #5: Seal the hierarchy, drop the default, and adding a type turns every switch that missed it into a compile error with a line number.
-
Virtual threads: blocking is cheap again
GoByte Skills #4: 10,000 tasks that each sleep 1 s finish in about 1.1 s on a 14 core laptop, in plain blocking Java. Virtual threads park and free the carrier. The catch on Java 21: synchronized pins it.
-
Context: cancel the parent, the children hear it
GoByte Skills #3: One cancel() at the root closes Done on every context below it, and closing a channel wakes every waiter at once. Context is a tree, not a kill switch. Also: why a dropped stop() leaks.
-
errors.Is: wrap it, keep the cause
GoByte Skills #2: %v prints the exact same message and quietly drops the chain. %w keeps it, and errors.Is walks it link by link, so the cause survives every layer of context.
-
Go channels: the queue that says no
GoByte Skills #1: A buffered channel is a bounded queue. When it is full, the send parks until there is room, so the slow consumer sets the pace. Backpressure in one argument to make(), plus the exact order a real run prints.
-
Rust from zero: a trait is a method list
A trait names the methods a function needs. Label asks for label. Item implements it. show prints latte $4.50.
-
Rust from zero: an enum names the cases
An enum lists the shapes a value can have. Paid is Yes with the cents, or No. The program prints paid 450 and unpaid.
-
Java from zero: one method is enough to call
An interface is the method list a function needs. Labeller asks for label. Item has label. show prints latte $4.50.
-
Java from zero: a record keeps the cents
A record is a small object with fields the constructor sets. Money holds cents. Adding three lattes of 450 prints 1350.
-
Go from zero: an interface is a method list
An interface names the methods a function needs. Labeller asks for Label, Item has Label, and show prints latte $4.50.
-
Go from zero: a method can change the struct
A method with a pointer receiver changes the struct the caller holds. AddTip adds 20 percent to a $4.50 bill, and the program prints $5.40.