Faultd.

Journal of a software engineer.

Archive: 2024

A list of 9 posts.

I don't like social coding

19 November, 2024

I've come to the conclusion that I don't like GitHub. No, not the website or the company, but the idea itself. "Social coding", the thing that has been its tagline. And no, not even the social part, but everything that we've come to accept as part of the "social" whenever we encounter other social things, like social networks. The vanity stuff, in particular.

You see, some of my projects get recognition, and that makes me feel good. My lizard brain takes it as validation, and concludes that for the brief moment following the seeing of a new "star" or "follow", I actually matter. I make a difference in the world. People like what I do. And this is great.

But then on the flip side, the vast majority of my projects get no stars or recognition at all. This, then, makes me feel bad. Am I not making good enough software? Am I even a good programmer? Maybe people just don't like me? And this is not great.

Maybe I'm just too sensitive to the subconscious mind programming of the modern world, but I'd rather not have any of this at all. Ultimately I make my projects because I want to make them. I make them because they are useful to me, and I wouldn't care if anyone even knows about my existence if it were not for all the indications showing me constantly if they do or not.

I've found that even the mere existence of these metrics on the page subconsciously make me crave recognition, and then make me want to partake in social media where I would post about my projects so that maybe someone would find it useful and "star" it or something. Whatever it is, I don't like it, and it's not something I want my hobby programming to be about, or even partly have, in no matter how small of a part.

Thus, I'm starting my move to SourceHut. I don't really care which platform is superior in features or whatever. This is not me saying you should also use SourceHut. I just want a simple git hosting with CI/CD and not much else, and from what little research I did, it seems to be the only such service without vanity metrics, and from what I can gather its founders also have no interest in something like that.

Loggr, so your days would be more enjoyable

11 November, 2024

I've created a new PHP library called Loggr. Just like the name would suggest, it is a logging library. However, unlike most logging libraries out there, it does not invent a yet-another-logging-format and instead implements multiple, popular, already-existing formats like IntelliJ, JSON, Laravel and Symfony.

Born out of the frustration of having to read through endless log files and not having any log viewing tool support any of the log files created, I hope to bring a little sunshine back to your life. It certainly has to mine.

PHP 8.4

9 November, 2024

In a week or so, PHP 8.4 will be out, and the most notable thing about it, to me at least, is the ability to use property hooks. The abuse of getter/setter methods has always bothered me in OO languages (especially Java), and I'm glad that the getters and setters can be written directly to the property itself now.

Clean Code Evangelists are probably not happy that this encourages directly using the properties instead of a wrapper method, but they can all get fucked anyway. To me, pragmatic and simple to understand code is the best, and religious bullshit cargo-culting of design patterns is not something I'm interested in.

Anyway, this is what it looks like:

class BookViewModel
{
    public function __construct(
        private array $authors,
    ) {}
    
    public string $credits {
        get {
            return implode(', ', array_map(
                fn (Author $author) => $author->name, 
                $this->authors,
            ));
        }
    }
    
    public Author $mainAuthor {
        set (Author $mainAuthor) {
            $this->authors[] = $mainAuthor;
            $this->mainAuthor = $mainAuthor;
        }
        
        get => $this->mainAuthor;
    }
}

(I stole this from Brent Roose's excellent blog post with a lot more info on PHP 8.4).

Boolean Expressions and Interpolated Expression Modifiers in HTMT

30 October, 2024

I recently released the 2.0 version of HTMT, and with it came new features, such as boolean expressions and interpolated expression modifiers. I feel like these are the two features that make HTMT pretty feature-complete now and allow me to focus on other projects, such as the Markdown parser that powers Tobey, and further down the line porting Invobi over to C# from its current PHP implementation.

Anyway, let's dive into these features.

Boolean Expressions

Boolean expressions are an addition to the if and unless attributes in HTMT. While previously you could only use these attributes to check if a variable was truthy or falsy, you can now use boolean expressions to check for equality,

So for example you could do something like this:

<div x:if="(a is b) or (b is c)">
    <p>Either a is b or b is c</p>
</div>

It supports the following operators: is, and and or, and you can use parentheses to group expressions. You can not only compare variables, but also strings and numbers (ints and floats).

Of course a simple truthy/falsey check is still possible, but if HTMT detects any spaces in the expression, it will treat it as a boolean expression.

I do plan to add more operators in the future, such as is not, is less than, is more than, and so forth. I like natural language, so I want to make it as easy to read as possible, and something that designers can easily understand.

Interpolated Expression Modifiers

Interpolated expression modifiers are a way to modify the output of an expression. They are added to the end of an expression and are separated by a pipe |, allowing you to chain multiple modifiers together, like so:

<p x:inner-text="{title|uppercase|reversed}">

This would output the title variable, but it would make the output uppercase and then reverse it.

Modifiers can also take arguments, like so:

<p x:inner-text="{title|truncate:10}">

This would truncate the title variable to 10 characters.

The arguments can be anything, and it is up to the modifier to parse them into what they need. All of this is, of course, extendable, meaning that you can create your own modifiers and use them in your templates.

Currently, the following modifiers are available in HTMT:

I don't have any need for more right now, but I'm open to pull requests if you want to contribute.


All in all I'm really happy with how HTMT is turning out, and I'm excited to see what people will build with it. It has been immensely useful to myself, and has been very fun to build. I really enjoy C# and the .NET ecosystem, and I'm looking forward to building more tools and libraries in this space.

Introducing HTMT

14 October, 2024

Woah, where have I been? Well, since my last post I've gotten a new job at Novater that I'm really enjoying, and I've also been busy working on my first ever C# project: HTMT or Hypertext Markup Templating. It's a templating language that is a superset of HTML/XML, and looks a little something like this:

<!DOCTYPE html>
<html>
    <head>
        <title x:inner-text="{title}"></title>
    </head>
    <body>
        <h1 x:inner-text="{title}"></h1>
        
        <div class="posts" x:if="posts">
            <div x:for="posts" x:as="post">
                <h2>
                    <a x:href="/blog/{post.url}" x:inner-text="{post.title}"></a>
                </h2>
                <div x:inner-html="{post.body}"></div>
            </div>
        </div>
    </body>
</html>

I was re-writing Tobey in C# and wanted to use a templating language, but quickly discovered that there seem to be no templating languages that support trimming and native AOT compilation, so I decided to make one.

Another goal of mine with this was to eliminate the frustration I've had with many other templating languages - namely that they quite often lack good editor support or syntax highlighting, and because HTMT works by using regular HTML attributes, you won't need any additional syntax highlighting.

There's still a bunch I want to achieve with this, such as partials, more complex conditionals, and more, but I'm really happy with how it's turning out.

You can read more about HTMT on GitHub or NuGet.


You may be wondering why C#? And what happened to C++? Well, while I really enjoy C++, I wanted to set my main focus on something that is actually employable and also a joy to write - with great tooling, ecosystem and a huge array of things you can do with it, C# fits that bill perfectly. Hence, why I've been re-writing Tobey in C# and also building HTMT in C#. As part of the Tobey re-write, I will soon publish another library as well - a Markdown parser, naturally also one that supports trimming and native AOT compilation.

PHP Career Trajectory

4 September, 2024

I've been pondering lately about PHP and its place in the world. It's an infamous and imperfect language yet so much of the web runs on it, and it's not going anywhere anytime soon. That said, I do think I have a pretty good idea on what the future looks like for those who are banking on PHP as their career.

While PHP, especially in the last few years, has been making huge strides in improving its warts and catching up with modern programming languages, I don't see many greenfield projects that start out with PHP. In fact, I see less and less job opportunities for PHP developers in general, especially those who are exclusively PHP and not full-stack developers.

From my experience and observations it seems PHP is almost exclusively used for low-budget projects e.g small business websites, blogs, and the like, and whatever bigger more complex projects that run on PHP are almost always legacy projects that lack a budget or motivation for a rewrite. This explains also why the average PHP developer salary is one of the lowest in the industry.

My prediction is that if you're a PHP developer right now, your salary will most likely start to increase soon, as universities no longer teach PHP and the number of new PHP developers is decreasing, while the footprint of PHP projects is still huge. PHP will enter its "COBOL phase", where most of the projects will be maintenance of legacy projects. This is good news in that you can make more money, possibly.

Now whether you can sustain an entire programming career on that I do not know, and that depends on how far along in your career you are. If you're a junior, I would recommend migrating to something that doesn't lose 2-5% of its popularity each year (according to StackOverflow surveys from 2020 onward), and even more I'd recommend learning programming fundamentals to such a degree that languages no longer really matter and become easy to pick up - that's how you become an actual software engineer and not just a {language} developer.

Data Composition in Tobey

26 August, 2024

I've just finished implementing basic data composition in Tobey. This is a feature that allows you to create data from content for use within templates, with a simple YAML DSL. Here's an example:

composer:
  posts:
    template: post.html
    sort_by: id

This will create a posts variable that contains all entries in the "blog" directory, sorted by their YAML meta-data id, in descending order. This data can then be used in templates to render the blog posts, for example:

{{ for post in posts }}
  <article>
    <h2>{{ post.title }}</h2>
    <p>{{ post.date }}</p>
    <p>{{ post.content }}</p>
  </article>
{{ end }}

And in fact, I use this exact data composition for the front page of this very website of mine. It currently only supports where and sort clauses, and the where clauses only support == comparisons, but I plan to expand on this in the future, and I want to add a where_not, where_in, where_not_in, offset and limit clauses as well, which should allow for pretty complex use cases.

Tobey now has Windows builds

26 August, 2024

Thanks to the help of Abdullah, who figured out why my initial tries at a Windows build failed, Tobey now has Windows builds. It never even crossed my mind that by using the latest C++ standard, there may be compilers that don't support it yet, which was the case here with MinGW. I've now switched to using MSVC.

I intend to make the installation process easier soon as well, so that Windows users could install Tobey with something like scoop or chocolatey, and Linux users with perhaps an installation script or a package manager as well.

Hello Tobey

25 August, 2024

I'll be honest, I've been rather bored with web development for the past couple of years. I've been doing it well over a decade now, and it's really just an endless cycle of building a similar-ish CRUD app over and over again. Yeah, there's been some novel things here and there, but it really is mostly the same. Heck, it's often the same twice - once you write the logic in the back-end, and then again in your front-end SPA. Often I feel like we're just reinventing the wheel just for the sake of reinventing it.

I've looked into an avenue out of web development, and I think I've found a solid path. It's a bit long, but it aligns with things I'm looking for at this stage of my life. Systems programming. Now I know nobody wants to hire a web dev to do systems programming, which is why I said it's a bit long. I'll first have to educate myself quite a bit, build some things, and then once comfortable enough, I can start attempting to find someone willing to pay me for it.

Well into my 30s now, I want and appreciate a bit of a slower pace to things. Web development changes from under you so quickly that you'll never become an expert of anything, and I really want to be an expert of something. I want to invest my time into technologies and concepts that will be relevant not just for a long time, but hopefully until I retire. Since everything, including your microwave, is made with systems programming, I think it's a pretty safe bet.

This, then, brings me to Tobey. Usually when I learn new languages, I like to build a parser in it or something. This time, with Tobey, I built a Markdown and a YAML parser, then put them together to form a FrontMatter parser, and then used all of that to build a static site generator, and I decided to do it all in C++. Why? Because I've always wanted to check it out, and while I do have experience with Rust, I wanted to see how C++ compares. Honestly? C++ is great. I find it very enjoyable to write and debugging with GDB via CLion is also a breeze.

It's a language that can be both elegantly simple and painfully complex at the same time, and you can choose your own adventure. I know people say C++ is riddled with too many features and that this makes the language hard, but I mean, you don't have to use every feature, surely? In any case, I'm not here to justify my choices to anyone, I'm here to learn and have fun, and C++ is providing me with both.

I'm continuing to build Tobey and will publish updates right here as I go along. I'm also eye-balling to buy a Nucleo and see if I can build something with it as well and tip my toes into embedded systems programming. I'm excited to see where this journey takes me.