I wonder what would be more efficient, constantly trying to eke out some performance out of a inherently slow language? Or writing/rewriting new/critical paths of the codebase in a faster language. Ruby used to be able to say we sacrifice performance for developer productivity. I don’t think this is any longer true, there’s plenty of languages out there that developers can be just as productive with, while producing…
How to Fix Slow Code in Ruby
101–110 of 213 posts
Re: How to Fix Slow Code in Ruby
#102Earlier quoted context omitted.
I can do the same with Elixir's Phoenix, with exactly 3 lines in a production console like in your example. What you describe is not exclusive to Rails.
Yeah, maybe I should rewrite one day, but customers wouldn't care much and I am content wit Ruby.
Re: How to Fix Slow Code in Ruby
#103Earlier quoted context omitted.
> And yet Phoenix hasn't stolen a significant amount of market share from Rails. I thought we all learned popularity does not correlate with quality. It correlates pretty closely with corporate inertia and perceived lower risk of developer churn though. Businesses love tech stack for which there are bigger pools of programmers. Says nothing of the quality of the stacks. > If you're measuring hardware loads and bustin…
> For 3.5 years with Elixir this is the first time I hear that this is a problem. Any data to back this up? My point is that it doesn't come with Phoenix out of the box (unless something has changed?), and that difference in philosophy is the core of what I'm getting at. With rails new I'm getting an end-to-end test suite and chrome driver installation for free. Phoenix also has no plans of implementing something sim…
You put a lot of weight on built-in features of frameworks in your reply. This is not an objective truth and even DHH himself admitted as much -- including in his article "Rails is Omakase" which I very much enjoyed (because he says that the Rails team picks what they deem the best ingredients and if you disagree then you are not the target audience).
You find value in "officially vetted" libraries, I find value in being assemble to assemble my chair the way I want it to, with parts I built or bought myself.
Neither practice is superior per se. Let's both admit that.
> They won't even consider adding basic things for developer productivity like undoing a generator.
Honest question: how many tech stacks even allow for that? Does Ruby have bytecode instrumentation on the level of, say, the JVM? (Java's instrumentation has unlocked it some quite impressive code generation and runtime code analysis abilities.)
Generating boilerplate is pretty easy. But how many tools out there can scan your code and tell you "this looks like Devise's boilerplate with exceptions in files A and B on lines 123 to 150 and 201 to 217"?
If Rails can do that I'd be very impressed. It couldn't, as far as I was aware, about 4 years ago.
> There's a balance of making something easy to use and making something "technically superior".
I never said this was important to me. I value Elixir's hassle-free parallelism and concurrency (which is more than what can be said about 99% of the tech out there where those things are always an afterthought). And Elixir is still pretty easy to use. I don't see why both things have to be presented as opponents? Seems like a false dichotomy.
> The Rails team seems to care much more deeply about what the framework feels like to use
You have spoken to the authors and they have told you this, in these exact words?
> ...and the Phoenix team cares more about building something that is "dogmatically perfect" (which you're correlating with quality)
And you have spoken with the Phoenix team. And they told you this. Exactly this?
No. They don't do that. They don't want to steer developers in the direction they might deem the best (they said as much on ElixirForum). They give you freedom to choose. And the community has provided alternative approaches for a number of the classic building blocks of a web app. That's all there is to it and I am not sure how you managed to so grossly misrepesent it. :(
I also never said anything about dogmatically perfect being important (much less correlated to quality!). You are projecting and we are talking past each other which doesn't help the discussion at all. If I cared about purity or similar concepts in the "dogmatically perfect" lane I'd go for Haskell or even Idris. Elixir -- and thus Phoenix -- are very far from "pure", "dogmatically perfect" or any such other academic ideals.
Really not sure where you got that from?
> What's easier for someone to learn?
This is extremely subjective and varies from person to person. Are you claiming that Rails' way is factually superior to learn? To me both are quite straightforward and both require you to have learned some concepts beforehand. And both aren't exactly English with which you command the machine, no?
> If Phoenix wants to increase their adoption, then I think they need to accept that things like this matter.
Ever since I dropped off the mainstream tech train and started working on the sidelines I've noticed something extremely curious which is happening very consistently: the people who work with mainstream tech always assume that the smaller community wants more adoption.
There have been a number of discussions on ElixirForum about this and various important figures of the maintainers' teams have openly said that they aren't aiming to make the language and its stack more popular; they want to make useful tech. One example is the recent Phoenix 1.5.0 release which now comes integrated with LiveView. A lot of people apparently don't want to deal with JS because at least 50% of the new posts on the forum since the announcement have asked exclusively about LiveView.
So again, the maintainers aim to make useful tech, not to trend on Twitter, dev.to, StackOverflow, or anywhere else really.
---
This became rather long. I apologise for that but still wanted to address several misconceptions that seem to have arisen in this discussion.
Re: How to Fix Slow Code in Ruby
#104Earlier quoted context omitted.
> And yet Phoenix hasn't stolen a significant amount of market share from Rails. I thought we all learned popularity does not correlate with quality. It correlates pretty closely with corporate inertia and perceived lower risk of developer churn though. Businesses love tech stack for which there are bigger pools of programmers. Says nothing of the quality of the stacks. > If you're measuring hardware loads and bustin…
For years several Elixir cargo cult members are trying to preach to the Rails community to make the move and join them. But performance! But functional programming! Nobody cares guys. If performance and functional programming were critical in our domain we wouldn't have been Rails programmers right? I suspect most of the Ruby devs who got bored with Ruby already made the move to Elixir. The rest just read posts like…
1. The Elixir community doesn't seem to aim for popularity (at least several important maintainers have said so on ElixirForum).
2. The tech is useful, scales very well and helps with the hosting costs by using less resources. That's an objective fact, proven in many blog posts where people sat down and measured.
3. Concurrency and parallelism are extremely important and will get more and more important as our CPUs can't get faster single-core performance and are just getting more cores.
It's OK if you don't care about any of those things. Really. I personally never got offended if something I like is disliked by others (as we should all).
But making a strawman and then crushing it is not a productive way to discuss either.
Re: How to Fix Slow Code in Ruby
#105Earlier quoted context omitted.
Is this an honest question? I honestly can't tell and I am not saying it to show disrespect -- just wondering if you are sarcastic. Erlang/Elixir have built-in caches that respond in the matter of 30-150 nanoseconds. Why would you need an external service for that? It's adding complexity -- and likely hosting costs. Isn't it self-evident to you that adding Redis as a caching layer to your stack is a bandaid to a deep…
> Why would you need an external service for that? It's adding complexity -- and likely hosting costs. We're also dependent on mysql, are you gonna implement that in Elixir as well? Redis is a great piece of software, and it's a real SHARED cache, so it could work for sessions or other small state management you sometimes want to remember for example. What you described won't work for that.
Sessions work quite fine in Elixir's local cache as well. :)
Re: How to Fix Slow Code in Ruby
#106What's current state on GraalVM as it relates to running production Ruby code? From what I understand, it's the fastest VM out there at the moment for Ruby. And yes, it's from Oracle but they have GPL'd the code [2] [1] https://www.graalvm.org [2] https://www.graalvm.org/docs/faq/ Edit: looks like TruffleRuby is built onto of Graal. https://github.com/oracle/truffleruby
Not sure when they clarified the licensing around GraalVM, but it's what kept me away from it since it's inception. Looks like the single executable binary is under the Oracle license side of the equation.
Re: How to Fix Slow Code in Ruby
#107Earlier quoted context omitted.
Last time I tried to run Truffle on the company test suite it spent an hour processing 1/8th of the suite. Then it was killed by the OOM killer. On a 32 GB machine. To be fair there was only one or two errors during that, so compatibility is at least getting there. Meanwhile Ruby 2.6.5 chugs along and finishes the whole suite in 8 minutes. Never hitting any unreasonable amounts of memory.
Are you serious - the whole Shopify test suite finishes under 8 minutes? That's pretty great no? Are there multiple processes running it?
Re: How to Fix Slow Code in Ruby
#108...Rewrite in almost anything else and you'll have fast code. :) It's quite amazing the lengths the companies will go to just to avoid changing their status quo. But for them it makes sense. --- EDIT: Downvoters, calm down. Ruby on Rails is objectively quite a slow framework and this is proven in many public benchmarks (Techempower included). And Ruby isn't the fastest among the dynamic languages either. Less cargo c…
Stuff like this always confuses me. It's like asking how to exercise without sweating. I would think the first sign of performance problems would mean some profiling and some porting of sections to a native language. Instead some companies go down a crazy rabbit hole instead of just making some shared libraries.
Then people go on all sorts of crazy journeys to justify their investments in pain and burned money.
Even though I get downvoted at places in this thread (and upvoted generously on others), I will never tell to people "you should always just rewrite to Elixir". Meh. If your app works fine, have it be in COBOL or PL/1 if that helps you do your job better.
But as you said, when your app/hosting starts struggling you should start rethinking your choices if all the lower-hanging fruit has been already collected.
Re: How to Fix Slow Code in Ruby
#109Earlier quoted context omitted.
> And yet Phoenix hasn't stolen a significant amount of market share from Rails. I thought we all learned popularity does not correlate with quality. It correlates pretty closely with corporate inertia and perceived lower risk of developer churn though. Businesses love tech stack for which there are bigger pools of programmers. Says nothing of the quality of the stacks. > If you're measuring hardware loads and bustin…
> For 3.5 years with Elixir this is the first time I hear that this is a problem. Any data to back this up? My point is that it doesn't come with Phoenix out of the box (unless something has changed?), and that difference in philosophy is the core of what I'm getting at. With rails new I'm getting an end-to-end test suite and chrome driver installation for free. Phoenix also has no plans of implementing something sim…
It's gonna be tough for them really, even if it's a great framework (I have no idea). Elixir didn't take off like Golang or other languages from the last decade. It seems to have quite the learning curve, so for beginners any of ruby / php or even .net / java will make much more sense. For seniors...idk. Not everyone like functional programming. I do hear praise for the language I can't deny it and what seems like a tiny but vibrant community, but the numbers are just not there. I hope Elixir can maintain it's niche and not outright die just because I know some people rely on it for their pay check but honestly I'm not sure if we'll still have these discussions 5 years from now.
Re: How to Fix Slow Code in Ruby
#110Earlier quoted context omitted.
Yes, Ruby is meant to be easy and magical, but it was never meant to be fast. It's fast enough for most things, but you also wouldn't show up to a drag race with a tuned bicycle.
https://crystal-lang.org/ almost the same as ruby. Blazing fast.