HACKER Q&A
📣 asib

How do you do web development without a framework?


Every time a web framework is discussed on HN, inevitably a number of people will comment that they prefer to use a curated selection of libraries over a framework. I tend to use frameworks because of their out-of-the-box functionality, e.g. to create an admin interface for an MVP in Django can be literally a few lines of code per model. That kind of speed in early-stage development is something I consider crucial.

So my question is, for those who roll their own framework using libraries, have you created your own equivalents that provide similar power with very few lines or do you just prioritise the flexibility of using libraries (as opposed to an opinionated framework) over (at least early-stage) development speed?


  👤 semicolonandson Accepted Answer ✓
Before I start, some context: I'm an indie-hacker and live off a web-app I programmed myself and maintained for over a decade (check my profile if you're curious). This context is important because 1) I don't need the shared knowledge that a framework facilitates when working on a team 2) My codebase is small (~14k LOC)

I don't use any front-end framework for my JS. Instead I have a have a `main` function that gets initiated and loads up everything that I need on the page (handles, script tags, etc). I wire together interactivity with the DOM via HTML ids (I never use these for CSS, so it's clear their purpose is as JS hooks). I have a `library` file with useful functions (e.g. grabbing query params, hiding or unhiding elements.

If this all sounds very basic, it's because it is. I don't need anything more.


👤 potta_coffee
Before learning Go, I've always used frameworks. Go's standard library is good enough for lots of things. For instance, I feel like the experience of building a REST api in Flask is comparable to building one in Go without a framework. Flask provides similar functionality to that provided in the Go standard library (very rough comparison here, please don't kill me anyone).

👤 asguy
Take a look at MDN’s docs. It’s amazing how nice modern browsers are to program just out of the box, with no ad-ons.

I start with ECMAScript/JavaScript, but lately I’ve been throwing TypeScript in the mix. Usually get a build system working (e.g. WebPack). Then if I need it, I add in a library or two to help out with DOM management (e.g. mithril.js, react).