Live data from Hacker News

Ruby's exceptional creatures

exceptionalcreatures.com

71–80 of 133 posts

Re: Ruby's exceptional creatures

#71
post #61

Earlier quoted context omitted.

Python is so much bigger than Ruby. It's not just machine learning. There's also numpy and Jupyter for the scientific community, which are huge. There's arcade for making 2D games. There's Micropython for microcontrollers. There are async database drivers and web frameworks. There's interop for many other programming languages, and it's really easy to make a distributable package with Python runtime included. And tha…

Yes, it is only machine learning. Trying to separate it from the scientific community is creating a wall that does not exist. Besides, barely anyone uses python for 2d games or microcontrollers (out of hobbyist programs, and ruby also has a stack there with mruby or dragonruby, which have professional adoption mostly in japan), and you can't say with a straight face that python is a meaningful player in the Web appli…

> Yes, it is only machine learning. Trying to separate it from the scientific community is creating a wall that does not exist.

What? 99% of science has nothing to do with machine learning. Jupyter is used in a million different environments such as pure mathematics or computational chemistry where machine learning is almost completely absent.

> and you can't say with a straight face that python is a meaningful player in the Web application space, beyond its niche

According to the 2023 Stack Overflow Developer Survey[1], Django is more than twice as widely used as Ruby on Rails.

[1] https://survey.stackoverflow.co/2023/

Re: Ruby's exceptional creatures

#72

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

I definitely prefer Clojure/Elixir-style macros to Ruby’s meta-programming features. They’re still better than nothing, though. Method-mossing and friends played a critical role in making a framework like Rails possible in Ruby. In contrast, languages like Python and JavaScript just aren’t quite expressive enough to do it. A lot of energy went into attempts over the years, too! At best, something like Sails could get…

python has `__getattr__` (and a lot of other dunder magic), what is still missing? With named arguments and (kw)args, there is even more ergonomic magic I think. And django's orm also has similar magical abilities as activerecord.

I think a lot of the metaprogramming abilities Python has are just used less often than in Ruby. Not because it is less expressive, but because it has a culture of simplicity whereas brevity and generality are more valued in Ruby (Rails) culture.

Re: Ruby's exceptional creatures

#73
post #68

Earlier quoted context omitted.

This is more or less personal preference though. When you say that Ruby ignites a passion for coding for you then that might not happen for other people. For example I only feel a headache when I look at Ruby code. For context: I worked with C, C#, some Python and now mostly work in Go.

How often do you see people describe that kind of passion for Python? Maybe for lisps, Erlang, Haskell, Smalltalk. It may well put some people off, that's fine, but personally I dread it when I have to work with languages that don't instill that kind of passion. There are plenty of things I'd like to be different about Ruby and the tooling, but with Ruby I feel like I'm crafting something that at least has the potent…

> How often do you see people describe that kind of passion for Python?

It's part of modern science/technology culture to indiscriminately hate the most widespread things.

Personally, I find Python simply amazing and delightful to work with. And I consider its syntax, especially semantic indentation which eliminates so much visual noise, to be the best among all languages that ever achieved widespread adoption.

Re: Ruby's exceptional creatures

#74

Earlier quoted context omitted.

The biggest difference between both is mainly their machine learning story but if you don't intend to go in it (this is a very specific career choice), I'd say both are equally good options. I'd say both are pretty bad at performance critical tasks or UI stuff where usually you would use neither of those.

Python is so much bigger than Ruby. It's not just machine learning. There's also numpy and Jupyter for the scientific community, which are huge. There's arcade for making 2D games. There's Micropython for microcontrollers. There are async database drivers and web frameworks. There's interop for many other programming languages, and it's really easy to make a distributable package with Python runtime included. And tha…

Most people are not going to run into most of those, whether or not they use Python. They are niches. Sure, Python is more widespread, but it's still only one of many.

"Nobody" uses Python for 2D games. "Nobody" uses Ruby either, but there's Dragonruby (write once, deploy to Windows, Mac, Linux, Web Assembly, iOS, Android, Nintendo Switch, XBOX One, and PS4).

There's interop for many other programming languages, including several options for embedding Python code in Ruby (and the reverse). I've come across Ruby embedded more places than I've come across embedded Python (the number of companies I've come across both are in the single digits).

But ultimately it doesn't matter. If you pick jobs based on currently used languages rather than what you want to work on, you're painting yourself into a corner with either language.

Re: Ruby's exceptional creatures

#75

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

In every language without method_missing or equivalent, people end up writing custom dispatch based on message values sooner or later, sometimes re-implementing full method dispatch, and occasionally a full inheritance mechanism in the process.

If the set of messages you need to handle dynamically is to only ever be small, define_method() is the better choice, but when it is not, I'll take careful use of method_missing over some monstrosity that ends up emulating the same machinery with lots of extra code any day.

If you struggle with debugging due to method_missing, consider reviewing how you debug code, as it wouldn't even make my top ten of debugging challenges in the Ruby code I've worked on in the last 17 years of daily Ruby use.

Re: Ruby's exceptional creatures

#76

Earlier quoted context omitted.

Do you mean the class << self pattern?

That's what I thought as well. If someone's opening metaclasses to define singleton methods they probably know all about the Ruby object model. I don't see how it could be done "without knowing you're doing so".

The people who did it first did understand the meta model.

Unfortunately some people started following without full understanding. I wasn't at forefront of things back then, so I only noticed when the people who did know better started to writing about abuse of this technique.

Re: Ruby's exceptional creatures

#77

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

These days (years) I work mostly in Java and would love to have method_missing or define_method. Of course I can do everything I want without them, but it's not fun.

Re: Ruby's exceptional creatures

#78
post #41

Ruby is a good gateway to programming, better than C, C++, Java, Python,...

Better than Python? 15 years ago I would have agreed. Today, Python is a "gateway" to programming that is also the real thing. It's like one of those old languages designed for beginners to learn coding... and then you can continue to use the same language for your entire professional career as a software engineer, to build just about any production-ready application. Ruby is a beautiful language, but unless you are…

I wish Python had a bit of this thing (love?) that Ruby has, though...

Re: Ruby's exceptional creatures

#79
post #25

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

One rule I try to go by, and I feel like this should be a pretty moderate take but isn't actually that commonly stated: If we're talking about Rails at least, then meta-programming/magic/indirection, all that should be very rare in application code. It makes sense sometimes in more abstract libraries, where you have to handle flexible problems, but in application code it's really worthwhile to just be straightforward…

Rails, to me as someone who loves Ruby and use it for "everything" (including my editor, terminal, window manager), is a poster-child for poorly written Ruby.

It creates code bases that seems to have a tendency to turn into sprawling messes. I appreciate that it has driven a lot of people to Ruby, and in that way it's an amazing and impressive success, but recruiters get it somewhat right for the wrong reason when they sometimes list Rails as a "language".

I'm very happy to use "magic" in Ruby, but it should be high-impact, low code, and contained. E.g. I'm very comfortable with the "magic" in my window manager that turns event classes received from the X11 binding into method call on a target class, so that MotionNotify turns into target.on_motion_notify(event) without me having to specify every event class. It's simple, small, and let me cut a lot of code.

A lot of non-Rubyists would hate it, though.

The irony, though, about your complaint is that Rails code is some of the most verbose Ruby code you'll find, because it's geared at making cookie cutter creation of sites easy, and so a lot of patterns involve an excessive separation into vast amounts of low-impact, verbose classes that do way too little (the obsession with some Rails devs of writing "service classes" for things that should just have been a single method, for example, drives me crazy - yes there are valid uses of service classes, no almost no uses of them in Rails apps are reasonable)

Re: Ruby's exceptional creatures

#80
post #73
post #68

Earlier quoted context omitted.

How often do you see people describe that kind of passion for Python? Maybe for lisps, Erlang, Haskell, Smalltalk. It may well put some people off, that's fine, but personally I dread it when I have to work with languages that don't instill that kind of passion. There are plenty of things I'd like to be different about Ruby and the tooling, but with Ruby I feel like I'm crafting something that at least has the potent…

> How often do you see people describe that kind of passion for Python? It's part of modern science/technology culture to indiscriminately hate the most widespread things. Personally, I find Python simply amazing and delightful to work with. And I consider its syntax, especially semantic indentation which eliminates so much visual noise, to be the best among all languages that ever achieved widespread adoption.

> It's part of modern science/technology culture to indiscriminately hate the most widespread things.

This is evasive. How often did you see people describe Python that way before it became as widespread as it is now?

> And I consider its syntax, especially semantic indentation which eliminates so much visual noise, to be the best among all languages that ever achieved widespread adoption.

And for me it is why Python will never even make my top 10 preferred languages, and is a language I actively avoid when I have a chance, because I find it visually absolutely awful. I'd suspect (yes, it's pure speculation) you'll find about as many people who detest Python over that alone, as who find Python "delightful". Useful, sure, but finding people who describe Python as delightful is a rarity.

But as I said, some people find brutalist architecture to be amazing too, and that's fair enough.

Post reply on HN