Server-Side Frameworks - Trust me, you don't wanna write this crap from scratch. [The Web Explained: Part 5]

Server-Side Frameworks - Trust me, you don't wanna write this crap from scratch. [The Web Explained: Part 5]

March 15, 2021 | 🕐9 Min Reading Time

🏰 Server-Side Frameworks

It should be no surprise to you that the same inherent laziness desire for efficiency that motivates many front-end programmers to utilize packages and frameworks to speed up application development exists on the backend as well. As you dive deeper and deeper down into the strata that is software development on the web, it becomes more and more like a fractal.

You choose a language first, and then you're met with even more choices regarding the ideal framework to use with each language. Even when you've chosen that, there is sometimes a myriad of choices that we must make regarding the implementation of the framework.

Do not. I repeat. DO NOT let this analysis paralysis stop you from just choosing something and diving in. I've yet to find the perfect framework, although Rails people would tell you it's the one true God (hard to disagree, tbh). Also, people keep making new ones, so they're never happy either. Just pick one that speaks to your heart and go with it for the purposes of your education.

Furthermore, many of these frameworks come with different flavors of the same things:

  • Helpful scripts, generators, and CLIs (command-line interfaces) to save you time doing repetitive stuff
  • Established conventions and best-practices on how to accomplish that totally-not-unique thing you're doing
  • Documentation and community
  • Common tools to accomplish common tasks
  • etc.

Given that there is such a ripe opportunity for decision-fatigue to crush your soul before you even get started, I'm going to present you a minimal and opinionated list of what framework I would learn were I to create a web application with any of these languages. These are merely suggestions to help you narrow your focus at this juncture, so I encourage you to explore on your own. Additionally, the code samples are just to illustrate and give you further familiarity with what the language and framework look like, give you a 100,000' view, and are far from any sort of best practice.

Finding your ideal technology stack is a lot like dating to find your true soulmate in life.

Before you find "the one", there's gonna be some great long-term relationships, maybe a few flings here or there, but ultimately you'll land on something that really complements your life in a way that makes waking up each day a joy. You also learn to deal with and work around a certain amount of bullshit and imperfection...I know my wife does this masterfully. But, as with any relationship, the longer you are in it, the more you learn to appreciate the intricacies and minuscule nuances that make it truly special.

🚂 Ruby: Ruby on Rails


Rails was first introduced in 2004, and it has a very loyal following. Sites like Github, Airbnb, and Kickstarter all use Rails. I've personally used Rails and have loved the experience through-and-through. In addition, the company behind Rails (Basecamp) is just as opinionated as the framework, and I personally find myself agreeing with them a lot.

Why People Love It:

Example Code to Respond to an API request to GET burgers

class Api::CheeseburgerController < ApplicationController # GET /burgers def index # imagine we have a database of burgers @burgers = Burger.all render json: @burgers end

🧠 Learn more about Ruby on Rails:

> Code Academy: Learn Ruby on Rails
> Go Rails: Rails for Beginners

🐍 Python: Django

(I have not professionally used) A fine example of a nope rope / danger noodle

One could argue that Django is more popular than something like Ruby on Rails because Python is such a prevalent language. Designing software isn't always a popularity contest, however. So if I had to choose between Rails and Django, Rails would still be my go-to based solely on my own experiences with Rails and (relative) lack of experience with Django. It's my article; I can say what I want. Take that.

Why People Love It:

Example Code to Respond to an API request to GET burgers

# ---- from django.urls import path from .views import send_burgers urlpatterns = [ path('burgers/', send_burgers, name='send_burgers'), ] # ---- from django.http import JsonResponse from models import Burger def send_json(request): data = Burger.objects.all() return JsonResponse(list(data))

Learn more about Django:

> Writing Your First Django App
> FreeCodeCamp: Django Web Framework - Full Course for Beginners

⚡️ Node: Express

light and fast

I probably do something in Express every day. It's almost become my daily driver at this point. Compared to frameworks like Ruby on Rails or Django, Express is going to have you feeling like Marie Kondo was on an absolute rampage and took away all the features you weren't using anyway. Express is intentionally minimal and requires you to find which NPM packages you would like to use to accomplish your mission.

Why People Love It:

  • Pretty easy to configure and customize.
  • Middleware is pretty neat and powerful.
  • You can choose a variety of templating engines for rending things like HTML.
  • Darn simple to make a down-and-dirty API endpoint.
  • Writing Javascript everywhere is nice.
  • Express is used under-the-hood to power even more complex frameworks, like NestJS, making it a great starting point for NodeJS development.

Example Code to Respond to an API request to GET burgers

import express from 'express'; const app = express(); const db = require('./models'); app.get('/burgers', async (req, res) => { const BurgerModel = db.Burger; const burgers = await BurgerModel.findAll(); return res.json(burgers); }); // start the app and make it available at http://localhost:3000 app.listen(3000, () => console.log(`Example app listening on port 3000!`));

🧠 Learn more about Express:

>Getting Started With Express
>Express in 10 Minutes

😸 Node: NestJS

The internet loves cats.

NestJS is kind of a new kid on the block, but it's taking the Node.js backend world by storm. It uses Typescript, which is basically Javascript with superpowers, to deliver efficient and scalable server-side applications. We use NestJS where I work, and the developers that use it daily are raving fans of its simplicity, power, and how much they get out-of-the-box for free.

Why People Love It:

  • Easy to use, learn, and master.
  • Documentation is great.
  • Currently one of the fastest-growing Node.js frameworks.
  • Simultaneously built for small shops and large scale enterprise applications.
  • It gives you a huge boost at the start and then nurtures that with a framework built to ensure you're doing the right thing from then on out, using tried and true Node.js and TypeScript architectural patterns.
  • Kitty Cats.
  • Seriously the cat thing is to die for.

Example Code to Respond to an API request to GET burgers

import { Controller, Get } from '@nestjs/common'; import { BurgerService } from './burgers.service'; import { Burger as BurgerEntity } from './burger.entity'; import { BurgerDto } from './dto/burger.dto'; @Controller('burgers') export class BurgersController { constructor(private readonly burgerService: BurgerService) {} @Get() async findAll() { // get all burgers in the db return await this.burgerService.findAll(); } }

🧠 Learn more about NestJS:


🧙‍♂️ Java: Dropwizard

(have not professionally used)

I first heard about Dropwizard from a colleague I respected the hell out of during my time at Bunchball. His rather serious demeanor was betraying the fact that he was nonchalantly saying Dropwizard every 3 and half seconds as if it were a family moniker passed on to him from his Great Grandfather. Despite the strange name, Dropwizard has quickly become a favorite amongst my web-focused Java friends. This is primarily because Dropwizard focuses on giving you a toolkit of stable, mature libraries in a light-weight package that lets you focus on getting things done.

Why People Love It:

  • Super easy setup. You can create a REST API service pretty much right away.
  • Including mature and performant libraries ensures that this thing is ready for prime-time applications.
  • Easy Debugging.
  • Everyone is using it and it's...the...hottest...because...

...wait a second. SURPRISE** 🎉!

There's something I need you to learn about software development. That is that you can feel your heart flutter about a particular framework, slowly gain mastery, and have an absolute blast making apps with it. It'll feel like an extension of you. Making things with your BFF (best framework friend) will reach the level of zen that only Bob Ross knows as he whacks his paintbrush against the leg of his easel, blowing your mind making a photorealistic sky with Titanium White™ clouds amongst a vast sea of Prussian Blue.

I mean, look at this bliss

And then, you're going to find out that there's a new shiny thing out there. It's easier. It's faster. It will be the last framework you're ever going to need!

What are you to do? Why do you need to learn this lesson? As software developers, we are often tasked with finding the right tool for the job, and sometimes it's a little less cut-and-dry than simply selecting a hammer to hit a nail. New stuff comes along ALL THE DAMNED TIME, and you're going to feel like you're always behind. You're not.

Now, you should always keep an eye out for new things popping up and tinker with things that look promising, but ultimately if you're productive with a particular toolset, MAKE STUFF FOR PEOPLE WITH IT!

Most end-users wouldn't give two hells if you made it in Java, PHP, or Node. They. Will. Not. Care. Period. End of story.

So keep your mind open, keep poking around to see what's developing, but don't paralyze your soul on the never-ending treadmill of technological transience. Most of the skills you learn in one framework will transfer, in some way, to another...and another...and another.

You know, like this hot new framework that will solve all your woes for realz...Spring Boot.

🌱 Java: Spring Boot

(have not professionally used) sprout

Spring is among the most popular Java-based frameworks because of its modularity, enterprise-scale-focus, and a neat lil' feature called dependency injection. This is just a fancy label that means "when I need the functionality of some other bit of code, make that available to my code without a lot of fuss. kthxbye."

Spring, however, has a reputation for needing extensive configuration via XML files and lots of boilerplate setup to get going. Boo.

Enter Spring Boot, which takes an opinionated view of Spring and lets you focus on simply building an app instead of having to travel through the Sisyphean task of config files and plumbing. At its heart, it's still a Spring app, which means that you can still configure things to your heart's desire, but Spring Boot aims to get you to a state of "just running the damn thing" very quickly.

Why People Love It:

  • It abstracts away complexity and lets devs focus on just building their app.
  • It comes with production-ready things like health checks, metrics, and externalized configuration.
  • It's opinionated, so decision fatigue is reduced.
  • Strong community.
  • It's like Coke Zero - all the dependency injection flavor of Spring, without all the pesky XML calories.

Example Code to Respond to an API request to GET burgers

@RestController @RequestMapping("/burgers") public class BurgerController { // bring in our burger service dependency @Autowired private BurgerService service; @GetMapping("/") public Burgers read() { return service.findAll(); } ...

🧠 Learn more about Spring Boot:


♦️ PHP: Laravel

Just one last Nickelback joke, I swear.

Stepping onto the scene in 2011, Laravel has become the de-facto standard framework for building well-architected PHP applications. It's great for everyone, from new PHP developers to seasoned web veterans, and strives to create a pleasant developer experience (DX) in the process. It comes with awesome features such as dependency injection, an ORM (makes working with databases a breeze), queues and scheduled jobs, unit and integration testing, and more.

If I were to find myself writing a PHP-based application as I write this in 2021, I would choose Laravel without question. After a decade or more of seeing various frameworks come along, this is the first one that I've been really impressed with.

Why people love it:

  • Built-In Authentication and Authorization - you can implement an entire auth system in a few lines of code and a little command-line-fu.
  • Lots of great packages available for Laravel to extend and add functionality, making it a breeze to stand up things like eCommerce with Stripe, social login and authentication, OAuth, and full-text search.
  • The Eloquent ORM makes reading, writing, and updating databases a breeze.
  • The documentation is phenomenal.

Example Code to Respond to an API request to GET burgers

// import our imaginary burger Model Use App\Burger; Route::get('burgers', function() { // If the Content-Type and Accept headers are set to 'application/json', // this will return a JSON structure. return Burgers::all(); }); // bonus: get a burger by a specific ID Route::get('burgers/{id}', function($id) { return Burgers::find($id); });

Learn more about Laravel:


🎁 In Summary

In the words of the greatest poet of the 20th Century, Keanu Reeves..."whoa." I get it. That was a lot to get through. We definitely went about 5 miles wide and about 5 millimeters deep, however, so the next steps are completely on you.

The nice thing about software is that every single thing we've covered so far is 100% absolutely free. You can download each of these, try a new one each day of the week, AND have money left over for the best chicken dinner on the planet. It's really the type of win-win I strive to achieve in life, and if you keep reading along and journeying with me into the soft underbelly of the internet, you might even get dessert.

If you're serious about learning any framework, it's an excellent idea to make sure you know the language the framework is built on top of. Some people like to jump into using "Ruby on Rails" with complete disregard for the thing that makes up 36% of that phrase: ruby. You will quickly find yourself having a bad time if you dive into the framework without understanding the nuances of the language. It doesn't matter how well thought out the feng-shui-inspired streets of Seoul are; if you don't speak Korean you're going to find it hard to find your way for very long.

We covered a lot. So, for now, take a little break and relax. Don't feel overwhelmed.

“The secret of getting ahead is getting started. The secret to getting started is breaking your overwhelming tasks into small manageable tasks, and then starting on the first one...which is most likely learning about databases or something.” —Mark Twain (digitally remastered)