{"id":608,"date":"2019-03-12T16:52:58","date_gmt":"2019-03-12T15:52:58","guid":{"rendered":"http:\/\/blog.magnusmanske.de\/?p=608"},"modified":"2019-05-16T09:28:57","modified_gmt":"2019-05-16T08:28:57","slug":"dealing-with-the-rust","status":"publish","type":"post","link":"http:\/\/magnusmanske.de\/wordpress\/archives\/608","title":{"rendered":"Dealing with the Rust"},"content":{"rendered":"<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Rust_(programming_language)\">Rust<\/a> is a up-and-coming programming language, developed by the Mozilla Foundation, and is used in the Firefox rendering engine, as well as the <a href=\"https:\/\/www.infoq.com\/news\/2019\/03\/rust-npm-performance\">Node Package Manager<\/a>, amongst others. There is a lot to say about Rust; suffice it to say that it&#8217;s designed to be memory-safe, fast (think: <a href=\"https:\/\/benchmarksgame-team.pages.debian.net\/benchmarksgame\/faster\/rust.html\">C or better<\/a>), it can compile to <a href=\"https:\/\/en.wikipedia.org\/wiki\/WebAssembly\">WebAssembly<\/a>, and has been voted &#8220;most loved language&#8221; on StackOverflow in <a href=\"https:\/\/insights.stackoverflow.com\/survey\/2017\/#most-loved-dreaded-and-wanted\">2017<\/a> <em>and<\/em> <a href=\"https:\/\/insights.stackoverflow.com\/survey\/2018\/#most-loved-dreaded-and-wanted\">2018<\/a>. As far as new-ish languages go, this is one to keep an eye on.<\/p>\n<p>Rust comes with a fantastic package manager, <a href=\"https:\/\/doc.rust-lang.org\/cargo\/\">Cargo<\/a>, which, by default, uses <em>crates<\/em> (aka libraries) from <a href=\"https:\/\/crates.io\/\">crates.io<\/a>, the central repository for Rust code. As part of my personal and professional attempt at grasping Rust (it has a bit of a learning curve), I wrote a tiny crate to access the API of MediaWiki installations. Right now, it can<\/p>\n<ul>\n<li>run the usual API queries, and return the result as JSON (using the Rust serde_json crate)<\/li>\n<li>optionally, continue queries for which there are more results available, and merge all the results into a single JSON result<\/li>\n<li>log in your bot, and edit<\/li>\n<\/ul>\n<p>This represents a bare-bones approach, but it would already be quite useful for simple command-line tools and bots. Because Rust compiles into stand-alone binaries, such tools are easy to run; no issues with Composer and PHP versions, node.js version\/dependency hell, Python <em>virtualenv<\/em>s, etc.<\/p>\n<p>The next functionality to implement might include OAuth logins, and a SPARQL query wrapper.<\/p>\n<p>If you know Rust, and would like to play, the crate is called <a href=\"https:\/\/crates.io\/crates\/mediawiki\">mediawiki<\/a>, and the initial version is 0.1.0. The <a href=\"https:\/\/github.com\/magnusmanske\/mediawiki_rust\">repository<\/a> has two code examples to get you started. Ideas, improvements, and Pull Requests are always welcome!<\/p>\n<p><em>Update<\/em>: A basic SPARQL query functionality is now in the repo (not the crate &#8211; yet!)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rust is a up-and-coming programming language, developed by the Mozilla Foundation, and is used in the Firefox rendering engine, as well as the Node Package Manager, amongst others. There is a lot to say about Rust; suffice it to say that it&#8217;s designed to be memory-safe, fast (think: C or better), it can compile to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,7],"tags":[],"class_list":["post-608","post","type-post","status-publish","format-standard","hentry","category-rust","category-wikimedia-2"],"_links":{"self":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/comments?post=608"}],"version-history":[{"count":3,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/608\/revisions"}],"predecessor-version":[{"id":611,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/608\/revisions\/611"}],"wp:attachment":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/media?parent=608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/categories?post=608"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/tags?post=608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}