Better HN
topnewbestaskshowjobs
Log inSign up

hakunin

2,515 karma · joined Mar 4, 2010 (16y ago) · 549 submissions

https://max.engineer, mastodon:ruby.social/@maxim, x.com/hakunin, bsky.app/profile/max.engineer

meet.hn/city/43.1009031,-75.2326641/City-of-Utica

---

Submissions

comment 2y ago · link · parent

Covid virus during pregnancy increases risk of bad outcomes dramatically, but a lot of patients have the wrong (reverse) idea, and therefore refuse the vaccine. Refusing the vaccine is probably a contributing factor. (Source: wife is OB).

302.

Why Upgrade PostgreSQL(why-upgrade.depesz.com ↗)

1 points · by hakunin · 2y ago · discuss

comment 2y ago · link · parent

I've written up some rules that I've successfully applied in my teams. https://max.engineer/mindful-code-reviews

comment 2y ago · link · parent

Couple of points on this.

1. A lot of problems arise from too few people working on too many things. If it's one-two devs and backlog is growing, the problem is not that you have no time to fix things, but that you're understaffed. If you have enough people, then from the business perspective it shouldn't even be that noticeable that someone is refining previous work, while someone else is building the next thing.

2. If you're not understaffed, then the best time to clean up new code is during or immediately after writing it. A phrase I like to use is "while it's still fresh in memory". You're saving time and not adding new bugs, by not having to remember everything again, load all that context back into your head.

comment 2y ago · link · parent

The problem here is not that developers are too busy, but that code reviews are considered second class citizens to churning out new code. It's like saying "many devs are super busy working on feature A so they just write quick and dirty code for feature B". If reviews are integral part of feature production pipeline, there should be no issue to sit down and spend a day reviewing code. For bigger, more complex things it could be a few rounds of reviews.

There is an approximate non linear relationship between time it takes to produce the first PR and time it takes to go through all rounds of review. This time can be pretty reliably calculated and taken into account.

comment 2y ago · link · parent

The worst use of analogy in my view is to use it not for improving understanding, but for morally loading the subject with the baggage from the analogy. When you say that data is like organs, you are morally loading all of our worst perceptions on what organ trade can be (harvesting, trafficking, and exploitation crimes) onto data. Data resale is serious for different reasons, and trying to morally load it with organ considerations is obfuscating those reasons. We should instead understand those reasons for data itself.

comment 2y ago · link · parent

I've been using History Book app[1] (only on Apple ecosystem). The search is starting to slow down at 25k pages, hoping it can hold up.

[1]: https://apps.apple.com/us/app/history-book-browse-search/id1...

comment 2y ago · link · parent

Did the repetition become obvious before or after you saw both implementations? It’s possible that if you dried it up right away, you would’ve abstracted the wrong thing, and it’s way more obvious only in hindsight.

comment 2y ago · link · parent

Yes, but his law is descriptive, not prescriptive. Just because it tends to happen doesn't mean it should happen, or happens for good reasons.

comment 2y ago · link · parent

This is good sometimes, other times it risks losing the audience. Extra info works better when they're ready (i.e. asked for it). This is why it's such a difficult balancing act. You don't want to preemptively answer questions that people didn't realize they should ask yet.

comment 2y ago · link · parent

One of the problems I often see is that when trying to explain one of the possible options, people don't understand it. When that happens, you try to explain it to them harder. Your explanation is then mistaken for pushing for that option. It's important to carefully navigate around this perception. People should understand that first you just want to be on the same page what your options are, and then discuss the best one.

comment 2y ago · link · parent

Trying to solve a communication problem with more code and infra is often a mistake. This is something many engineers don't realize they're essentially doing. Some communication problems can be somewhat alleviated by processes and technology enforcing those processes, but you must always consider the cost, and weigh it against alternatives that don't require engineering overhead. In almost every case like this, increasing the amount of code and infrastructure is the wrong option.

comment 2y ago · link · parent

I think not getting hung up on a method to solving a problem is a great message to remember. You should be open to switch to a different method if it solves the problem better.

Type safety is just one such method. The actual problem is making code easier to maintain for humans. Type safety is not always the best means to that end. Our brains perceive information in a complicated way. Sometimes too much information can overwhelm us and obfuscate something simple. Sometimes too much detail about each value can make us lose the overall flow of the program.

My advice: (aside from reading other people's code) try to read what you wrote, and have others read what you wrote in code reviews. Do you and your colleagues understand it? Make it as brief and simple as possible without losing that understanding. Address any "how" questions by rewriting the code clearer, "what" questions by improving naming, and "why" questions by adding comments. These are your code's 3 primary objectives: explaining how, what, and why to your colleagues. I once wrote a post about it.[1]

[1]: https://max.engineer/maintainable-code

comment 2y ago · link · parent

I agree that if you make a very complex query in ActiveRecord, it could eat a lot of resources.

That said, I would highly recommend going with raw queries for this sort of complexity, no matter the language. There are usually 2 kinds of queries: normal ORM-powered CRUD operations (which can get moderately complex), and hairy specialized report-style calculations. The latter I always recommend to keep in raw, well-written, well-commented SQL form. You can still wrap it into some nice object.

You could write them in something efficient like Jet or Elixir's Ecto, but for such a complex case I'd argue that you shouldn't obfuscate SQL at all. For all other cases ActiveRecord works well.

If you are serving these results in real time, something like materialized views (in postgres) would move the burden of calculation to when data changes, rather than when data is viewed.

And to tie it back to the original convo: a very efficient concurrent language doesn't solve these root causes, rather gives you more time not to address them, and allows you to get away with more neglect. There's some value in that, but you have to weigh it against the downsides mentioned in previous comments. If the language+framework is super efficient and has no downsides to its ecosystem and ergonomics, then there's no debate, I'd just use that.

comment 2y ago · link · parent

A internal network boundary is probably worth it for heavy jobs, since you usually don't want it to interfere with serving web requests (no matter the tech).

You probably already know what I would say to each of those examples.

> Rails timing out after 30s while allocating 500MB of memory (mostly) in ActiveRecord to compute 5MB of JSON to return to an API caller.

I can make a JS or Go program perform the same way. In fact the exact same thing happened in my shop with Go/Gorm. The key question is: how do you compute the 5mb of JSON? The devil is in those details. We changed the way we computed ours, and the issue was gone.

> 90% of request latency of ~10s spent waiting for downstream services to respond to requests. Most of these could be fired off concurrently (ie `Promise.all` in node). 9s/10s this Rails worker is sitting around doing nothing and eating up ~300MB of memory.

This sounds broken. Why is the worker doing nothing for 9 out of 10s? But like I said earlier, there are a bunch of ways to use HTTP1.1 pipelining to run them concurrently. (https://github.com/excon/excon and https://github.com/HoneyryderChuck/httpx support it, but you can also do that with Net::HTTP I believe) And you can still start threads, which are still concurrent while blocking on IO.

> trying to extract out Authorization to a centralized service (so that other extracted services don't have to call into the monolith in order to make authorization decisions) is a major pain as the monolith now has to make calls out to the centralized auth system to in order to make authz decisions.

This seems unrelated to Rails. Not sure why monolith can't continue handling authorization.

comment 2y ago · link · parent

You're saying that NodeJS monolith comes with no downsides compared to Rails at early stages. We disagree here.

From my brief surveys, nodejs ecosystem comes with less security out of the box, less standardized project structures, fewer thoroughly-designed and supported packages (vs cutting edge experiments), more complex upgrade paths, more projects getting abandoned, all of which can slow you down every day. Friction from these can be deadly.

On the other hand, being in the corner at scale doesn't force you to rewrite everything. Just the piece that put you there. You can leave Rails app to handle most things, and extract parts of specialized infra as needed.

Would be curious to look at specifics — what kind of pains your company is experiencing with Rails today.

comment 2y ago · link · parent

I understand your general point, but these solutions are not niche. They cover almost everything needed in web dev. The niche problems are the ones that arise at scale, which is when a business typically has the resources to solve them. (Hint: you don't have to solve them in Rails).

Large app / company challenges don't apply to new apps. Statements like "I wouldn't start a new app without a great concurrency story." or "I wouldn't start a new app without microservices." etc don't make sense, because new apps have different priorities (i.e. finding the fit, surviving, staying relevant).

I went through a phase of building Elixir/Phoenix apps for 3 years, thinking that I will switch permanently, but ended up coming back to Rails due to higher productivity in that stack. This was in 2015-2018, so maybe Elixir/Phoenix has gotten more ergonomic since. I'm not sure.

comment 2y ago · link · parent

Http clients have pipelining for parallel requests that doesn't require threads. Database calls in Rails 7 now have `load_async`. You can still have other services, outside of Rails. Would that cover it?

P.S. I'm a huge fan of Elixir/Phoenix, but didn't find the big need for concurrency in practice that Rails doesn't address somehow.

comment 2y ago · link · parent

Just out of curiosity, what are you doing with a great concurrency story in a company you start in 2024?

comment 2y ago · link · parent

One strong point for productivity/getting stuff done fast in real world: good REPL. It's not just Rails of course, but worth noting when comparing interpreted languages to compiled ones. Rails console is not only a great development tool, it's also an invaluable way to tackle customer support problems quickly.

comment 2y ago · link · parent

There formed a subculture inside Ruby community, of people who love code that is as structured and declarative as possible, with an abstraction over anything that has a name, and a hierarchy of namespaces that map onto paths or grouping of similar things, rather than parts of a module or a library. There are many examples of libs like these out there (I won't name names). For example, libraries that let you write "service objects" declaratively with some block/lambda trickery.

I find this to be a fun way to play with and explore Ruby, but once it comes to building stuff for production, I encourage to take a bunch of steps back and rethink what is really being gained. Many of these libraries end up turning Ruby almost unrecognizable. And the fact is that if you sit down and try to rewrite the same thing into plain imperative ruby, you'd lose nothing (it won't even be longer), but you'd gain clarity and maintainability, because code becomes simple and obvious. I know this because I've done all of the above in the past, and it humbled me a number of times. I wish more people were trying to do this exercise of ruthlessly comparing their lib's solution to the same thing done in plain ruby. It may feel bad at first because it bursts the bubble of excitement one may've inflated while building a lib. But then I find it actually makes you more excited about Ruby again.

I haven't personally used Hanami, been following it from a distance, and I might be wrong in this impression, but I found it to be leaning a little too hard into the camp described above. That said, performance gains are certainly welcome.

comment 2y ago · link · parent

> I used to be a Rails developer, but I'd never start a new Rails project today. Frontend frameworks and serverless backends have made Rails obsolete.

Feels like a bold conclusion to make based on a trend, when there are so many other explanations. If Rails is no longer in the hype cycle, but still is a superior solution, does that make it obsolete? If Rails shops generally have smaller teams, does that make them obsolete? Why did the author choose that one explanation?

comment 2y ago · link · parent

I'm on Safari on MacOS with AdGuard and StopTheMadness. Nothing seems to have autoplayed.

comment 2y ago · link · parent

I've been contemplating the issue in the headline, as pertains to my value. When I help somebody in 40 mins with something they've been stuck on for 3 months, my value is clear to everyone. When I work there the whole time, and nobody ever gets stuck for 3 months, my value is unclear. Don't know how to deal with this paradox.

comment 2y ago · link · parent

Zed is a great contender for Ruby. I'm considering it, coming from Sublime Text, only needs a few small additions. Much better first impressions than VSCode.

326.

John Oliver offers to pay Clarence Thomas $1M a year if he quits Supreme Court(theguardian.com ↗)

16 points · by hakunin · 2y ago · 12 comments

comment 2y ago · link · parent

I don't think this is quite right. I've done a survey a few months ago when deciding what to use for a new project (primarily comparing Ruby and Go). What I saw was many people rallying around the top useful libs out there. I also saw numerous brand new libs showing up, fixing mistakes of their predecessors. And each time I compared a popular Ruby project with a popular Go one, I'd find consistent activity from multiple maintainers in the former. And a lot of initial activity that completely dies down in the latter.

The overall feeling I got is that Ruby on Rails has gotten a lot more "getting shit done", "don't waste time" mode, — many businesses depend on it. Libs became higher quality compared to the early playful years.

comment 2y ago · link · parent

I used to have fancy long config files full of default writes, but every MacOS update changes so many things that it’s borderline stressful to run the file ever again. Things break in weird ways. The config ends up only being useful for the one time I setup this machine, and not the next.

So my new approach: an Apple note where I just write down any settings I tweak manually in UI. If they ever relocate, I will find them in another place. I also write down any custom setup I do (like cron, etc).

I also keep an iCloud dir of various software configs, and a Brewfile for all the software installs. I haven’t tried transitioning from this setup yet, but hopefully it’s much more straightforward, albeit a bit time consuming (it’s always time consuming).

comment 2y ago · link · parent

I'm arguing in favor of coupling. Don't think front-ends should be decoupled in most situations.

There's this notion I don't see discussed often. The more distant/unstable the link is between a caller and a callee, the more coupled they should be. The closer and more reliable the link is, the less coupled they should be.

That's why when we build interfaces in a single codebase, we can let them be minimal, and let callers use loops for batch operations. But when talking over network, we build elaborate protocols and languages (e.g. SQL) to allow for more complex operations in one roundtrip.

So if one is trying to treat their backend like it's part of their front-end's codebase, that can be fetched and looped over with little regard for the many failure modes, they're going to have a bad time. The front-end to back-end is one of the most distant and unstable links we have in computing, if not _the_ most unstable. This also applies to any intermediary back-end over network.

Minimize network interactions, and shift most work into the single backend codebase for maximum reuse and reliability.

1
101112
19