8 ms·
Ruby already solved my problem
- iagooar 11mo agoRuby 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.
- matltc 11mo agoAgreed. Was looking around for STL files so I could print a ruby and put it on my desk. Glad to see it's getting love on here recently.
- amerine 11mo agoI love this idea!! Any luck finding an STL or at least a 3d model I can convert and copy your idea?
- jonah 11mo agoA quick search returned this: https://sketchfab.com/3d-models/gemstone-pack-68c4ec3dd23247188884243ad8bb2492 https://sketchfab.com/3d-models/gemstone-pack-68c4ec3dd23247... Not _exactly_ the same cut, but might be good enough for you?
- graypegg 11mo agoI gave it a try! I tried to get the odd-ball perfectly circular cut and square dimensions, but I'm mostly just eyeballing it. Haven't tried printing it yet, but I have some nice red filament that I think is going to look good! Here's a screenshot from inside FreeCAD: https://f.toi.sh/rubygem-screenshot.png https://f.toi.sh/rubygem-screenshot.png A nice manifold solid: https://f.toi.sh/rubygem.3mf https://f.toi.sh/rubygem.3mf / https://f.toi.sh/rubygem.stl https://f.toi.sh/rubygem.stl A terrifying non-manifold FreeCAD mess: (requires surface WB) https://f.toi.sh/rubygem.FCStd https://f.toi.sh/rubygem.FCStd
- netghost 11mo agoA long while back I wrote a bunch of articles covering some of the standard library: https://snakeshands.com/series/ruby_standard_library/ https://snakeshands.com/series/ruby_standard_library/ Ruby, and Ruby on Rails is a treasure trove of little handy bits you can use if you just know where to look. I really miss some aspects of ruby (I just don't have a chance to use it these days).
- dmix 11mo agoI'm worried LLMs will make people ignore what's already there and auto generate useless functions instead of using what's there in Ruby/Rails. I've been using Rails for almost 20yrs (on and off) and I can't count the number of times I did something only to find out it was either natively supported in a recent version... or at least a new best practice in modern Rails. You find the same thing with JS to an even higher degree, but there's always 10 options in NPM and they all need to be updated every year otherwise the other 20+ packages you depend on can't be upgraded. There's a stark contrast in maintenance overhead and DX between frontend and server side. Even the rails JS libraries are very stable. Hotwire's Stimulus hasn't had a release since 2023 and it always works just fine. https://github.com/hotwired/stimulus/releases https://github.com/hotwired/stimulus/releases
- pxc 11mo ago> I'm worried LLMs will make people ignore what's already there and auto generate useless functions instead of using what's there in Ruby/Rails. I think you're probably right. But fwiw, as a non-Rubyist who values good style and is recently working in a one-off Ruby codebase, I've found it easy to use LLMs to write Ruby code that is idiomatic and leverages built-ins well. I use ChatGPT 5 Thinking for this, and I don't let it generate any code that I use directly. I ask it about ways to do things, including stuff built-in to the stdlib, and sometimes have it generate 3 or 4 implementations. Then I compare them, consult the language docs or stdlib API docs or the pickaxe book, and choose what seems the most stylish or composable. I then write it out by hand, bearing in mind what I just learned, and see what Rubocop has to say about its style. I wouldn't say LLMs have been essential in this, but they've been pretty convenient. Because Ruby has relatively a lot of special syntax, it's also nice to be able to inquire directly about the meaning of some syntax in a bit of generated code-- especially when it involves characters that are (for some reason) ungoogleable, like an ampersand. I think people who use LLMs to generate code and people that embrace agentic coding AIs and "vibe coding" will absolutely fall into the pattern you describe. But RTFMers and developers who care about craftsmanship will probably use LLMs as another discovery mechanisms for the stdlib, popular Gems, and popular style conventions.
- c-hendricks 11mo agotitle is actually "Ruby already solved my problem"
- throwaway81523 11mo agoThanks, that helped. My unspoken question when I saw the title was "does that mean you now have two problems?".
- adverbly 11mo agoIf 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!
- jnovek 11mo agoI love writing Ruby. It’s one of the most pleasant and elegant languages I’ve used… but the footguns it comes equipped with rival those of Perl.
- ajoski9 11mo agoAgreed. Also pretty to look at IMHO
- IshKebab 11mo agoBut awful to navigate - the terse syntax combined with lack of static types and regular use of generated identifiers turns large codebases into Where's Wally. Good luck finding where the `process` function is called from. You can't even search for `process(` like you can in most languages.
- 15155 11mo agoYou can search for "def process" - it's inheritance and metaprogramming that make finding the underlying implementation difficult.
- Someone 11mo ago>> Good luck finding where the `process` function is called from. You can't even search for `process(` like you can in most languages. > You can search for "def process" That tells you where it is defined, not where it is called from.
- lloeki 11mo 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/4e4d2b32353c8ded870c149f45fa401c89a11479/lib/rubygems/core_ext https://github.com/ruby/rubygems/tree/4e4d2b32353c8ded870c14...
- dragonwriter 11mo agoNitpicking your nitpick, but Ruby’s standard library has three components: * default libraries (these are maintained by the Ruby core team, delivered with Ruby, and upgraded only as part of Ruby version upgrades.) * default gems (these are maintained by the Ruby core team, delivered with Ruby, not removable, can be required directly just like default libraries, but can be updated separately from Ruby version upgrades.) * bundled gems (these are gems that are delivered and installed with Ruby, but which can be upgraded separately or removed.) Rubygems is a default gem. [0] It used to not be part of the standard library, but it has been since Ruby 1.9, released in 2007. [0] see, https://stdgems.org/ https://stdgems.org/
- zahlman 11mo agoFrankly I wish Python's standard library were more like this. Maybe then we wouldn't be seeing tens of millions of daily downloads of pip (most likely orchestrated by other copies of pip!), requests (already vendored by pip!), setuptools, six (compatibility wrappers for ancient 2.x code, declared as a dependency by python-dateutil so that it can keep supporting 2.x, even though it's overwhelmingly downloaded for up-to-date Python installations).... ...There are presumably many other ways to solve that problem, but still.
- dragonwriter 11mo agoWhen Ruby gemified the standard library, it wasn't about moving popular third-party libs into the standard library as gems, but making large parts of the standard library separately updateable (and, in some cases, removeable); all of the standard library used to be the equivalent of "default libraries", the change was moving them from that status to default or bundled gems. So, doing the same thing with Python would be less like bundling requests with python and more like moving http into a wheel that was installed with python but could be upgraded separately.
- skrebbel 11mo agoUnrelated 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.
- vault 11mo agoLike you, I remember 15 years ago when I decided to solve Project Euler in Ruby, a completely new language to me. I still remember the joy I was feeling when I started coding with this new language. So elegant! So natural! Like it was made to fit my brain. It's a pity I ended up working professionally with entirely different stuff.
- js2 11mo agoChallenge accepted: from dataclasses import dataclass @dataclass(frozen=True, order=True) class AppVersion: major: int = 0 minor: int = 0 patch: int = 0 @classmethod def from_string(cls, version_string: str): return cls(*[int(x) for x in version_string.split(".")]) def __str__(self): return f"{self.major}.{self.minor}.{self.patch}" Before dataclasses you could've used namedtuples, at a loss of attribute typing and default initializer: from collections import namedtuple class AppVersion(namedtuple("AppVersion", "major minor patch")): @classmethod def from_string(cls, version_string: str): parts = [int(x) for x in version_string.split(".")] + [0, 0] return cls(*parts[:3]) def __str__(self): return f"{self.major}.{self.minor}.{self.patch}"
- aldousd666 11mo agoI 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!
- psadauskas 11mo agoI use it quite a bit when I have to monkeypatch a gem to backport a fix while I wait for a release: raise "check if monkeypatch in #{__FILE__} is still needed" if Gem::Version.new(Rails.version) >= Gem::Version.new("8.0.0") This will blow up immediately when the gem gets upgraded, so we can see if we still need it, instead of it laying around in wait to cause a subtle bug in the future.
- saghm 11mo ago> They were practically throwing stuff when I got there and explained that lexicographical comparison of the strings would not work. Versions numbers can go to 10!?!
- shevy-java 11mo ago> I discovered this a few years ago Right. I think I found it on stackoverflow. The question is: why does the official documentation not mention this, along with guides? Answer: because documentation is something the ruby core team does not want to think about. It is using scary language after all: English. The bane of most japanese developers. Plus, it is well-documented in Japanese already ... :>
- stefan_ 11mo agoAaand 10 years later you just learned to compare versions by equality instead of being impossibly clever.
- parentheses 11mo agoI 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 https://docs.python.org/3/library/index.html The benefit there is that their quality, security, completeness and documentation are all great!
- matusp 11mo agoIf I would get a cent every time I solved a difficult problem in a project by pulling out difflib and shocking the team with it, I would have two cents. It's not a lot, but it's amusing that it happened two times already.
- zahlman 11mo ago"STL" is not an abbreviation for "standard library". It doesn't even correctly refer to the C++ standard library; that's a misnomer. There was only one STL, and it was third-party; saying "Python's STL" makes barely any more sense than saying "Python's Boost". https://en.wikipedia.org/wiki/Standard_Template_Library https://en.wikipedia.org/wiki/Standard_Template_Library
- 123sereusername 11mo ago[dead]
- deleted 11mo ago[deleted]
- websitescenes 11mo agoDamn, I miss ruby and particularly Rails sooo much. I'm stuck rebuilding wheels in node currently :)
- Bergrebell 11mo agoGoing back to rails after all this JS years was the best decision we’ve ever made. Current state of rails is lit!
- jaredcwhite 11mo agoRuby 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.
- kazinator 11mo agoTXR 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 11mo agoThese objects can be inserted into a hash table, and are keyed by their semantic value, not the string: 1> (hash) #H(()) 2> *1 #H(()) 3> (set [*1 (new (app-ver "1.2.3.0004"))] 'mapped) mapped 4> *1 #H(() (#S(app-ver str "1.2.3.0004" vec (1 2 3 4)) mapped)) 5> [*1 (new (app-ver "1.2.3.4"))] mapped 6> [*1 (new (app-ver "1.2.03.4"))] mapped 7> [*1 (new (app-ver "1.2.02.4"))] nil
- frostyel 11mo ago[dead]
- PufPufPuf 11mo agoToday 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.
- jbverschoor 11mo agoJust not the same. And yes.. without ecosystem/libraries, everybody’s just creating their own thing over and over again and there’s not a coherent way of thinking The Joy of Ruby
- PufPufPuf 11mo agoRuby developers truly are a special breed. I once spent a few months in a Ruby company, so I'm speaking from experience. Debugging anything in Rails creates strong feelings, but I wouldn't describe them as "joy".
- jbverschoor 11mo agoFully agree. The same can be said about JavaScript. Too many hashmaps being used where you should just use a class?
- another_twist 11mo agoI wish I was in the Ruby camp. Unfortunately the learning curve is quite high, you kinda have to know what you are doing from a language standpoint. I am more of a Java nerd myself and for me the cost of switching to any other language is simply not justified. But every now and then, I do get fomo.