by buf · 5y ago · 0 comments
1. Pure vanilla rails
2. Then the front end grows into an SPA as functionality becomes more complex
3. More microservices like search emerge into their own thing
By step 3, I've got a dozen engineers and things are still as smooth as one engineer. Engineering is never the bottleneck. The tech debt is super easy to spot. It's incredibly simple to know how to scale horizontally to many more engineers.
Rails can get you very very far. It's not sexy, but it gets me to market faster than anything out there.
Until you want to integrate Stripe, BrainTree, PayPal or Paddle and then you can't find an official library for Elixir. Even common things like pagination isn't fully solved with well maintained libraries in Elixir. Then there's things like wanting to create notifications (showing unread icons, sending email / sns notifications, etc.) where Rails has this solved with well supported gems but there's nothing like this in Elixir. There's dozens of other things too, and all of this adds up to you having to be an expert in Elixir and have to write all of this functionality from scratch.
If you're in it for the long haul and are investing years into the project with a big team that's fine, but if you're a solo developer building an app and want to focus on writing your app's features, in my opinion Phoenix can't really be compared to Rails. Especially with Hotwire Turbo being recently announced, now you can get all of those awesome real time features into a Rails app quite easily (IMO even easier than Live View).
I started a SAAS app with Phoenix a while back and ultimately backed out of it because all of the above. It just felt like I was in a perpetual state of having to write libraries instead of my application. It was one of those things where I got super excited initially but after 2 years of trying, waiting for certain features to come, etc. it ended up not being for me.
I have no regrets tho because I learned a really big lesson from that, which is if you want to build something now, use whatever tech stack you know right now and if you're very much inclined to deviate from that and learn something new then pick something based on what exists today in that tech stack. Not what's "on the horizon" or "coming soon". You could set yourself up for waiting forever, or if that feature you wanted in the future does come out it could be way different than what was originally claimed and now it feels like you've delayed what you wanted to do for so long for nothing.
In other words, nothing is ever going to be perfect. Just pick something and build it. Also trust what folks do, not what they say.
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 using Elixir.
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 rarely any examples posted on how to do it and almost never in a production ready way.
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/pay-rails/pay in Elixir / Phoenix. 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 maybe more folks would use the framework.
Sure it has the core stuff, but things like ActionMailer and the built in S3 support in ActiveStorage, Devise, keep me going back. Too many of those things are not there... yet ... with Phoenix
Also nothing beats active record after they added Arel which turns your query into an AST and optimizes it before sending it out - Ecto is not really there yet and doesn't look like it will get there
When you do, you can push that work to a version controlled database view, and wrap it in a ActiveRecord class interface and still get all of the ORM niceties.
Ideally in my mind, I'd like to use JS (well, TS), because it's the language I work in most of the time these days... but I can pick up different languages as needed, that's not a major issue and I've done some Ruby way back when - more important to me is making the development of the backend as simple and as quick as possible (the less code the better!), and that it will run reliably. A good selection of well-tested off-the-shelf modules to integrate other services is always a good thing. It seems like Rails is well ahead of any JS-based solution in these regards, from what I can see.
I had been evaluating PostGraphile, which appeals because of the "low-code" approach, but I guess I'm a little concerned about doing most of the logic in database functions, because I've worked on a system like that years ago and found things like testing and debugging pretty painful. If anyone has evaulated PostGraphile (or Hasura etc) vs. Rails, I'd love to hear your thoughts (or equally, any other solutions to check out!).
Problems usually come from when teams start with point 3 and 2 when in reality they should stay lean in the beginning.
You can make anything with anything, but Rails is the closest thing to an Aspect Oriented Programming environment that I’ve seen in the wild. It’s not easy to replicate that type of ecosystem with any other framework. I’ve spent ample time on teams using Go, Python, PHP, Java and C#.
There’s just no comparison vs what a small Ruby team can accomplish.
I was trying to do that on my first big PHP project, and got called out. The architect said "your code is too good, PHP is for writing crap". If you are going to write good code, you should do it in another language.
Symfony framework is a great example of a PHP framework written by Java programmers. All the same verbosity as Java, but without the benefits of Java.
Yes, you can write bad code in any language.
PHP makes it hard NOT to. The footguns are all sitting out in the open, loaded, and the safeties are off.
Jokes aside, Laravel is probably a more likely contender to provide a Rails experience for PHP.
And it's easy to get clouded by anecdotal data, I'm sure I'm biased as well. But after some time in the industry, it matters more who the person is that is using the framework, than the framework itself. If you put an equally skilled developer with the same amount of experience in either Symfony or Rails, I'm sure they can be as productive as the other. But then skilled developers tend to gravitate towards Rails more than Symfony, so hard to judge in the real world.
I would say it is as productive as rails too.
There is no ActiveRecord and way way less magic which slows (initial) development speed but it pays off in less bugs to fix.
So overall development speed is roughly the same. But with Go you gain co routines and nice performance which can make life a lot easier.
Gos type system, while somewhat poor, still helps too.
The worst part of the whole thing is actually the weird Go std lib templating.
Some things you may find nice are: the elegance and ease of use of blocks instead of explicitly declared lambdas, the standard library full of nicely named methods with aliases for the most used ones (e.g. array.map / array.collect do the same thing, some people hate this), the {do,if,case,loop}-end syntax that doesn't fuck your code up when you just quickly comment these parts out without reindenting the rest, and if you're into OOP (as in OOP, not explosion-in-the-factory-factory), then of course the hardcore OOP-ness.
I've been using Python recently as I've done more ML work, and I do prefer Ruby (though the syntaxes are similar and you won't have any difficulty).
If you learn for Rails, start with 5.2.3, webpacker and the other black magic in Rails 6 will frustrate you and currently eliminates a lot of the ease of getting started and building relatively sophisticated web apps quickly.
Anyone else agree with this?
Webpacker is here to stay and takes about 5 minutes to understand. Might as well take advantage of it so you can quickly add complex front end components via React or whatever flavor of FE you prefer.
However, I joined a rails company about a year ago and the codebase is just a mess at this scale. I find it annoying that in order to know where dependencies are coming from, I can't just go to the top of the file and see what's imported. I have to know how rails injects it and then track it down from there.
Don't get me wrong, there are issues with django, Go, etc.. but for the most part I can jump in and track down what's happening much easier.
Now, Ruby itself isn't bad at all.
It also implicitly discourages you from asking yourself if you should be accessing the thing you are. IMO a lot of the tight coupling in Rails codebases begins with being able to grab literally anything and use it with no one the wiser unless the read that specific line of code.
I prefer to start with Sinatra + Sequel for web projects. Sometimes Padrino + Sequel. As your project grows, sure, you'll pull in many things similar to Rails, and probably pull in some projects that started out with Rails too, but it allows you to be much explicit about which dependencies you pull in, why, and to limited where it gets pulled in.
I find the tooling (I use vim with solargraph) to be not only underwhelming but frustrating. No I am not willing to use a different editor. Rails code is not at all discoverable because I cannot follow method calls/objects half of the time. In order to alleviate this, I suppose, rails tries very hard to standardize things. Ok. Fine.
The ease of creating model relationships can also produce a nasty set of relationships between tables if you are not careful. One project I worked on used the fast_jsonapi where one table had relationships spanning most of the system. Dealing with that was borderline ridiculous.