News for hackers. Stuff that matters.
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.