Блог* – Telegram
1.9K subscribers
3.46K photos
135 videos
15 files
3.69K links
Блог со звёздочкой.

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

Небольшое прикольное комьюнити: @decltype_chat_ptr_t
Автор: @insert_reference_here
Download Telegram
Forwarded from Segment@tion fault
Наши ААА
8🤯2
#prog #rust #article

My Year With Rust: The Good, The Bad, The Ugly

<...>

I always feel that reducing Rust to its safety aspect is doing the language a disservice. While safety might be important for big corporations, a small-time game developer like me doesn't really care about it. For me, Rust is so much more than just safety.

<...>

Rust Does Not Crash

Okay, this is an exaggeration, but it is somewhat true, especially for safe Rust. The truth is probably closer that Rust gives me a huge amount of confidence. When it compiles, it generally works. It won't protect you from all kinds of logic errors, but it prevents a whole class of errors from happening and turns many into compile time rather than runtime ones.

I admit, when I first started with Rust, correctness was not really a big concern. The program should run of course, but crashing or bugs are not the end of the world most of the time, especially when it comes to games. They just happen.

However, correctness is something that I really started to appreciate after using Rust for a while. It really grew on me to a point where I don't want to miss it anymore.

<...>

The language itself also has some holes. Rust offers many useful features with its lifetimes, traits, and it's typesystem, but I am constantly hitting unstable features or outright forbidden operations when trying to use them together in certain contexts.

<...>

As mentioned before, Rust focuses on correctness. There are many tracking issues that seem to be stuck for years, because there is no agreement on a solution, or because it wouldn't work on some exotic platforms or due to a niche reason. It's quickly adding new features that people can agree on, but the difficult questions seem to be stuck at times, with only an occasional bump being a lost soul, asking for the current status.

<...>

Switching To Other Languages Feels Off

I know. This sounds like /r/rustjerk content, feel free to skip over this part, but my point is not that Rust is superior, but more that it can causes changes in general, at least it did to me. Rust just does so many things differently.

Being conditioned to please the borrow checker will just change how you approach problems and write code in general. It takes a lot of time to switch from the "ownership and lifetime" model to the "Oprah handing out mutable references"-style. The cost of the context switch is huge.
👍1🤨1
#prog #rust #article

Native Reflection in Rust

Пост про библиотеку deflect, которая добавляет в Rust рефлексию, но, в отличие от, скажем, bevy_reflect, работает для всех типов, а не только для тех, на которых навешан дерайв.

TL;DR:

pub trait Reflect {
#[inline(never)]
fn local_type_id(&self) -> usize {
<Self as Reflect>::local_type_id as usize
}
}

impl<T: ?Sized> Reflect for T {}

When you call .reflect on a dyn Reflect value, deflect figures out its concrete type in four steps:

1. invokes
local_type_id to get the memory address of your value’s static implementation of local_type_id
2. maps that memory address to an offset in your application’s binary
3. searches your application’s debuginfo for the entry describing the function at that offset
4. parses that debugging information entry (DIE) to determine the type of
local_type_id’s &self parameter.

The DIE of the Self type has information about the kind of the type (struct, enum, pointer, primitive, etc.), its size, alignment, and the locations and types of its fields. With all this, deflect is able to dynamically reflect the structure of your value’s bytes.

Разумеется, из-за механизма работы не работает на бинарниках без DWARF-символов.
😱84🤔2👍1
🔥17😁73
Блог*
Телега, ты чего?
На телефоне при этом всё в порядке
🤔1
Forwarded from Типа про IT
Media is too big
VIEW IN TELEGRAM
Ну и в чём этот иудейский Альф не прав?
5😁2
Killer feature
11🔥3
Забавно, конечно, как на запрос "pair of tits" в Яндекс срабатывает фильтр "взрослого" контента и выдаёт одних синиц, но на запрос с опечаткой "pair od tits" выдаёт кучу фото женщин в бикини
🔥5
Блог*
Что-то про (не)рациональную трату средств
Доукомплектовался

(на самом деле заказал вместе со всеми остальными книгами, но конкретно эта шла дольше всех остальных)
👍8🤮82😁2
This media is not supported in your browser
VIEW IN TELEGRAM
🔥3👍1👎1
Меня заставили создать канал
🔲 Sticker
У Телеграма есть ограничение на видеостикеры: они должны длиться не больше 3 секунд. А это полный Bad Apple в одном стикере.

Почитайте как сделано.

tl;dr:
- Телеграм читает длину видео из заголовков, а их можно подменить
- Ограничение в 256 КБ никуда не девается, так что Bad Apple пришлось нещадно жать
- Находчивый автор сделал и пак с полным фильмом Шрек в 45 стикерах
🔥4😁4👍2
🤔20😁13🔥32👍1