Most experienced programmers know that KISS means Keep It Simple,
Stupid.
But should it?
I think a better interpretation would be Keep It Short (and) Simple?
It is good that people know they should keep their programs simle – and
that some even does.
I don’t doubt that the edgyness of calling code—and the people who wrote
it—stupid is part of why the KISS meme is so well known,
but I have two objections.
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.
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.
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?
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.
I have done some exploration of different options for logging in java.
The code I base this text on is available as kaj/explorelogs on
github.
I explore the industry-standard logging packages slf4j, log4j, and
appache commons logging as well as java.util.logging.
And I take a look at the Loggger in play framework 1.x as well as my
own wrapper around log4j.