Migrating Tokio and Futures – What to Look for

I’ve finally found courage to look after migrating audioserve to new hyper and tokio and futures crates. As new futures (0.3) are significantly different from previous version, mainly due to support of async/await keywords, I was expecting significant effort, so I was kind of delaying it. Now when it’s almost done, I’d like to reflect a bit on the effort. Firstly – it was not as bad as expected (although after updating cargo dependencies I’ve got about a hundred of errors). Secondly – there are some patterns to follow in migration, which I’ve like to describe further in the article.

Continue reading Migrating Tokio and Futures – What to Look for

Performance Should Matter

As I did not have much time to focus on larger programming projects recently I’ve done several exercises on exercism Rust track. It was quite fun and I hope learned a bit. But I found one issue there – when looking at solutions of others, some of them, even when code look very nice and has stars from other users, is performing very badly. I consider this as quite bad practice – if one chooses a “Systems Programming Language” as Rust he should think about performance and understand implications of:

a) general algorithm complexity
So chosen solution should try to use sound algorithm, with complexity close to best possible

b) using complex fancy functional constructs
Rust is advertising “zero cost abstractions”, however while it works in many cases it has to be used with caution – you have to use a bit of common sense.

Continue reading Performance Should Matter

Selfhosting in Era of Cloud

Today one can choose from overwhelming variety of online (cloud) services in almost any thinkable area. Many of them provide vast amount of content and have professional user interfaces / clients. So why to bother with selfhosting, when one can just choose from this broad offer? And I’m here referring mainly to personal selfhosting – e.g. running some services from computer/server running at your home and providing these services to yourself plus family members. Does it make still any sense, when you can hardly compete with internet giants? In this article I’d like to present few reasons, why I think that selfhosting still have some values.

Continue reading Selfhosting in Era of Cloud

First Impressions about New Rust Async

Just recently async and await made it to stable version of Rust. futures library 0.3 is also out and rest of other important libraries is following – for me tokio and hyper are particularly interesting. tokio is now in alpha stage supporting new futures, so I decided it’s about a time to give it a try. Some time ago I’ve rewritten ptunnel in Rust using 0.1 version of tokio and futures. So here are my first experiences with new libraries and upgrade.

Continue reading First Impressions about New Rust Async

Audioserve new features

I have been working on some new features in audioserve and they are now available in latest releases. In this article I’d like to talk little bit about them and probably later also provide new demo videos, as there has been many changes from last demos.

Summary of new features:

  • Single file audiobooks (m4b) support
  • Alternative subfolders sorting (recent, alphabetical) and most recent folders list
  • Folders download in web client
  • Easier deployment with smaller docker image or static binary
  • Server config file
  • Playback sharing/synchronization between clients

See below for details.

Continue reading Audioserve new features

Higher Rank Trait Bounds in Practice

Higher Rank Trait Bounds (HRTB) is relatively advanced feature in Rust, you can read short explanation in the reference, and more detailed explanation in in the RFC (frankly spoken RFC is bit more complicated, at least for me).

HRTBs are applied for lifetime parameters only (at least now) and are useful in cases where lifetime parameter in trait cannot be bound to any existing lifetime, but is valid for any particular lifetime, that happen to appear in place where type implementing the trait is used.

Continue reading Higher Rank Trait Bounds in Practice

Lightweight Tasks Switch in Go vs Rust

I’ve have been following this excellent book “Operating Systems: Three Easy Pieces” and as I’ve been doing a homework – measuring time of context switch and as I was looking around and found another interesting article related to this topic. It also compares thread switches to switches in “Go routines” – lightweight threads in Go language. Base on these sources I’m made couple of mine own test (yes I know, all benchmarks sucks, but nevertheless they are somehow attractive (as gossips are) and somehow addictive).

Continue reading Lightweight Tasks Switch in Go vs Rust

Rust, I love you, I really do

In past 5 years Stackoverflow was running a comprehensive survey (here is latest for 2019), which, among other questions, asked for ‘most loved programming language’   – which basically means language developers used, like it and definitely want to continue with. Rust is doing very well in this category – it leads this category for past 4 years ( and this was one of reasons, why I started to play with Rust).  As this SO survey (with similar questions) is around for 5 years, it’s about time to put data in chart: Continue reading Rust, I love you, I really do

Hyper Websocket

As much as I do like Rust I have to admit there are some disadvantages of using this language – one common problem is immaturity and fragmentation of libraries –  I encountered this recently when I was looking for a way how create a websocket endpoint for audioserve.  audioserve is using low level HTTP library hyper – as it’s API is quite simple (which was it’s key design principle). I wanted to add websocket support on lowest possible level.  Actually it turned out as not totally trivial –  some frameworks like warp or actix have build in websocket support, but for pure hyper + websocket we have to start from bottom.  Continue reading Hyper Websocket

My Digital Bits And Pieces