Skip to content

Commit

Permalink
Merge pull request #1 from opensourceworks-org/doc/backends
Browse files Browse the repository at this point in the history
Doc/backends
  • Loading branch information
jeroenflvr authored Sep 23, 2024
2 parents c97f1a6 + 9618ccb commit 2883fbc
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 38 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem "minima", "~> 2.5"
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
gem "jekyll-remote-theme"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ GEM
webrick (~> 1.7)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-remote-theme (0.4.3)
addressable (~> 2.0)
jekyll (>= 3.5, < 5.0)
jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0)
rubyzip (>= 1.3.0, < 3.0)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-seo-tag (2.8.0)
Expand Down Expand Up @@ -89,6 +94,7 @@ GEM
ffi (~> 1.0)
rexml (3.3.7)
rouge (4.4.0)
rubyzip (2.3.2)
safe_yaml (1.0.5)
sass-embedded (1.79.3)
google-protobuf (~> 4.27)
Expand Down Expand Up @@ -173,6 +179,7 @@ DEPENDENCIES
http_parser.rb (~> 0.6.0)
jekyll (~> 4.3.4)
jekyll-feed (~> 0.12)
jekyll-remote-theme
minima (~> 2.5)
tzinfo (>= 1, < 3)
tzinfo-data
Expand Down
32 changes: 32 additions & 0 deletions _posts/2024-06-22-website-backends.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
layout: post
title: "Website Backends"
date: 2024-06-22 22:52:10 +0200
categories: code backend programming languages
---
## So many new programming languages
There are so many new and improved general purpose programming languages lately. [LLVM](https://llvm.org/) probably has something to do with that. Anyway, C and C++ are the defacto standard languages for embedded and performance critical applications, including games, web development, etc. But what about Rust, Go, Zig? I might check out Gleam, Odin, Roc, ... later too. They all look so incredibly promising.

## The start
To learn a new programming language, they say you should build a go-to project. Something you're familiar with. But also, something which fits in the language's capabilities. I've been wanting to build a portfolio site for a very long time, just never had a reason or the will to get at it.
Playing around with [htmx](https://htmx.org/) at my current professional project, [a backend](https://flexworks.eu) seemed like a good fit.

## The environment
Anything frontend is htmx. Static content is fetched by the backend from a static location on an openresty server, which I already wanted to use as reverse proxy (ssl offloading, cache, etc). Static components like js, css and images are served directly from a /static endpoint on the reverse proxy.

The frontend is all htmx and bootstrap. This is not a performance benchmark (per se), so the focus is on using whatever is popular and convenient. The projects will run on rasperry pi 4B, a pi zero 2w and even a pi zero 1.1 w (32bit). All dockerized. Development is on a macbook air M1 13", an HP 840 G3 i5-u6300u elitebook and an HP Proliant ML110 G6 Xeon X3440. Apart from the mac, the rest is pretty old and resourcilly challenged. Perfect for these programming languages. I can already guess that compile times will hurt, but looking forward to runtime performance.

[![sequence diagram](https://flexworks.eu/static/img/flexworks.eu.sequence.diagram.amber.svg)](https://flexworks.eu/static/img/flexworks.eu.sequence.diagram.amber.svg)

## The contestants



| Language | Web Server | Templating Engine |
| -------- | ---------- | ----------------- |
| [Go](https://go.dev/) | [Chi](https://go-chi.io/#/) | [Templ](https://templ.guide/) |
| [Python](https://www.python.org/) | [FastAPI](https://fastapi.tiangolo.com/)/[Uvicorn](https://www.uvicorn.org/) | [Jinja2](https://jinja.palletsprojects.com/) |
| [C#](https://learn.microsoft.com/dotnet/csharp/) | [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) | [Razor Pages](https://learn.microsoft.com/aspnet/core/razor-pages/) |
| [Rust](https://www.rust-lang.org/) | [Axum](https://github.com/tokio-rs/axum) | [Askama](https://github.com/djc/askama) |
| [Zig](https://ziglang.org/) | [Zap](https://github.com/Snektron/zigzap) | [Mustache](https://mustache.github.io/) |

22 changes: 22 additions & 0 deletions _posts/2024-09-22-pulling-the-plug.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
layout: post
title: "Pulling the Plug"
date: 2024-09-22 22:52:10 +0200
categories: code backend programming languages
---

## First
1. [Website Backends]({{ site.baseurl }}/code/backend/programming/languages/2024/06/22/website-backends.html)

## The Start
Initially, I wanted to get a feel for some of the new cool general purpose programming languages. I'm using Python extensively on my professional project as a data engineer, so that's pretty much the reference. That's also how I rolled into looking at Rust ([Polars](https://pola.rs/), [DataFusion](https://datafusion.apache.org/), [Delta-rs](https://delta-io.github.io/delta-rs/)). Given Zig's interoperability with C, that's what I'm using to rewrite the excellent-although-slightly-aged lightweight no-nonsense monitoring tool Xymon in. C# is my son's go-to language and it's supported at my current project as well. And Go, well, hard to ignore it with its pedigree. Also, it's easy, fast to write, fast to execute, fast to compile, fast to set up, fast to read...

## Pull the plug (partially)

I think I got a pretty good basic understanding of the languages by now. Maintaining 5 different backends is impossible with a full time job.
Next, I'll post my findings for each of them (spoiler: they're all great). For the [portfolio website](https://flexworks.eu), I'll stick to Rust, as that currently, and unfortunately, is the only language I'm not using professionally.

I could have used C/C++ with [facil.io](https://facil.io/) as the reference instead of python, since all the others are compiled too, but I think python is more popular than C/C++, at least for this kind of stuff.



29 changes: 0 additions & 29 deletions _posts/2024-09-22-welcome-to-jekyll.markdown

This file was deleted.

52 changes: 52 additions & 0 deletions _under_construction/2024-09-23-the-report.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: post
title: "The Report"
date: 2024-09-23 08:52:10 +0200
categories: code backend programming languages
---

## First
1. [Website Backends]({{ site.baseurl }}/code/backend/programming/languages/2024/06/22/website-backends.html)
2. [Pull the Plug]({{ site.baseurl }}/code/backend/programming/languages/2024/09/22/pulling-the-plug.html)

## TLDR;


| Language | Webserver | Templating Engine |
| -------- | --------- | ----------------- |
| __Go__ is a great language for pretty much anything, and even more and more so for data processing. Compiles incredibly fast. The only language that did not struggle with my older hardware. | __Chi__ is simple to use, plenty fast. Used Air for hot reloading. Great experience. | __Templ__ is the templating engine I struggled with the most. Cool how it compiles the templates in, but syntax is sometimes a bit verbose |
| __Python__ is by far the slowest at runtime and the only interpreted language used here. Deployment is annoying with having to set up a python environment first. Used [Rye](https://rye.astral.sh/) instead of [Poetry](https://python-poetry.org/) which made that experience a lot faster though. | __Fastapi/Uvicorn__ is excellent, especially with Pydantic integration. Batteries included. | I have been using __jinja2__ templates for a while with django, ansible, flask and also fastapi. It's pretty much my reference for the other templating engines. |
| __C#__ worked out better than I initially thought. `public static void Main(String[] args)` aside, it's a mature language with great documentation and community. DotNET8 allows for statically compiled single binary, including the [.NET runtime](https://learn.microsoft.com/en-us/dotnet/standard/clr). That CLR gets extracted to a temp location when executing the binary. | Built-in. Made me reconsider Go with Chi and should have gone with the standard lib http server too. No complaints. | Razor pages are nice, but it's an all or nothing kind of deal, no partials. I mixed built-in routing and __RazorPages__. There's a [RazorSlices](https://github.com/DamianEdwards/RazorSlices), although for the few times I needed partials, I just replaced placeholder tags. |
| __Rust__ is a handful. Always. Every single line needs to pass the borrow checker. Makes for better code, but you need to get passed the frustrations first. Compilation is really slow. Just like with Python, you drag in a lot of dependencies. But when you run it, WOW! | __Axum__ is cool, has all you need. | __Askama__ templates are much like jinja2. Good stuff. |
| __Zig__ is a great language. Really love it. Also the way it interops with C. The language is very immature and the documentation, if there is any, is already superseded and obsolete. The community is very active and supportive. Struggled with a memory leak, but once I wrapped the General Purpose Allocator in the Arena allocator, I was able to pinpoint the culprit with the gpa's memory leak detection. | __Zap__ is a Zig wrapper around facil.io, a C library. It's great, has everything I needed. Because of [this](https://github.com/zigzap/zap/pull/132#issue-2538805273), I should check out [httpz](https://github.com/karlseguin/http.zig) and [jetzig](https://www.jetzig.dev/) instead.| __Mustache__ comes with facil.io. Not the best syntax, but supports includes, partials etc. Pretty straight forward.|


### GO

#### pros
#### cons
#### overall

### Python
#### pros
#### cons
#### overall

### C#
#### pros
#### cons
#### overall

### Rust
#### pros
#### cons
#### overall

### Zig
#### pros
#### cons
#### overall

## Conclusion


15 changes: 6 additions & 9 deletions about.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ title: About
permalink: /about/
---

This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)
I'm Jeroen. Trying to keep things interesting and working in different area's in Information Technology: backend, data, infrastructure/ops, cloud, monitoring, security, automation ...

You can find the source code for Minima at GitHub:
[jekyll][jekyll-organization] /
[minima](https://github.com/jekyll/minima)
Some things I'm currently working on:
- Xymon rewrite (Zig)
- [deltalake-tools](https://pypi.org/project/deltalake-tools/): A set of easy to use commands for deltalake, with a command line interface. (Python, rewriting in Rust)
- [NotMongo](https://notmongo.opensourceworks.org/): A Maybe DuckDB extension for json APIs (C++)

You can find the source code for Jekyll at GitHub:
[jekyll][jekyll-organization] /
[jekyll](https://github.com/jekyll/jekyll)


[jekyll-organization]: https://github.com/jekyll
[jeroen](mailto:[email protected])

0 comments on commit 2883fbc

Please sign in to comment.