FFI in Rust - writing bindings for libcpuid

FFI in Rust - writing bindings for libcpuid

A few days ago I needed to find my CPU name and clock frequency in a Rust program. One can parse /etc/cpuinfo or the output of lscpu, but I wanted to encapsulate this functionality in a library of sorts. Meanwhile, I stumbled upon libcpuid, which is a small C library that does exactly what I needed (although not by reading from the proc filesystem). That left me wondering how hard would it be to create a Rust wrapper for libcpuid. Turns out it's quite simple!

Continue reading »
Written on Sept. 20, 2014

Beginning Rust - solving Euler problem #1

Beginning Rust - solving Euler problem #1

Rust is a relatively new programming language (first alpha released in 2012) which recently caught my attention. Although I'm mostly a Python hacker and Web developer, I still do lower level coding from time to time, including some open source work in C++. Besides, I enjoy the elegance of Haskell; the functional approach to solving problems is quite enlightening. Where does Rust fit into that? The language is still a work-in-progress territory (as of this post the current version is 0.10), but there are already many interesting features. Memory safety, strong typing (with type inference), pattern matching and a slick concurrency model are just a few of those. Let's jump in!

Continue reading »
Written on April 27, 2014

pygcvs 0.1.3 released

Yesterday I've released pygcvs 0.1.3 which fixes a small bug with parsing star coordinaates. The bug appeared when the coordinate part of GCVS entry was a string containing only spaces (for example when the star exists under an alternative designation). There are about 150 such stars in GCVS, for example VY Cep, which is actually another name for RR Cep. Starting from pygvs 0.1.3, such empty coordinates are correctly parsed as a pair of None values.

Continue reading »
Written on March 15, 2014