#web development

blog

PHP Traits: Multiple Inheritance Revisited

When I first wrote about my hacky TypeScript multiple inheritance implementation that destroyed a codebase, I included a small (emphasis on small) section about multiple inheritance in C++, mostly as a joke about how complicated my TypeScript solution was becoming. I was, however, unaware of PHP’s approach to the concept, so I thought I should write an addendum to that piece. PHP, while primarily functional, does boast object-oriented capabilities that have only improved over time. One of these (added in PHP 5.4!) is Traits, which allow you to compartmentalize code into modules added arbitrarily to classes. Traits are essentially small
Read More
blog

You might be hurting your SEO with a GitHub Pages SPA

In theory, GitHub Pages is a great way to host the frontend of your single-page application, built in React, Angular, or any number of similar solutions. It is fast, easy to configure, and comes with automation capabilities to build your application directly from source. While even a cursory amount of research into the topic will reveal a critical flaw and a convenient workaround solution, this solution could end up hurting your SEO in the long run. GitHub Pages Does Not Natively Support SPAs GitHub Pages lacks a direct way to rewrite incoming traffic to a single file (your index.html), a
Read More
blog

Angular Multiple Inheritance (How to Destroy a Codebase)

This is not a tutorial; please don’t do this. A Brief Primer on Inheritance A common school of thought among programmers is to reduce repetition wherever possible. Usually, this is a good idea, as if I need to change something, I only need to change it in one place. We usually accomplish this using inheritance, like this simple example: This way, both an instance of Animal and an instance of Dog have the name property, but Dogs also have the bark method. If we need to later add a property to both Animals and Dogs, we can just add it
Read More
blog

The Terrible, Horrible, No Good, Very Bad PHP Stock Functions

A lot of defenders of PHP will say that the language has improved immensely in later versions with better support for OOP, which it has! However, PHP is fundamentally broken in its implementations of its stock functions, even compared to other dynamically-typed languages such as JavaScript. Let’s look at some examples: PHP – Functions of a String Function Prefix String is first parameter? Descriptive Name explode ❌ ❌ Sorta ord ❌ ❌ ❌ strstr str ✅ ❌ str_pad str_ ✅ ✅ substr ❌ ✅ ✅ There’s a great amount of inconsistency here, especially with how the functions are named. For
Read More
blog

Implementing WebP Conditionally

What is WebP? We use a lot of images when we build websites nowadays, and while some might disagree with this, I doubt it’s going anywhere. As a result, we have to invest a lot of work into optimizing those images as much as possible, often resorting to ugly and dated compression techniques. WebP is a new image format designed by Google for the modern web. According to a Google study, the average WebP file size is 25-34% smaller than a JPEG equivalent . What’s the Catch? The advantages of WebP seem obvious: lower file sizes with a negligible change
Read More