An introduction to Phoenix LiveView

The last year or two, I’ve been playing around with Elixir. Chris McCord, author of the Phoenix web framework, is working on a new feature for Phoenix: LiveView.

Phoenix LiveView is an exciting new library which enables rich, real-time user experiences with server-rendered HTML. LiveView powered applications are stateful on the server with bidrectional communication via WebSockets, offering a vastly simplified programming model compared to JavaScript alternatives.

In short, LiveView enables you to enable interactive, real-time app, without touching any JavaScript, as the application logic lives on the server.

LiveView looks like an interesting alternative to the current SPA trend. You can read Chris’ entire walkthrough on dockyard.com. Even if you’re not familiar with Elixir yet, LiveView’s proposed programming model is an interesting topic on it’s own.

Everyone has JavaScript, right?

I used to think disabled JavaScript went hand in hand with visitors explicitly blocking it. I came to the conclusion that I don’t necessarily need to cater to that crowd, because the degraded user experience was by choice. After reading through this chart, I realized how wrong I was.

Sometimes your JavaScript just won’t work. Be prepared.

Read the flowchart on kryogenix.org.

Not all code is the same

As a short follow-up to Everyone has JavaScript, right?, there’s more to JavaScript than availability, there are also the performance implications.

I don’t think most people are saying, “don’t use JavaScript.” That would be absurd.

But use less, use it wisely, and don’t depend on a giant framework for simple stuff. Use as little JS as possible to get the experience you want. You can do that and still have a great, immersive app.

I believe we’re reaching for JavaScript more often because of its ecosystem, not because it’s the better solution. The JavaScript ecosystem simply has incredible tools to build interfaces, and I hope server side solutions will still be able to compete.

I don’t have a conclusion ready, I’m just interested in the topic. To be explored in 2019. Meanwhile, read Chris Ferdinandi’s thoughts on the matter.

iA Writer 5.2 will embrace variable fonts

iA Writer is one of my favorite pieces of software, and I can’t even say why. It just feels so good. In the upcoming 5.2 release, iA Writer will replace the current iA Writer Duo font with iA Writer Quattro, a variable font.

While traditional fonts offer in a limited number of weights, variable fonts offer an infinite scale between the weights and features.

Variable fonts have different “axis” which allow an infinite amount of variations.

Gingham variable font. Taken from Get started with variable fonts by Richard Rutter.

In iA Writer 5.2 we automatically adjust the optical weight depending on the type size you use. Weights change depending on size. The font is getting thinner and tighter spaced as we increase the type size. This has not been possible in the past.

Not just size, but different screens demand different weights, too. Fonts look different on screens; some screens have more or fewer pixels, like retina and high-density retina. Depending on what device you use, we apply different gradings.

Our job would almost be boring if type size, pixel density, and screen type were the only challenges of modern typography. As you might have noticed, dark backgrounds make white text shine brighter. That’s why iA Writer 5.2 tones the optical weight down another 5% for night mode. Who does such crazy things? Crazy people.

I, for one, welcome our new variable font overlords. More words and pictures on ia.net.

If you want to learn more about variable fonts in general, or play around with a few specimens, check out Axis-Praxis.

A blogging style guide

Robert Heaton shares 39 bullets to improve your blogging. A few of my favorites:

Choose a few people whose style you like and copy it as hard as you can without infringing on any intellectual property. I aim for a combination of the Economist, Paul Krugman, and Terry Pratchett.

If you need a quick name for a generic fictional character, consider using one from a culture or gender that you usually wouldn’t. Even if you don’t believe that representation in the media matters, you’ve surely got to concede that there’s still a chance that it might, and that the cost of sometimes calling your imaginary computer programmers Julianna is zero.

It’s fine to spend 10, 20, 30 minutes staring into space when your plan for the day says that you’re meant to be writing.

It is admittedly even better to spend that 30 minutes spamming down any old nonsense that you can refine later, or that at least helps get you mentally unblocked.

Read all 39 tips on robertheating.com.

Bézier moi

I’ve been reading up on SVG and Bézier curves for a side project that involves a custom-made chart (blog post about that later!). Funnily enough, this article on Bézier curves popped up on Hacker News earlier this week.

One little animation in the article totally stands out, and helped me make sense of what the control points of a Bézier curve actually do.

Taken from cormullion.github.io

While you’re waiting, have a look at another animation; this is my artist’s impression of the De Casteljau algorithm dividing the control polygons around a Bézier curve as the parameter n moves from 0 to 1. The idea is that as p1 divides A to A1, p2 divides A1 to B1 and p3 divides B1 to B. So, pp1 divides p1 to p2, and pp2 divides p2 to p3. And you keep doing this until you can’t divide any more, and eventually the point P plots the course of the final Bézier curve. The red and blue parts of the curve show that this technique is also a good way to split a single Bézier curve into two separate ones, and the red and blue parts are separate control polygons.

Read the full article on cormullion.github.io.

Readability is relative

When I write a library that’s going to be used by others, I strive for a gentle learning curve. When someone reads code that uses my library, I want them to understand what’s happening without reading a bunch of documentation first. I tend to keep my API’s as explicit as possible, and try to stay away from odd or foreign notations.

My colleague Brent is writing a library to deal with date & time periods in PHP. There was a discussion whether a period’s boundaries should be included in the range or not.

Read more

Chris Ferdinandi's CSS methodology

There are a few fleshed-out articles about why utility-first CSS is a good thing. However, if you’re just a little curious and want a brief introduction, Chris Ferdinandi has your back.

In JavaScript, we create small, modular functions that can be reused throughout the code base to keep our code DRY. In CSS, for some reason, it’s not seen as weird in the slightest to repeat yourself a lot.

Utility classes help keep CSS DRY.

The stylesheet for my website is so small that I can inline all of my CSS still send most of the page in a single HTTP request.

Read the rest of Chris’ article on gomakethings.com.

Hungry for more? Check out In Defense of Utility-First CSS by Sarah Dayan or CSS Utility Classes and “Separation of Concerns” by Adam Wathan.

Highlighting code blocks with league/commonmark

Since the first iteration of my blog—some time around 2016—I’ve used highlight.js to highlight code blocks. With highlight.js being so popular, I never really second guessed the idea. It was a given to use JavaScript.

A few weeks ago, TJ Miller introduced me to highlight.php by writing a Parsedown extension for it. Highlight.php does the exact same thing as highlight.js: they both add tags and classes to your code blocks, which enables them to be highlighted with CSS. The difference is, highlight.php does this on the server.

Read more

Mo' models mo' problems

One of the best things about Vue templates is the special v-model prop. v-model allows you two quickly map prop getters and setters without breaking unidirectional data flow. Props down, events up.

Read more

Distraction-less user interfaces: Delayed transient states

This is the first post in a series about removing distractions from an interface to provide a better user experience.

I have a specific pet peeve with user interfaces: things that draw my attention when they don’t need to. In any graphical interface, movement is distraction. Our eyes are naturally drawn to anything in motion.

Motion is a powerful tool. We can abuse this distraction to attract our users to a certain place: a notification, an added list item after a background refresh, etc. Let’s look into the movement behind a form submission. Below are three dummy forms, each with a different server response time.

Read more

A good issue

Maintaining a number of open source projects comes with a number of issues. Reporting a good issue will result in a more engaged approach from project maintainers. Don’t forget: there’s a human behind every project.

Read more

Code splitting with Laravel Mix

Code splitting is bundler feature—if you’re using Laravel Mix, you’re bundling your assets with Webpack—that allows you to split application scripts in multiple files. These can then conditionally be loaded at a later stage.

Read more