8 ms·
From Ruby to Node: Overhauling Shopify’s CLI for a better developer experience
- tiffanyh 4y agoI always got the vibe Shopify developers didn’t want to rock-the-boat to much with Tobias (founder/ceo) on tech stack, given his past role as a core Rails developer.
- dorianmariefr 4y agoHeroku did the same
- mtmail 4y agomore background info https://blog.herokuapp.com/evolution-of-heroku-cli-2008-2017 https://blog.herokuapp.com/evolution-of-heroku-cli-2008-2017 Their version 6, started with Ruby, then go/node, then pure node. https://github.com/heroku/cli https://github.com/heroku/cli "This is the next generation Node-based Heroku CLI. The goals of this project were to make plugins more flexible, remove Ruby as a runtime dependency, and make the CLI faster. [...] It has identical functionality to the old Ruby CLI."
- berkle4455 4y agoIf only Heroku had any customers remaining to use it
- hit8run 4y agoThe free tier shutdown was definitely not the best marketing. Their prices are steep in a docker/kubernetes world. They could have had at least left the free tier for Ruby projects as it’s their origin.
- phaedryx 4y agoInteresting. TIL about the Open CLI framework that they all seem to be moving to: https://oclif.io/ https://oclif.io/
- meagher 4y agoCAC also quite good: https://github.com/cacjs/cac https://github.com/cacjs/cac. Used by Vite and many others.
- swyx 4y agoits from heroku! we even did a conference once! https://www.heroku.com/events/2019/oclifconf https://www.heroku.com/events/2019/oclifconf (and i gave one of my most random talks ever https://www.youtube.com/watch?v=1_w1YWCHXFg https://www.youtube.com/watch?v=1_w1YWCHXFg)
- xavdid 4y agoIt's from Salesforce/Heroku. The documentation is definitely lacking, but it's battle-tested and under fairly active development. I moved the Zapier CLI to oclif a few years ago over a bespoke version, since it handles a lot of the nitty-gritty of displaying text in terminals. It's a pretty nice setup and allowed us to focus on the important things.
- skipants 4y agoIt's great too -- spiked out a CLI using it in my last company. It was really easy to set up and program in.
- prng2021 4y agoSame here. I wonder why it hasn't gotten more adoption.
- olso 4y agoThe CLI is nice, but developing Shopify apps+themes is still a wild west.
- jumpyjumps 4y agoI'm begging you, just use a language that compiles to a single binary. It can self update in place, be easily installed on developer machines and CI pipelines without requiring a whole additional toolchain in every container. Google, Heroku, AWS, Shopify all do and it's an awful developer experience.
- maccard 4y ago> I'm begging you, just use a language that compiles to a single binary. It can self update in place Is there a library that does self updating in place for binaries? Go is the langage that comes to mind when talking about single binary, so maybe a go library?
- ezekg 4y agoMaybe check out https://github.com/keygen-sh/keygen-go https://github.com/keygen-sh/keygen-go? Let’s you add auto upgrades to any free or commercial Go app (with support for licensing too). (I’m the founder of the licensing API.)
- eatonphil 4y agoWhat's the mechanism for self-updating in place? Something more intelligent than just downloading and copying the file over itself? A running program itself is a copy of the file on disk, I think. So that sounds fine. But this still depends on getting permissions right though I think. Also, does a binary always know where it lives (across Win/Mac/Linux)?
- cbarrick 4y agoDownload-and-copy is the way. A single binary CLI can just copy over itself and exec into the new version. You can preserve the permissions of the original file. With scripting-language CLIs, you either have to deal with the module install process or use an external packaging solution.
- silasb 4y ago
- jacobsenscott 4y agoGood luck! I've found any cli with any kind of runtime dependency other than maybe sh eventually becomes difficult to run. I think they all tend to end up getting packaged with an isolated copy (node/ruby/python) of whatever runtime they need.
- ruby_duby_doo 4y agoPSA: The singleton context configuration is probably the most disgusting thing I've seen in Ruby culture. Please do not bring this practice to node -- I've already witnessed this crime in shopify SDKs and stripe.
- deleted 4y ago[deleted]
- cezart 4y agoHonest question: Why is it a bad pattern? And what are some better alternatives from other ecosystems?
- latchkey 4y agoThe singleton pattern generally tends to be hard to write tests for. Singletons are basically a global object with static methods. The dependency injection pattern fits better. DI is basically passing around objects which conform to an interface. This way you can mock out those objects more easily.
- RangerScience 4y agoOne issue that a lot of patterns run into in Ruby (and other highly flexible languages) is that a lot of patterns exist to help you deal with the restrictions the language puts on what you can do with it. Ruby has enough sharp knives that many patterns are pointless, or trivial enough that they're idioms instead, or that the downsides of the pattern are drastically limited. (example: command pattern vs lambdas; delegate vs blocks) Having singletons can make sense, if the abstraction has to be leaky... (examples of abstractions that must be leaky: AWS vs GCP) (examples of abstractions that can be tight: Segment vs Rudderstack) ...because then you're never really in a position where you need multiple objects, or to swap out the implementing object, during production runtime. So you don't benefit much from DI on prod. And in Ruby, when you're in the tests, there's a handful of nice and handy shenanigans you can pull to remove the downside / AKA make it trivial to mock the object. -- AKA Ruby is flexible enough that you need DI like a contortionist needs a backscratcher.
- eatwater123 4y agoCool. But god, the Shopify CLI / developer experience has degraded so much in the past few years. With the newest iteration, they want a full app re-structure just to work with the CLI properly. It is absolutely brutal. Sure, before they had basically no tooling, but then they had some basic ones that everyone was basically happy with, and then they just decided to iterate too much. (saying this as a ~ 8 year long Partner / Expert / App Developer) I've spoken to some Shopify employees and they all agreed that the developer teams are a bit of a mess. It seems like nobody managing the developer products are actually using the end results, otherwise they'd realize the hoops needed to work through (unless you are starting a brand new project right now --- and hoping that they don't decide to change it all, like they have 5 times in the past 3 years)
- primax 4y agoThis is where I'm at right now. We have 40000 items on the store and I'm writing an updater for it, and the entire official ecosystem is a dumpster fire. I've found some ok golang api clients which seem to do the trick so far.
- drchiu 4y agoA lot of Shopify Partners I've talked to feel the same way. The tooling and API has become harder to work with over the past couple of years. The previous designs (which worked very well for a long time) seemed to have been all thrown out/deprecated to such a large degree it has caused a lot of long time devs to be scratching their heads.
- deleted 4y ago[deleted]
- lelandfe 4y agoThey sure do like to start over, huh? What's funny is that Slate was canned while still in beta: https://github.com/Shopify/slate#-slate---end-of-support-january-2020 https://github.com/Shopify/slate#-slate---end-of-support-jan...
- btown 4y agoOne of the things I find fascinating is that in the days where it was Liquid templates, and Vercel etc. were barely a twinkle in people's eyes, Shopify had a huge value add - that you or an app development consultancy could iterate on customizing interfaces here and there, and deploy changes from the CLI or directly on the Shopify platform, without needing to worry about deployment, payment processing, etc. But so much has changed now. Deploying a customized frontend has a negligible cost, and the API surface that Shopify powers could be powered by a myriad of tools, with Stripe etc. doing large amounts of heavy lifting on the administrative side. Were contractual obligations, and not wanting to bite the hand that feeds, the only thing preventing longstanding Shopify app developers from joining together and creating an industry-standard alternative API surface that could be deployed in different ways?
- pastor_bob 4y agoI just find working with Node to be gross. Look at this: https://github.com/Shopify/cli/blob/main/package.json https://github.com/Shopify/cli/blob/main/package.json but wait...this too: https://github.com/Shopify/cli/blob/main/packages/app/package.json https://github.com/Shopify/cli/blob/main/packages/app/packag... https://github.com/Shopify/cli/blob/main/packages/cli-hydrogen/package.json https://github.com/Shopify/cli/blob/main/packages/cli-hydrog... https://github.com/Shopify/cli/blob/main/packages/cli/package.json https://github.com/Shopify/cli/blob/main/packages/cli/packag... https://github.com/Shopify/cli/blob/main/packages/create-app/package.json https://github.com/Shopify/cli/blob/main/packages/create-app... etc, etc, etc VS https://github.com/Shopify/shopify-cli/blob/main/Gemfile https://github.com/Shopify/shopify-cli/blob/main/Gemfile What am i missing? Why do you have to rely on all that junk to run a CLI? It feels like people choose Node because creating a Rube Goldberg machine creates job security.
- deleted 4y ago[deleted]
- lacasito25 4y agoThe project looks extremely messy, so many packages inside packages. It feels like java, but less performant
- jacobsenscott 4y agoOne reason is because ruby has a large standard library. Also people just pick what they know - there are more js devs than ruby devs. Also neither ruby nor node are a good choice for a cli, so it is kind of a moo point.
- 4y ago
- ericb 4y agoRegarding one of the problems they cited--If anyone is interested in deploying a stand-alone ruby CLI executable using a modern Ruby (3.1), the fork here can do that, but you need to compile the rubyc for each platform first (not used the linked ones in the readme). https://github.com/ericbeland/ruby-packer https://github.com/ericbeland/ruby-packer Also, there was an issue with the most recent X-Code, so I had to actually downgrade my local X-Code to compile rubyc. I wonder if Shopify had known they could build the ruby CLI into stand-alone binaries (no Ruby install or Node needed) if they would have still gone the Node route? Not that I blame them for not knowing--I had to fork the motor-admin fork, and update a few things to get it working. The original ruby-packer only works with ancient Rubies.
- hit8run 4y agoQuestionable decision making. Why not use Go when minimizing runtime dependencies is first priority? I’d probably just have cleaned up the Ruby code and used something like Ruby-Packer to create binaries. When typing is so important why not use rbs? Makes no sense to me.
- gregors 4y agoAgreed. Go is the obvious clear winner here for a CLI executable.
- wiseowise 4y agoRbs doesn’t hold a candle to TS.
- chillfox 4y agoOr they could have ported their Ruby to Crystal. That would have given the same benefits of Go when it comes to runtime, but with the benefit of only needing to do minor refactoring of the code instead of a full rewrite.
- croes 4y agoDeveloper experience seldom correlates with user experience.
- notkurt 4y agoNice. But there is so much more work to be done. From a customer perspective, it's great. However, really feel as the entire developer experience is in need of an overhaul (And it seems pretty clear that they know that too). In saying that, even if things don't change, it's still the best option for a lot of merchants.
- aliqot 4y agoSo who's left, basically Github?
- wiseowise 4y agoLeft with what?
- sk0g 4y agoUsing Ruby primarily is my best guess.
- insane_dreamer 4y agoStripe, for one
- jwcooper 4y agoShopify's monolith is Rails. They seem to be more involved with contributing to Ruby than any other company, contributing an incredible amount, including yjit and object shapes and more.
- golondon 4y agoIt increasingly feels like the decisions taken and the work done at Shopify API / Libraries / CLIs / Docs etc are done for promos, rather than thinking about DevEx of people who try to build reliable product on their platform. I notice this pattern of shoving nodejs / js, especially react through people's throat for the apps developed on the platform. Polaris, Session tokens and all the boilerplate apps the CLI generates are great examples of that. I would rather having Polaris as CSS framework + some JS bits in vanilla-JS, Auth + Session tokens as just as a small JS library. But instead I am forced to use React. I know Polaris is also available as CSS only but that's almost impossible to use as it's not designed for human use really. Or Bridge exists as a library but for many cases it's just way too bloated and documentation for non-react version of those things are not so good.
- goatlover 4y agoI don't understand going from Ruby to JS. Go or Rust sure, but Node for CLI? What is gained by doing that lateral move?
- aliqot 4y agoDevelopers who'll work right out of school, is my guess. Rails is great for the people who used it during that generation, and still is, I'm told. JS offers cheaper and more plentiful talent, and doesn't require as big of a mind shift as rust. If they become more JS centric, given the overlap in JS and Rust ideology, I could absolutely see them involving Rust soon after.
- kenhwang 4y agoIf that's true that a company as big and established as Shopify can't afford to attract, onboard, and train ruby devs, it really feels like the beginning of the end for ruby.
- aliqot 4y agoRuby will be fine, this is more of an impact on Rails as the centerpiece for getting-to-MVP fastest. It once was the case, and might still be in some capacity, but everyone with that expertise is on years 10-15 in their career and don't come so cheap because they've put in the work to earn more and are well within their rights to say they aren't going to work all nighters.
- AlchemistCamp 4y agoI wouldn’t say that at all. I know several successful indiehacker types who started in the past five years and have had success with Rails. Several of them started with JS first, but Ruby is still growing on an absolute basis, despite having a smaller portion of the market as a whole than it did a decade ago. I suspect a part of this is that startups that use Rails (or Phoenix or Laravel) don’t need as many devs as startups doing a mix and match of many libraries instead of a full stack web framework.
- tinglymintyfrsh 4y agoIt's possible to write CLI tools with support generic plugins in static languages: drop in {{name}}-{{extension}} executables in a private vendored plugins/bin directory. docker for 1, cargo for another. At MAANGs, Rust is taking over and Go is waning. Go allows for quick productivity from 0 but it plateaus due to an unwillingness to add features. Rust has a Haskell/Nix/(fancy tool) problem but it has a good productivity curve that keeps going. Sometimes worse is better as UNIX people might recall.
- AlchemistCamp 4y ago> ”Go and Rust allow distributing a static binary, but at the cost of fewer people at Shopify being inclined to contribute due to the lack of familiarity with the language.” If learning a language as simple as Golang is a real barrier for Shopify engineers, then I’d say they need to reevaluate their hiring processes. Especially given that they’re talking about CLI apps as opposed to something like distributed systems. I’ve hired multiple engineers who had zero experience with Elixir at all and it’s generally just taken a couple of days to get up to speed. I’ve had the same experience on client projects, too. I don’t think Elixir is as difficult to learn as JS or Rust, but Golang might even be simpler given how small the language is.
- tdumitrescu 4y agoI work somewhere with plenty smart engineers, and plenty of in-house golang expertise. I've seen several small internal tools rewritten from Python to Go, and contributions by the wider team totally dropped off. It used to be absolutely trivial for anyone to make changes, and the "deployment" of such scripts was basically "get the code reviewed and merge it." Now there's a whole Bazel song and dance, compilation as part of the dev cycle, producing binaries for distribution, and it's introduced just enough friction that people no longer make the little tweaks that used to be dead simple. Say what you will about loosey-goosey dynamic languages, but they work superbly for things like CLI tools.
- deleted 4y ago[deleted]
- AlchemistCamp 4y agoI haven't used Bazel for CLI apps and may have significantly underestimated how much other complexity they have around their deployment processes. That said, it's also very possible and common to make Node apps a pain to work on and distribute, too.
- Beltalowda 4y agoIMO the big advantage of languages like Go in this space is that you can ship a binary to your users and that will Just Work™. Shipping a Python tool tends to be significantly more complex either for your users who will have to set up Python + dependencies, or for your build (e.g. the Python AWS CLI just ships an entire Python environment, which is a "solution" of sorts I guess, but it's not very easy or simple to do). I don't think Go has to increase more friction in the dev workflow, but it probably does require a little bit (one-time) more effort to get it right.
- pjotrp 4y agoLooks like it is mostly deployment issues they are fighting. I suggest to use a true deployment tool like GNU Guix.
- nigamanth 4y agoRuby on Rails is better than NodeJS for eCommerce still. I don't know why they switched, but I haven't used ruby on rails that much.