Readit News logoReadit News
whichdan commented on Simplify your code: Functional core, imperative shell   testing.googleblog.com/20... · Posted by u/reqo
montebicyclelo · 2 months ago

    bulk_send(
        generate_expiry_email(user) 
        for user in db.getUsers() 
        if is_expired(user, date.now())
    )
(...Just another flavour of syntax to look at)

whichdan · 2 months ago
The nice thing with the Elixir example is that you can easily `tap()` to inspect how the data looks at any point in the pipeline. You can also easily insert steps into the pipeline, or reuse pipeline steps. And due to the way modules are usually organized, it would more realistically read like this, if we were in a BulkEmails module:

  Users.all()
  |> Enum.filter(&Users.is_expired?(&1, Date.utc_today()))
  |> Enum.map(&generate_expiry_email/1)
  |> tap(&IO.inspect(label: "Expiry Email"))
  |> Enum.reject(&is_nil/1)
  |> bulk_send()
The nice thing here is that we can easily log to the console, and also filter out nil expiry emails. In production code, `generate_expiry_email/1` would likely return a Result (a tuple of `{:ok, email}` or `{:error, reason}`), so we could complicate this a bit further and collect the errors to send to a logger, or to update some flag in the db.

It just becomes so easy to incrementally add functionality here.

---

Quick syntax reference for anyone reading:

- Pipelines apply the previous result as the first argument of the next function

- The `/1` after a function name indicates the arity, since Elixir supports multiple dispatch

- `&fun/1` expands to `fn arg -> fun(arg) end`

- `&fun(&1, "something")` expands to `fn arg -> fun(arg, "something") end`

whichdan commented on iPhone Air   apple.com/newsroom/2025/0... · Posted by u/excerionsforte
o_m · 4 months ago
This will be the replacement for my iPhone 13 mini. Although I wish they would make another mini instead.
whichdan · 4 months ago
I wonder if the thinner profile will make it more comfortable in smaller hands (both in terms of reach and center-of-gravity), but I'm skeptical.
whichdan commented on How I Experience Web Today (2021)   how-i-experience-web-toda... · Posted by u/airstrike
cle · a year ago
It's even worse than that, first Google will bug you to use Chrome, then bug you to login, then after your search the browser will pop up "Google would like to use your current location". And then the first half-page of results are ads. And half of the actual results are AI slop and a helpful AI summary of the slop. And that's before you even get to the page.
whichdan · a year ago
Oh, don't forget, if you click "Allow (current location)" it will also reload the page.
whichdan commented on VanillaJSX.com   vanillajsx.com/... · Posted by u/novocantico
slmjkdbtl · a year ago
I never understand the appeal of JSX over something like

  h("div", {}, [
    h("p", {}, "this is easy"),
    ...list.map((l) => h("li", {}, l),
  ])
With this you automatically get loops, variable interpolation etc without having to invent a compiler and new syntax. Can someone help me understand?

whichdan · a year ago
Elm works a lot like this and it's quite nice.

Deleted Comment

whichdan commented on Putting the "J" in the RPG, Part 3: Playing Final Fantasy VII   filfre.net/2023/12/puttin... · Posted by u/doppp
delecti · 2 years ago
I think the main problem with 13 is that it doesn't give the illusion of freedom. I finished FFX for the first time recently (having previously gotten stuck on Gagazet Seymour), and it's almost as restrictive as 13, it just hides it better with cities, temple puzzles, and the sphere grid. In 13 there's no illusion about the fact that you have no choice but to keep running straight down the hallways, and leveling up only at the pace the game allows. A little misidrection or a few minigames would have gone such a long way to break up the pacing.
whichdan · 2 years ago
Totally agree; I started replaying 13 somewhat recently, and just felt worn down after playing for a few hours. The nonstop battles with no real break between them just isn't fun, despite the game having amazing aesthetics.
whichdan commented on iPhone 15 and iPhone 15 Plus   apple.com/newsroom/2023/0... · Posted by u/mikece
jmkni · 2 years ago
Gutted that the iPhone mini is essentially dead. I don't want a phone any bigger.

I'll hang onto my 13 Mini for as long as I can, hopefully they will update the SE to basically be the new Mini.

whichdan · 2 years ago
I'm really bummed there isn't a Mini - I'd be happy with getting one every third generation, even. For the size of my hands, the center-of-gravity is too high in the 6.1" phones, so I can't comfortably hold it with one hand.
whichdan commented on Reddit just auto removed my comment with a link to Lemmy.ml   programming.dev/post/3400... · Posted by u/choult
kapp_in_life · 3 years ago
lemmy.ml is returning a 500 error right now. Is that maybe related? https://lemmy.ml/
whichdan · 3 years ago
I got a 500 on first load, and intermittent issues on subsequent loads, so it's not just you!
whichdan commented on Rails Cheat Sheet   fly.io/ruby-dispatch/welc... · Posted by u/joemasilotti
buzz27 · 3 years ago
> need incredible amounts of tests to compensate for the lack of compile-time type checking

can you explain this a bit more? it seems to me that test coverage and typing solve different problems.

whichdan · 3 years ago
Without compile-time type checking, every single line of code needs to be evaluated with a unit test to ensure there won't be any runtime syntax errors.
whichdan commented on Rails Cheat Sheet   fly.io/ruby-dispatch/welc... · Posted by u/joemasilotti
gymbeaux · 3 years ago
I always hear good things about Ruby on Rails, yet it remains relatively niche. I first heard about Ruby + Rails in 2013, and ten years later it seems to be just as niche. Loved by those who use it, but niche. Why does it continue to struggle in this way when more recent languages like Go are booming?
whichdan · 3 years ago
I think Rails is a victim of its own success: many of the hot new Rails codebases from that time are now 10 year old monoliths. And those monoliths need incredible amounts of tests to compensate for the lack of compile-time type checking, Rails version upgrades are multi-month nightmares, and the object-oriented statefulness of the language means that complex load-bearing code can be extremely tricky to untangle.

There are certainly new compelling projects like Sorbet to add type checking, and the ecosystem itself is very mature, it's just that the average codebase is not going to live up the experience you might have with a brand new one.

u/whichdan

KarmaCake day1249February 3, 2011
About
(They/Them) Senior Engineering Manager in Boston
View Original