1.83K subscribers
3.3K photos
132 videos
15 files
3.58K links
Блог со звёздочкой.

Много репостов, немножко программирования.

Небольшое прикольное комьюнити: @decltype_chat_ptr_t
Автор: @insert_reference_here
Download Telegram
#prog #cpp #article

Concept archetypes

Concepts in the form added in C++20 used to be called lite. This is because they do not provide one quite important functionality: having the compiler check if the author of a constrained template is only using operations and types allowed by the constraining concept. In other words, we can say that our template only requires operations A and B to be valid, but we can still use some other operations inside and this is fine with the compiler. In this post we will show how this is problematic, even for programmers aware of the issue, and how to address it with 'concept archetypes'.
#prog #rust #rustlib #article

Gaffer: A prioritised micro-batch scheduler in rust

...I looked at existing schedulers but didn't find any which had features which allowed us to take advantage of these optimisation opportunities, so I took this as an opportunity to build a new scheduler and publish my first rust crate, deciding that it needed this set of features:

* Job enqueuing: jobs can be enqueued from other threads using a
Clone + Send sender.
* Recurring jobs: in case a job is not enqueued by some maximum timeout, a job can be automatically enqueued.
* Futures: other threads which enqueue jobs should be able to await the results.
* Prioritisation: the job queue is executed in priority, followed by submission order
* Job merging: any jobs with the same effect should be merged in the queue to avoid unnecessary load. This is probably the most important feature and it brings with it some extra challenges for the other features:
* merged jobs with differing priority levels must be merged into the highest priority level
* merged jobs with futures awaiting them need to awaken both with the result of the combined job, so the result needs to implement
Clone so that it can be provided to both.
* Parallel execution: multiple worker threads are processing the jobs
* Concurrent exclusion: but some jobs need to acquire some lock and so can't run at the same time as each other
* Priority throttling: and to leave capacity ready for higher priority jobs we can limit the number of threads which run the lower priority jobs.
🥰14👍21
Блог*
Какое покрытие полезнее?
Кстати, напоминаю про очень важный опрос
Похвастаюсь и здесь что-ли: я реализовал Rust RFC 3216. Вот прям PR уже смерджили.

TL;DR: фича позволяет явно писать лайфтайм параметры для замыканий:

let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
// ^^^^^^^^^^^--- new!

https://github.com/rust-lang/rust/pull/98705
👍12
👍 Завтрак пиццей
👎 Горло болит так, что не хочется лишний раз говорить
🌭21👍21👎1🌚1
IF LET CHAINS ARE STABILIZED IN RUST 1.64

rust-lang/rust/pull/94927#event-7007028976

> 2 years, 4 months, 3 weeks and 1 day of long nights, obstacles and headaches.
> Hope stabilization won't be reverted but regardless, thanks to everyone who helped make this feature a reality.

Для тех кто не в теме, в расте можно делать паттерн матчинг в ifwhile цикле). Называется эта конструкция "if-let" и выглядит примерно вот так:

// выражение vvv
if let Some(x) = opt { ... }
// ^^^^^^^ паттерн

Синтаксис конфузный, но что имеем, то имеем, ладно. Проблемы (которые решает фича выше) начинается когда хочется сравнить сразу несколько выражений с паттернами. Можно использовать туплы:

if let (Some(x), Ok(y)) = (opt, res) { ... }

Но мало того, что это абсолютно не читаемо, мало того что это вычисляет res даже если паттерн и без него бы не сматчился, так ещё и в res тут нельзя использовать x. Поэтому это очень неудобно. Можно использовать вложенность:

if let Some(x) = opt {
if let Ok(y) = res { ... }
}

Но это ломает else (с таким вариантом его надо дублировать во все сложенные if'ы). Это всё настолько печально, что есть даже крейт if_chain с макросом который разбирается со всеми этими проблемами. Ну и фича которую вот стабилизировали — if let chains, которая позволяет писать вот так:

if let Some(x) = opt && let Ok(y) = res { ... }

😌
👍9🎉2
Forwarded from Кибераутизм
"3-е кольцо Вавилонова И.Д."
Сережа Кшатри
4
#prog #rust #rustlib #article

Kani — bit-precise model checker for Rust. Верификатор, который исполняет код символически и потому эффективно проверяет код на всех возможных входах. Если код (без внесения ограничений на работу kani) проходит проверку, то его корректность можно считать доказанной.

А также статья, которая проверяет кусок логики из реального проекта:

Using the Kani Rust Verifier on a Firecracker Example
👍4
Forwarded from Generative Anton
Иногда я думаю, что идеи моего ресеча какая-то дичь и не стоит тратить на это время.

А потом вижу статью, в которой статистически подтверждается, что нападения волков в муниципалитетах Германии на уровне земель приводят к ультраправому голосованию, а зеленые на таких выборах голоса теряют 🤯

Популистское объединение против внешнего врага? Как вам объединение против волков 🐺🐺🐺!

Цитаты конечно платиновые (AfD -- ультраправая немецкая партия):

Second, we studied the AfD’s communication regarding the wolf, drawing on three data sources: 1) We obtained the entire universe of AfD Facebook ads between 2018 and 2022, amounting to 10,475 unique ads with 94,578,526 impressions. The data show that the AfD, indeed, uses the wolf as a way to garner votes and largely relies on a frame whereby the wolf hurts the economy
🤔1💩1
Forwarded from Гусь
Семья фронтендеров посадила дерево у подъезда, но потом не смогла попасть домой, потому что не знали как его обойти
😁9🔥8
Forwarded from Сергей Кондратьев
У семьи фронтендеров ДОМ и есть дерево
😁13🔥2👍1
👎1