News for hackers. Stuff that matters.
Re:Sorbet and 100% cov makes Ruby refactoring possible by pqdbr on Monday April 25, 2022 @04:24PM (#31160095)
It's a shame the article ends with "So as usual, consider not writing Ruby, but if you do, ...". That's worthless advice and many people, myself included, have Ruby as their most beloved programming language.
Re:Sorbet and 100% cov makes Ruby refactoring possible by rattray on Monday April 25, 2022 @05:15PM (#31160711)
Just because you disagree with it doesn't mean it's worthless advice.

I always have a fond flutter whenever I see Ruby (which I used to write, and really enjoyed) but absolutely wouldn't start a new project with it, for practical reasons. It's slow, it can turn into a big ball of mud as applications scale (there's no named imports for crying out loud, everything is just in a global namespace with side-effects everwyhere), etc.

Certainly there are still people/projects where, upon consideration, Ruby is still the best choice (eg; small Rails shop has a standard CRUD app to build quickly that will not likely ever scale to be huge). But you should still _consider_ not using Ruby.

Re:Sorbet and 100% cov makes Ruby refactoring possible by lbrito on Monday April 25, 2022 @11:12PM (#31163586)
In my experience all those cons are mostly just your company/team not knowing how to program in Ruby.
Re:Sorbet and 100% cov makes Ruby refactoring possible by norman784 on Tuesday April 26, 2022 @04:41AM (#31165287)
I read this argument lot from C/C++ devs in rust discussions, they just say that you are not a good developer and they never will do any mistake, but idk, I don't mind being a dumb developer, I like to have an app that I know works, even if you are a pro and you never do a mistake, your team surely will do, it put more burden in the devs, while there are tools that can make you life easier.

Then after that if you still choose ruby over a language that gives you more guarantees and safety then is your choice.

Re:Sorbet and 100% cov makes Ruby refactoring possible by lbrito on Tuesday April 26, 2022 @11:26AM (#31168666)
That's not the same argument at all. "know language X" != "be smart".

I am specifically calling out people that _don't know Ruby_ and complain about the language being this or that, when really their frustrations come from them being inexperienced in the language.

It is like never having used a hammer, gripping it close by the head, and complaining that it takes a lot of effort to nail things. Blame's not on the hammer, bud.

This might happen with every language. I don't know. I'm a Ruby developer and have seen this countless times. Also, none of this equates to saying that ruby is perfect. It is not.

Re:Sorbet and 100% cov makes Ruby refactoring possible by rattray on Tuesday April 26, 2022 @09:01AM (#31166939)
Most devs aren't learning Ruby anymore, so if true (I'm skeptical) that sounds like it could be a problem for many organizations (perhaps not yours).

Hiring only people who are already experts in a given technology shrinks your talent pool in an already-tight market, and training is expensive (time and/or money).

Re:Sorbet and 100% cov makes Ruby refactoring possible by lbrito on Tuesday April 26, 2022 @11:34AM (#31168791)
I'm not sure your premise is correct. Hired.com's 2022 report says Ruby is one of the most in demand skills.[1]

In any case I'm not saying Ruby is high barrier or anything. It isn't! It is totally viable to hire non rubyists and build them up. I have seen it before many times. Ruby is a simple, forgiving language with fantastic documentation and an excellent community. It is pretty ideal for newcomers really. Training pays off.

[1] https://hired.com/2022-state-of-software-engineers/

Re:Sorbet and 100% cov makes Ruby refactoring possible by white_dragon88 on Tuesday April 26, 2022 @03:39AM (#31164974)
How does a team not know how to code in Ruby? Doesn’t ergonomics matter?
Re:Sorbet and 100% cov makes Ruby refactoring possible by lbrito on Tuesday April 26, 2022 @11:35AM (#31168817)
>How does a team not know how to code in Ruby?

No one is born knowing how to program.

>Doesn’t ergonomics matter?

It does and Ruby does a good job with it. It is not a hard language to learn. See my response to sibling comment.

Re:Sorbet and 100% cov makes Ruby refactoring possible by aantix on Monday April 25, 2022 @08:35PM (#31162634)
“Shopify's core monolith has over 2.8 million lines of Ruby code and 500,000 commits.”
Re:Sorbet and 100% cov makes Ruby refactoring possible by rattray on Monday April 25, 2022 @10:48PM (#31163454)
That doesn't mean it's without downsides or that they'd make the same choice today, with the options we have available now.

For example, they probably spend an absolute fortune on cloud costs, especially CI. Node, Go, Kotlin, Elixir or maybe even async+jit'd Python might all be 2-10x cheaper to run.

But I bet there are other choices that would have been worse. I often enjoyed working with Ruby at Stripe, especially once Sorbet came along.

Re:Sorbet and 100% cov makes Ruby refactoring possible by endgame on Monday April 25, 2022 @10:15PM (#31163258)
And they had to become PLT experts to build the tool that let them tame that.
Re:Sorbet and 100% cov makes Ruby refactoring possible by gnufied on Monday April 25, 2022 @10:29PM (#31163340)
In fairness all major companies which use a Language extensively tend to invest in all aspects of its well being. Facebook did with PHP, Google hired Guido (and bunch of other python maintainers) and now go.

If your business depends on having a well maintained platform, then it makes sense to invest in it. Shopify should be commended for investing in Ruby. As a former contributor to Rails and Ruby ecosystem in general - IMO I would still choose Ruby for certain kind of work. I write Go mostly these days and parsing random JSON for example is major PITA (so it would be in many other static languages).

Re:Sorbet and 100% cov makes Ruby refactoring possible by rattray on Monday April 25, 2022 @10:42PM (#31163414)
Minor nit, if you're thinking of Sorbet, that was Stripe (but Shopify has done a lot of great work on Ruby things too, incl Sorbet stuff).

Disclaimer, former Stripe employee.

Re:Sorbet and 100% cov makes Ruby refactoring possible by endgame on Tuesday April 26, 2022 @08:33PM (#31174891)
Thanks, I had indeed got my S-companies confused. I must've been thinking of Shopify's nix work, and put them in a mental bucket of "does advanced stuff".
Re:Sorbet and 100% cov makes Ruby refactoring possible by Zababa on Tuesday April 26, 2022 @11:18AM (#31168544)
Another way to put it would be that Ruby is so productive for the average developer at Shopify that they can afford to pay PLT experts to work on the tooling.
Re:Sorbet and 100% cov makes Ruby refactoring possible by h3mb3 on Tuesday April 26, 2022 @03:50AM (#31165042)
What is PLT referring to?
Re:Sorbet and 100% cov makes Ruby refactoring possible by methyl on Tuesday April 26, 2022 @04:38AM (#31165276)
programming language theory
Re:Sorbet and 100% cov makes Ruby refactoring possible by matheusmoreira on Monday April 25, 2022 @11:25PM (#31163639)
> there's no named imports for crying out loud, everything is just in a global namespace with side-effects everwyhere

Yeah, this is a significant flaw. I with it had a simple module system like Javascript's require function which just returns a normal object containing functions and data.

Re:Sorbet and 100% cov makes Ruby refactoring possible by bestinterest on Monday April 25, 2022 @04:30PM (#31160193)
There is a gap between languages at the moment imo. Ruby is just ruthlessly productive.

Compare https://github.com/benhoyt/countwords/blob/master/simple.rb with https://github.com/benhoyt/countwords/blob/master/simple.go

Hoping new age compiled languages like Crystal & Nim fill the gap of performance, types & productivity. But compile speeds need to be factored in.

Re:Sorbet and 100% cov makes Ruby refactoring possible by banana_maker on Monday April 25, 2022 @06:10PM (#31161405)
Comparing a trivial <500 LoC program between languages doesn't tell you anything that's useful other than the terseness of the syntax. You might as well chain unix utilities together at that point.

Maintaining a 5k+ LoC java/c#/go/rust/crystal codebase is orders of magnitude simpler than standard ruby. Sorbet/RBS bridge that gap now, but are a pita to use compared to natively implementing a type system. I know with rust/go I get a simple binary at the end to copy over. Rust, unfortunately, has slow compilation times still compared to go, but I really can't stand error handling in go compared to rust.

That said, "ruthlessly productive" is an apt description. I just don't want to have to maintain a large rails codebase again without sorbet/rbs. I'm hoping phoenix/elixir or something in rust catches on.

Re:Sorbet and 100% cov makes Ruby refactoring possible by sparker72678 on Monday April 25, 2022 @11:39PM (#31163693)
That 5k line Java codebase is probably equivalent to the 500 line Ruby one. ;)
Re:Sorbet and 100% cov makes Ruby refactoring possible by realusername on Tuesday April 26, 2022 @01:22AM (#31164225)
Yeah not really, for maintainability, I'll pick Ruby over Java any day. I've seen how the large java project tend to be and I want no part of that.
Re:Sorbet and 100% cov makes Ruby refactoring possible by pphysch on Monday April 25, 2022 @06:48PM (#31161810)
Is Ruby "ruthlessly productive" for building a fast, highly concurrent program that can be deployed to X platforms with minimal fuss? No.

Is Golang "ruthlessly productive" for interfacing with complex relational databases? No, not even with generics.

Tradeoffs, every language has 'em.

Re:Sorbet and 100% cov makes Ruby refactoring possible by Scarbutt on Monday April 25, 2022 @08:15PM (#31162523)
What mainstream programming language is good for interfacing with complex relational databases?
Re:Sorbet and 100% cov makes Ruby refactoring possible by norman784 on Tuesday April 26, 2022 @04:46AM (#31165304)
Rust is getting there, with sqlx[0] you can write plain sql and it gets validated at compile time.

[0]https://github.com/launchbadge/sqlx

Re:Sorbet and 100% cov makes Ruby refactoring possible by pphysch on Tuesday April 26, 2022 @12:44PM (#31169717)
Any language with metaprogramming like operator overloading so you can create an ergonomic ORM, basically.

For such a language to be reasonably productive you want to be able to overload "mystruct.myvar" to not simply grab "myvar" from memory, but smartly fetch it from a remote database, cache it, etc.

It will never be perfect (blah blah impedence mismatch) but a proper ORM is so much more productive and readable than writing crap like `Manager(mystruct).GetAttr("myvar")...` or bespoke SQL composition.

Re:Sorbet and 100% cov makes Ruby refactoring possible by AlchemistCamp on Monday April 25, 2022 @08:51PM (#31162739)
Elixir is great at it and becoming increasingly mainstream.
Re:Sorbet and 100% cov makes Ruby refactoring possible by golergka on Tuesday April 26, 2022 @03:37AM (#31164967)
SQL. Typescript with library like pgtyped basically allows you to write raw SQL queries and then generates all the static typings for them.
Re:Sorbet and 100% cov makes Ruby refactoring possible by mixedCase on Tuesday April 26, 2022 @02:42PM (#31171425)
F# by way of type providers. Many other languages could similarly bridge the gap with codegen.
Re:Sorbet and 100% cov makes Ruby refactoring possible by jatone on Monday April 25, 2022 @09:24PM (#31162956)
> Is Golang "ruthlessly productive" for interfacing with complex relational databases?

neither is ruby lol.

Re:Sorbet and 100% cov makes Ruby refactoring possible by rco8786 on Monday April 25, 2022 @04:39PM (#31160299)
> Ruby is just ruthlessly productive.

This is the best description of Ruby I've ever read.

Re:Sorbet and 100% cov makes Ruby refactoring possible by princevegeta89 on Monday April 25, 2022 @05:03PM (#31160561)
+1. After working on Elixir for a long time I missed the simple ruby way to do things and found myself running in circles to troubleshoot some basic 3rd party libraries. Going back to Ruby for my next side project.
Re:Sorbet and 100% cov makes Ruby refactoring possible by ananthakumaran on Monday April 25, 2022 @09:14PM (#31162887)
Having used both Ruby and Elixir, this is exact opposite of my experience. I would say Elixir/Erlang is one of the best language from observability/debugging perspective. Immutability, per process heap, ability to trace any module/function call in production (recon), remote shell etc make it trivial to debug most of the issues. I have found memory leak in production from 3rd party library in less than 30 minutes. Just looking at the process list sorted by memory will tell which library is leaking (in majority of the cases), as most of the processes has single purpose.
Re:Sorbet and 100% cov makes Ruby refactoring possible by AlchemistCamp on Monday April 25, 2022 @08:53PM (#31162748)
Strange. I like Ruby, but probably the biggest gain I got from moving to Elixir was the comparative ease of debugging.

Its immutability drastically reduces the search space.

Re:Sorbet and 100% cov makes Ruby refactoring possible by princevegeta89 on Tuesday April 26, 2022 @01:02AM (#31164104)
Agree with your point about debugging being easier but in my case I ended up doing a lot of housekeeping for things that are easy in ruby. This time I'm only concerned about the speed of development and ruby to me is the winner
Re:Sorbet and 100% cov makes Ruby refactoring possible by gedy on Monday April 25, 2022 @05:38PM (#31161012)
> Ruby is just ruthlessly productive.

Not disagreeing, but the nuance is productive for writing new code/features. It really feels counter productive once you have a large codebase/team and you need to refactor existing apps.

Spent 5 years at a Rails shop and it's crazy how much engineering effort was spent on keeping this app going. Adding typing seems like a nice step to help here.

Re:Sorbet and 100% cov makes Ruby refactoring possible by klardotsh on Monday April 25, 2022 @06:17PM (#31161473)
Yeah, I disagree with "ruthlessly productive" as a blanket statement because of this. I tend to find that a huge chunk of the time I save at write-time in Ruby (Rails)/Python/etc., I end up repaying at either runtime (nil exceptions) or read/explain-to-other-dev/refactor times, sometimes in multiplicative form (chasing down why something became nil, or a string, or an elephant, but only if the ORM did X, Y, and Z to the DB response, etc. gets ridiculous quickly)
Re:Sorbet and 100% cov makes Ruby refactoring possible by recuter on Monday April 25, 2022 @05:01PM (#31160538)
Well, the go one would compile to an easily deployable binary and actually be able to, you know, count a whole lot of words quickly. But the ruby one is much more terse and quicker to write.

I say we go back to awk and get the best of both worlds:

  '{num+=NF} END{print num+0}'
Re:Sorbet and 100% cov makes Ruby refactoring possible by lambdaba on Monday April 25, 2022 @07:00PM (#31161938)
Ironically half that code (END...) is valid Ruby!
Re:Sorbet and 100% cov makes Ruby refactoring possible by lawl on Monday April 25, 2022 @05:16PM (#31160732)
> Hoping new age compiled languages like Crystal & Nim fill the gap of performance, types & productivity.

Yes, go is verbose at times. But the go language server for example lets you not write a lot of the boiler plate you see there.

E.g. instead of typing out a for loop, i'd just (start) typing `foo.range!`, or for sorting `foo.sort!`.

I'm not going to argue that writing it in go even with those would be more terse, just that I think it looks worse than it is.

Re:Sorbet and 100% cov makes Ruby refactoring possible by folkrav on Monday April 25, 2022 @07:12PM (#31162058)
Yeah the go one looks terrible but then you take a look at it and it's just creating slices, looping over stuff and appending stuff to the aforementioned slices. The syntax is much less expressive, therefore very verbose, but it's basically doing the same thing, without the sugar of being able to inline some of the logic.
Re:Sorbet and 100% cov makes Ruby refactoring possible by latenightcoding on Monday April 25, 2022 @05:01PM (#31160539)
The Perl solution would be significantly smaller tho.
Re:Sorbet and 100% cov makes Ruby refactoring possible by overgard on Monday April 25, 2022 @09:23PM (#31162954)
I dont know if toy examples prove anything about productivity. I never quite understood what makes Ruby more productive. Dynamic types?
Re:Sorbet and 100% cov makes Ruby refactoring possible by norman784 on Tuesday April 26, 2022 @04:49AM (#31165323)
I think is that is has a great standard library + with rails a lot of utilities out of the box, other than that some people just like the syntax.

So said that they standard library is huge, where other languages prefer to have slimmer ones and let the community build the utilities.

Re:Sorbet and 100% cov makes Ruby refactoring possible by cutler on Tuesday April 26, 2022 @06:42AM (#31165826)
Principle of least surprise.
Re:Sorbet and 100% cov makes Ruby refactoring possible by afandian on Monday April 25, 2022 @04:41PM (#31160324)
I've not written Ruby since about 2006 except with a stint in a Rails codebase which did nothing to give me any faith. How do you go about e.g. extracting a group of fields and renaming them? Or reorder function arguments? Is there a static tool that can do this, or do you have to do some kind of text search and hope you got them all?
Re:Sorbet and 100% cov makes Ruby refactoring possible by dymk on Monday April 25, 2022 @04:46PM (#31160373)
There's basically no tool for doing that, aside from relying on tests to tell you a callsite is now incorrect. "find and replace" is... okay, up to a point, but obviously that has its limitations (especially once you start metaprogramming).

That being said, I still love Ruby. I have all sorts of little tools written in it that would have been a pain to do in another language.

Re:Sorbet and 100% cov makes Ruby refactoring possible by afandian on Monday April 25, 2022 @05:23PM (#31160815)
Coming from a Clojure background which is … different. But I understand the enthusiasm around similar language features.

But to borrow words from another comment I find Kotlin “ruthlessly productive”. Apart from the lambdas, functions, data classes and immutably, it’s the ability to quickly and correctly refactor that makes me feel like I can work at speed and try stuff out.

Re:Sorbet and 100% cov makes Ruby refactoring possible by dymk on Monday April 25, 2022 @07:43PM (#31162308)
I wish I could find Kotlin as ruthlessly productive as Ruby, but... I'm having a hard time doing so. It's got nothing to do with the language itself - at work, I really enjoy Kotlin.

Here's where Ruby shines for me: when I'm whipping up a script, I can toss a `Bundler.setup(:default)` at the top of the script, `vim mything.rb`, `$> ruby mything.rb` (or `./mything.rb` if I hashbang at the top), and I'm off to the races.

With Kotlin, it feels like I need to set up a project in IntelliJ, `$> ./gradlew run`, wait 10 seconds for the whole thing to compile, and finally my thing is running.

Is there a streamlined way to run a Kotlin script without building a whole jar, from the command line? I know this is generally not as easy with compiled languages. The D programming language is a notable example that has a "D script" mode (hashbang with `rdmd`), which quickly compiles+runs in a single step.

Re:Sorbet and 100% cov makes Ruby refactoring possible by lbhdc on Monday April 25, 2022 @08:03PM (#31162456)
kotlin has support for being run like a standalone script. I believe the convention is giving them the `.kts` extension.

Here is an example with a shebang https://github.com/Kotlin/kotlin-script-examples/blob/master...

Re:Sorbet and 100% cov makes Ruby refactoring possible by dymk on Tuesday April 26, 2022 @12:22PM (#31169417)
Thank you! The syntax for specifying dependencies was the bit of the missing puzzle piece for me.
Re:Sorbet and 100% cov makes Ruby refactoring possible by Gigachad on Monday April 25, 2022 @07:20PM (#31162120)
The ruby way is you just don’t do that. Or you use named arguments which are unordered.

In most ruby code I have worked with, most non trivial methods use named arguments.

Re:Sorbet and 100% cov makes Ruby refactoring possible by sparker72678 on Monday April 25, 2022 @11:42PM (#31163705)
There are IDEs with this kind of functionality. RubyMine has a fairly robust refactoring tool, for example.
Re:Sorbet and 100% cov makes Ruby refactoring possible by ecshafer on Monday April 25, 2022 @05:00PM (#31160517)
Absolutely agree. Ruby is a great and beautiful language, and Rails is imo the best web framework for getting things done.
Re:Sorbet and 100% cov makes Ruby refactoring possible by RTFM_PLEASE on Monday April 25, 2022 @05:18PM (#31160764)
Rails is frankly a double-edged sword, though. While it helped propel Ruby, and is a great framework, it also seems to have permanently marked the language with a notion that its simply a vehicle for Rails.

Ruby is probably one of the more coherently designed general purpose programming languages (in my opinion, much more so than Python, a language that dominates the industry) but doesn't seem to get much use in that domain, which is a shame.

Re:Sorbet and 100% cov makes Ruby refactoring possible by chris24680 on Monday April 25, 2022 @06:17PM (#31161467)
As a rails developer I really believe if Ruby had at least one more 'Killer App' it would lead to a much healthier overall community.