Live data from Hacker News

Happy Birthday, Ruby

github.com

141–150 of 239 posts

Re: Happy Birthday, Ruby

#141
post #80

Earlier quoted context omitted.

I don't understand your bit about "cuteness over familiarity". Can you give an example outside that's not Rails-related (given that Rails seems to be the main source of your concrete complaints)? Sigils in Ruby actually do have strong and clear meanings. And the difference between symbols and strings is a useful distinction. And contrary to your statement, Ruby's stdlib is far more complete and more internally consis…

Yes, maybe my problem is more with Rails. (Because of monkeypatched APIs, it’s not always obvious to me whether a particular weirdness originates from Ruby’s standard library or is a Rails addition. Arguably this is something the language has also encouraged though.) Is there any reason to use Ruby outside Rails? Its niche seems to completely overlap with Python and modern JavaScript, and those have enormously more e…

> Is there any reason to use Ruby outside Rails?

Ruby is a perfectly good scripting language. I use it with love and passion to do the kind of stuff other people use Python, Perl or Bash for.

Re: Happy Birthday, Ruby

#142
post #39

Earlier quoted context omitted.

Check out Crystal - Its statically typed, compiled, and a near one to one implementation of Ruby. https://crystal-lang.org

> a near one to one implementation of Ruby This isn't the case at all. It has completely different semantics (for good reasons).

It also has different semantics for bad reasons. For example, Ruby’s if ... then ... else (single-line) has been deliberately removed because the devs have a mild preference against it. For someone like me who’s been writing that since BASIC in 1981 or so, that’s a surprisingly big PITA.

I like Crystal, but there are a few too many needless gotchas for it to be comfortable.

Re: Happy Birthday, Ruby

#143
post #101

Earlier quoted context omitted.

You are right, but aren't really attacking the point I was making. Even with totally optimized sql, one language's ORM will be inherently slower than another due to the intrisics of how the records being operated on are represented in that particular language. In Rails's case, EVERY single record pulled out of a database gets its own object. There is overhead to being able to represent table members from a relational…

That is why we have pluck

> it's hard to see those consequences at the outset due to the fact that Rails code is so easy to pick up and understand

Yes, there are tools in ActiveRecord that can help mitigate some of the performance issues, but as I noted above, it's extremely easy to overlook such tools until you are too far down stream to really do much about it. The symptoms of not using such features may not show up until much later when the number of records swells, and some code someone wrote 2 years ago starts slowing down the whole shebang simply because they used a select rather than a pluck. This is ESPECIALLY true in large corporate web app environments where the number of records is large and the number of people with their fingers in the code base is equally sizable. And good luck convincing management to go back and fix old ORM tech debt until the whole thing starts falling apart at the seams.

Hell, pluck didn't even exist until 2012 with the release of 3.2.1.

Re: Happy Birthday, Ruby

#144
post #113

Earlier quoted context omitted.

I'm not sure what language would be more beautiful than ruby, to be honest, and it's not even my favorite language to use. Let's do a mini code challenge in the thread -- implement fizzbuzz in the most beautiful way you can, in the most beautiful language you know:

Ruby the Ruby way: module FizzBuzz def to_fb s = '' s

Cleaner and more idiomatic version: https://news.ycombinator.com/item?id=18873581#18877403

Re: Happy Birthday, Ruby

#145
post #16

Ruby is the very least favorite of all the programming languages I've had to use regularly over my career. Its syntax strongly favors cuteness over familiarity. Wherever Ruby can diverge from expectations to give you a pointless little tickle of whimsical inventiveness instead, it seems to do so. Visually it looks like an unwanted love child of Pascal and Python. There's no clear rhyme or reason to the use of sigils…

So, I'm old, and have done lots of stuff in lots of languages in frameworks. For about a dozen years, Rails was my go-to toolkit. I've written a couple dozen production applications with it. Unfortunately, Rails has really fallen out of favor lately. Even a Rails-specialty shop I worked for briefly has pivoted to using ASP.NET. I've played around in that stack, and found it lacking. (EF just doesn't compete as an ORM…

Opposite ask:

What would your state of the art be for starting something new with Rails? / suggestions to become quickly productive

Re: Happy Birthday, Ruby

#146
post #137
post #91

Earlier quoted context omitted.

Do you have any experience with Django? I haven't used rails myself, but I'm told they are very similar in the "look at what I'm not doing" regard.

As somebody who was a Rubyist for about a decade but has worked at a Django shop for several years now, I definitely see how they're similar, but I don't think Django is clearly the better of the two. Django is simultaneously less helpful (you have to do more things explicitly, such as specifying routes) and less flexible (for one example, Django doesn't have a public query builder and doesn't have a replaceable ORM…

Where is the evidence, outside Hacker News, for this increasing popularity of static typing? The fastest growing languages by most metrics are currently Javascript and Python, both of which are dynamically typed.

Re: Happy Birthday, Ruby

#147

Earlier quoted context omitted.

I have heard a number of things like chess and go and poker described as easy to learn but impossible to master. Rails is not like this. Rails is more like bridge where you have to learn the rules as well as this whole bidding system that fills a book before you can actually play the game. There is no real magic in Rails, and once you learn the tricks yourself it becomes the most pleasant and productive ecosystem to…

> There is no real magic in Rails For most parts of Rails, I agree. There is one very important one where I don't: ActiveRecord's internal behaviors are opaque enough at most levels where you care about your database to be fairly called "magic". Having to reverse-engineer ActiveRecord to make my database stop puking and to generate a make developers who know Rails but not databases not get upset that now the solution…

Fair enough, I would say that the internals of ActiveRecord/Arel/etc can be complicated but also do a lot of work. I watched a number of presentations by tenderlove and had a bit of background/interest in that area to start with. "Go watch this guy's videos about relational algebra and SQL generation" is probably not what you want to hear when there's a bug though.

By the time you've gotten there though you've certainly more than figured out how method_missing and different filename based conventions work though, you've seen what Rails is and I'd be curious to find out what you like better!

Re: Happy Birthday, Ruby

#148
post #80

Earlier quoted context omitted.

Yes, maybe my problem is more with Rails. (Because of monkeypatched APIs, it’s not always obvious to me whether a particular weirdness originates from Ruby’s standard library or is a Rails addition. Arguably this is something the language has also encouraged though.) Is there any reason to use Ruby outside Rails? Its niche seems to completely overlap with Python and modern JavaScript, and those have enormously more e…

I work with Ruby on the web, but rarely with Rails. Apart from the Ruby language itself -- which I love, even though I sympathize with those who don't -- I can't imagine giving up these two libraries by Jeremy Evans: [Sequel]( https://github.com/jeremyevans/sequel ) - Sequel is the best ORM I've ever used, in any language. Fast, stable, unbelievably well maintained, and offers great low-level access to the database w…

I came here basically to write this same comment. Can't give enough love to Jeremy Evans and his toolkit, Sequel and Roda are both "gems" of open source (pardon the ruby pun).

Re: Happy Birthday, Ruby

#149
post #3

> Ruby isn't the most beautiful language out there Huh, I sure think it is. I wonder what the author thinks the competition might be? Ruby has its issues for sure, but aesthetics ain't one of them - far and away my favourite out of any major language.

I'm not sure what language would be more beautiful than ruby, to be honest, and it's not even my favorite language to use. Let's do a mini code challenge in the thread -- implement fizzbuzz in the most beautiful way you can, in the most beautiful language you know:

  #!/usr/bin/env ruby

  puts((1..100).map do |n|
    "#{:Fizz if (n % 3).zero?}"\
    "#{:Buzz if (n % 5).zero?}"
      .then
      .find { |s| !s.empty? } || n
  end)

Re: Happy Birthday, Ruby

#150

Earlier quoted context omitted.

I'm not sure what language would be more beautiful than ruby, to be honest, and it's not even my favorite language to use. Let's do a mini code challenge in the thread -- implement fizzbuzz in the most beautiful way you can, in the most beautiful language you know:

(defn fizz-buzz [n] (map #(cond (= 0 (mod % 15)) "FizzBuzz" (= 0 (mod % 5)) "Fizz" (= 0 (mod % 3)) "Buzz" :else %) (range 1 n)))

    (def fizzbuzz-nums (range 1 101))

    (defn fizz? [n] (zero? (% n)))

    (defn buzz? [n] (zero? (% n 5)))

    (defn fizzbuzz? [n] (and (fizz? n) (buzz? n)))

    (defn fizzbuzz [n]
      (cond (fizzbuzz? n) "FizzBuzz"
            (fizz?     n) "Fizz"
            (buzz?     n) "Buzz"
            :else         n)))

    (def fizzbuzz-list (map fizzbuzz fizzbuzz-nums))

    (apply println fizzbuzz-list)
Post reply on HN