Rasmus​.krats​.se

This page in English

Inlägg taggade ”rust”

Skriverier då och då, på webben sedan 1994.

En månad på Sveriges Radio

Publicerad 2024-07-02 21:49. Taggat , , .

Nu har jag jobbat drygt en månad på Sveriges Radio. (Ja, nästan två efter att texten legat opublicerad ett tag.) Jag tog jobbet för att programmera i Rust, och det har jag gjort. Jag har jobbat i tre olika kodbaser, så än så länge har jag lagt för lite tid i vardera för att verkligen förstå dem. Men jag känner ändå att jag faktiskt har gjort nytta i ett par av projekten.

Två av projekten hanterar real­tids­ljud, vilket innebär att man får 2×48 samples att behandla varje milli­sekund. I det ena projektet brukar vi prova med en fil som är halv­timme, och den behandlar vi på knappt fem sekunder, så vi har lite marginal där. Å andra sidan vill vi behandla flera ljud­strömmar parallellt, och nätverk och annat ger ju lite overhead.

Läs hela En månad på Sveriges Radio.

Tack och hej, KTH

Publicerad 2024-05-08 19:35. Taggat , , , .

Efter drygt 20 år som anställd utvecklare på KTH tar jag, efter helgen, tjänstledigt i sex månader för att prova en tjänst på Sveriges Radio. Det har varit givande, lärorika och roliga år. Annars hade jag naturligtvis slutat för länge sedan.

Det finns många riktningar man kan utvecklas i som system­utvecklare. Många som har några års erfarenhet blir teamledare eller chefer. En del fokuserar på UX eller kravhämtning. Det är viktiga saker och någon måste göra dem (även om det i många fall kan finnas lite väl många chefer och få som gör jobbet), men det är inte vad jag vill göra. Många system (inte bara på KTH) skulle nog fungera betydligt bättre om fler erfarna pro­gramme­rare faktiskt ägnade sig åt pro­gramme­ring.

Läs hela Tack och hej, KTH.

Rsass 0.28.0 released

Posted 2023-07-09 12:45. Tagged , , , , .

It is time to announce rsass, rsass-macros and rsass-cli version 0.28.0. Almost half a year has gone since the last release, and as usual, there is a bunch of breaking changes and a bunch of improvements.

A small symbolic milestone is that 2/3 of the tests in sass-spec now passes (up from 66.5 % in the previous release to 66.8 % now). Also, I have reduced the number of cases where rsass fails with the wrong output even further.

My thanks to new contributor Grey Hill.

Read whole Rsass 0.28.0 released.

Command line interface url

Posted 2023-02-05 23:25. Tagged , , .

I wrote a little command-line interface for sending a http request and getting the response. I call the package url-cli, and the command itself is url. It has sub-commands for the different http methods.

If you have a rust toolchain installed, you can get it by cargo install. I haven’t made any binary packages yet.

:; cargo install url-cli
[... building, installing ...]
:; url get https://rasmus.krats.se/2023/url-cli.en
<!doctype html>
[... and all the rest of the html for this web page ...]

Read whole Command line interface url with 2 comments.

Rsass 0.27.0 released

Posted 2023-01-17 21:06. Tagged , , , , .

Again, after almost four months since the last release, it is time to announce rsass 0.27.0. There is a bunch of breaking changes and a bunch of improvements.

This time, one change may seem drastic: The rsass crate no longer contains the command-line program rsass. Instead, that is now provided by a separate rsass-cli crate. So you no longer have to enable a commandline feature, instead you can install the command line interface with:

:; cargo install rsass-cli

There is also a new rsass-macros crate. Read on into the Macros section for that.

Read whole Rsass 0.27.0 released.

Rsass 0.26.0 released

Posted 2022-09-18 20:04. Tagged , , , , .

More than three months after the last release, is is now the time to announce rsass 0.26.0. There is a bunch of breaking changes and a bunch of improvements. The changelog has the whole (too long) list.

But this time, some of the changes may go a bit deeper. As usual, the breaking changes is breaking mainly to users who in some way modify the global context from rust code, maybe by providing their own builtin functions or maybe just by inserting a global variable.

Also this time, there is an improved way of calling ructe from a cargo build.rs program, see the Cargo section below.

Read whole Rsass 0.26.0 released.

Tracker-free youtube embedding

Posted 2022-04-03 18:04. Tagged , , , , , .

Sometimes I want to embed a video on my site. Most of the videos I want to embed are on youtube. Klicking share on a video and choosing embed, I get a bunch of html code I can copy into a post. Something like this, for example:

<iframe width="560" height="315" src="https://www.youtube.com/embed/3St1CoH1rKU"
  title="YouTube video player" frameborder="0"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen>
</iframe>

That’s very easy. The downside is that youtube gets a request for the iframe (and a bunch of stuff it loads from there) every time someone looks at my page, which makes it possible for them to track you, my reader, across my site and other sites that includes videos.

Read whole Tracker-free youtube embedding.

Gästföreläsning om Rust

Publicerad 2022-03-01 22:56. Taggat , .

I går fick jag hålla en gäst­föreläsning om program­språket Rust på kursen programmerings­paradigm på KTH. Jag är inte en van föreläsare (och helt klart inte på-minuten-deltagare), så det är ganska mycket tvekan och stakningar i början, men jag lämnar i alla fall inte rummet förrän efter föreläsningen, och så småningom kommer jag igång lite.

Föreläsningen är en ganska allmän introduktion till Rust, främst riktad till personer som kan programmera i något imperativt språk och i alla fall har provat lite i något funktionellt språk. I kursen programmerings­paradigm lär man sig bland annat Haskell.

Läs hela Gästföreläsning om Rust.

Ny blogmjukvara

Publicerad 2022-01-16 22:07. Taggat , , , , .

Jag har skrivit ny blogmjukvara igen! Den förra hette r5, som i Rasmus (utan 5 bokstäver). Den nya är skriven i Rust (källkodsfilerna heter .rs), så det kändes naturligt att kalla den r4s, också som i Rasmus (men utan 4 bokstäver 😎).

Nu får vi se om ett nytt kul blogprogram får mig att skriva fler blogposter.

Utseendet är inspirerat av Eric Meyers Hamonshu och hans teknik Pseudo-Randomly Adding Illustrations with CSS, men med bilder och typografi som känns mer jag.

Läs hela Ny blogmjukvara med 1 kommentarer.

Web frameworks in Rust

Posted 2020-09-09 20:48. 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.

Read whole Web frameworks in Rust.

Julia fractals in Rust wasm

Posted 2019-07-26 19:12. Tagged , , , , .

I like to write programs to render fractals, and especially Julia set fractals. I also like the Rust programming language. Among other advantages it happens to be great for compiling to wasm, the new format for executing code in a web browser. And I like to code stuff for the webb. So how come I haven’t written a wasm Julia renderer in Rust yet?

Well, now I have.

WebAssembly seems to be all the rage currently. While I certainly wouldn’t mind replacing all javascript code with rust, that seems impractical for things running in the browser, as everything about the DOM and event handling still have to go through javascript bindings. As it is a good thing to keep javascript minimal for progressive enhancement, that makes the code contain very little more than event bindings anyway.

Read whole Julia fractals in Rust wasm with 2 comments.

Rust and me in 2019

Posted 2019-01-26 16:25. Tagged , , , .

There is A Call for Community Blog posts over at the Rust Programming Language Blog. This is my entry, briefly describing my hopes and expectations for Rust, it’s eco-system and my own participation in 2019.

Read whole Rust and me in 2019.

Propaganda­cykling

Publicerad 2018-02-11 21:10. Taggat , , , , , , , .

Jag har inte lagt upp någon propagandacykling här på bloggen på ganska länge. Naturligtvis cyklar jag fortfarande till jobbet de flesta av de dagar jag inte jobbar hemifrån, och jag brukar ta en bild och lägga ut på twitter.

Men jag har ett projekt för att organisera mitt bildarkiv på gång också.

Det har kommit så långt att det är smidigare att lägga upp mina bilder där än här. Så vill du se mina samlade cykelbilder så finns de där!

Men jag får väl inkludera tre ganska färska bilder här också.

Läs hela Propaganda­cykling.

Rust and the web in 2018

Posted 2018-01-07 22:50. 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.

Read whole Rust and the web in 2018.

A compiling template system in Rust

Posted 2016-10-07 18:32. 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?

Read whole A compiling template system in Rust with 3 comments.