274 points · by yboulkaid · 4y ago · 199 comments
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!
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.
I have a theory that there's a perverse incentive for startups to make their work more expensive and therefore more complicated. It's related to this quote by Paul Graham about funding:
"VCs don't invest $x million because that's the amount you need, but because that's the amount the structure of their business requires them to invest. Like steroids, these sudden huge investments can do more harm than good. Google survived enormous VC funding because it could legitimately absorb large amounts of money. They had to buy a lot of servers and a lot of bandwidth to crawl the whole Web. Less fortunate startups just end up hiring armies of people to sit around having meetings."
(from here http://www.paulgraham.com/venturecapital.html)
For those that aren't VC funded I think that a lot can be explained by cargo-culting; "If startup X is using Node/React/Redux/microservices and they just scored a 20m Series A then we'd better do it too"
Part of it is also from employees: "everyone else is using Node/React/Redux/microservices, if I can push my company to do it I will have more relevant skills for the market". I often hear that for k8s too.
I honestly don't see how that can be better than sticking to Rails/Laravel/Django and embrace the monolith. All this madness of building things at every single company as if it were Netflix or Amazon is an insane waste of resources. Some days I feel like we (engineers) are like kids playing with the toys we want to play with rather than be solving real business problems and maintaining our projects in good shape technically speaking.
Otherwise it’s insanely hard to measure, bc people will come up with bs about how difficulty, complexity, test coverage, change management, dependencies.
People complain about car maintenance and the plumber, but programmers are worse.. you simply have to believe they’re working on magic… bc, we’ll, you wouldn’t understand right?
The problem is, nobody is asking if those Jira tasks could have been avoided, or be a lot smaller if we were working on a more productive stack.
At the end of the day product managers get used to everything taking a lot of time and assume that's the only way (which, to be honest, in this context it is... as reached this point it is very difficult to go back).
And also, when productivity was discussed... there was always someone suggesting the problem was the current "legacy" stack (i.e. React, Elixir) and that we should instead move to this other new stack to be more productive (Go, Svelte) and there we go again...
Ruby is elegant, brings me joy and puts me in a state of flow.
Ruby and Rails are pragmatic choices for building a business, they may not be cool anymore but they are focused on developer happiness and productivity.
I couldn't be happier with the direction that Ruby 3.0 and Rails 7.0 are taking at the moment. We have businesses to run and Ruby allows just for that. It's boring, it's stable and will deliver results.
I wouldn't pick it to build the next Discord though.. One must use the right tool for the job.
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, well, almost everything.
My opinion: they will take dynamic typing from my dead cold hands.
Surprisingly, Crystal seems to be much leaner in runtime size than Rust, with similar performance (although the use case is so simple that even good old Ruby is fast enough).
But then again, I feel you cannot beat Ruby in terms of dev productivity.
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...
[1]Stop designing languages. Write libraries instead:
https://jaxenter.com/stop-designing-languages-write-librarie...
I did try the community made plug-in for elixir, but had trouble getting the debugger to work which was a show stopper for me.
Python I find equally if not more simple. Would you agree?
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 just call methods. Even Haskell has dot notation to chain functions since it's just so much easier to read and write...
`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.
There are other things too, like how print used to be written like a keyword not a function for some reason, and enforced indentation instead of braces or "end" keywords, all just really bugged me. It felt like somebody made YAML Turing complete...
Are you referring to function composition?
Ruby has a focus on developer joy and productivity. In some cases this comes to the detriment of language simplicity, and existing features can complicate language evolution.
Surprisingly with this complexity Ruby has had a bit more success with optimized implementations than Python, such as Truffle Ruby.
Ruby is a bit more multi-paradigm than Python IMHO, and has been jokingly called a "language for connecting adults". One can monkey-patch override division to return fractions, with the person maintaining the project deciding if this is a good idea or not. This can potentially make projects with a large number of dependencies harder to debug, which interestingly seems to have created some push-back on importing lots of arbitrary dependencies.
With both Python and Ruby, you wind up having divisions between dependencies because of the poor mismatch between different paradigms - for instance, libraries built to work with Python Twisted or Ruby EventMachine for I/O, or libraries built to work generically or to integrate into say Django on Python's side or Rails on Ruby's side.
Interestingly the communities seem to have different key focus areas - Ruby has historically been very focused on testing (cucumber and selenium for instance) while Python has had a lot of focus on documentation (pydoc and sphinx). Oddly, neither really has had a noticeable literate programming push.
A couple of things I found surprising about Python was having to do the whole `re.compile` thing instead of just `//` in Ruby. Also, no one will ever convince me that a list comprehension is simpler than `map` and related functions. Also, it's hard to beat the convenience of libs that let you do `1.day.ago`.
Ruby gets complicated when people start throwing around metaprogramming where they shouldn't.
I do like Python's file == module. Python seems like it would be a good functional programming language but it goes and only allows for single line lambdas.
Again, I don't know Python very well.
This is true. Thankfully it appears that the broader Ruby community has recognized this as well, and has moved away from metaprogramming to a large extent. It's still there, but you don't see it utilized nearly as frequently as you once did.
Simple, yes. But when I want to write a script as fast as possible with the least amount of effort I don't want simple. I want convenient and powerful. Many things which in Python take multiple lines in Ruby are simple one liners.
There's a certain dichotomy between Ruby and Python that I also see in many other pairs of languages. One language is simple, easy to learn and easy to read (Python), but is not as powerful or convenient to write. The other language is more complex, harder to learn and harder to read (Ruby), but is more powerful and convenient to write.
It seems like most people prefer the first category, which I think is why languages like Python or Go are so popular. There's nothing wrong with that as it's a tradeoff, but I personally prefer the second category, which is the reason why I do all of my scripting in Ruby and not in Python like everybody else.
Simply put I don't really mind the extra complexity since it is essentially mostly a one time cost, so I always pick whichever tool will make me more efficient in the long run. And out of the two (Python and Ruby) that's Ruby. (With a few exceptions like, e.g. machine learning, where you don't really have a choice.)
Python is a "simpler" language with its preference for "one obvious way", and it does tend to support fewer paradigms than Ruby. Ruby is a more complex language, supporting many approaches. But if you are familiar with the various approaches, that can be "simpler" if it allows you to choose the most fitting approach for whatever problem you have at hand.
To put it another way, "simple" can mean "the language is small/has an obvious way it wants you to do things", or "simple" can mean "the language is flexible enough to be used to model your problem in the most appropriate way". Python is the first kind of simple, Ruby is the second.
IMHO Ruby is much more expressive than Python, and the stdlib is better designed and less crufty. Ruby really has one of the best stdlibs around, I think, and a lot of languages could learn a lot from it - particularly the design of `Enumerable`.
So I prefer Ruby when I have the choice. Part of that is probably just familiarity, but I've been a full time dev on both Ruby & Python projects for long stretches of time so I think I'm in a decent position to compare them. My personal preferences/taste is another aspect, of course, and there's no objective accounting for that.
The case where I often will prefer Python is if I'm scripting something that needs some degree of portability. If you pick a random Linux box it's much more likely to have some version of Python installed than Ruby, so if I'm writing something that should be easy to copy to a box and use without additional setup, I'm more likely to pick Python.
e.g. https://gist.github.com/destiny-index/2a2e7e586bb9cd6e5c3000...
Depends which one you prefer.
Moreover, the choice of which idiom to use conveys the intent and mindset of the author.
But like any complex language, it's also possible to write very unpoetically, and like any complex language, readability is a function of familiarity with the language's syntax and idioms.
Ruby, on the other hand, is literally meant to delight you with its choices/options/expressiveness and I find that it absolutely delivers on that promise.
But yes outside web - data science, web crawlers etc...Python has the clear advantage.
The Ruby devs I know are overall great devs
The Python people are second-rate.
Ruby produced tons of good software as a framework base besides Rails.
Python? Eh.
At my previous company you could only "touch" your own service, so once there was any kind of "architecture spaghetti"... good luck fixing that across 3 ~ 4 different services... and good luck aligning 3 ~ 4 teams priorities to fix it.
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 :)
1. https://www.oreilly.com/library/view/polished-ruby-programmi...
I strayed from the CS path into econometrics and then data science, so Ruby just wasn't a good fit for basically anything I do. That seems to remain the case, unfortunately, though I like it on the language level more than my bread and butter Python. Oh well.
Most of my Ruby work has been outside of web. Message brokers, cloud orchestration and assorted devops, a text editor (for my own use - it's replaced Emacs for me), financial simulations. And that means the majority of my work for the last 15 years.
Ruby has gotten more low key, but for those of us who never really liked Rails that's not really mattered much.
God, yes. Especially with Hotwire [1], which advertises being able to do modern web apps with a minimum of JS. I've played around with it, and for me it completely eliminates the need for AngularJS/React/whatever.
Strait up, use Rails with all the defaults (ImportMap, Hotwire) but use Postgres and maybe Tailwind (`rails new myapp --database=postgresql --css=tailwind`). No extra gems are needed really (if anything, they add more complexity as not all are updated to be compatible with Rails 7).
Regarding Django, my problem with it is that it is not a "full stack" framework anymore. Both Rails and Laravel provide a very good frontend solution. Rails with hotwire, etc and Laravel with livewire. Just the fact that django has no official way to compile/build assets, and the templating language is really arcane and limited for today's needs. Just compare that with Blade (Laravel's templates) which allow you to build components out of the box.
for authentication/authorization/security, it's great to learn by writing those from scratch, but unless you want that to be your career focus, you'd really be much better off to defer to battle-hardened libraries in those areas for any commercially-/publicly-oriented web app.
I’d recommend using rails without any front-end framework initially so you understand the HTTP calls going on. Just return HTML from your controllers (classes that run specific code when you hit an endpoint.) Build up from there and you’ll get the hang of it while understanding what’s happening underneath.
Unscientific poll with possibly a biased sample: more people find functional easier to work with. But telling, the difference is more pronounced among bootcampers and informally educated programmers than formally educated programmers https://twitter.com/DNAutics/status/1459348334007787526.
Not to mention that Elixir is basically "mostly functional but you don't have to faff around with monads or anything to do imperative".
With node projects they typically keep all of their dependency neatly under node_modules/ and you can clearly see how things are included and how things work.
Learning a language/runtime takes some effort but much less, IMHO, than learning a framework. Doesn't matter if that is Rails, Django, Ember, Angular, iOS SDK, Android SDK, React+Redux+???, and so on.
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 the bundle config. Otherwise, works great.
ie. # ~/.bundle/config
---
BUNDLE_BUILD__PG: "--with-pg_config=/usr/local/Cellar/postgresql@10/10.19_1/bin/pg_config --with-cflags=-Wno-error=implicit-function-declaration"
BUNDLE_BUILD__THIN: "--with-cflags=-Wno-error=implicit-function-declaration"
BUNDLE_BUILD__FFI: "--with-cflags=-Wno-error=implicit-function-declaration"
If you need the kitchen-sink you might as well use Rails. But often you might need only a tiny fraction, and Sinatra is small enough to read. If you need a "halfway house" between Sinatra and Rails, Padrino layers nicely on top of Sinatra and you can pick and choose which parts of Padrino you want to use.
My preferred stack is Sinatra + Sequel as the ORM, but if I need something "quick and dirty" I might throw Padrino on top as it's lightweight and unopinionated enough it doesn't get in my face the way Rails does.
The caveat is that if your team is used to Rails chances are they'll hate you if you make them use Sinatra and they don't share a dislike for big frameworks.
Tech trends are weird, and the "hot new thing" is usually based off of some blog post or tech company saying its cool. Plus with things like TruffleRuby and Sorbet and JITs, there's some interesting development in the ecosystem.
That's not a coincidence. Ruby is heavily Smalltalk-inspired syntax with a dash of Perl and Awk thrown in (notice all the "$"+single character bits, as well as a look at the "-n" command line) wrapped in nicer syntax.
One could consider https://rubygems.org/gems/oga, as it doesn't have any installation problems. It's not actively maintained though (mostly because the author considers it to be complete). I do think the author is a bit of a weirdo though :)
Bundle hung again?
Ah, its just Nokogiri.
With native extensions. To-con-vey one’s mood
In sev-en-teen syll-able-s
Is ve-ry dif-fic
John Cooper Clarke Bundle hung again?
Ah, it's just Nokogiri's
Native extensions.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.
That's either bundler (which `require`s every dependency you specify unless you tell it not to) or the Rails autoloader[1] (which goes hunting for a file that might define the constant, which also allows hot-reloading to work). Ruby itself requires you to `require` everything.
[1]: https://guides.rubyonrails.org/autoloading_and_reloading_con...
For many gems, all you're going to get are a couple of examples in the readme. If you're lucky, there will be some generated rubydocs, but quite often that isn't helpful either, because it's just a list of method names with no descriptions, or it's not clear at all which pieces are intended to be the public API. Even Rails has this problem sometimes. The guides are very good, but when I need to do something off that beaten path, I'm often reaching for stackoverflow.
yard server --gems --reload
For rails and ruby docs, I use Dash (on Mac). I use Dash for local docs for other languages and systems as well. Just a handy tool for local docs.
JS libraries, IME, are often very bad, though there are some good ones. But, on Ruby, I would go further and say that, especially compared to Python which is so similar in many other respects, Ruby (and not just the library ecosystem,) has a very bad documentation culture.
In fact, more than in libraries, this is evident in the first-party documentation available on the language homepage.
Well done!
To be honest, it's always this dice roll with most things on pypi. If there are wheels for you, golden. If not, you better hope it's a pure python package or it doesn't pull any outside libs. Things are getting better though with solutions like cibuildwheel.
For all that I despise Java's ridiculous boiler plate, I always know exactly what's going on.
In Ruby, I feel like there are unknowns in every file.
I hate Java, but Ruby makes me miss Java.
Not my experience at all when doing Spring Boot, talk about magic. Rails looks dead simple compared to that.
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.
Magic is built into the Ruby language, what with everything being "message passing" under the hood.
The IDEs have partial autocompletion but obviously not as good as with compiled languages. Same for finding where a method is used or how to refactor code without breaking the world. Those are all IDEs features that made me more productive, made my codebase more robust and helped me refactoring often fearlessly.
Sorbet is a good attempt to fix some of that, but it then adds a lot of verbosity and it is difficult to use in practice since is not adopted by all the ecosystem and when relying on third parties you'll find yourself doing a lot of T.cast, T.unfase, T.must
That said I can see a lot of value in Ruby: concise code, powerful iterators, very expressive and very flexible. Perhaps so flexible that it gives you many ways to shoot yourself
For CI scripting you use "rvm (path) do (command)."
Want something fast and simple? Use Go.
Want something really fast and powerful? Use Rust.
Want something ubiquitous, with lots of developers in the labor market? Use Java.
Excuse my ignorance, but what is Ruby's strength?
Also you can short circuit a lot of what you said with Crystal lang (for speed) or Ruby on Jets (for ease of deployment, serverless, etc). At Arist (YC S20), we were able to fully rebuild our app in Ruby on Jets, pass a pen test, get SOC 2 compliance, all in under 12 months. This frankly would have taken years if we couldn't lean on the Rails ecosystem, and our Appdex score is 0.999 typically, and we are prepared to 10-20x our current traffic because everything is serverless and each endpoint in each controller automatically becomes its own lambda upon deployment. Yet we can lean on the usual rails app structure, and use gems and features designed for rails.
With things like Go, basic string operations like reverse string are left to the user to implement. In the ruby/rails ecosystem we have Active Support. To that same point, you also get the most fully featured ORM in the world in the form of ActiveRecord. No other ORM comes even close to the features AR provides.
To your point though, we do use Rust for image and gif processing in one small lambda. I love Rust, but there simply isn't a web framework with the "sane defaults, everything included by default" mentality of rails yet. Cookie management, CSRF protection, etc., are largely left to the programmer to configure correctly, and it's simply a waste of time if you are trying to iterate quickly as a startup.
Where you can really get into trouble is if you take rails things for granted, and then go to a framework in another language. For example, you could have been brought up on rails and just take for granted that cookies are encrypted by default, and not realize that your supposedly server side cookie secrets stuff in express is being set in plain text.
What I like about rails, though, is it tries really hard to stop you from doing something stupid. Strong Params is a great example of that. You have to really fight ActionController to get it to do something actually unsafe. By that same token, properly configured rubocop will catch 100% of potential SQL injection vulnerabilities.
So Ruby's catchphrase is "developer happiness". There you go.