21 ms·
An Ode to Ruby
- cHaOs667 5y agoA big shoutout to the author to include the Nokogiri installation "experience"... :D <3 Well done!
- tibbon 5y agoI have similar problems in Python with OpenCV. It should be so simple, but generally is not (or at least last I tried)
- squaresmile 5y agoOpenCV has wheels built for all common platforms so it should be fine now. If your platform or python version is too new/old/unsupported then yeah, you can forget about building it and use another platform/python version. 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.
- hnlmorg 5y agoThis reminded me of Black Perl, a poem written in Perl 3 https://en.wikipedia.org/wiki/Black_Perl https://en.wikipedia.org/wiki/Black_Perl
- cutler 5y agoHow I miss Perl and it's acolytes, especially The Damian and Randall Schwartz.
- burlesona 5y agoVery 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 https://github.com/jeremyevans
- brightball 5y agoI use Sequel and the Parallel gem all the time. Good stuff.
- Lio 5y agoI'd also suggest Jeremy's book Polished Ruby[1]. It's excellent IMHO. 1. https://www.oreilly.com/library/view/polished-ruby-programming/9781801072724/ https://www.oreilly.com/library/view/polished-ruby-programmi...
- scruple 5y agoI no longer write Ruby professionally but in my last 18-24 months of Ruby work I leaned heavily on some of Jeremy's excellent work with roda, sequel, and others (forme, erubi, rack-unreloader, etc.). Top notch work, truly. I had no idea that he had written a book, thanks for pointing that out, and I'll definitely be picking a copy up.
- Mikeb85 5y agoIt's too bad Ruby isn't seen as 'cool' anymore, it's just so easy to be productive in it. And now MJIT, YJIT and TruffleRuby are making some very impressive performance gains. Rails is also better than ever and I still can't think of a better language for scripting.
- pantulis 5y agoWhat 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, well, almost everything. My opinion: they will take dynamic typing from my dead cold hands.
- brigandish 5y agoI 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.
- pantulis 5y agoCrystal was overall a pleasant experience, which I cannot say for Rust. Although it was probably my fault: 1) for being "rusty" as a programmer myself, and 2) having zero experience with Rust. I want to believe that once you get over the learning curve in Rust development speed becomes much higher. 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.
- m12k 5y agoI've heard it described that Rust allows you to write programs in a specific way. If you try to write them in any other way, you're going to have a very, very bad time, and fight the borrow checker every step of the way. But if you embrace that way of writing programs, it makes it pretty easy, you get really good error messages, and as a cherry on top your program will be provably sound in a way pretty much no other language can guarantee. So it all comes down to whether you're interested in learning that specific way of structuring programs.
- YorickPeterse 5y ago> For I once again have trouble installing Nokogiri. One could consider https://rubygems.org/gems/oga 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 :)
- Lukas_Skywalker 5y agoThanks for creating oga :) I use it a lot. Bonus: it's even slightly faster than Nokogiri.
- pantulis 5y agoI used to joke about Nokogiri dependency troubles for many years, but to be honest the experience in macOS lately has been straightforward for me.
- ascendantlogic 5y agoMy eye still twitches when I think about all the times it blew up my bundle installs.
- Mikeb85 5y agoJust curious, what's the issue with Nokogiri for some people? It always installs just fine for me...
- pantulis 5y agoIn OS X it was usual to have your bundle explode when compiling Nokogori due to som libXml dependency, circa 2010.
- JamesSwift 5y agoI've lost countless hours to "works on my machine but not coworkers" which turned out to be issues compiling nokogiri with native extensions. It broke all the time between macOS updates. Vagrant / docker were a godsend to removing that element of uncertainty.
- bachmeier 5y agoOne of my goals for 2022 is to write my first real web app. I want to understand things like authentication, creating an API, and security. My initial impression is that the JS/Node world is miserable. Rails looks 1000 times more pleasant.
- tjpnz 5y agoDefinitely consider Python with FastAPI too. I got a simple API up and running in a few hours with OAuth2. Auth comes batteries included and wasn't nearly as complex as I feared.
- matwood 5y agoI don't know about miserable, but definitely easier to get side tracked deciding what libs to use. Rails tends to push users down a path that works for most things. This makes it much easier for new users. JS leaves it up to the developer to pick and choose what libs which is not new user friendly.
- tyre 5y agoRails is quite pleasant. There is a reason it became so popular. 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.
- ascendantlogic 5y agoRails and Django are both very pleasant and have enormous ecosystems where every imaginable problem has been encountered and "solved". It's been a while since i was writing Rails but from what I gather Rails 7 is a homerun release and has a lot of buzz around it.
- midrus 5y agoI'd also add Laravel here. 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.
- jmuguy 5y agoA quick Haiku Bundle hung again? Ah, its just Nokogiri. With native extensions.
- samb1729 5y agoHaikus are 5/7/5 syllables, this is 5/7/6
- jjgreen 5y agoTo-con-vey one’s mood In sev-en-teen syll-able-s Is ve-ry dif-fic John Cooper Clarke
- dankwizard 5y agoOh I like this!
- cutler 5y agoA legend in the John Peel Hall of Fame alongside Ivor Cutler and Viv Stanshall.
- malloryerik 5y agoBundle hung again? Ah, it's just Nokogiri's Native extensions.
- troysk 5y agoclaps!!!
- rubyist5eva 5y agoI 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 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"
- nitrogen 5y agoI'm curious, do you know what function was being declared implicitly? That's really atypical in modern C code, so there's probably a missing #include somewhere that could be fixed upstream.
- rubyist5eva 5y agoWe're on an older version of Ruby so that's the most likely reason. MacOS Monterrey is really new and we deploy to RHEL so the differences in versions can be fairly stark.
- weatherlite 5y agoSo 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.
- vidarh 5y agoSinatra is small (the main part is about 2k lines). That's the main upside and/or downside depending on your philosophy. As someone who likes to know what goes on, I love Sinatra, but Sinatra does force you to pull in other code as needed yourself - you don't get handheld the way you do with Rails. 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.
- mrtranscendence 5y agoA coworker of mine is leaving for a Ruby job, which caught me off guard, so I've had Ruby on the brain a bit lately. I was a big fan of Ruby for a few years back in 2004-2006 or thereabouts. Rails was the new hot thing, but I wasn't into web dev so I didn't pay all that much attention to it. I remember blindsiding my networking professor by using Ruby for an assignment when he expected but failed to specify Java or C ... he was a good sport, thankfully. 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.
- vidarh 5y agoI used Ruby for my MSc thesis... which involved applying statistical approaches to reduce error rates in OCR. I did have to call out to C code for a few things (k-means in Ruby 1.8.x was not fast...). 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.
- jack_riminton 5y agoI 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!
- andrei_says_ 5y ago“Cool” is so subjective. When I want “cool”, I re—watch Le Samurai. Ruby is elegant, brings me joy and puts me in a state of flow.
- ryanbrunner 5y agoMy 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.
- jack_riminton 5y agoI'm not surprised. 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 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"
- eximius 5y agoI think Ruby might be the antithesis to Java. 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.
- weatherlite 5y ago> 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.
- marquis_andras 5y agoThis 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.
- weatherlite 5y agoI 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.
- cutler 5y agoIt's not your fault. Spring Boot is a trip to hell compared with Rails.
- eximius 5y agoPerhaps I've only had to deal with sane Java codebases - I feel like magic is not the norm in Java. Magic is built into the Ruby language, what with everything being "message passing" under the hood.
- halfmatthalfcat 5y agoManaging different projects with different Ruby versions with rbenv has been the bane of my existence the past couple weeks. Why isn’t this experience fleshed out better by now?
- nitrogen 5y agoUse rvm with .ruby-version (and optionally .ruby-gemset) files in each project. RVM hooks into the cd command so it's automatic. For CI scripting you use "rvm (path) do (command)."
- jamesgeck0 5y agorbenv also automatically swaps versions based on .ruby-version files. I believe it accomplishes this by wrapping the ruby binary with a script that checks your project directory; it doesn't touch cd.
- regularfry 5y agoPersonally I get very good mileage out of the ruby-install/chruby/rv trifecta. RVM and rbenv tried to do too much for my liking.
- fourseventy 5y agohaha the last line "For I once again have trouble installing Nokogiri." is so true
- vlunkr 5y agoHere's my hot take on Ruby (as a big Ruby fan): Ruby libraries in general have bad documentation. Some other languages I've worked with in the same time frame that typically have better docs are node.js/regular js, Python, Golang and Elixir. 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.
- mrinterweb 5y agoMy favorite documentation trick for ruby is to run your own doc server locally documenting the versions of the gems you are using. I use the "yard" gem. 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.
- dragonwriter 5y ago> Here's my hot take on Ruby (as a big Ruby fan): Ruby libraries in general have bad documentation. Some other languages I've worked with in the same time frame that typically have better docs are node.js/regular js, Python, Golang and Elixir. 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.
- vlunkr 5y agoI agree, JS is kind of all over the place.
- sdze 5y ago
- fuzzyengineer 5y ago...you might not immerse me in the meta’verse but I am happy getting lost in meta’programming…
- scelerat 5y agoStarted 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.
- psadauskas 5y ago> Ruby just finds stuff without me having to 'import' or 'require' it. 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_constants.html https://guides.rubyonrails.org/autoloading_and_reloading_con...
- scelerat 5y agothanks!
- funny_falcon 5y agoRuby requires to `require` somewhere in the project, not in the the file where actual usage is.
- ecshafer 5y agoI am a newbie to Ruby. I hadn't touched it before a few months ago, after coming to Shopify. But I really think Ruby is a fantastic language, I would much rather program in Ruby than in Python, JS or Java right now. It reminds me of small talk and is just nice to write. And Rails, wow Rails is such a good web framework, there's no surprises, and its opinionated nature makes it really easy to come up to speed in even a big code base. 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.
- vidarh 5y ago> It reminds me of small talk 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.
- vidarh 5y ago[too late to edit: That should of course be Smalltalk-inspired semantics not syntax]
- jebronie 5y agoWant something easy to host? Use PHP. 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?
- sam0x17 5y agoProductivity. 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.
- jebronie 5y agoThank you. I sometime read that too much "magic" and abstractions can quickly get in the way when doing something complicated that is not covered by a heavely opinionated framework. Is this nonsense in your estimation, or is this something to look out for?
- sam0x17 5y agoThis is very true if you don't actually understand and/or couldn't implement the magic yourself. As someone who has had to implement CSRF protection, cookie management, etc., from scratch in other languages/frameworks, it's just a pure productivity boost when I use something rails-based. 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.
- dmontero 5y agoComing from Scala and Kotlin I don't find working with Ruby extremely productive. 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
- Agingcoder 5y agoThis reminds me of 'ode to a near pointer' about flat real mode in a very old diskmag (imphobia). I was never able to find it again unfortunately...