fabiochiu/medium-articles huggingface dataset:
Shipping Rust Binaries with GoReleaser
By: Dotan Nahum
Tags: Programming, Docker, Rust, Rustlang, Go

As consumers, we like to get a binary release in one of the following ways:

OS native package format such as deb , rpm and so on.

, and so on. Language native package format such as pip , npm and so on. It's not common to supply a pure binary artifact this way but some do it, such as puppeteer which downloads a latest binary of a headless Chrome.

, and so on. It's not common to supply a pure binary artifact this way but some do it, such as puppeteer which downloads a latest binary of a headless Chrome. A curl shell combo such as curl http://acme.org/bin | sh which is fast, has no dependencies, but receives criticism because you're essentially letting your users execute remote code. This is why I avoid these, but if I must, verify the shell script by hand first.

which is fast, has no dependencies, but receives criticism because you're essentially letting your users execute remote code. This is why I avoid these, but if I must, verify the shell script by hand first. A modern binary packager such as Homebrew.

While the process may differ from one technique to another, they all require a way to host the binaries or packages, except perhaps the language-native package formats, where you can get away with pushing large binaries into the registries (but it may be frowned upon).

In principle, these are the steps required do package and release:

Cross compile your binaries (e.g. Linux, Windows, macOS), since we’re distributing binaries we have to have a ready-made version per platform and architecture. Package (e.g. tar, zip), some platforms expect a specific packaging format. Digest your packages (e.g. sha256) — while we’re all enjoying a reliable internet connection and file hosting solutions — we’re not assuming it’s always the case for all users. It’s wise to verify downloads by having it digested. Upload to <provider> using some kind of path format scheme (e.g. to S3 as `v0.0.1/project-name/tarball). Set up the distribution artifact (e.g. generate a shellfile for download and verification from S3 using the given format scheme).

For an open source project, there are many tools to use, because Github Releases and Git tags make it a breeze to construct a great release process. For other projects, Amazon S3 would be perfect for storing, and an opinionated release formatting rules helps. This is where GoReleaser shines.

Using GoReleaser with Rust

Although GoReleaser supports building just Go projects, it does so much more in the packaging and distribution department that it is extremely hard to ignore.

It can package, generate sha256 sums, upload to Github releases or Amazon S3 or custom HTTP endpoints, as well as generate a changelog, semantic versions and a lot more. The website doesn’t show everything, so I recommend looking at the repo for docs and to find out what more it can support.

So it has everything we want, but it can’t build anything other than Go.
How I manage to handle 1 million requests of updating per minute with Rust
By: Thiện Trần
Tags: Programming, Golang, Rust

How I manage to handle 1 million requests of updating per minute with Rust Thiện Trần Jun 17·7 min read

For the last month, I’ve been working on improving the performance of our services, and all of them are using Django REST Framework. After enhancing API endpoints such as CRUD, statistics, cron jobs… and the performance works fine. But, when the time comes, we want these services can handle more requests and do better performance. Don’t make me wrong, Django has done very well at the point of its jobs “rapid development and clean, pragmatic design” and it’s true, DRF helped us kept the deadline, however, it’s time to make something that fit our desire.

At the start point, we have built the monolith service, which means, inside of it, there are plenty of businesses. Looking at them, I started thinking to separate some businesses into smaller services, therefore, I can improve much easier and more flexibly. So, I choose one of those, a small business to improve and see how could it be better. In this topic, I will show you how I build the best that I could to solve the problem.

Just to be clear, I think I should tell you that I've implemented this small business in 2 ways. One is Golang with Ginonic framework, the other is Rust with the help of Actix and sqlx. The result of Golang is very cool. After modifying the config of database and doing some other tricks, this is the best result of it for 15000 rps:

If you want to know what are those tricks, I’ll be back on another topic after 😃. Some of those tricks are described in this topic too when I implementing Rust server. However, this result doesn’t satisfy the title of this article, and while the p95, avg are ok but the max is 7.44s, it’s huge 😤. The garbage collector of Golang makes that peak. That thing is really hurt, right 😢. That is the reason why I used another language, Rust. Therefore, I will go into detail with my Rust implementation for the rest of this topic, the best result that I have.

Okay, talking too much! Let’s Rust into it👌!
Lore, lore, learn by heart
By: George Shuklin
Tags: Programming, Lore, Command Line, Rust, Cargo

Lore, lore, learn by heart

I’m taking pleasure of rewriting my code for higher and higher performance. There is a something compensating in perfecting nanoseconds and counting CPU ticks. My job is all about Python (slow) and Ansible (…ekhem… super slow), so to be able to mess with nanoseconds a true self-esteem boost.

But in the process I learned yet another tiny-tiny bit of lore you normally can’t reason about beforehand.

Cargo provides with many nice commands: cargo test , cargo bench , etc. They allow to run tests and benchmarks.

But did you know that those tests and benchmarks have own command options? Up to a certain point I was sure that cargo test --help is enough to see all of them. NOPE. Listen, folks, and remember the lore:

cargo test -- --help

cargo bench -- --help

Each of those shows a very own unique set of options which must be passed with this -- trick. The trick itself is reasonable: in Unix command line it’s a well-known (another lore here) way to separate options from ‘arguments’ if your argument has misfortune to contain something ‘dash-like’. The one of the most common cases (for me) is to search text starting with ‘-’ symbol in grep :

grep -r * -- -find-this

So cargo is doing the same. It allows to separate own options (for cargo binary) from options passed to the child binaries. test is a separate binary, compiled for testing purposes only. Benchmark is a separate binary, etc. So -- is used to separate options for those binaries from options of cargo itself.

Retrospectively this make a total sense. Discoverability is non-existing though.

The option I was hunting for was --nocapture to disable capturing of stdout of my tests. Debugger is great, but some cases are faster to solve by just looking on output. Turns out, the proper call is: cargo test -- --nocapture .
Getting started with Kafka and Rust: Part 1
By: Abhishek Gupta
Tags: Programming, Kafka, Rust

Producer callback

We are flying blind right now! Unless we explicitly create a consumer to look at our messages, we have no clue whether they are being sent to Kafka. Let’s fix that by implementing a ProducerContext (trait) to hook into the produce event — it’s like a callback.

Start by creating a struct and an empty implementation for the ClientContext trait (this is mandatory).

Now comes the main part where we implement the delivery function in the ProducerContext trait.

We match against the DeliveryResult (which is a Result after all) to account for success ( Ok ) and failure ( Err ) scenarios. All we do is simply log the message in both cases, since this is just an example. You could do pretty much anything you wanted to here (don't go crazy though!)

We’ve ignored DeliveryOpaque which is an associated type of the ProducerContext trait

We need to make sure that we plug in our ProducerContext implementation. We do this by using the create_with_context method (instead of create) and make sure by providing the correct type for BaseProducer as well.

let producer: BaseProducer<ProduceCallbackLogger> = ClientConfig::new().set(....)

...

.create_with_context(ProduceCallbackLogger {})

...

How does the “callback get called”?

Ok, we have the implementation, but we need a way to trigger it! One of the ways is to call flush on the producer. So, we could write our producer as such:

add producer.flush(Duration::from_secs(3)); , and

, and comment the sleep (just for now)

Hold on, we can do better!

The send method is non-blocking (be default) but by calling flush after each send , we have now converted this into a synchronous invocation - not recommended from a performance perspective.

We can improve the situation by using a ThreadedProducer. It takes care of invoking the poll method in a background thread to ensure that the delivery callback notifications are delivered. Doing this is very simple — just change the type from BaseProducer to ThreadedProducer !

# before: BaseProducer<ProduceCallbackLogger>

# after: ThreadedProducer<ProduceCallbackLogger>

Also, we don’t need the call to flush anymore.

...

//producer.flush(Duration::from_secs(3));

//println!("flushed message");

thread::sleep(Duration::from_secs(3));

...

The code is available in src/2_threaded_producer.rs

Run the program again

Rename the file src/2_threaded_producer.rs to main.rs and

to and execute cargo run

Output:

sending message

sending message

produced message with key key-1 in offset 6 of partition 2

produced message with key key-2 in offset 3 of partition 0

sending message

produced message with key key-3 in offset 7 of partition

As expected, you should be able to see the producer event callback, denoting that the messages were indeed sent to the Kafka topic. Of course, you can connect to the topic directly and double-check, just like before:

&KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic rust --from-beginning
My Project to write Embedded OS in Rust
By: Garasubo, ガラスボー
Tags: Baremetal, Programming, Arm, Rust

This is an English version of my blog post. The original version is here (Japanese).

I made my project to write Embedded OS in Rust public in Github.

The target architecture is Arm Cortex-M series. My application is running on Nucleo-F4291ZI board and QEMU.

Currently, I implemented those functionality:

Round-robin scheduler to schedule processes running in Thread mode

SVC interfaces to call kernel function for user processes (e.g. print messages using USART, sleep to wait for interrupts)

Move to sleep mode to wait for interrupt when there is no executable processes

There are only a few functionality yet, but the core structure is being completed, I think.

What I learned

I read Tock, existing embedded OS written in Rust and The Embedonomicon Book, the document for bare-metal programming in Rust. Those were great resources for me.

Peripheral interfaces

I tried to utilize several crates provided by Rust Embedded group, especially, svd2rust. svd2rust generates nice Rust interfaces from SVD file. It looks very nice, and with this, I could write small bare-metal programs, like LED blink, hello world with UART or something like that. But when I tried to write OS, I found that this is not so convenient as I expected. svd2rust generates API to get an instance to access peripherals safely. But the code forbades to call this API twice to make this instance as singleton. It sounds reasonable to limit peripheral access, but in writing OS, I often met situation to share this instance between interrupt handlers and main function. Of course, you can share the instance through global variables, but access to mutable global variables has a lot of limitations in Rust. Especially, in no_std environment, we cannot use Mutex or Arc. So, code would become complicated to escape those limitations.

So, I implemented my own peripheral interfaces (see device module in my project). Maybe, I can replace it with svd2rust APIs relatively easily for now, but in the early stage, I recommend to create your own peripheral interfaces.

Test

Rust has nice built-in test framework. However, the framework depends on std libraries, so we cannot run tests in a straight-forward way. In Writing an OS in Rust, “Testing” section explains how to write unit tests using QEMU. In this way, we can run tests on QEMU if there are dependencies on Arm architecture. However, it is still difficult to write a good test related to peripherals. I think the best way to write tests is making modules independent from the hardware. My util module doesn’t have dependency on hardware-related modules. So, I can write tests in the usual way in this module since it can run on std environment as well.

Future works

ErkOS doesn’t have much functionality. So, my plan for the next step is:

Implement heap memory allocator

Inter process communication

Scheduler with priority

More peripheral drivers

Migrating to other architectures

Rust and its toolchains becomes better and better. Let’s try to write baremetal software with Rust!
WebAssembly on the server-side
By: Michael Yuan
Tags: Ethereum, Microservices, Rust, Webassembly, Blockchain

WebAssembly (Wasm), originally invented and developed by Mozilla, Google, Microsoft, Apple, and others at W3C; is a high-performance execution engine for in-browser web applications. As it gains popularity on the client-side, Wasm is also becoming a serious contender as a server-side technology.

Value propositions

Wasm’s move from client-side to server-side follows well-traveled paths of previous generations of technologies such as Java and JavaScript. Compared with existing solutions, Wasm offers some compelling value propositions on the server-side.

Compared with the JVM and JavaScript engines, Wasm supports 20+ programming languages via the LLVM toolchain, offering developers freedom and productivity. In particular, it supports new programming languages beloved by influential developers, such as Rust. At the same time, Wasm could support native hardware features such as AI-optimized chips and field-programmable gate array (FPGA) hardware circuits. Wasm provides near-native performance without sacrificing safety.

Check out how to run high-performance Rust functions in Node.js web apps. In this setup, the Rust function is compiled to portable WebAssembly bytecode and runs safely in a WebAssembly VM.

When compared with containers like Docker, Wasm provides a higher level of abstraction, and hence higher productivity, for developers. Wasm can deploy code and applications instantly, instead of launching operating systems.

Wasm consumes much less memory and resources than typical containers. In particular, its security model allows modular access to the underlying hardware and Operating System (OS), on a per-function call basis, ensuring safety while retaining native performance.

If WASM+WASI existed in 2008, we wouldn’t have needed to created Docker. That’s how important it is. WebAssembly on the server is the future of computing. — Solomon Hykes, Co-founder of Docker

Furthermore, the server-side Wasm benefits from significant innovations coming from the blockchain community.
Learning Rust by Contrasting with TypeScript: Part 1
By: John Tucker
Tags: Web Development, Typescript, Rust

Seeing Rust as a potential successor to TypeScript, we go through through the Rust Book with TypeScript in mind.

Motivation

Watch the video.

Prerequisites

The common requirement for both the Rust and TypeScript projects is the GIT version control system.

Rust Installation

Rust installation involves installing global binaries, e.g., rustc and cargo. This article was written using version 1.38.0.

TypeScript Installation

TypeScript depends on the JavaScript runtime Node.js; must first be installed. This installation involves installing global binaries, e.g., node and npm. This article was written using version 12.13.0.

TypeScript itself is installed as a Node.js project dependency as we will see below.

Rust Project Creation

Project setup involves running the cargo command to scaffold a Rust project:

note: The completed project is available for download.

cargo new r00_hello_world

The project is also initialized as a GIT repository with a .gitignore file. It also includes the sample source file: src/main.rs:

TypeScript Project Creation

Project setup first requires scaffolding a JavaScript Node.js project by creating a folder and using the npm command:

note: The completed project is available for download.

mkdir t00_hello_world

cd t00_hello_world

npm init --yes

We initialize the project as a GIT repository with:

git init

and create a .gitignore file:

We then convert the JavaScript Node.js project into TypeScript by first installing the TypeScript development dependency:

npm install -D typescript

We then create a TypeScript configuration file: tsconfig.json. Here we use the microsoft/TypeScript-Node-Starter example.

We update the .gitignore file to ignore the output directory: dist:

We update the package.json; updating the main value and adding a start and build to scripts:

Finally, we create the source file: src/index.ts:

Rust Build

During development, we use the following command to build a Rust project:

cargo build

The output is a compiled OS executable: target/debug/r00_hello_world.

For release, an optimized build, we use the following command:

cargo build --release

The output is a compiled OS executable: target/release/r00_hello_world.

TypeScript Build

We use the following command to build a TypeScript project:

npm run build

The output is a transpiled JavaScript file: dist/index.js.

Rust Execute

We simply execute the compiled OS executable as we would any other:

./target/debug/r00_hello_world

We can also use the command:

cargo run

to both build and run.

TypeScript Execute

We execute the transpiled JavaScript file using the npm script:

npm start

or we can execute it directly:

node dist/index.js

In either case, we are executing our project on top of the JavaScript runtime.

Next Steps

Now that we are done with the project mechanics for each of the languages, we will start to dive into the languages themselves in the next article: Learning Rust by Contrasting with TypeScript: Part 2.
We want smaller, faster, more secure native apps
By: Daniel Thompson-Yvetot
Tags: Security, Development, Rust, Appsec, Cross Platform Apps

A Paradigm Shift

Tauri approaches these issues head on, as it was designed from the ground up to embrace novel patterns for secure development and creative flexibility that leverage the language features of Rust and enable you to grow your app using any front-end framework you like. And all of that in a much more secure distribution environment.

With Tauri as a component in your toolchain, you will be able to design, build, audit and deploy tiny, fast, robust and secure native applications for the major Desktop and Mobile platforms in record time. You can do all this within your preferred dev environment, using any framework and without even needing to know the Rust programming language. If you know Rust, however, you will be empowered to make even more amazing integrations with the underlying operating system and hardware.

The Tauri-Team has already completed some initial proofs of concept using WebViews (with really encouraging results such as < 3MB binaries on MacOS, Windows and Linux). At the moment we are finalizing the API, preparing smoke-tests, investigating cross-compilation tools and even building a binary evaluation harness. However, we are not totally satisfied with the WebView approach, and are investigating alternatives like Servo and Webkit.

Get in Touch

Tauri apps aren’t quite ready for prime-time and there is a lot of work needed in the codebase and the governance structure to get to that point. Nevertheless, in our quest for transparency and community involvement, we are taking this opportunity to invite everyone from the Rust, Appsec and Dev communities to come around and find out where the project is at, where it is going and how to get involved in the working groups.

Tauri is an organization that seeks to follow the best practices of the SFOSC principles. It is our duty and pleasure to humbly invite you to visit our public GitHub project page, hang out at our Discord chat server, donate money at our Open Collective page or simply follow our Tweets.

About the Author:

Daniel Thompson-Yvetot is the principal architect and security engineer behind Tauri. He has been an open source evangelist for the last 13 years and is an active member of the Sustainable Free and Open Source Communities (SFOSC).
Texture Synthesis and Remixing from a Single Example
By: Anastasia Opara
Tags: Game Development, Rust, Procedural Generation, Content Creation, Open Source

A big part of a game developer’s time is spent translating creative ideas into representations that software can understand. And that requires a good grasp of how the software works, making game development difficult for most people to master.

At Embark, we believe it should be as easy to create as it is to play. And that pushes us to rethink the way we create today. I’m a procedural artist here at the studio, and I spend my days thinking a lot about these sorts of challenges from a content creation perspective.

So for example, let’s say I want to build a 3D model of a bridge. In essence, what I have to do is to convey that intent via a sequence of tool actions, like extrude, bevel, transform, etc. Often the final combination of steps is not immediately obvious. And even before I can start tackling this puzzle, I need to learn the language of the software. What is that tool called? Where is it located in the UI? How do I do “X”? Will tool A + B allow me to do a C-like transformation?

With proceduralism, the aim is to automate parts of that software translation by building a higher abstraction level on top. For example, we could express building a bridge, as a spline and a couple of semantically meaningful sliders — a representation that is much closer to our “raw” creative intent — and let the algorithm handle the rest.

Designing these specialized procedural algorithms, however, requires a lot of knowledge that is orthogonal to content creators’ skills. Even for an expert, it’s time-consuming and the result is usually suitable for a narrow subset of use cases (for instance, I can’t generate houses with a bridge algorithm). In practice, we end up with a separation between users and tool creators.

But what if we could automatically extract rules from examples? Thus allowing anyone to make their own tools by simply showing what they want. This is where example-based methods come in.
Announcing Arboric GraphQL API Gateway
By: Alistair A. Israel
Tags: Rust, Api Management, Rustlang, Api Gateway, GraphQL

Arboric GraphQL API Gateway

In case you haven’t heard, GraphQL is the new Web service API standard that’s rapidly gaining adoption and popularity.

Developers like it because it makes it easier to prototype, develop, consume and maintain APIs whether for React SPA/PWA apps or Flutter mobile apps.

I particularly like how GraphQL frees us from CRUD (or HTTP REST verbs) thinking and aligns extremely well with Domain Driven Design (DDD), Command Query Responsibility Segregation (CQRS) and Event Sourcing, making it easier to design and implement APIs as distributed microservices even for complex domains.

API Managers

If you’ve been working on large-scale APIs for some time now, you’re sure to have encountered, likely even used an API manager for your REST APIs.

API Managers or API gateways provide a variety of features that ease the development and operation of Web services / APIs, such as:

TLS/SSL(HTTPS) termination

Routing/forwarding to distributed back-end services

Caching

Throttling/DDoS protection

Authentication

Authorisation (using ACLs or access control lists)

Audit or metering

Content transformation

Some API management services even provide integrated billing services for providers looking to monetise their APIs.

As we were developing our hotel & resort property management SaaS, Shore Suite and other APIs for our consulting engagements, it quickly became apparent though that all existing API gateways or API managers out there are REST-centric and not equipped to handle GraphQL queries.

Since GraphQL only exposes a single endpoint, and generally uses only HTTP POST, traditional query path-based metering and access controls simply won’t work!

It was with this motivation that brought us to develop Arboric – the first API manager dedicated for GraphQL.

Arboric–the Dedicated GraphQL API Manager

The core Arboric API gateway is written in Rust and will be open source and free to use.

We chose Rust because of its promise of stronger guarantees around safety and memory use, while at the same time compiling to blazing-fast native code, without the performance hit of a garbage collector. Rust is hopefully the ‘modern’ C++ alternative we’ve been looking for, that can outperform Java and/or Go.

The initial “proof of concept” version 0.1 is feature complete and demonstrates the following capabilities:

Authentication and validation of JWT bearer tokens against a secret signing key

Parsing of GraphQL requests

Authorisation of requests against a whitelist of roles mapped to queries/fields

Logging of queries to InfluxDB

It’s available at https://github.com/arboric/arboric

Next milestone is a major refactor and code cleanup, with an eye towards making the core gateway “production ready” (for, um, ‘modest’ meanings of the word production).

Project Goals

Arboric is an ambitious project, and we’re looking to implement several things over the coming months, including:

TLS edge termination

Mutual TLS to back-end services

GraphQL schema stitching

We welcome early adopters and contributors!
[Rust] Type system
By: Brian Pan
Tags: Rust

Deref

& -> get reference of the var

* -> deref an address

Without the Deref trait, the compiler can only dereference & references. The deref method gives the compiler the ability to take a value of any type that implements Deref and call the deref method to get a & reference that it knows how to dereference.

The reason the deref method returns a reference to a value and that the plain dereference outside the parentheses in *(y.deref()) is still necessary is the ownership system. If the deref method returned the value directly instead of a reference to the value, the value would be moved out of self . We don’t want to take ownership of the inner value inside MyBox<T> in this case or in most cases where we use the dereference operator.

// def of the trait Deref

type trait Deref {

type Target : ?Sized;

fn deref(&self) -> &Self::Target;

} // impl example

impl ops::Deref for String {

type Target = str;

fn deref(&self) -> &str {

unsafe {

str::from_utf8_unchecked(&self.vec)

}

}

} // cast &String to &str

fn main() {

let x = "hello".to_string();

// or use x.deref()

// *x -> *(x.deref()) -> str type match &*x {

"hello" => {println!("!")},

_ -> {}

}

}

Traits as the tags

Sized :Types ensure the size during compiled period

Unsize: Types that can be “unsized” to a dynamically-sized type.

Copy: Types whose values can be duplicated simply by copying bits.

Clone: A common trait for the ability to explicitly duplicate an object.

Send: Types that can be transferred across thread boundaries.

Sync: Types share ref safely between threads

pub trait Clone : Sized {

fn clone(&self) -> Self;

fn clone_from(&mut self, source: &Self){

*self = source.clone();

}

} // example of implementing Clone trait

impl Clone for T {

fn clone(&self) -> T {

*self

}

}

Trait from & into
Federated ML to cut the mustard for privacy concerned industries
By: Oana Olteanu
Tags: Federated Learning, Startup, Rust, AI, Webassembly

Federated learning was invented at Google in 2015 and represents a better way to do ML at the edge. Recently it moved from research to being applied and useful. What it means is, for each device, a model is trained with the data available to that device, and then each of the models sends back some parameters to the server. Basically, the data does not move, it remains on the device, only the parameters are used to train a model from all the nodes that reported back. Once the master model gets better, it pushes updates to the devices, making each individual device model better. In other words, federated learning is distributed ML across devices.

Federated learning is important because it frees companies from moving data, which means less engineering trouble and less privacy trouble. It is also important because it allows for more accurate ML since the model can be trained on a higher, more varied volume of data. One area where this has proven to lead to better results is in predictive maintenance. Healthcare could also benefit from it greatly and financial services. These industries are handling valuable PII data that must be protected at all costs. The custodians of this data have to choose between privacy OR getting more value out of the data. Federated learning would transform the OR statement into an and statement, privacy AND making use of the data, without exposing the data for mishandling or fraud.

Federated Learning is happening at the same time as WebAssembly and Rust. This makes for a killer combination. Rust is a better C++ with a static garbage collector for better memory management. With Rust, developers can write safer code for powerful applications. WebAssembly moves these powerful apps to the browser by giving them a near-native feel and speed. When we use these apps in the browser, we generate a lot of data that is personal and must be protected. Federated Learning preserves the privacy of the data and enables value creation without compromising us and our data. Federated Learning + WebAssembly + Rust = safer, faster, more valuable apps #futureisbright

If you are a federated learning practitioner, I’d love to grab a virtual coffee and share learnings.

Oana
RustFest EU Barcelona 🇪🇸 2019
By: Irvi Aini
Tags: Rustlang, Barcelona, Travel, Rust

Fri, Sep 20, 6:19 PM

Dear Irvi!

Thank you very much for applying for a RustFest Scholarship! We are thrilled to let you know that your application has been ACCEPTED and you have been awarded a RustFest Scholarship!

Your scholarship award includes:

Conference ticket to RustFest Barcelona 2019 with full access to talks, workshops and all side events

Travel support (flight tickets) up to 800 EUR

Accommodation support of up to 400 EUR

Reimbursement of Visa fees up to a maximum value of the equivalent of 250 EUR

Travel stipend of up to a 100 EUR for incidentals (reimbursed according to receipts, after the conference)

If you have questions about the scholarship award, ensure you have carefully read through the scholarship announcement, and if you still have concerns feel free to reach out to us straight away and we are happy to answer any questions you may still have!

Accommodation:

You have requested to book your own accommodation. Your costs will be reimbursed after the conference, provided you submit your receipts/bookings, up to the above stated limits.

Travel:

You have requested to book your own travel. Your costs will be reimbursed after the conference, provided you submit your receipts/bookings, up to the above stated limits.

Suggested travel dates: November 7 (Thursday) or November 8 (Friday) — November 11 (Monday) or November 12 (Tuesday)

In the case of extended stay/personal time in Barcelona, you will need to cover for the rest of the days yourself.

Visa:

We will provide you with sufficient documentation (e.g. invitation letter) for your visa application, as well as will be reimbursing your visa-related costs up to the above stated limit. Don’t hesitate to let us know if there is anything we can do to facilitate the visa process.

Please let us know if you have any questions, or if for whatever reason you are no longer able to join us at RustFest. Please also send us the above requested information ASAP so we could sort this out as soon as possible. If e-mail is not the best way to keep in touch, please let us know the preferred way to keep in touch with you (phone number, WhatsApp, Telegram etc.) and we will do our best to use the channel best suited for you for further communication.

Thank you again and looking forward to welcoming you at RustFest Barcelona!

RustFest Barcelona, Diversity & Inclusion Team
How it works?
By: George Shuklin
Tags: Game Development, Piston, Programming, Glx, Rust

How it works?

I made my demo app running reasonably well from algorithmic point of view. It adjust speed based on previous runs, it uses multi-threading to unload math from the main thread. It good… well, it’s better than it was.

But I found that my ‘draw’ code sucks. It’s mostly copy-paste from examples and I can’t find a bit of docs on what’s going on.

Here are things I understand:

Inside event loop we have Render event… Well, Rust code is more expressive than my English:

while let Some(e) = events.next(&mut window) {

...

piston::Event::Loop(piston::Loop::Render(_)) => {

As far as I understand, it an event to render the picture on the next frame. This part I understand.

Now strange bits are coming, for whom I have no idea why and what:

texture.update(&mut texture_context, &buf).unwrap();

We update texture using texture context. Texture context appears once more in the code, when we create texture:

let mut texture: pw::G2dTexture = pw:: Texture::from_image(

&mut texture_context,

&buf,

&pw::TextureSettings::new()

).unwrap();

And here the texture content creation:

let mut texture_context = pw::TextureContext {

factory: window.factory.clone(),

encoder: window.factory.create_command_buffer().into()

};

What is ‘factory’ here? A function to create texture? What is ‘encoder’? What create_command_buffer function does (outside of the name)?

Why so? Can I write my own? What those functions should do?

And here is the drawing part:

window.draw_2d(

&e,

|context, graph_2d, device| {

texture_context.encoder.flush(device);

pw::image(&texture, context.transform, graph_2d);

}

);

The draw_2d function takes event and closure (lambda), which is called… And I have no idea how many times it called during a single rendering event.

But it calls ‘encoder.flush’ (which, I presume, collapses all command into one, or write my changes onto texture).

And then it call image function with context.transform . What’s this? and thing which was ‘g’ in original example, and I renamed it to graph_2d but I forgot why.

Anyway, any attempt to read about textures and the way it all work just hitting the wall. There is nothing to read. Is this an answer to my question? I doubt this.

Basically, there are few things which worries me:

Total lack of documentation on library outside of introduction code. The navigational problem. As soon as I wanted to declare it dead, I found it’s not, and I found some reading on Encoder thing. It was not inside TextureContent, but inside of gfx module. How could I know where to look?

Overall, I like how it looks, but lack of documentation together with my shaky Rust knowledge made my ‘reverse-engineering’ research way harder than I expected.
Rust-lang, at a glance
By: Jim Yt Chen
Tags: Programming, Programming Paradigms, Rust

Just a quick glance at Rust-lang, haven’t really done things with it. But I’m interested in its memory management system, so called “ownership”, and no “null” design.

Rust, borned in 2006, was firstly a personal project but then sponsored by Mozilla since 2009. It’s a compiled language and is known for its compilation time check.

There are two popular approaches of memory managements in modern programming languages. The first one is you, the developer, explicit allocate and deallocate them. The other is me, the runtime, do all the nasty things for you, which is known for garbage collection (GC).

As I remember the old days dealing with C programs, I should always remember to free the memory allocated for the use. Not to mention that, I should always be aware of how the memory is passed around. And I met Java, which was firstly attractive to me for it’s ambitious goal, “write once, run anywhere”. That was my first time feel great about coding (and OOP was fascinating to me). Java introduced GC mechanism for the programs. I still remember some mechanisms like Mark and Sweep.

Great, I don’t need to worry about memory management anymore. Right? The truth is no. How come? Well, everything has its pros and, of course, its cons. The good news is you don’t need to manually do that, but as your program grows and runs, it’s pretty much easy to see the program is getting slower and slower. And then GC jumps in and says, “dude, I’m doing good for you. Stand aside and wait for me.” Great, now that my program needs to wait. Well, this is not a bad thing though, just a trade-off.

Other than the two approaches, Rust now says you don’t need to do what you do as in C/C++, nor suffer from the GC. Rust uses the concept of “ownership” of value and by leveraging the design, it can do away more than memory management. It could also checks if your code has some potential invalid data, like memory got freed or messed up, during compilation time. This is interesting, but I’m still looking into the more complex scenario than the tutorial samples.

Another interesting thing is no null value. This concepts gets more and more popular these days. For example, Swift and Kotlin both introduce optional. Ruby actually has an optional operator, ?. . I’m not sure if Swift and Kotlin is designed with no null. But I’m sure Ruby has nil and it returns nil if the operand is a nil .

Still looking into it and see if there’s anything to try out with it.
Some LeetCode Contest solution, in Rust 🦀️
By: Mark Feng
Tags: Programming, Algorithms, Rust, Rustlang, Leetcode

Keyword: Sliding window

Use a counter to keep track of the appearances outside of the sliding window, and try to narrow the window as small as possible.

Rust solution:

use std::cmp;

use std::collections::HashMap;



struct Solution {}



impl Solution {

pub fn balanced_string(s: String) -> i32 {

let mut counter: HashMap<char, i32> = HashMap::new();

for c in ['Q', 'W', 'E', 'R'].iter() {

counter.insert(*c, 0);

}

for c in s.chars() {

let new_count = match counter.get(&c) {

Some(&val) => val + 1,

None => 1,

};

counter.insert(c, new_count);

}

let length = s.len() as i32;

let mut result = length;

let expected = length / 4;



let (mut j, mut i) = (0_i32, 0_i32);

while j < length {

let char_j = s.chars().nth(j as usize).unwrap();

counter.insert(char_j, counter.get(&char_j).unwrap() - 1);



// sliding window

while i < length

&& counter[&'Q'] <= expected

&& counter[&'W'] <= expected

&& counter[&'E'] <= expected

&& counter[&'R'] <= expected

{

result = cmp::min(result, j - i + 1);



let char_i = s.chars().nth(i as usize).unwrap();

counter.insert(char_i, counter.get(&char_i).unwrap() + 1);

i += 1;

}

j += 1;

}



result

}

}



#[cfg(test)]

mod tests {

use super::*;



#[test]

fn test() {

let s = "QWER".to_string();

assert_eq!(Solution::balanced_string(s), 0);



let s = "QQWE".to_string();

assert_eq!(Solution::balanced_string(s), 1);

}

}

Some places in the code may be not necessary:
Getting started with Deno.js
By: Vaibhav Mehta
Tags: JavaScript, Nodejs, Deno, Rust, Typescript

Our first Deno app

Now that we have some fair idea on how to execute code using REPL or a .ts file, we will now move to a little more complex program where we will explore additional features of Deno.

In the below app, we are merely fetching some data from the third-party website and printing it in the terminal.

We will create a new file for the program, say Request.ts .

touch Request.ts

Add the below code to Request.ts



const getRecords = await fetch(' //fetch the data from JSONBin.io - JSON Storage website (public record)const getRecords =fetch(' https://api.jsonbin.io/b/5ec136d747a2266b1479ecc7' ); //proceed once the promise is resolved from the previous statement, fetch the response body and parse it to json

const getData = await getRecords.json(); //prints the retrieved data

console.log(getData); //[ 1,2,3,4,5 ]

In the above code, we request the JSON data from JSONBin.io (a free JSON hosting website) and later we parse the response using .json() and then we print the response using console.log() statement.

Now, we will run the above code using the following command.

deno run Request.ts

Fair. When we run the file, we expect the file to output the contents we just retrieved, but instead, it errors out.

Fetching data from a third-party website using the fetch API with Deno

😖 Why is it erroring out? As we discussed earlier, unlike Node.js, Deno provides a secure runtime for JavaScript, and hence, since your script file is trying to access an external resource, you need to grant the permission to the script to do so. Try rerunning the following command, but this time, we will pass the necessary permission for the script to fetch the data.

deno run --allow-net Request.ts //script will now output the contents of the file like

//[ 1, 2, 3, 4, 5 ]

Run a .ts file to fetch the data from a third-party website

These are some key takeaways from the above app we just created.
Create Your JS Runtime With Deno
By: Darren Liew
Tags: Js Runtime, Rusty V8, Rust, Nodejs, Deno

Deno is not only bring us a new js/ts runtime, it also bring us a new V8 binding with rusty_v8 lib. I create this series to keep track the steps I did to create my own JS runtime with rusty_v8.

Setup

macOS Catalina

Z Shell

cargo 1.43.0 (2cbe9048e 2020–05–03). to install cargo, I did this

curl https://sh.rustup.rs -sSf | sh

after that, add $HOME/.cargo/bin to ~/.zshrc .

to have the new effect immediately, run it with

source ~/.zshrc

Before create let’s copy…

I find that studying existing code and make small increment changes from there is a great way to learn. Let’s clone deno and see how it did v8 binding.



cd {YOUR/PATH/TO/DENO}

git submodule init

git submodule update

cargo build git clone https://github.com/denoland/deno.git {YOUR/PATH/TO/DENO}cd {YOUR/PATH/TO/DENO}git submodule initgit submodule updatecargo build

If successful you should see

Finished dev [unoptimized + debuginfo] target(s) in 1m 44s

I found a good place to start is at core/examples/http_bench.rs . unfortunately this folder is not build by default. to build it:

add " core/examples", into ./Cargo.toml add a new Cargo.toml file into core/examples folder and copy and paste following text into the file

[package] name = "deno_core_http_bench" version = "0.45.0" edition = "2018" [dependencies] deno_core = { path = ".." } derive_deref = "1.1.0" tokio = { version = "0.2.20", features = ["rt-core", "tcp"] } log = "0.4.8" futures = { version = "0.3.4", features = ["thread-pool", "compat"] } [[bin]] name = "http_bench" path = "http_bench.rs"

build again with cargo build you should see http_bench executable file in target/debug/http_bench

execute the binary and it will run a server and listen to localhost:4544. on your browser type http://localhost:4544 you should see Hello World

Congratulations! you have created a js runtime although it only run http_bench.js for now. in the following series, we make the runtime more useful and execute any js file that pass in as command line argument.
From Python to Rust: Part 1.
Tags: Coding, Programming, Rust, Rustlang, Python

In this series of articles, we will explore a young and very exciting programming language — Rust. We will see how Rust can help us to speed up some of our existing and future Python code. Many agree, that the key features of Python are its simplicity and readability. Let’s try and see if we can have the same or similar simplicity and readability from Rust and get that incredible execution speed of a compiled language.

While Python is an amazing, general purpose language and is super easy to write and understand, it might be too slow when we need to write an algorithm that needs to ‘crunch’ through a lot of data. Of course, well written Python code that uses something like NumPy or Cython, is still, very very fast and probably enough in most cases. All of the checks that are done by interpreted language like Python, will slow our code a lot.

We will look at Python and Rust code side-by-side and attempt to port (rewrite) some of our Bioinformatics related code from Python to Rust while comparing code execution speed of both. We will see, that we don’t necessarily need/have to sacrifice simplicity of Python for Rust’s speed. And some functionality, written in Python, will stay in Python and just call our faster code, rewritten in Rust. This way we will attempt to get a ‘sweet spot’ (best from both languages) to solve our Bioinformatics problems.
My Journey to Happiness
By: The Anonymous Doctor
Tags: Authentic, Overcoming Depression, Love Yourself, Journey Of Life, Journal

My Journey to Happiness

The concept of documenting one’s life is the ultimate expression of self-love. Being bold enough to lay bare the insecurities and vulnerabilities of human existence for others to openly judge. All the while accepting that this is me and my story and I am not going to allow anyone, anymore to undermine my happiness and sense of self-worth.

I sit writing this first insight with anxious anticipation. How vulnerable I am, how scared I am, how naked I am prepared to go in unravelling the layers of ego and unlocking the doors to my core. I write this behind the veil of anonymity to raise this terrifying ceiling. To pacify this fear and embolden my conviction in documenting my life and my struggle, my fears and my hopes. This will not be a masterpiece nor will it be a marvel of authentic literature. It is simply my scratch book of existence, unexplored, unsure and desperate for clarity. A hopeful beacon among the infinite consciousness.

This journal hopes to share my life in a raw and human way, journeying through the lessons and experiences of modern life. It does not hope to instruct others on how best to value or perceive matters. Merely, it shares my own web-strings of consciousness as I mature this world — a 21st century human living in a metropolis of global interconnectedness. It offers a digital timestamp on my being and place in this continuum of existence in this cosmic marvel called life.

While I have enjoyed celebrating the lives of others as they document their journeys in an audiovisual manner — offering coveted glimpses into their days and personalities I do not feel confident enough to reveal my character’s identity so publicly. While it would be advantageous to leverage this story on another platform this is not my aim with this task. This is my time, my self-reflection, my inner zone of confidence and I want to claim it and own it. I want to unashamedly declare my unfiltered process of growth and battle to find meaning and purpose in this often alienating world.

As I shall explore the motivations for this arose not out of the pursuit of success or attention but rather self-growth, happiness and creative expression. It has been said by the Japanese that we have 3 faces — one we show to the world, one we show to those close to us and one we keep hidden deep — censored for public viewing. I have wrestled with this concept of visibility for as long as I can remember. Afraid to fully express my true character, choices and beliefs. How many of us have been diminished by society to be someone, something or go somewhere we are not meant to? I at least, have felt this burden greatly and know the pain that it invokes. A stifling chokehold on happiness. A hypoxic existence. Starved of true meaning and fulfilment. It is my hope that through this medium of reflection, I can uncover the sources of my pain and that it may spark the genesis for my healing and offer a loving mirror to any other soul who this resonates with. Sending out love to the universe. Yours deeply, human.