r/ruby • u/amicloud • Jan 21 '18
Holy shit I love Ruby
I've been mostly working on projects written in Java, C#, and Python...
But I got the chance to update one of my Ruby projects yesterday and I only then realized just how much I love using Ruby. It's just a wonderful language, it really is. It's not often that I look at code that I wrote and think to myself "That's some beautiful code", but with Ruby it is.
9
u/dr-drew Jan 21 '18
Check out crystal it’s just as fun but more powerful!
5
u/amicloud Jan 21 '18
Ruby with the speed of C? Oh my
8
u/dr-drew Jan 21 '18
Yep! It’s pretty fantastic. Still young so obviously doesn’t have as huge of a community but people are working on it and it’s honestly a super enjoyable experience to work in.
I did some benchmarks of doing a massive Postgres migration in a rails app with complicated joins and such and in ruby it was around 7hours where crystal was 1.5 - we’re talking millions of tables and such but it blew my mind at the speed.
I’ve been writing micro services for heavy lifting with it and incorporating into my ruby apps to really get the feel and find its purpose and I am super impressed.
7
u/GroceryBagHead Jan 22 '18
Don't get the Postgres comparison. Are you pulling data down and then mangling it in code? Because executing joins and stuff happens on the database, language that calls it doesn't matter.
2
u/ignurant Jan 22 '18
Maybe the bigger thing was related to DB caching? It can be really hard to benchmark code if it interacts with the DB.
Anyway, not that I'm doubting improvements in speed by using Crystal, but this is definitely not the type of benchmark I would give too much weight to.
1
u/dr-drew Jan 22 '18
No, it was running off of a sql file locally for testing to ensure and test, it was impressive. Granted a DB maybe isn’t the best benchmark, but in my case it made sense and made a huge impact in speed. Especially the migration I was running but it was a good comparison between ruby and crystal in my case as I could easily benchmark it.
The way I see it, it was a good IRL sample of “okay let’s see how this goes” and the results were impressive
2
u/dr-drew Jan 22 '18
No running locally as tests. I wound up spinning up my microservice and performance has been been bumped significantly running through crystal.
The IO of Postgres is your baseline so throwing crystal in there in place ruby for the migration wound up way faster
4
u/briang_ Jan 22 '18
It's on reddit, too: /r/crystal_programming!
2
u/sneakpeekbot Jan 22 '18
Here's a sneak peek of /r/crystal_programming using the top posts of the year!
#1: Crystal 0.24.1 is released | 3 comments
#2: Crystal 0.23 released! | 0 comments
#3: Crystal has a new Website! | 3 commentsI'm a bot, beep boop | Downvote to remove | Contact ^^me | ^^Info | ^^Opt-out
3
u/the-sprawl Jan 22 '18
Crystal has been awesome. Wish we could get more people using it, since wide adoption will help it mature much faster.
2
u/dr-drew Jan 22 '18
Adoption is growing quite quickly but agree we need more folks participating! It’s super exciting to be close to such a new language, so just keep spreading the word!
2
u/holyjeff Jan 22 '18
It's funny how we love Ruby but are waiting for perks that come from using Crystal :D.
Crystal is not Ruby but we hope it will be.
1
u/dr-drew Jan 22 '18
Crystal is not ruby of course, but writing low level code in the syntax is great.
14
u/Xychologist Jan 21 '18
The flipside of Ruby being fun to write is that it's fun for everyone in slightly different ways, resulting in a mash of coding styles. I have the joy of being one of a team maintaining a decade-old Rails monolith with about 50% test coverage and a succession of about thirty junior devs as previous maintainers.
Most of the time, it works. When it doesn't, finding the problem can be a nightmare. Fixing it can be a month's work, and it tells you nothing about whether it still works until you have QA try everything they can think of and report that they didn't cause any exceptions, which is still only a 'maybe'.
Ruby is a beautiful language, but I really wish it would punish beginners harder. It's so easy and fun to write crap code that 'works' that some people stay that level forever.
7
u/tomthecool Jan 21 '18
When it doesn't, finding the problem can be a nightmare. Fixing it can be a month's work, and it tells you nothing about whether it still works until you have QA try everything they can think of and report that they didn't cause any exceptions, which is still only a 'maybe'.
Doesn't that argument apply to any large, "badly written/poorly tested" project??
It's certainly true that this can happen in ruby projects (I have first hand experience of that!). But I've also seen this happen in C++, Java, PHP, Python, JavaScript, ...
Ruby is a beautiful language, but I really wish it would punish beginners harder.
Beginners probably need to work alongside a skilled mid/senior-level developer, to get good habits. This applies to any language, in my opinion.
4
u/nachoBA Jan 21 '18
to me it only happens with ruby & smalltalk coincidence?
5
u/tadrinth Jan 21 '18
Not a coincidence, Snalltalk was one of Matz's inspirations when he was designing Ruby.
2
u/giantbears Jan 21 '18
i love it too! i was just talking about this with a co worker! i never get to use it at work (we do mostly java and python) and i wish i did because something about it just makes me happy
1
u/Zerocchi Jan 22 '18
Yeah I know how you feel. I primarily write in Java and Python before but I fell in love in Ruby because of how natural it is to write the code. For me Python is easier but Ruby feels just right. I don't know how to convey my feelings tbh but it's such a pleasure to write in Ruby. Hope it'll gain more trajectory thought.
1
0
Jan 21 '18
[deleted]
14
u/kobaltzz Jan 22 '18
Of course the downside is that large Ruby projects must maintain consistent conventions and implement thorough testing, otherwise they become incredibly painful to understand and unexpectedly fragile.
I do not know why Ruby is singled out here. I believe that it applies to all languages. ;)
5
2
u/tncbbthositg Feb 05 '18
I actually usually feel the same way about C# too. I’ve written a lot of Ruby aver the last 5 years or so and pretty often I think, “hmm, this is too clever for Ruby code. Nobody will ever find it. If this were C# at least the IDE could find it with static analysis.”
That is to say, while I love Ruby, I loved C# too (and I miss static type checking and the stronger type system.
Back when I was a C# developer, I actually said out loud, “thank God I get to write C# for a living!”
That being said, Swift is pretty pleasant too. And if you’re stuck with the JVM, Kotlin looks pretty pleasant.
27
u/xiongchiamiov Jan 21 '18
I don't love maintaining large Ruby projects (due primarily to trying to figure out where logic is defined). But there is something very odd about how enjoyable is is to write. I've talked to several other people and they all agree that it's just fun - but none of us have been able to pinpoint why.