Learning Ruby: Things I Like, Things I Miss from Python

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • Nest

    A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀

  • I've had good experience using Nest.JS [1] for the backend and next.js for the frontend. Nest has defaults for ORM, validation, task scheduling, authentication, etc, I find it a lot easier to work with when compared to plain express projects with tons of glue.

    Disclaimer: I have never tried Rails

    [1] https://nestjs.com/

  • unholy

    a ruby-to-pyc compiler

  • > Python and Ruby are really similar.

    Yes they are, as seen in the old _why's project:

    https://github.com/whymirror/unholy

    > Compile Ruby to Python bytecode. And, in addition, translate that bytecode back to Python source code using Decompyle (included.)

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • Strapi

    🚀 Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable and developer-first.

  • redwood

    The App Framework for Startups

  • * Strapi [4], hapi [5] et al: plenty of backend functionality, but frontend agnostic.

    Has anybody had experience with any of these (or others) and can report back?

    [1] - https://redwoodjs.com/

  • Ruby style guide

    A community-driven Ruby coding style guide

  • The solution is the same as in many other programming languages: adopt a coding standard and enforce it in an automated fashion, i.e. in the CI/CD pipeline. Code style then becomes mostly a non-issue and not an object of discussion.

    In the case of Ruby:

    * most popular style guide: https://rubystyle.guide/

    * automated tool for linting and enforcing code style: https://rubocop.org/

  • rubocop-rails

    A RuboCop extension focused on enforcing Rails best practices and coding conventions.

  • I just would like to point out that even though that is the most sane way, it comes with it owns set of problems. One of them is when developers start to code to cheat the linter, or they complicate the code just to "make the linter happy", another is when the linting rule introduces problems/errors like https://github.com/rubocop-hq/rubocop-rails/issues/418

  • noticed

    Notifications for Ruby on Rails applications

  • > I think often the things that don’t exist are not there for good reasons... using Stripe’s api for example from a module is pretty trivial in my experience, it’s just HTTP and you don’t need to be super clever about it.

    It's way more involved than inserting an auth token header into an HTTP request and calling some API endpoint.

    For example, what about verifying webhooks? The official libraries for Stripe (Python, Ruby, Node, PHP, Go, JS, etc.) deal with this for you.

    But with Elixir, you're on your own. This is very low level code to have to deal with and it's extremely important you get it right.

    You're left having to parse Stripe's specification on this and then implement the code yourself in Elixir. It's so tricky and involved that the Dashbit company (the creator of Elixir and members of the core team work there) wrote a blog post on it at https://dashbit.co/blog/how-we-verify-webhooks.

    But before a few months ago that blog post didn't exist. Also this isn't the only thing you'll have to do yourself when it comes to interacting with Stripe.

    Then you'll have to do similar things for other payment providers all which are different in a lot of ways, but with Rails you have the combination of having official Ruby clients from those payment providers and even the Pay gem which lets you support payments from multiple providers. That could easily be a few months of dev time just for that abstraction alone if you had to go about that from scratch and your implementation wouldn't have any track record until you start using it and ironing out the bugs from real world experience.

    > Again notifications doesn’t sound particularly difficult and I don’t see why I’d want to rely on some complex gem that does every option when I don’t need them

    Don't take this the wrong way but this seems to be the mindset of almost everyone I chatted with when it comes to Elixir. When someone asks how to do something, the answer is it's trivial or easy to implement but there's never any examples posted on how to do it.

    In my mind trivial or easy means I can sit down in maybe a few hours or a day and write a production ready solution, complete with tests and have it work exactly how I want without running into any major roadblocks.

    I'd be curious to see how you would implement https://github.com/excid3/noticed or https://github.com/excid3/pay. Based on your responses of saying these things are easy I'm guessing you've written large apps with Phoenix where you've developed features like this in a production app? It would be fantastic if you could post some code examples or a blog post on how you went about this. Not just to answer my specific question but I'm sure the community would appreciate having concrete examples of how it's done. This way more folks would use the framework.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • stripity_stripe

    An Elixir Library for Stripe

  • I'm going to attempt to answer by way of links to active projects for you:

    Stripe, including webhooks support, actively developed: https://github.com/code-corps/stripity_stripe

    Global pay solution that supports everything: they are all a bit crap you're right, the best I've found is https://github.com/aviabird/gringotts and ex_money really is amazing that integrates with it (I would suggest it's better than the equivalent ruby gem). To be fair I'm not sure I'd want to use the pay gem with anything complex as you need to be able to use the specific quirks of each API properly.

    You're also right about noticed, after looking into it more it would be worth building for elixir for sure. Ravenx represents a start but it's unmaintained and doesn't have a huge number of strategies. It depends on how much I needed to do notifications like this. For the apps that I've built we've just needed database and grouped emails sent once per day, no need for texts or slack etc. There's no reason these couldn't be added fairly simply but I agree noticed is very neat.

  • Django

    The Web framework for perfectionists with deadlines.

  • I like using Django [0] with django-rest-framework [1] and dj-rest-auth [2]. This gets you Rails-inspired organization, with a nice abstraction for REST endpoints in general, and a login/logout/registration/email verification/social auth in particular. Everything is built on the very well maintained allauth [3] module. Here's a good quickstart [4]. I've used Ruby in production, but I like Python's "one way of doing things" approach.

    [0] - https://www.djangoproject.com/

  • gringotts

    A complete payment library for Elixir and Phoenix Framework

  • Thanks.

    > Stripe, including webhooks support, actively developed

    I've looked into Stripity Stripe. For some time it was unmaintained and ended up getting taken over by another maintainer. It's also not as comprehensive as the official Stripe libraries. There's also a very big difference in using an official Stripe library and hoping for the best with a random one someone developed. Just skimming the code base it looks like the Checkout module is missing features that exist in the official Stripe library in every other supported language.

    According to the README file for Stripity Stripe it's also using Stripe's API version from 2019. There have been multiple major API updates since then, and there's been an open issue since November 2020 to add support for newer API versions with no replies. Personally I would be using one of those major features too.

    And this really is the point I'm trying to drive home. With Ruby, Python, Go, PHP, Node, Java and .NET these are problems you don't even need to think about. You just pick the payment provider's official SDK and start coding immediately, often times there's also an abundance of resources to implement the billing code itself into your app too through blog posts, official docs, YouTube videos, and even paid products like https://spark.laravel.com/. Stuff that makes integrating billing into your app (through Stripe, BrainTree and Paddle) being something you get done in 1 day instead of 3 months.

    With Elixir it becomes weeks of comprehensive research, evaluating questionable libraries, opening PRs, and becoming a full time library developer just to get to the point where you could even maybe begin to start accepting payments with just Stripe.

    > the best I've found is https://github.com/aviabird/gringotts

    I asked the Gringotts developers if they would be supporting PayPal about 5 hours after they announced the project ~3 years ago. He said it was coming and to stay tuned. It's now ~3 years later and PayPal support isn't there. Neither is BrainTree or Paddle. Here's the open issue for PayPal support from 2018 (not by me, I asked on another site) https://github.com/aviabird/gringotts/issues/114. The Stripe integration is also missing a ton and hasn't been touched since 2018.

    By the way, the Pay gem is really good. It's a smart abstraction and supports a ton of different subscription / 1 off payment use cases. Even complex ones like the type of app I was building.

    > It's definitely a few weeks work to roll your own from scratch so to be honest I'd probably just integrate with Twilio and just pay for someone else to handle this for me.

    Twilio ends up being 1 potential delivery method, it's not really someone you pay to solve the problem for you.

    There's wanting to show notification in the app over websockets, saving them into a database, emailing them out only if they are unread, maybe sending an SNS through Twilio, Slack and other providers.

    The noticed gem handles all of this for you (and supports Twilio too).

    Notifications in general is another example where other frameworks have this solved in very good ways, but it becomes another example where you have to stop developing your app and start developing a notification library with Elixir.

    At this point we've only talked about payments and notifications too. There's lots of other examples.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts