News for hackers. Stuff that matters.
Re:Ruby Is Still a Diamond by WJW on Thursday September 02, 2021 @09:33AM (#28391776)
Ruby occupies a similar space to Golang in my mind, where it is "just" a solid business oriented language that gets out of your way. It will never wow you like Rust or Haskell and that is fine, because that is not what it is aiming for. Rails is one of best DSLs for writing simple SAAS apps, too.

That said, different usecases require different languages. I would never use Ruby for a compiler project.

Re:Ruby Is Still a Diamond by nixpulvis on Thursday September 02, 2021 @09:46AM (#28391922)
I still get a real kick out of Ruby's elegant and powerful metaprogramming, which is something other languages don't often compare to.

    class String

      def colorize(color_code)
        "\e[#{color_code}m#{self}\e[0m"
      end
    end
The general advice is to avoid confusing others though, so changing base classes like this is not really a business-safe idea.
Re:Ruby Is Still a Diamond by sealthedeal on Thursday September 02, 2021 @10:17AM (#28392313)
I do love this. The ability to change base classes so easily is such a "With great power comes great responsibility" lol.
Re:Ruby Is Still a Diamond by slx26 on Thursday September 02, 2021 @09:56AM (#28392041)
And besides general craziness and DSLs as pointed above, you can also easily experiment with relatively complex language-level constructs, like derived attributes or cacheable functions [talked a bit about it here https://news.ycombinator.com/item?id=22338923].

Trying to make such experiments safe in Ruby would be unwise, but starting them in Ruby is happiness.

Re:Ruby Is Still a Diamond by agumonkey on Thursday September 02, 2021 @10:20AM (#28392364)
That's pretty smalltalkish, also with the trend of extension functions you get that more often these days. I remember doing such things in kotlin. Maybe not perfect for large projects but a real pleasure for developpers.
Re:Ruby Is Still a Diamond by sadfev on Thursday September 02, 2021 @10:27AM (#28392466)
Ruby is Smalltalk becoming successful. Ruby meta programming is very nice. Ruby is OO both internally and externally. Unlike Python which doesn’t feel very OO.
Re:Ruby Is Still a Diamond by blacktriangle on Friday September 03, 2021 @09:46AM (#28404173)
Ruby is Smalltalk jettisoning everything that makes Smalltalk awesome.
Re:Ruby Is Still a Diamond by matsemann on Thursday September 02, 2021 @10:25AM (#28392439)
What's nice about extension functions in Kotlin is that they are statically imported. So you're not really modifying the class, and there is no danger of collisions (like it was when people monkey-patched javascript built-ins back in the day).
Re:Ruby Is Still a Diamond by modal-soul on Thursday September 02, 2021 @10:34AM (#28392578)
Ruby's refinements sound somewhat similar; they let you scope your monkey-patches.
Re:Ruby Is Still a Diamond by bitwize on Thursday September 02, 2021 @11:03AM (#28392933)
A major difference between Smalltalk and Ruby is that in Smalltalk, the live system knows its own source code, and you program through the live running system. Ruby doesn't really do this, it's more of a scripting language with Smalltalk semantics. Ruby source reads like Monticello changesets, a suboptimal format for exploring and modifying a dynamic object system.
Re:Ruby Is Still a Diamond by burlesona on Thursday September 02, 2021 @10:47AM (#28392714)
Supposing you need to do this kind of stuff a lot, one fairly nice workaround is to subclass the base class and then use that subclass when you need added mutative and/or chain able functionality.

The drawback in this case is it's not as concise as just typing in a String literal :)

Re:Ruby Is Still a Diamond by shagie on Thursday September 02, 2021 @09:52AM (#28391979)
Is there a good way to verify that all of the code is business-safe?
Re:Ruby Is Still a Diamond by nixpulvis on Thursday September 02, 2021 @09:53AM (#28391995)
Delete it? Otherwise no.

But this is true of any language. The truth is in the middle ground.

Re:Ruby Is Still a Diamond by shagie on Thursday September 02, 2021 @09:58AM (#28392075)
It's not entirely true of any language.

In Java, for example, one can do static analysis and identify when a class is doing reflection... and flag as an error if the class is doing reflection on a class that is an instance of java.something.

Re:Ruby Is Still a Diamond by bradstewart on Thursday September 02, 2021 @11:36AM (#28393374)
How do you define "business safe"? Java won't prevent you from sending a message to the wrong customer or something like that.
Re:Ruby Is Still a Diamond by shagie on Thursday September 02, 2021 @12:44PM (#28394284)
I can look at the code and see if anyone is doing:

        Class cache = Integer.class.getDeclaredClasses()[0];
        Field c = cache.getDeclaredField("cache");
        c.setAccessible(true);
I can examine to see that java.lang.{something} class is getting reflected on. I can check to see if anything is calling getDeclaredField and flag that. I can see the setAccessible and really flag that.

This isn't about coding errors. This is about being able to analyze the code and see if the code is using prohibited methods.

Through static analysis, I can verify if anyone is trying to do something tricky with the String class.

Can I verify if a method is being modified added to an instance of a String in Ruby through static analysis?

Re:Ruby Is Still a Diamond by WJW on Thursday September 02, 2021 @02:54PM (#28395887)
I don't know of anyone actually doing that, but all the code is right there. You could probably wrangle the linter into checking those things if you really want to. That said, many Ruby frameworks rely on being able to dynamically add methods to classes at runtime so I don't think such a thing would be all that beneficial.
Re:Ruby Is Still a Diamond by JohnWhigham on Thursday September 02, 2021 @09:42AM (#28391864)
Go has Google support behind it though. Its journey is far from over (that is, until Google abandons it for another language), whereas Ruby's/Rail's growth phase is more than a decade behind us, and it's hard to know what its future holds. I hope it's a good one since I've been doing Rails my whole career.
Re:Ruby Is Still a Diamond by MattGaiser on Thursday September 02, 2021 @09:59AM (#28392076)
FWIW, I had a call with a recruiter a couple days ago who claimed that the most expensive candidates to find at the moment are Rails people.

And I'm not a Rails person, so it wasn't flattery.

Re:Ruby Is Still a Diamond by throw_m239339 on Thursday September 02, 2021 @10:19AM (#28392357)
> FWIW, I had a call with a recruiter a couple days ago who claimed that the most expensive candidates to find at the moment are Rails people.

Maybe in USA. In Europe, Rails has been far less popular. Now I imagine expensive candidates means the ability to work on decade old Rails codebases from previous versions, which means with a lot of Rails experience.

Re:Ruby Is Still a Diamond by MattGaiser on Thursday September 02, 2021 @10:25AM (#28392434)
Specifically asked about this. Mixture of old codebases and new.

Half the companies using it are 1-2 years old according to him. Lots of 10 person startup teams just fresh off a raise.

Re:Ruby Is Still a Diamond by JohnWhigham on Thursday September 02, 2021 @10:13AM (#28392262)
I've noticed that as well, that senior Ruby/Rails people will become very valuable in the coming years, which is good to hear. However, 10+ years into the future is the real scary part. Will jobs dry up so much so (especially due to the accelerating pace of tech turnover) that Ruby/Rails will essentially become the FORTRAN of the times? Who knows.
Re:Ruby Is Still a Diamond by chipotle_coyote on Thursday September 02, 2021 @12:10PM (#28393838)
Not so long ago, before the rise of Node.js and when it seemed like Rails was The Way of the Future (tm) and everyone was really down on PHP, I used to joke that there was a silver lining to PHP becoming the next COBOL: there weren't many COBOL jobs around, but there also weren't many COBOL programmers around, and if you needed a COBOL programmer the chances were that you really needed a COBOL programmer.

As things have played out, PHP has done pretty well at modernizing (I know some would debate that, but that's a different thread), and Rails has faded a bit into the background -- although now I joke that because Rails is well out of its fad phase, it can get down to the real work.

I do wonder whether Rails has been kind of a mixed blessing for Ruby all in all, though. I think Ruby is, in itself, a great alternative to Python or Perl, and it's the language I reach for first when I'm writing short utility scripts -- but since Rails exploded in popularity before Ruby itself did, a lot of Ruby programmers really only know Ruby to the degree they know Rails.

Re:Ruby Is Still a Diamond by dragonwriter on Thursday September 02, 2021 @12:14PM (#28393889)
> a lot of Ruby programmers really only know Ruby to the degree they know Rails

This so bad that frequently I see “Ruby on Rails” in lists of programming languages aside “PHP”, or “Elixir”, or “JavaScript”.

(When I was most in to Ruby – but not so much Rails, even then – there was actually a palpable divide in the community between the Rails-only community and the broader Ruby community, some of which was Rails-inclusive.)

Re:Ruby Is Still a Diamond by MattGaiser on Thursday September 02, 2021 @12:20PM (#28393957)
Granted, I have never used it a lot except for hacky projects, but I have never used any Ruby except in the context of Rails. Is it really used for anything else?
Re:Ruby Is Still a Diamond by JohnWhigham on Thursday September 02, 2021 @12:38PM (#28394203)
Yeah Rails is definitely a blessing and a curse. I only know of Chef and Puppet being kinda big, but both of those are waning in popularity.
Re:Ruby Is Still a Diamond by joelbluminator on Thursday September 02, 2021 @10:34AM (#28392574)
Unlikely. To this day Rails is still being chosen for new projects. I see it for example in HackerNews job postings. You can see the company's tech and year of founding so you know it is new startups. Sure, its not close to how popular it used to be, but definitely not dying. And then what about all the existing code? There is a lot. I think Rails has its place and is still good at what it does, a segment of the population will continue loving working with it.
Re:Ruby Is Still a Diamond by MattGaiser on Thursday September 02, 2021 @10:28AM (#28392491)
Do companies care about about tech turnover?

I have friends everywhere from FAANGMULA to Deloitte to 100 person tech startups (and I am at one myself)to banks. We have a group chat of classmates.

No attempts to stem the wave of resignations anywhere as far as we can tell.

Re:Ruby Is Still a Diamond by mchusma on Thursday September 02, 2021 @10:00AM (#28392094)
Stripe, Shopify, and others are contributing. They are large enough to provide some large corporate assurance, if that is what you are looking for.
Re:Ruby Is Still a Diamond by bastardoperator on Thursday September 02, 2021 @11:15AM (#28393076)
Don't forget Square, GitHub, Airbnb, Bloomberg, Zendesk...
Re:Ruby Is Still a Diamond by bfung on Thursday September 02, 2021 @11:12AM (#28393039)
While not widely advertised, matz works at heroku, which was acquired by salesforce for more than 10 years now. In essence, Ruby is supported by Salesforce.
Re:Ruby Is Still a Diamond by Mikeb85 on Thursday September 02, 2021 @11:38AM (#28393410)
Google abandons as much as they support.

The Ruby and Rails ecosystem has Stripe, Shopify, GitHub actively pushing new things all the time, DHH and co working on version 7 right now, etc...

Re:Ruby Is Still a Diamond by danjac on Thursday September 02, 2021 @11:07AM (#28392975)
> until Google abandons it

Given Google's track record I'm not sure that's the most reassuring argument...

Re:Ruby Is Still a Diamond by fomine3 on Thursday September 02, 2021 @10:19PM (#28399743)
Ruby is for handful hacking lang for me like old days Perl. It seems that thoughts who learned Ruby for production Rails app vs learned Ruby for hack is very different.

Python is also great but I still wish Ruby is installed everywhere for writing one-liner since Python isn't good for that.

Re:Ruby Is Still a Diamond by sadfev on Friday September 03, 2021 @08:29PM (#28410989)
I also think Ruby should be the natural successor to peel on all *Nix systems.

Ruby is ridiculously useful. Python edges it out for scientific/engineering applications because of Scipy and now Machine Learning ecosystem.

Re:Ruby Is Still a Diamond by thealienthing on Thursday September 02, 2021 @11:35AM (#28393372)
I've felted wowed in theory by Rust but every time I come to it, I'm constantly getting stuck by how much the compiler gets in my way. On one hand, the idea that the compiler is your friend that stops you from making dumb memory decisions unlike in c++. But with Rust, I can't get even simple tasks done which really frustrates me. Perhaps Go might be a language to checkout if it "gets out of your way" as you say.
Re:Ruby Is Still a Diamond by joelbluminator on Thursday September 02, 2021 @10:17AM (#28392303)
What is the wow with Rust? Seriously asking.
Re:Ruby Is Still a Diamond by nobleach on Thursday September 02, 2021 @10:29AM (#28392500)
A few things come to mind. Rust has the potential to be fast... VERY fast. It also can be very safe. Pretty much everything in Rust utilizes the Result type (an Either Monad that causes Errors/Exceptions to become first-class citizens). It compiles to a single binary. Many of the packages in the ecosystem are very high-quality (Serde for example).

Even still, this doesn't mean anyone should drop what they're doing and migrate all their code to Rust! If you're a Ruby dev (especially if you do Rails) and you're making a living churning out apps with your good old friends like Devise, RSpec, etc. Rust is probably not the thing that'll really wow you. It _can_ do web, and do it REALLY well. But the experience is very different. (Actix/Rocket)

Re:Ruby Is Still a Diamond by zdragnar on Thursday September 02, 2021 @12:26PM (#28394053)
> Rust has the potential to be fast... VERY fast

I think this should be phrased differently. There is a minor bloom of zero-allocation web frameworks in go and java, and probably a few others, which blow their peers out of the water and are horribly not at all idiomatic usages of the languages.

They can be very fast, but the performance cliff for using idiomatic code is very significant.

Does idiomatic rust perform VERY fast? Can it be both very safe AND very performant? I think the answer to both of those is yes, but I honestly haven't used it enough to know.

Re:Ruby Is Still a Diamond by joelbluminator on Thursday September 02, 2021 @10:59AM (#28392896)
So Rust wants to be the new C? Like if someone was writing a new OS or code for an autonomous vehicle today is Rust a likely candidate?
Re:Ruby Is Still a Diamond by mping on Thursday September 02, 2021 @11:33AM (#28393342)
Rust wants to be the new C without C warts, using the compiler to ensure memory safety (up to a point), promoting immutability and having generics baked in.

I'm not a C programmer, but I think Rust can fit almost everywhere C can fit.

Re:Ruby Is Still a Diamond by unrealhoang on Thursday September 02, 2021 @10:40AM (#28392642)
The ability to use mutable data structure with worry-free mentality of immutable data structure (FP langs) is really new and special.
Re:Ruby Is Still a Diamond by joelbluminator on Thursday September 02, 2021 @10:57AM (#28392855)
So its a functional language with good performance? Or a systems functional language?
Re:Ruby Is Still a Diamond by closeparen on Thursday September 02, 2021 @01:13PM (#28394666)
Rather than designing around shared mutable state like a functional language, it gives you the tools to do it with greater confidence.
Re:Ruby Is Still a Diamond by azangru on Thursday September 02, 2021 @10:29AM (#28392510)
Yeah, I was wondering about that as well. Maybe the parent comment meant the practical implications, such as C-like speed with memory safety? As a language, Haskell has much more wow in it.
Re:Ruby Is Still a Diamond by joelbluminator on Thursday September 02, 2021 @10:58AM (#28392876)
Does it have C like speed though? Have no idea. I guess I just don't care enough about performance for Rust to be a thing for me.
Re:Ruby Is Still a Diamond by qsort on Thursday September 02, 2021 @11:24AM (#28393204)
I don't really use Rust so YMMV, but what's genuinely special about it is that it's a new take on a system-level language with very modern features (Error monad, borrow checker, pattern matching, functional-like semantics) that were previously exclusive domain of garbage collected languages.

Honestly I kind of cringe at the "do everything in rust" crowd, if you need to, say, write an API, you can just do that in Python or Ruby or Go, 99% of the times the performance penalty won't matter and Rust is just a very complicated tool for that job.

But it single-handedly reopened the discussion on high performance, safe(r) languages, and I believe that's a very good thing even though I don't use Rust day-to-day. Projects like Zig are in a sense following in the footsteps of Rust.

Re:Ruby Is Still a Diamond by Mikeb85 on Thursday September 02, 2021 @11:41AM (#28393457)
Systems programming language that's safer than C++, just as performant and has lots of functional goodies.
Re:Ruby Is Still a Diamond by bitwize on Thursday September 02, 2021 @11:00AM (#28392901)
Go is not a business oriented language. To be a business language, you need a decimal data type built in (or in the standard library), that doesn't make you go through hoops like this:

    total = new Decimal(principal);
    total.mul(1.0 + interest);
In other words decimals support the same operations as the rest of the language's numeric tower. Go doesn't have this.

Go is a networking language. It's good for writing microservices and network protocol clients and servers. That's about it.