Live data from Hacker News

An Ode to Ruby

blog.yboulkaid.com

71–80 of 204 posts

Re: An Ode to Ruby

#71
post #57
post #33

Earlier quoted context omitted.

To be fair, you almost never should use the map builtin instead of the pythonic equivalent, list comprehensions. `print([x + 1 for x in [1, 2, 3])` I agree that the ruby approach is better in terms of consistency, but most developers will be aware of the conventions python uses.

Python, I think, has n number of ways of doing the same thing while Ruby's everything is object approach forces you down a single approach. So while reading ruby code, you usually don't have to shift your mental model from OOP to procedural/list comprehension etc. If Ruby gets a good machine learning library on par with something like Pytorch, I am sure many folks will shift to it and we might see new DSL emerge.

Which is ironic, given that "There should be one-- and preferably only one --obvious way to do it" is in PEP 20.

Re: An Ode to Ruby

#72

Very well done, esp. the nokogiri bit :D That said if you're in Ruby land and do want something "shiny", I'd encourage you to look at Jeremy Evans work (Roda and Sequel in particular) and some of the broader ecosystem beyond Rails. There's a lot of good stuff beyond just Rails :) https://github.com/jeremyevans

I'd also suggest Jeremy's book Polished Ruby[1]. It's excellent IMHO.

1. https://www.oreilly.com/library/view/polished-ruby-programmi...

Re: An Ode to Ruby

#73
post #28
post #12

Earlier quoted context omitted.

"I still can't think of a better language for scripting." Python I find equally if not more simple. Would you agree?

Nope. Can't stand that Python uses built-in functions for basic things like list, map, fold, etc... instead of methods on base classes. Here's a super basic example. Add one to an array [1,2,3] and print results. Python: print(list(map(lambda x: x + 1, [1,2,3]))) Ruby: print [1,2,3].map {|x| x + 1} So much more readable, easy to write, etc... Ruby keeps it consistent by making pretty much everything an object and you…

For me it's annotations. Looked at from a distance, what appears to have happened is that the implementation hit a certain level of complexity before class methods got implemented, and it ended up being easier to do them with "@classmethod" than with "def self.foo", or to fix whatever reason it is that makes "def foo(a,b,c)" not act like a class method if "a" isn't "self".

Re: An Ode to Ruby

#74

Earlier quoted context omitted.

> For all that I despise Java's ridiculous boiler plate, I always know exactly what's going on Not my experience at all when doing Spring Boot, talk about magic. Rails looks dead simple compared to that.

This has been my experience too. I constantly fear Spring Boot magically reconfiguring itself based on what it finds in the classpath, and half the codebase being annotations and import statements. I've found the metaprogramming in Ruby much easier to understand and teach than Java's reflection and annotation processing.

I really gave Spring Boot a shot, it's just way above my head. Never felt like I had a good sense of knowing what the heck was going on what with all the Beans and annotations. But my Java was pretty poor - that could be the reason. However I never had this difficulty with Rails/Django/Node, they all felt pretty intuitive to me.

Re: An Ode to Ruby

#76
Started a new job in the past year and it's 50% rails, 50% react. Thought I would chafe after returning to ruby after ten years of nothing but JS and TS, but I quite like it.

I only wish there was slightly less magic and a bit more declaration. It always weirds me out that Ruby just finds stuff without me having to 'import' or 'require' it. I have a love/hate relationship with much of the DSL stuff too (more 'magic') but overall, working with Rails and Ruby is quite nice.

Re: An Ode to Ruby

#77
post #36

Earlier quoted context omitted.

Ok, that's a nicer result (obviously I don't write Python lol) but still seems inconsistent to me (putting the function before the array) considering Python is an OO language and most people are going to be writing methods for classes where you call methods with dot. I just remember list comprehensions from Coffee-script and not going to lie, I hate them. It's like reading backwards.

> still seems inconsistent to me (putting the function before the array) I'm experienced in ruby, and learning python for a project. I don't think I'll ever not wince when using python's ternary; ruby: size = (waist > 30) ? 'large' : 'small' python: size = 'large' if (waist > 30) else 'small'

I've always assumed this was to maintain syntactic consistency with comprehensions like [x for x in arr if x > 2].

Re: An Ode to Ruby

#78

I like that the Ruby community has embraced the fact it is no longer cool. I recently interviewed for a ruby/rails job where the dev team had come from a previous start up that tried to port an existing Rails app to a React/Microservices one with disastrous results. For this job they were relishing coming back to a monolithic Rails app. I hope this trend continues!

My latest job is at a place where we have an extremely 'old-school' Rails app. The vast majority of UI is server-rendered HTML, Javascript (at least that we wrote, we do use Turbo) is very, very minimal, and we're just one very large service.

The previous place I was at was a microservice heavy (the count of services was almost on par with the number of developers) React and Node based application.

I'm orders of magnitude more productive with the Rails app, it's more well regarded by our customers, and using it, there's no obvious telltale signs that it's not using the modern SPA approach.

Re: An Ode to Ruby

#79

I love Ruby - Rails has been my day job for the past decade and my life is so much more pleasant when working with it than the odd time I've ventured off into things like Go or Java. For personal things, my bread and butter is Sinatra and Sequel and that's a great combo as well. My only real issue with it is differences in building native extensions on macos vs linux, usually need to set different compiler flags in t…

So what's the upside for you with Sinatra? I'm embarrassed to having been doing Ruby for 8 years and never touching it. Just never saw the need - Rails in API mode seems adequate.

Re: An Ode to Ruby

#80

Earlier quoted context omitted.

What was cool was Rails, IMHO, and Ruby was the surprise inside it. I've had my own personal Advent of Code these holidays, coding a small API for a personal need. Ruby (Sinatra) took one morning to full deployment in Heroku. Then I tried Crystal (Kemal) and it took me a couple of days to figure out how to map JSON to Crystal data structures. Then I rewrote it again in Rust (Rocket). Two weeks till I figured out, wel…

I also took a while to get used to the typing in Crystal but once you do get it, it's worth the effort IMO. I occasionally still fire up Ruby but if I have anything more to do than a quick command-line command, I use Crystal, so many less problems.

I think I'd be more interested in Crystal if it was easier to integrate into existing ruby code bases via something like the FFI.

As it is from Ruby 3.0 we have built in optional static typing and with interesting projects like Sorbet Compiler[1] we have the option to statically compile making use of that. It's still WIP I believe but it's giving ruby devs some cool options.

1. https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-comp...

Post reply on HN