2,515 karma · joined Mar 4, 2010 (16y ago) · 549 submissions
meet.hn/city/43.1009031,-75.2326641/City-of-Utica
---
302.
Why Upgrade PostgreSQL(why-upgrade.depesz.com ↗)
1 points · by hakunin · 2y ago · discuss
comment 2y ago · link · parent
comment 2y ago · link · parent
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
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
comment 2y ago · link · parent
[1]: https://apps.apple.com/us/app/history-book-browse-search/id1...
comment 2y ago · link · parent
comment 2y ago · link · parent
comment 2y ago · link · parent
comment 2y ago · link · parent
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]
comment 2y ago · link · parent
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
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
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
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
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
comment 2y ago · link · parent
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
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
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
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
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
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.