DevNexus Day 1: WebAssembly, Productivity
Together with four “AwesomeSauce” colleagues from Info Support, I’m attending DevNexus this year. For me, it’s the second time I’m here, as I spoke here in 2018, too. Next to delivering my own “React in 50 minutes” session I’m attending some sessions to update with new technology advancements.
Ray Tsang and Burr Sutter took the stage first in a “banjo coding duel”. Spring Boot vs Quarkus, Kubernetes vs OpenShift, and all kinds of cool tips & tricks. Some of them (like Jib) where already on my list to experiment with. Seeing them in action actually reinforced the feeling that it’s worth checking them out. Now only if I would find some more time… 😀
WebAssembly for Modern Cross-Platform Web Development
Jeremy Likness introduced me into the wonderful world of WebAssembly.
What if you could run code in your browser at near-native speeds - without plugins - and use the language of your choice?
WebAssembly (WASM) lets you do that. It translates source code into a platform-agnostic stack-based bytecode. Those binaries are relatively small: an example fractal program turns into a 21 kB binary.
You can’t load WASM binaries directly into a page.
Instead, you need to download the WASM binary (for instance with
fetch) and then load it with the browser WebAssembly API.
Alternatively, you can play with WebAssembly in the browser using Webassembly Studio.
Alternatively, some languages already provide API’s make building WASM binaries easier. The presentation contained a few live coding examples.
Using Rust has an advantage over Go because its binaries are a lot smaller (tens of kB).
WebAssembly System Interface
Using the WebAssembly System Interface (WASI) you can even run them from a command line. This allows you to write programs that run inside a browser the same way as they run in a terminal.
The possibilities of WASM are a bit limited, since there are no formal API’s for interacting with the environment. But on the other hand, a “hello world” program (only 182 bytes!) truly becomes a “run once, run anywhere” program. I feel this may be interesting technology to optimise performance-critical code for web applications. It may however be somewhat limited for building complete applications right now.
Seven Principles that will Boost your Developer Productivity
Next up in my personal schedule was Sebastian Daschner about Developer Productivity.
Being a German himself, Sebastian is probably the most qualified person to speak about efficiency and productivity.
He shared seven principles for being an efficient and productive developer:
- Embrace Automation — This is what computers are primarily meant for: they’re very well in doing stupid things correct and fast. Humans on the other hand are good at creative work and thinking. Finding shortcuts is an important part of that. Shortcuts is not only about “keyboard shortcuts”, but also features such as “live templates” in IntelliJ that let you inject some boilerplate snippets. You can define your own “live templates” tailored to the technology stack that you use. The bigger the size of the boilerplate snippets (think Kubernetes YAML!) the more advantage you can take from this.
- Focus & Eliminate Context Switches — A major context switch is the mouse! It requires your body and your mind to shift attention from the “home row” to where your mouse currently resides. Also, getting to know your text editor, e.g. ViM and really understanding its different modes and navigation can safe you a lot of time. In order to prevent context switches, it’s important to have quick feedback on whatever you do. Everything under 200 milliseconds feels instant, every thing under 2 seconds feels like waiting, and above that, you easily become distracted.
- Take a Step Back and Reflect — A very good question to ask yourself regularly: “what am I actually doing during the day?” It might give you valuable input for improving on principle #1, because if there’s things that you do everyday, you can probably automate it.
- Don’t Make me Think (Twice) —
You may find yourself in this deja-vu situation where you try to remember how you did something.
In that case, define what the process actually is, and of course automate it.
The benefit is that it makes it easier to perform it next time (principle #1 again), and it also acts as a kind of documentation.
Since the human mind is not the most efficient storage unit, it’s import to keep a todo list. Even if it’s a plain text file or a piece of paper. It’s important to keep it prioritised, and also keep track of what you actually did. Take some time at the end of your planning horizon (day, week, sprint) to review that list and see what is most important to do during the next iteration. This helps you start your next iteration in a productive matter, and it will make sure that the most important things will get done.
- Know Your Craft — Simply put: “know what you’re doing”. Abstraction is a very powerful concept in computing, but it drifts you away from what is happening under the hood. With less writing we can achieve more, which makes it more important to know exactly what method, annotation or design pattern to use. An important way to achieve this knowledge is to actually read the documentation. We often do that as a last resort, but it’s way more efficient if you start with doing that.
Guess what, a good way to communicate what you did and how it works is to document it.
It serves two goals: it doesn’t let you make think twice (principle #4) and it helps your colleagues.
Not the “this is a bridge” level comments, but write about the why of the decisions you made when writing the code.
Teaching is a great way of learning: it will make you more knowledgeable, and it will educate the people that you are teaching.
- Used the Saved Time to Relax Not a very German remark, but taking time off to relax is actually a good thing. It may be tempting to keep on improving, but relaxing makes more room in the mind.
Excurse: Using the shell
Any shell lets you use your computer very powerful, but according to Sebastian, the Z shell (ZSH) takes it one step further:
- let’s you switch directory without
cd(but not by default?!)
- you can use tab completion once instead of having it to do at every completion stop
Apart from the question whether ZSH or Bash is better, aliases are a very powerful way to make your life easier.
cat ~/.bash_history | sort -u - or
cat ~/.zsh_history | sort -u - to see which commands you type often.
See the Improving Your Command Line Productivity video course for more inspiration.
Read more about the second day of DevNexus.