GoByte Blog
Engineering lessons and marketing playbooks from the team behind GoByte.
Latest, page 2
RSS-
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.
-
Python from zero: a method uses self
A method changes the object through self. A bill starts at 0 cents, add puts a latte on it, and the program prints 450.
-
Python from zero: two names can share one list
Assigning a list to a second name does not copy it. list() does. The program adds a muffin to the ticket and prints ['latte'] ['latte', 'muffin'].
-
Python from zero: a class is the object
A class groups fields and a method. Item stores a drink and a price in cents. label prints latte $4.50.
-
Python from zero: a value has a type
Every Python value has a type. name is a str, cents is an int, and ready is a bool. The program prints latte $4.50 ready, then str int bool.
-
Motion from zero: easing is a function of time
Easing maps a time from 0 to 1 onto a progress from 0 to 1. easeOut is slow at the end. The program prints 0, 0.75, and 1.
-
Motion from zero: move the transform, not the width
Changing width makes the browser lay the page out again. Changing a transform does not. The price label moves with translateX(24px). Its width stays.
-
Motion from zero: an animation is an object
One object holds the slide of a price label: the duration, the distance, and the opacity. The program builds one and prints 320, 24, and 1.
-
Motion from zero: time and distance are numbers
A duration is a number of milliseconds. A distance is a number of pixels. 320 and 24 slide a price label. The program prints 320 and 24.