juan_gandhi: (Default)
2020-01-08 07:02 pm
Entry tags:

пару слов про rust

Принцип дизайна: non sunt entia multiplicanda sine necessitatem.

Короче, CPS рулит; сейчас вмажу моноид, https://docs.rs/functional/0.0.5/functional/trait.Monoid.html, чтобы вообще не дублировать ничего и не писать циклы, где не надо (а просто fold). 

Подробности:

1. Не нужно дублировать данные. Если у тебя есть данные, присобачь к ним какой-нибудь метод, чтобы применять твою функцию и устраивать какой-нибудь fold, возможно, с мапингом и фильтрацией.

2. Поэтому, вместо того, чтобы передавать коллекцию в функцию, передавай функцию в коллекцию.

3. Для фолда моноид самое то (а иначе откуда фолд?) В моноиде есть "начальное значение" и ассоциативная бинарная операция. Чтобы проехаться по коллекции, это все что надо - начали с "начального значения", и все данные переварили, получив одно значение. Левый фолд или правый - для моноида роли не играет, можно и распараллелить.

juan_gandhi: (Default)
2019-12-24 08:20 am
Entry tags:

rust cache

Понадобился мне кеш в задаче. Ну конечно я и сам этого кеша понаписал дохрена, но что б не погуглить. Нагуглил. Это макро! Код ты вообще не меняешь, только заворачиваешь в вызов макро, с указанием, где у тебя кеш хранится. И все. Лайк!

#[macro_use] extern crate cached;

/// Defines a function named `fib` that uses a cache named `FIB`
cached!{
    FIB;
    fn fib(n: u64) -> u64 = {
        if n == 0 || n == 1 { return n }
        fib(n-1) + fib(n-2)
    }
}
juan_gandhi: (Default)
2019-12-01 10:24 pm
Entry tags:

talking about Rust

Its performance is amazing. The sum of the first 2m primes (have to calculate the primes first): 32 seconds (optimized compilation).

Why does performance even bother me? I don't know, just as a surprise.

Shit, found a bug. In short, 160ms in Rust (the naive algorithm), 700ms in Scala (same algorithm).
juan_gandhi: (Default)
2019-10-13 04:47 am
Entry tags:

Rustonomicon

the dark arts of Rust 

How to fuck (up) Rust and shoot in your leg professionally, as if it were C++.
juan_gandhi: (Default)
2019-10-05 10:20 am
Entry tags:

rust optimization

It turns out, if you build rust code with full optimization, it will be e.g. 12 times faster (my example, with Mandelbrot set, 10" vs 2'). 
juan_gandhi: (Default)
2019-09-22 04:01 pm
Entry tags:

о, нафигачил



src: https://github.com/vpatryshev/rustex/tree/master/mandelbrot

Will have to sanitize and civilize the code, of course.

It was the first time I generated Mandelbrot, which is weird, eh.
juan_gandhi: (Default)
2019-08-09 07:51 am
Entry tags:

laconic Rust

enum Option {
    Some(T),
    None,
}
juan_gandhi: (Default)
2019-07-18 03:09 pm
Entry tags:

bad bad jvm

Rust allows this, but Scala does not

fn main() {
let c = 'z';
let z = 'ℤ';
let heart_eyed_cat = '😻';
}


juan_gandhi: (Default)
2019-07-09 01:22 pm
Entry tags:

secure programming

> rustc -version
error: Unrecognized option: 'e' 
juan_gandhi: (Default)
2017-12-30 10:13 am
Entry tags:

dawn project

http://dawn.cs.stanford.edu/ 

"DAWN is a five-year research project to democratize AI by making it dramatically easier to build AI-powered applications.

Our past research–from Spark to MesosDeepDive, and HogWild!–already powers major functionality all over Silicon Valley–and the world. Between fighting against human traffickingassisting in cancer diagnosis and performing high-throughput genome sequencing, we’ve invested heavily in tools for AI and data product development.

The next step is to make these tools more efficient and more accessible, from training set creation and model design to monitoring, efficient execution, and hardware-efficient implementation. This technology holds the power to change science and society—and we’re creating this change with partners throughout campus and beyond."