James
types4life.bsky.social
James
@types4life.bsky.social
he/him. Lover of type theory and functional programming. Also, comedy and politics. Not super optimistic.
Reposted by James
Chapter 2 of my Scala Developer's notes on the Rust Book:

https://rossabaker.com/blog/rust-book-programming-a-guessing-game/

#rust #scala
Rust Book, Chapter 2: Programming a Guessing Game
Chapter Two introduces a wide range of Rust constructs to build something a little more substantial than Hello, World. In this post, we’ll try to map Rust’s approach to mutability, error handling, and side effects to `val=/=var`, `Either`, and `IO`. None of these mappings is perfect, because the two languages diverge in more than syntax, but much remains familiar. ## New projects # `cargo new` is much like `sbt new`, but lacks the templating power of giter8. It isn’t as necessary in Rust, because we’re not trying to embed our domain name in a package statement or directory structure, but expect to add your own project metadata, like `authors` and `license`. ## `let` and `let mut` # Scala has two orthogonal notions of mutability: * Reference: A `var` can be reassigned to a different reference, whereas a `val` can’t. * Data: An `Array` is mutable, and a `List` is immutable. | Immutable reference | Mutable reference ---|---|--- Immutable data | `val x = List(1, 2)` | `var y = List(1, 2)` Mutable data | `val z = Array(1, 2)` | `var w = Array(1, 2)` In Typelevel Scala, we aspire to the top left quadrant, avoid the bottom right. Sometimes we put one degree of mutability in `IO`, but carefully wash our hands before returning to work. In Rust, both kinds of mutability are determined by the `mut` keyword. | Immutable reference | Mutable reference ---|---|--- Immutable data | `let x = vec![1, 2]` | Mutable data | | `let mut w = vec![1, 2]` Instead of separate mutable and immutable collections, the individual operations may take either an immutable or mutable reference to the collection. This lets us mutate the vector referenced by `w` (e.g., `w[0] = 3`) or reassign `w` to a new `Vec` (e.g., `w = vec![3, 4]`). Both of these are disallowed on `x`. ## Associated functions # Rust’s associated functions, like `String::new()`, serve a similar purpose to Scala’s companion objects. ## `Result` # A Rust `Result` is either `Ok` or `Err`. Either? Yeah, like Scala’s `Either`! Scala calls them `Left` and `Right`, and it’s only by convention (and the convenience of `map` and friends) that the okay type goes on the right and the error type goes on the left. Rust gives us better names, which is a good thing, because it flips the order of the parameters from what Scala developers are used to. Early versions of Cats had `Xor`. Not only was my shitpost that we should call them `Sinister` and `Dexter` denied, but the type was removed altogether. Rust’s judgmental names sound more like Scala’s `Success` and `Failure` from `Try`. But only a `Throwable` can go in `Failure`, whereas Rust allows anything in `Err`, just like `Left`. ## Footguns # Like Scala, Rust promises us safety and mostly delivers, but gives us a few functions to point at our feet and shoot off our toes. Rust’s `result.expect(s)` is similar to Scala’s `option.get`, but worse: Scala throws an exception that might be recovered, whereas Rust panics before a dramatic, error-coded exit. Like Scala, linters can help. Like Scala, such methods are often less verbose if you think you’re smarter than the type system. Like Scala, you’re usually not. ## Lockfiles # We won’t go deep into crates vs. jars now, except to emphasize that a `Cargo.toml` file can resolve to different versions of dependencies over time. If you don’t check in your `Cargo.lock` today, you may be saying “worked on my machine” to a frustrated colleague in the future. ## We aren’t in FP anymore, Alice # This chapter is printing to the console, reading from the console, generating random numbers, and nary an `IO` in sight. This is not different from standard Scala, but is jarring coming from Typelevel Scala. We find a lot in Rust that’s familiar: its enums are like Scala’s sealed traits. We already discussed `Result` and `Either`. Its pattern matching brings a new syntax but most of the same benefits and safety. But to be successful in this journey, we need to accept that mutability is more acceptable, and that we’ll rely on different safety nets like the borrow checker to keep us safe. You’ll miss some things and appreciate other things and that’s okay because they’re different languages, even if a lot of us enjoy both. ## Shadowing # In Scala, it’s frowned on to shadow an existing variable in a tighter scope, and forbidden in the same scope. It’s socially acceptable in Rust. CC-BY-SA-4.0 let mut guess = String::new(); io::stdin() .read_line(&mut guess) .expect("Failed to read line"); let guess: u32 = guess.trim().parse().expect("Please type a number!"); This can get confusing in a large function. In a small function, it ties together the transformation from an unwanted, mutable `String` to the desired, immutable `Int` without any namespace pollution. Use with care.
rossabaker.com
December 30, 2025 at 3:45 AM
Reposted by James
Robber: "Give me the most valuable thing you own!"

Me: "Oh wow ok. I have here a mint copy of the Battlestar Galatica board game in shrink with all the expansions. You'll have to find the right buyer but-"

Robber: "WTF? Give me all your money!"

Me: "Oh man I am like, so broke until payday. lol"
December 29, 2025 at 3:39 PM
Reposted by James
Reminder that if you still have FSA funds to spend this year, you can spend them at FSA store: fsastore.com - you can purchase menstrual products for example to donate to your local pantries and homeless shelters. I have $130 left and that's what I did yesterday.
FSA Store | Shop Over 2,500+ FSA Eligible Products & Services
Shop the largest online marketplace of guaranteed FSA eligible products. The easiest way to spend your funds with zero guesswork on thousands of items.
fsastore.com
December 29, 2025 at 1:51 AM
Maybe if I were assimilated by the Borg, they could cure my ADHD. I think I'm ready.
December 28, 2025 at 7:59 AM
Reposted by James
In the next four years you’ll see a lot of New York Post articles about City Hall that don’t make sense when you read them as an outsider because they’re just permission to hit the anger button in the reader’s brain. This is about seeing someone non-binary in power and getting permission to be mad.
Best Twitter riposte of the day
December 28, 2025 at 1:13 AM
Reposted by James
Happy Pop-Tarts Bowl Day to all who celebrate
December 27, 2025 at 4:34 PM
Reposted by James
I'm 37 now which means only 1 more year til I'm legally allowed to post on Bluesky dot app
December 20, 2025 at 6:12 PM
Reposted by James
This really is grotesque: they went through years-long citizenship processes and are now being denied simply because if the country they are from. It’s formalized bigotry.
“She showed up as scheduled, and when she arrived, officers were asking everyone what country they were from, and if they said a certain country, they were told to step out of line and that their oath ceremonies were canceled.”

www.wgbh.org/news/local/2... @gbhnews.bsky.social
Immigrants kept from Faneuil Hall citizenship ceremony as feds crackdown nationwide
Trump administration is pausing naturalizations for immigrants from 19 countries.
www.wgbh.org
December 6, 2025 at 12:32 AM
Reposted by James
Pricing currently is “LOL I dunno” which is gonna sink or swim the entire endeavor.
AWS and Google Cloud announce a jointly built multicloud networking solution and a new open interoperability spec; AWS plans a rollout with Azure later in 2026 (Ryan Christoffel/9to5Mac)

Main Link | Techmeme Permalink
December 2, 2025 at 3:18 AM
Reposted by James
Everyone is getting upset about the data centers. They pollute a lot and use a lot of energy and will eventually be very ugly/huge vacant buildings. And I understand being mad about that. Until you consider the state of the lazer tag industry at this moment, and how much help that sector needs.
December 1, 2025 at 4:07 AM
Reposted by James
The only legitimate software development methodology:
1. Think very hard about an implementation
2. Don't do anything
November 27, 2025 at 4:11 PM
Reposted by James
Tony: Hey Dave. Check it out. I added a button to the login page.
Dave: Oh yeah?
Tony: Yeah it's right there. See that right there, little oval in blue with a check mark next to it, says "stay logged in on this device"?
Dave: Oh yeah ok cool. What's it do?
Tony: literally nothing
November 27, 2025 at 5:06 PM
Reposted by James
10/10 take. No notes.
November 7, 2025 at 5:49 PM
Reposted by James
Pure cruelty.

Officially, stores cannot give SNAP recipients preferential treatment absent a waiver, w waivers given to places encouraging healthy eating.

So obvs a rule aimed at preventing junk-food places from targeting SNAP.

This is … SO much not that.

And this enforcement is a CHOICE.
The USDA sent an email to grocery stores telling them they are prohibited from offering special discounts to customers affected by the SNAP funding lapse.
I'm aware of at least 2 stores that had offered struggling customers a discount, then withdrew it after receiving this email
November 2, 2025 at 8:44 PM
Reposted by James
Can't overstate how fucked up it is that unraveling what is arguably the greatest achievement in the history of humanity is now a motivating issue of one of the two dominant parties in the U.S.
October 31, 2025 at 4:13 AM
Reposted by James
"According to his running club, the man, who is a U.S. citizen, was returning from a team run when agents pulled him out of his vehicle, tackled him to the ground and kneeled on top of him, allegedly breaking six ribs and causing internal bleeding"
US citizen, 67, ‘has six ribs broken’ by Border Patrol agents, his running club says
The incident unfolded Saturday in Chicago’s Old Irving Park neighborhood, where residents say federal agents disrupted a children’s Halloween parade
www.independent.co.uk
October 28, 2025 at 8:40 PM
Reposted by James
📣THREAD: It’s surprising to me that so many people were surprised to learn that Signal runs partly on AWS (something we can do because we use encryption to make sure no one but you–not AWS, not Signal, not anyone–can access your comms).

It’s also concerning. 1/
PSA: we're aware that Signal is down for some people. This appears to be related to a major AWS outage. Stand by.
October 27, 2025 at 10:38 AM
Reposted by James
LinkedIn just made an update, and it is USING YOUR DATA.

As of Nov 3, your posts/comments/activity will be used to train AI automatically.

Rather than in, it’s opt-out.

If you do nothing, your stuff becomes free fuel for AI with no "undo"

Wanna opt out? Update your settings: lnkd.in/emughyJ8
LinkedIn Login, Sign in | LinkedIn
Login to LinkedIn to keep in touch with people you know, share ideas, and build your career.
lnkd.in
October 26, 2025 at 4:38 PM
Reposted by James
Monthly DoD payroll is ~$16 billion. This supposed "gift" would cover less than 1% of that amount.

If split evenly among active duty service members, each would get just under $100.

Reporters who don't challenge on this are committing egregious malpractice.
New: The Pentagon confirms to CNN it will funnel $130M from an anonymous Trump “friend” toward military pay.

Asked about the donor’s identity and any foreign or domestic entanglements, the WH referred questions to DoD. DoD then referred questions back to the WH
www.cnn.com/2025/10/24/p...
Pentagon to use $130 million donation from anonymous Trump ‘friend’ to pay military members | CNN Politics
The Trump administration plans to funnel a $130 million donation from an anonymous ally of President Donald Trump toward paying military service members during the government shutdown, the Defense Dep...
www.cnn.com
October 24, 2025 at 9:52 PM
Reposted by James
This story is extraordinary even by 2025 standards. Marco Rubio, the nation's top diplomat, made a deal with Bukele and agreed to renege on informant agreements in a years-long DOJ investigation into MS-13, totally undercutting credibility of such agreements.

www.washingtonpost.com/national-sec...
Rubio promised to betray U.S. informants to get Trump’s El Salvador prison deal
To secure U.S. access to President Nayib Bukele’s notorious CECOT prison, Rubio agreed to turn over several MS-13 leaders central to a long-running Justice Department investigation.
www.washingtonpost.com
October 19, 2025 at 2:05 PM
Reposted by James
Subject of Investigation: Are some Congressional Republicans Nazis
Means of Investigation: look at them
Conclusion of Investigation: yeop
Politico received an initial tip that a Taylor staffer had a swastika neatly pinned to his cubicle during a zoom call. When confronted, the congressman’s press office pretty implausibly sought to present the situation as a police matter, and Politico went along with that in its headline and lede.
Capitol Police called to investigate swastika in GOP congressional office

An American flag altered to include an image of a swastika was found in Rep. Dave Taylor’s office.
www.politico.com/news/2025/10...
October 15, 2025 at 9:28 PM
Reposted by James
Conspiracy theories about health fill a vacuum created by the lack of doctors in many rural communities. Meanwhile, doctors in these areas say patients have become increasingly distrustful and sometimes hostile. n.pr/4nRqsdT
In rural America, scarce doctors battle misinformation as they practice medicine
Conspiracy theories about health fill a vacuum created by the lack of doctors in many rural communities. Meanwhile, doctors in these areas say patients have become increasingly distrustful and sometimes hostile.
n.pr
October 15, 2025 at 10:47 PM
Reposted by James
Welcome new Bluesky users, to prove that your are at least 36 years old, the minimum age for this website, please list your favorite song on the first ten volumes of Now! That’s What I Call Music. Please consult this playlist if you need assistance.

music.apple.com/us/playlist/...
Now thats what i call music(US Vol 1-10 by Cooper Lund on Apple Music
Playlist · 174 Songs
music.apple.com
October 15, 2025 at 11:32 PM
Reposted by James
You gently run your hand through the rack. You can feel it—pure cotton, rich wool, Irish linen. The plump buttonholes are handsewn; the buttons attached with a firm shank. You flip the price tag over. It's affordable

You buy the jacket and go home, which is only 15 mins away. Your apt is $600/month
October 15, 2025 at 7:00 AM