6 ms·
It's a shame the article ends with "So as usual, consider not writing Ruby, but if you do, ...". That's worthless advice and many people, myself included, have
by pqdbr 4y ago
It's a shame the article ends with "So as usual, consider not writing Ruby, but if you do, ...". That's worthless advice and many people, myself included, have Ruby as their most beloved programming language.
- bestinterest 4y agoThere is a gap between languages at the moment imo. Ruby is just ruthlessly productive. Compare https://github.com/benhoyt/countwords/blob/master/simple.rb https://github.com/benhoyt/countwords/blob/master/simple.rb with https://github.com/benhoyt/countwords/blob/master/simple.go https://github.com/benhoyt/countwords/blob/master/simple.go Hoping new age compiled languages like Crystal & Nim fill the gap of performance, types & productivity. But compile speeds need to be factored in.
- rco8786 4y ago> Ruby is just ruthlessly productive. This is the best description of Ruby I've ever read.
- princevegeta89 4y ago+1. After working on Elixir for a long time I missed the simple ruby way to do things and found myself running in circles to troubleshoot some basic 3rd party libraries. Going back to Ruby for my next side project.
- AlchemistCamp 4y agoStrange. I like Ruby, but probably the biggest gain I got from moving to Elixir was the comparative ease of debugging. Its immutability drastically reduces the search space.
- princevegeta89 4y agoAgree with your point about debugging being easier but in my case I ended up doing a lot of housekeeping for things that are easy in ruby. This time I'm only concerned about the speed of development and ruby to me is the winner
- ananthakumaran 4y agoHaving used both Ruby and Elixir, this is exact opposite of my experience. I would say Elixir/Erlang is one of the best language from observability/debugging perspective. Immutability, per process heap, ability to trace any module/function call in production (recon), remote shell etc make it trivial to debug most of the issues. I have found memory leak in production from 3rd party library in less than 30 minutes. Just looking at the process list sorted by memory will tell which library is leaking (in majority of the cases), as most of the processes has single purpose.
- recuter 4y agoWell, the go one would compile to an easily deployable binary and actually be able to, you know, count a whole lot of words quickly. But the ruby one is much more terse and quicker to write. I say we go back to awk and get the best of both worlds: '{num+=NF} END{print num+0}'
- lambdaba 4y agoIronically half that code (END...) is valid Ruby!
- latenightcoding 4y agoThe Perl solution would be significantly smaller tho.
- lawl 4y ago> Hoping new age compiled languages like Crystal & Nim fill the gap of performance, types & productivity. Yes, go is verbose at times. But the go language server for example lets you not write a lot of the boiler plate you see there. E.g. instead of typing out a for loop, i'd just (start) typing `foo.range!`, or for sorting `foo.sort!`. I'm not going to argue that writing it in go even with those would be more terse, just that I think it looks worse than it is.
- folkrav 4y agoYeah the go one looks terrible but then you take a look at it and it's just creating slices, looping over stuff and appending stuff to the aforementioned slices. The syntax is much less expressive, therefore very verbose, but it's basically doing the same thing, without the sugar of being able to inline some of the logic.
- gedy 4y ago> Ruby is just ruthlessly productive. Not disagreeing, but the nuance is productive for writing new code/features. It really feels counter productive once you have a large codebase/team and you need to refactor existing apps. Spent 5 years at a Rails shop and it's crazy how much engineering effort was spent on keeping this app going. Adding typing seems like a nice step to help here.
- klardotsh 4y agoYeah, I disagree with "ruthlessly productive" as a blanket statement because of this. I tend to find that a huge chunk of the time I save at write-time in Ruby (Rails)/Python/etc., I end up repaying at either runtime (nil exceptions) or read/explain-to-other-dev/refactor times, sometimes in multiplicative form (chasing down why something became nil, or a string, or an elephant, but only if the ORM did X, Y, and Z to the DB response, etc. gets ridiculous quickly)
- banana_maker 4y agoComparing a trivial <500 LoC program between languages doesn't tell you anything that's useful other than the terseness of the syntax. You might as well chain unix utilities together at that point. Maintaining a 5k+ LoC java/c#/go/rust/crystal codebase is orders of magnitude simpler than standard ruby. Sorbet/RBS bridge that gap now, but are a pita to use compared to natively implementing a type system. I know with rust/go I get a simple binary at the end to copy over. Rust, unfortunately, has slow compilation times still compared to go, but I really can't stand error handling in go compared to rust. That said, "ruthlessly productive" is an apt description. I just don't want to have to maintain a large rails codebase again without sorbet/rbs. I'm hoping phoenix/elixir or something in rust catches on.
- sparker72678 4y agoThat 5k line Java codebase is probably equivalent to the 500 line Ruby one. ;)
- realusername 4y agoYeah not really, for maintainability, I'll pick Ruby over Java any day. I've seen how the large java project tend to be and I want no part of that.
- pphysch 4y agoIs Ruby "ruthlessly productive" for building a fast, highly concurrent program that can be deployed to X platforms with minimal fuss? No. Is Golang "ruthlessly productive" for interfacing with complex relational databases? No, not even with generics. Tradeoffs, every language has 'em.
- Scarbutt 4y agoWhat mainstream programming language is good for interfacing with complex relational databases?
- AlchemistCamp 4y agoElixir is great at it and becoming increasingly mainstream.
- golergka 4y agoSQL. Typescript with library like pgtyped basically allows you to write raw SQL queries and then generates all the static typings for them.
- norman784 4y agoRust is getting there, with sqlx[0] you can write plain sql and it gets validated at compile time. [0]https://github.com/launchbadge/sqlx https://github.com/launchbadge/sqlx
- pphysch 4y agoAny language with metaprogramming like operator overloading so you can create an ergonomic ORM, basically. For such a language to be reasonably productive you want to be able to overload "mystruct.myvar" to not simply grab "myvar" from memory, but smartly fetch it from a remote database, cache it, etc. It will never be perfect (blah blah impedence mismatch) but a proper ORM is so much more productive and readable than writing crap like `Manager(mystruct).GetAttr("myvar")...` or bespoke SQL composition.
- mixedCase 4y agoF# by way of type providers. Many other languages could similarly bridge the gap with codegen.
- overgard 4y agoI dont know if toy examples prove anything about productivity. I never quite understood what makes Ruby more productive. Dynamic types?
- norman784 4y agoI think is that is has a great standard library + with rails a lot of utilities out of the box, other than that some people just like the syntax. So said that they standard library is huge, where other languages prefer to have slimmer ones and let the community build the utilities.
- cutler 4y agoPrinciple of least surprise.
- afandian 4y agoI've not written Ruby since about 2006 except with a stint in a Rails codebase which did nothing to give me any faith. How do you go about e.g. extracting a group of fields and renaming them? Or reorder function arguments? Is there a static tool that can do this, or do you have to do some kind of text search and hope you got them all?
- dymk 4y agoThere's basically no tool for doing that, aside from relying on tests to tell you a callsite is now incorrect. "find and replace" is... okay, up to a point, but obviously that has its limitations (especially once you start metaprogramming). That being said, I still love Ruby. I have all sorts of little tools written in it that would have been a pain to do in another language.
- afandian 4y agoComing from a Clojure background which is … different. But I understand the enthusiasm around similar language features. But to borrow words from another comment I find Kotlin “ruthlessly productive”. Apart from the lambdas, functions, data classes and immutably, it’s the ability to quickly and correctly refactor that makes me feel like I can work at speed and try stuff out.
- dymk 4y agoI wish I could find Kotlin as ruthlessly productive as Ruby, but... I'm having a hard time doing so. It's got nothing to do with the language itself - at work, I really enjoy Kotlin. Here's where Ruby shines for me: when I'm whipping up a script, I can toss a `Bundler.setup(:default)` at the top of the script, `vim mything.rb`, `$> ruby mything.rb` (or `./mything.rb` if I hashbang at the top), and I'm off to the races. With Kotlin, it feels like I need to set up a project in IntelliJ, `$> ./gradlew run`, wait 10 seconds for the whole thing to compile, and finally my thing is running. Is there a streamlined way to run a Kotlin script without building a whole jar, from the command line? I know this is generally not as easy with compiled languages. The D programming language is a notable example that has a "D script" mode (hashbang with `rdmd`), which quickly compiles+runs in a single step.
- ecshafer 4y agoAbsolutely agree. Ruby is a great and beautiful language, and Rails is imo the best web framework for getting things done.
- RTFM_PLEASE 4y agoRails is frankly a double-edged sword, though. While it helped propel Ruby, and is a great framework, it also seems to have permanently marked the language with a notion that its simply a vehicle for Rails. Ruby is probably one of the more coherently designed general purpose programming languages (in my opinion, much more so than Python, a language that dominates the industry) but doesn't seem to get much use in that domain, which is a shame.
- chris24680 4y agoAs a rails developer I really believe if Ruby had at least one more 'Killer App' it would lead to a much healthier overall community.
- rattray 4y agoJust because you disagree with it doesn't mean it's worthless advice. I always have a fond flutter whenever I see Ruby (which I used to write, and really enjoyed) but absolutely wouldn't start a new project with it, for practical reasons. It's slow, it can turn into a big ball of mud as applications scale (there's no named imports for crying out loud, everything is just in a global namespace with side-effects everwyhere), etc. Certainly there are still people/projects where, upon consideration, Ruby is still the best choice (eg; small Rails shop has a standard CRUD app to build quickly that will not likely ever scale to be huge). But you should still _consider_ not using Ruby.
- aantix 4y ago“Shopify's core monolith has over 2.8 million lines of Ruby code and 500,000 commits.”
- endgame 4y agoAnd they had to become PLT experts to build the tool that let them tame that.
- gnufied 4y agoIn fairness all major companies which use a Language extensively tend to invest in all aspects of its well being. Facebook did with PHP, Google hired Guido (and bunch of other python maintainers) and now go. If your business depends on having a well maintained platform, then it makes sense to invest in it. Shopify should be commended for investing in Ruby. As a former contributor to Rails and Ruby ecosystem in general - IMO I would still choose Ruby for certain kind of work. I write Go mostly these days and parsing random JSON for example is major PITA (so it would be in many other static languages).
- rattray 4y agoMinor nit, if you're thinking of Sorbet, that was Stripe (but Shopify has done a lot of great work on Ruby things too, incl Sorbet stuff). Disclaimer, former Stripe employee.