Pull to refresh

Optimizing Ruby Path Methods (byroot.github.io)

by weaksauce 64 comments 134 points
Read article View on HN

64 comments

[−] matltc 26d ago
Makes me miss Ruby. Been in node typescript recently. Everything is a callback returning a promise in some weird resolution chain, mapped and conditional types, having to define schemas for everything and getting yelled at by lsp all day... Oh then you gotta write react components and worry about rerenders and undefined behavior caused by impurity in state, npm, arcane .json configs

Versus active record, mvc, yaml configs, bundler, beautiful syntax, robust and trivially extendable stdlib, amazing native debugging and cli docs out of the box, everything out of the box if you're using Rails

I do not understand why it becomes increasingly irrelevant, especially in web development. I kinda get scripting--bash and python tend to run everywhere

[−] gejose 25d ago

> Everything is a callback returning a promise in some weird resolution chain

Care to provide some examples of this? This hasn't been my experience, in general.

[−] matltc 21d ago
Processing async messages received over a socket with multiple namespaces.

Any async chain really where the steps are in a pipeline

[−] anand_dev 24d ago
Spot on. The worst thing is digging through 500 lines of nested JSON just to find one tiny type mismatch that broke the build. Most diff tools make it worse by showing 100 changes when 99 of them are just whitespace noise. Really makes you miss the simplicity of Ruby/Rails.
[−] wanderlust123 26d ago
Lack of static types is one of the main reasons. Trying to decipher a complex ruby on rails codebase is unnecessarily difficult compared typescript. The tooling is also shit unless you use Ruby Mine.

An absolute shame given how good the functionality is baked into RoR.

[−] teaearlgraycold 26d ago

> getting yelled at by lsp all day

God forbid you get forced to fix bugs before they reach production.

[−] somewhatrandom9 26d ago
byroot sets a great example sharing his code optimization expertise. His blog has many great improvements like this. A 7x improvement in Dir.join and similar calls?! Thank you, byroot!
[−] chi_features 26d ago

> Given that the Intercom monolith CI runs with 1350 parallel workers by default

Wow! I'd love to hear more about how that's achieved

[−] DeathArrow 26d ago
What happened to Ruby? It was very successful at some point.

Maybe kids started using JS exclusively. But what happened to older developers? Did they move over?

Rails seemed to enable very fast prototyping and iteration. Isn't it still the case?

I see PHP usage going down, but PHP doesn't seem to have any advantages over JS, .NET, Python or Go. While Ruby coupled with Rails promised easy and rapid development.

Of course, Ruby might not be best suited for large code bases or microservices but probably 90% of the Internet are small to medium web sites.

[−] vidarh 26d ago

> More importantly, on CI systems it’s relatively common to check out code using git, and git doesn’t care about mtime

git doesn't care about mtime, but git maintains trees whose hash changes if any constituent part of the tree changes. It'd seem tempting to check for a .git and if present use the git tree to determine whether to invalidate the cache.

[−] _rwo 25d ago
nice write-up! I wonder tho - did the optimization really affect CI wall time? In my experience such micro optimization rarely move the needle - it obviously matters because a lot jobs are running in parallel, but did it in the end improved dev experience? (honest question, just curious)
[−] nixpulvis 26d ago
Would this be possible to mainline into ruby in some way?
[−] blinkbat 26d ago
don't take this the wrong way, but -- people still use ruby?