11/07/2024 - 22:20 · 10 Min read

How I over-optimized my site - Part 1: Backend

I've decided to move away from WordPress and Drupal - CMS that I once loved and used extensively in my early web development days

How I over-optimized my site - Part 1:  Backend

Abandoning Traditional Technologies

I've decided to move away from WordPress and Drupal - CMS that I once loved and used extensively in my early web development days. The main reason for this shift is that PHP, despite its widespread use, has several limitations that can impact modern web development:

  1. Performance: PHP is generally slower compared to compiled languages like Go or Rust. While recent versions have improved, PHP still lags behind in raw performance, which can be crucial for high-traffic applications.
  2. Request handling: PHP's model of re-initializing the environment for each request can be resource-intensive, potentially leading to slower response times and higher server costs, especially for applications with high concurrency.
  3. Memory management: PHP's memory management, while improved in recent versions, is still not as efficient as other modern languages. This can lead to higher resource usage and potential memory leaks in long-running applications.
  4. Language design: PHP's inconsistent syntax and historical lack of strictness can make it prone to errors and harder to maintain, especially in large codebases. While newer versions have introduced stricter typing, the language still carries some of its legacy inconsistencies.It's worth acknowledging that frameworks like Laravel have significantly improved PHP's capabilities, enhancing both its performance and structure. This has contributed to PHP's continued popularity in web development.

Golang for my project

  1. Performance: Golang, being a compiled language, significantly outperforms PHP in execution speed and resource efficiency. This is crucial for high-traffic applications and complex backend systems.
  2. Concurrency: Golang's goroutines and channels provide built-in, efficient concurrency handling, allowing for better performance in multi-tasking scenarios. PHP's single-threaded nature makes it less suitable for concurrent operations.
  3. Type Safety: Golang's strong, static typing catches many errors at compile-time, leading to more robust and maintainable code compared to PHP's dynamic typing.
  4. Modern Language Design: Golang was designed with modern computing needs in mind, offering a cleaner syntax, better standard library, and built-in tools for formatting and testing, addressing many of PHP's historical inconsistencies
  5. Im a gopher

While PHP remains viable for many web projects, Golang's strengths in these key areas make it a superior choice for building robust, scalable, and maintainable systems, particularly for complex backend services and high-performance applications.

Why Not Rust?

While Rust is a powerful systems programming language and one that I'm quite fond of, second only to Golang in my affections, I decided not to use it as the primary language for my web development projects for several reasons:

  1. Library Ecosystem: Compared to Golang, Rust has a less mature ecosystem for web development, with fewer battle-tested libraries and frameworks.
  2. Use Case Mismatch: Rust's strengths in low-level systems programming and memory safety are not fully utilized in typical web applications, making it an overqualified choice for most web development tasks.
  3. Development Speed: The strictness of Rust's compiler, while beneficial for system-critical applications, can slow down the rapid development cycles often required in web projects.

However, Rust isn't completely out of the picture. I plan to leverage its strengths in a specific area: WebAssembly for AI Features. For the AI components in the admin section, I intend to use Rust to develop WebAssembly modules. This approach allows us to harness Rust's performance benefits and strong type system for computationally intensive AI tasks that run in the browser, while keeping the main web application in Golang. This balanced approach allows me to use the right tool for each specific job, optimizing both development efficiency and application performance.