Choosing a Web Framework
One of my favorite delay tactics to starting a new project is overthinking which web framework to choose.
So, today, instead of dorky fantasy baseball content, I'm delivering some dorky content about programming languages.
Just as a reminder: The project idea is open-source fantasy leagues.
Considerations
- This is an open-source project. If I want to encourage contributions, I should pick a popular language like JavaScript or Python. But picking a niche language and framework could filter out all but the most serious contributors. These two kind of cancel each other out in my mind, and I'm not sure which I prefer.
- For a framework, however, having a certain critical mass makes it easier to find answers to my questions. It doesn't have to be huge, but it helps to have a few others who have gone before me. (Frameworks with long histories also sometimes turn up outdated answers.)
- This is a sports project, and lots of sports analytics are happening in Python and R. While Python has an actual ecosystem outside of data analysis, R pretty much just does that one thing.
- Could existing fantasy sites want to build this into their current sites? There are lots of oldish PHP sites out there and some .NET ones. Building on one of those platforms could make something that was easier for sites to integrate.
- For the most part, this isn't a resource-intensive project. A few features, like live stats and league chat, would be easier with Elixir/Phoenix (LiveView), maybe PHP/Laravel (Livewire) or Ruby/Rails (Hotwire).
- While it's not that intense, I still dream of scaling it to something big. Thousands or tens of thousands of leagues? A scripting language (Python, Ruby, JavaScript) would take more resources to scale than a compiled language (Elixir, Crystal).
Alright, I've dropped a bunch of names already. What language options have I mentioned so far?
- JavaScript
- Python
- R
- PHP
- C#
- Elixir
- Ruby
- Crystal
The list could go on: Go, Rust, Java, Nim... But I only need one and I've already got eight. Let's see if I can narrow things down instead of muddling it further.
Initial Eliminations
- You can tell by the last section, but I'm not seriously considering R for a web project, especially one that's more CRUD than number crunching.
- Is it bad if I don't like .NET/C# because it's too corporate?
- I am happy to do JavaScript on the frontend, but I don't think I want to use JavaScript for everything. There's too much flux in the JavaScript ecosystem, and I want this to stand the test of time.
- A couple of the language/framework combinations above draw inspiration from Ruby on Rails. However, I can't think of any area where Rails would be better than the spinoffs, at least for the issues I care about. So let's scratch it off the list.
- I always liked PHP's approach of a web-first language, so it makes me sad that Laravel throws that away to be just like every other language. Laravel ends up close to Django with a slick sheen put on top (and I'm not sure if that's even a compliment), and Python beats out PHP for being more useful in a sports data context.
That culls the list down to just three contenders:
Let's think through each of these regarding both the language and the most promising framework candidate.
Django (Python)
Pros
- I'm already familiar with Django and Python.
- Python is (maybe) the most popular language in the world right now.
- Python is one of the key languages for sports analytics.
Cons
- Django has no built-in option for live updating, but something like HTMX has become maybe the most common tool for it.
- Python would require greater scaling to support hundreds or thousands of users. (Note: I do not have any users yet.)
- Django is sort-of the most boring option. Should that count against it?
Phoenix (Elixir)
Pros
- Phoenix has a built-in option for live updating pages (LiveView).
- It's fast and lightweight (compiled).
- It's easy to deploy someplace like Fly.io
Cons
- Elixir uses a very different programming paradigm from what I'm most used to.
- Phoenix feels like it's striking a balance between easy and powerful, which means it's a little harder to get started.
Lucky/Marten (Crystal)
Pros
- Crystal is the most niche language on my list, which is nice to brag about.
- Marten has similarity with Django, which I am familiar with. (And I'm familiar with Marten's creator, Morgan Aubert, from using his forum plugin for Django. Am I too affected just because I saw someone's name in two different places on the internet?)
- Crystal should be fast and lightweight (compiled).
Cons
- Crystal is the most niche language on my list, which means it has the fewest resources for learning and troubleshooting.
- There's no baked in way to do live updating.
- If you count Amber as well, there are three competing web frameworks, and the one I'm leaning toward (Marten) is the least mature. It's definitely not clear if I'm picking something I can count on for the long-term.
Conclusion
I admit, I'm writing this after a few frustrating days of messing with Elixir and Phoenix. I start wondering if I need to either go back to something familiar (Django/Python) or towards something younger and less complex (Marten/Crystal).
The answer, once I think about it, is that I should probably push forward on what seemed like the best option at the beginning.
DraftKick Basketball is available now!
If you're still tracking your draft with a custom spreadsheet or even just pen and paper, you need to try DraftKick.
It is packed with features to help you succeed on draft day:
- Projected availability
- Keepers
- Salary cap (auction) drafts
- Custom league configuration
- Editable projections
- ...and more
It's completely free to try out!