Reminiscing this and that, on the web since 1995

Tagged development

Web frameworks in Rust

Published tagged , , .

When doing a web application server, one of the first things to decide is which "web application framework" or "request handler library" to use. In Rust, there are more alternatives for that question than in most programming languages, and anyone who has ported some code from tomcat jsp to play framework or from flask to django may dread making the wrong choice. On the other hand, Rust being very strict on static typing makes it very easy to do major refactorings, and I have switched existing projects from iron to nickel to gotham to warp myself without too big problems.

This page collects some of my personal thoughts on each alternative as of September 2020.

Läs och kommentera inlägget Web frameworks in Rust

Rust and the web in 2018

Published tagged , , , .

There is A Call for Community Blogposts over at the Rust Programming Language Blog. This is my entry.

I mainly do "server-based" web service development. The server sends html, css, images, and javascript to the browser. The javascript implements progressive enhancement for the content, but the site should be usable and as nice as possible even with javascript disabled. So while I certainly do RESTful json API:s, I also do server-side html templateing, css (and scss) minification, etc. I think Rust has great potential here, partly because of optimization and execution speed, but mainly because the type safety and fearless concurrency make it easy to actually get things right and avoid unpleasant surprises at runtime.

My wish for Rust in 2018 is a nice and convenient web service framework that runs on stable rust and gets maintenance and regular updates for many years to come. My intent for 2018 is to continue to maintain and improve ructe (and rsass), and try to integrate it with the best such framework i can find.

I currently have two web service projects in rust: homesite is a trivial example using iron and rphotos (https://img.krats.se/) is a more ambitious photo gallery / management app using nickel. Unfortunately, both iron and nickel seems more or less abandoned, as both still depend on hyper version 0.10.

Rocket.rs seems awesome, but requires unstable rust, and I would prefer to build my projects with the stable toolchain.

Maybe gotham can be the framework I'm looking for? I think it needs a lot easier request routing and path extraction, but there seems to be work going on to fix that. And maybe that is something I can help create? There are some issues tagged discussion and help wanted which might provide good starting points. And there is the Gotham book to read.

Or maybe either iron or nickel will make a comeback? There are open issues in both about working with hyper version 0.11 (iron#501 and nickel.rs#402), even if they haven't seen much activity recently.

Write a comment

A compiling template system in Rust

Published tagged , , , .

When developing web applications, it is often useful to have a template system. Something that lets you write generic versions of web pages, that the application can fill with the specific content for each page it should show. There exists lots of "languages" to write such templates, such as mustache, jinja2, and play 2 scala templates (twirl).

Most fits very well with a dynamic language, where you can get properties from an object, or even call a method, by its name in a plain string. In a statically compiled language, the actual names of fields and methods are not relevant, and generally not present, after compilation. This makes a "dynamic" template language a hard match for a compiling language such as rust. So why not try to create a better match?

Läs och kommentera inlägget A compiling template system in Rust

Some ways to log stuff in java

Published tagged , , .

Logging in java is a mess. For a long time there was no standard way of logging in java, so there is a lot of 3:rd party solutions. Apache commons logging, slf4j, and log4j are probably the most used.

By now, there is standard java.util.logging package, but most people stick to the old 3:rd party solutions. As we shall see, that isn't really surprising, since java util logging kind of sucks.

Läs och kommentera inlägget Some ways to log stuff in java