DEV Community

Cover image for Stop Shipping Bugs: How Bun + Hono Gave Me Rust-Level Confidence
Thomi Jasir
Thomi Jasir

Posted on

Stop Shipping Bugs: How Bun + Hono Gave Me Rust-Level Confidence

It’s been a long time since I last wrote an article like this. Since I’m working in a bank as a software engineer, being in a bank environment often makes me feel bored and sometimes, it feels like my skills are slowly becoming outdated.

I have expertise in Rust, and I have used Rust for over 2 years on my personal projects. Working with Rust was a great experience. I never felt this level of discipline in code before, because previously I used JavaScript.

As we know, JavaScript is easy and lives everywhere. One thing that I don’t like about JavaScript is that you can do one thing in many ways. It’s like the paradox of choice, when you have too many options, you get confused.

That’s why I started looking for another programming option, from JavaScript to TypeScript, and from TypeScript to Rust.

The result was amazing. In Rust, everything must be type-safe and super strict. The tooling in Rust for development is very good.

But being too strict makes development slow, because you need to define everything properly.

For critical applications like finance, it’s okay, but what about when we want to develop simple applications like chat apps or simple CRUD systems? I think it’s too much.

Then I started to think, why don’t we combine the strictness rules from Rust but apply them in TypeScript? That way, we can get better code discipline and better code quality, while still being flexible. This idea came to my mind for one week and never left my head.

After some research, I found a solution by combining Bun + Hono + the Rust Configuration Pattern (from my past experience).

Bun is a runtime environment like Node.js, but written in Zig. It has head-to-head performance comparable to Rust and C. For those of you who don’t know, Bun is like a JavaScript/TypeScript runtime that translates your JS code into a native binary.

After development, I built a backend service with predefined rules and strictness like Rust, but flexible like JavaScript. You can find it on my GitHub https://github.com/thomijasir/hono-starter.

Bun Hono Starter Kit

Specification Project

  • Bun as main environment
  • Hono API Framework
  • Typescript as main language
  • Zod for validation in runtime
  • Barrel Pattern Implementation

Project Structure

src/
├── middlewares/        # Hono middlewares (e.g., auth, logger)
├── modules/            # Feature modules (Domain Driven Design)
│   ├── users/          # Example module: Users
│   │   ├── controller.ts # Request handlers
│   │   ├── service.ts    # Business logic
│   │   ├── model.ts      # Data models/types
│   │   └── index.ts      # Routes definition
│   └── index.ts        # Exports all module routes
├── public/             # Static files (JSON mocks, assets) served by catch-all route
├── utils/              # Shared utilities (helpers, response formats)
├── index.ts            # Entry point
├── routes.ts           # Main application router
├── state.ts            # App state initialization (Config, DB)
└── types.ts            # Global type definition
Enter fullscreen mode Exit fullscreen mode

Conclusion

This Hono starter pack is a work in progress, and I am committed to its continuous improvement. If you have suggestions, please feel free to open an issue. If you would like to contribute to the codebase, your input is highly welcome.

I created this project because I enjoy streamlining workflows and helping fellow developers elevate their code quality. I hope this tool enables you to build high performance, high quality applications with minimal friction.

Top comments (0)