Skip to content

Instantly share code, notes, and snippets.

View ZhangHanDong's full-sized avatar
🦀
Rustacean

Alex ZhangHanDong

🦀
Rustacean
  • Beijing, China
View GitHub Profile
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active November 5, 2024 02:15
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?

@tstellanova
tstellanova / state_of_rust_fc_2020.md
Last active August 5, 2020 15:43
Current State of Embedded Rust for Flight Controllers

Introduction

A wide variety of widely-available flight controllers and associated robotics boards have been released in the past five years. These boards incorporate a careful selection of sensors and actuator outputs useful for robotics-- not just for flying vehicles, but also rovers and underwater vehicles. This living document analyzes briefly the compatibility of embedded Rust with these inexpensive and powerful boards.

Overall Utility Issues

General issues that impact the usefulness of embedded Rust with these kinds of boards:

  • No (or fragmented) DMA support. Some embedded HAL crates have DMA support already, but many do not. Almost none of the DMA APIs resemble each other. There is at least one effort underway to unify the DMA APIs

Rust 之所以为 Rust —— Rust进阶教程,前言

有段时间没有写关于Rust的东西了,在这段时间里,Rust发布了2018的大版本,增加了一些之前答应的功能,生态上有了一些进步。在国内国外,比起之前一段时间,听说过Rust的人变多了,关注Rust的人变多了,实际在写Rust的人也变多了。PYPL排行榜上,Rust目前已经升到了18位。超过前面17位的Visual Basic,甚至赶上第16位的Scala,我觉得也是很有希望的,只是可能再需要一点时间。整体来说,大概还算是欣欣向荣的。至于短时间内成为爆款什么的,个人觉得倒是可能性不大,不过万一火了呢,毕竟前面有Clojure、Scala的先例嘛。

这次打算写一点进阶的东西。如果是入门的话,其实现在Rust入门教程已经有很多了。官方的教程《The Rust Programming Language》已经出了实体书,还有Rust By Examples也在一直更新。Ralf Jung聚聚的《Rust 101》我也蛮喜欢的,还有Niko Matsakis聚聚之前录的《Into Rust》五集视频教程。还有很多我只听说过但是没有深入了解的,比如NRC聚聚写的Rust for C-Plus-Plus Programmers, Youtube上的jonhoo录的视频教程系列,还有O'Reilly出了一本实体书Programming Rust。国内这边,范老师和张老师先后出了两本Rust入门教程的实体书,很抱歉我还都没拜读过,不过听说口碑也都还可以。哦对了,可能很少有人知道,JetBrains已经把Rust官方的Rustlings做进了它的教育包里,也就是交互式教程。感兴趣的也可以玩玩看。

不过貌似网上关于进阶的东西貌似不是很多。Rust 并不是一门简单的语言,实际上它的技术细节是相当多的。初学者们在入门阶段读的东西,一般都是入门教程作者精心挑选之后拿给你们的东西。一次一个主题,能够在不把读者吓跑的同时把读者写程序解决实际问题时可能用到的主题内容细致的传达给读者。即使这样,内容就已经很多了…… 读者很少会有余力去想,有没有Rust本身的设计里有,但是书籍作者没有传达的内容呢?实际上,不但有,而且还很多很重要:)。

所以就有了这个系列,我会尝试跳过入门书籍的职责,直接讨论Rust的世

@HadrienG2
HadrienG2 / High_Performance_Rust.md
Last active October 29, 2024 02:08
Making Rust a perfect fit for high-performance computations

Hello, Rust community!

My name is Hadrien and I am a software performance engineer in a particle physics lab. My daily job is to figure out ways to make scientific software use hardware more efficiently without sacrificing its correctness, primarily by adapting old-ish codebases to the changes that occured in the software and computing landscape since the days where they were designed:

  • CPU clock rates and instruction-level parallelism stopped going up, so optimizing code is now more important.
  • Multi-core CPUs went from an exotic niche to a cheap commodity, so parallelism is not optional anymore.
  • Core counts grow faster than RAM prices go down, so multi-processing is not enough anymore.
  • SIMD vectors become wider and wider, so vectorization is not a gimmick anymore.
@rust-play
rust-play / playground.rs
Created October 15, 2018 10:45
Code shared from the Rust Playground
enum Result {
PeopleNotice,
Others,
}
fn fuck_the_users(n: i32) -> Result {
if n > 2 {
Result::PeopleNotice
}else {
Result::Others
@steveklabnik
steveklabnik / summary.md
Created September 29, 2015 14:39
my summary of "using Rust with Ruby: a deep dive with Yehuda Katz"

My summary of https://www.youtube.com/watch?v=IqrwPVtSHZI

TL;DR:

Rails has a library, ActiveSupport, which adds methods to Ruby core classes. One of those methods is String#blank?, which returns a boolean (sometimes I miss this convention in Rust, the ?) if the whole string is whitespace or not. It looks like this: https://github.com/rails/rails/blob/b3eac823006eb6a346f88793aabef28a6d4f928c/activesupport/lib/active_support/core_ext/object/blank.rb#L99-L117

It's pretty slow. So Discourse (which you may know from {users,internals}.rust-lang.org) uses the fast_blank gem, which provides this method via a C implementation instead. It looks like this: https://github.com/SamSaffron/fast_blank/blob/master/ext/fast_blank/fast_blank.c

For fun, Yehuda tried to re-write fast_blank in Rust. Which looks like this:

@ohanhi
ohanhi / frp.md
Last active May 6, 2024 05:17
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

class EmailValidator < ActiveModel::EachValidator
require 'resolv'
def validate_each(record, attribute, value)
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
record.errors[attribute] << (options[:message] || I18n.t('email.wrong'))
end
split_email = value.split("@")
domain = split_email[1].to_s
# Atom Cheatsheet.
# Project Key Bindings.
- 'cmd-shift-p': open the command palette.
- 'cmd-p' or 'cmd-t': open the fuzzy finder to find a file.
- 'cmd-b': look for a file that is already open.
- 'cmd-shift-b': search the list of files modified and untracked in your project repository.
- 'ctrl-0': open and focus the the tree view.