Ruby already solved my problem

joemasilotti | 251 points

If you ignore performance and mathematical elegance and safety and just look at how much a language lets you get away with from a productivity standpoint, I think Ruby is a pretty standout winner and nobody else even comes close really...

Very clear APIs and syntax(with the possible exception of blocks which can be weird because they aren't quite functions), and tons of raw metaprogramming powers.

You can argue it sacrifices too much of the other things to deliver on these things, but it's hard to argue against it doing well at what it optimizes for!

adverbly | a day ago

Ruby has a lot of these hidden gems (pun intended).

I wouldn't be as much in love with programming, if it wasn't for Ruby. And although I use many other programming languages these days, Ruby will forever have a special place in my heart.

iagooar | a day ago

Unrelated side note, but I haven't written any Ruby in maybe 15 years or so and dammn I forgot how elegant the language is at its core. The author's AppVersion class is so nicely done, it's nuts how succinct eg the compare implementation is.

Having done mostly TypeScript and Elixir lately, I had forgotten things could be so succinct yet so clear. The combo of modern (to me) Ruby's lambda syntax (in the .map call), parentheses-less function calls, the fact that arrays implement <=> by comparing each item in order, that there's an overloadable compare operator at all, having multiple value assignments in one go... It all really adds up!

In any other language I can think of real quick (TS, Elixir, C#, Python, PHP, Go) a fair number of these parts would be substantially more wordy or syntaxy at little immediately obvious benefit. Like, this class is super concise but it doesn't trade away any readability at all.

Having learned Ruby before Rails became commonplace, with its love for things that automagically work (until they don't), I had kinda grown to dislike it. But had forgotten how core Ruby is just an excellent programming language, regardless of what I think of the Rails ecosystem.

skrebbel | a day ago

> it’s built into Ruby!

Nitpick: technically `Gem::Version` is part of `rubygems`, and while `rubygems` is (typically) packaged with Ruby, it's actually entirely optional, so much so that `rubygems` actually monkeypatches† Ruby core's `Kernel` (notably `require`) to inject gem functionality.

MRuby has none of it, and CRuby has a `--disable-rubygems` configure flag.

Back in 1.8 days, you even had to manually require `rubygems`!

https://github.com/ruby/rubygems/tree/4e4d2b32353c8ded870c14...

lloeki | a day ago

Ruby is an awesome language. The first few 3.x releases brought incredible modern advancements, including pattern matching which I totally adore.

I'd love to see a lot more writing and advocacy around Ruby, and not Ruby/Rails. I don't use Ruby/Rails! I use Ruby. And I suspect a lot of folks who have left Ruby behind over the years might not realize some (many?) of their gripes are not with Ruby in general, but Rails in particular.

jaredcwhite | 20 hours ago

TXR Lisp:

  $ txr -i version.tl
  1> (equal (new (app-ver "1.2.003")) (new (app-ver "1.2.3")))
  t
  2> (equal (new (app-ver "1.2.003")) (new (app-ver "1.2.4")))
  nil
  3> (less (new (app-ver "1.2")) (new (app-ver "1.2.3")))
  t
  4> (greater (new (app-ver "1.2")) (new (app-ver "1.2.3")))
  nil
  5> (tostringp (new (app-ver "1.2.3.4")))
  "1.2.3.4"
  6> (tostring (new (app-ver "1.2.3.4")))
  "#S(app-ver str \"1.2.3.4\" vec (1 2 3 4))"
Code:

  (defstruct (app-ver str) ()
    str
    vec
    (:postinit (me)
      (set me.vec (flow me.str (spl ".") (mapcar int-str))))
    (:method equal (me) me.vec)
    (:method print (me stream pretty-p)
      (if pretty-p (put-string `@{me.vec "."}` stream) :)))
kazinator | 20 hours ago

Going back to rails after all this JS years was the best decision we’ve ever made. Current state of rails is lit!

Bergrebell | 20 hours ago

Damn, I miss ruby and particularly Rails sooo much. I'm stuck rebuilding wheels in node currently :)

websitescenes | 21 hours ago

title is actually "Ruby already solved my problem"

c-hendricks | a day ago

I discovered this a few years ago when someone who didn't understand what semver is was trying to do a rails version upgrade for us. They were practically throwing stuff when I got there and explained that lexicographical comparison of the strings would not work. I was about to write my own class for it, but then I thought that since Bundler knew how to resolve deps we should see what it uses. The rest is history!

aldousd666 | 21 hours ago

Today we're praising Ruby for... having a version parsing utility in the standard library? Really? Many languages like Python, C#, even PHP have it too.

PufPufPuf | 2 hours ago
[deleted]
| 21 hours ago

[dead]

frostyel | 17 hours ago

[dead]

123sereusername | 21 hours ago

I think this article is funny. Python's STL is way more useful and contains myriad useful things that Ruby lacks out of the box.

difflib is probably my favorite one to cite.

Go see for yourself: https://docs.python.org/3/library/index.html

The benefit there is that their quality, security, completeness and documentation are all great!

parentheses | 21 hours ago