#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.
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 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…
Полюбуйтесь на эту красоту из web-sys
🤯9🔥3😱3❤1👍1🤮1
#prog #rust #article
Native Reflection in Rust
Пост про библиотеку deflect, которая добавляет в Rust рефлексию, но, в отличие от, скажем, bevy_reflect, работает для всех типов, а не только для тех, на которых навешан дерайв.
TL;DR:
1. invokes
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
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-символов.
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 binary3. 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-символов.
Jack Sometimes Writes
Native Reflection in Rust
😱8❤4🤔2👍1
Forwarded from Типа про IT
Media is too big
VIEW IN TELEGRAM
Ну и в чём этот иудейский Альф не прав?
❤5😁2
Блог*
Частью решения является разбор строк вида: bright white bags contain 1 shiny gold bag. vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. faded blue bags contain no other bags. Напишем функцию для разбора одной подобной строки: fn parse_…
Обновил гист, добавив метод для парсинга числа с опциональным минусом
Забавно, конечно, как на запрос "pair of tits" в Яндекс срабатывает фильтр "взрослого" контента и выдаёт одних синиц, но на запрос с опечаткой "pair od tits" выдаёт кучу фото женщин в бикини
🔥5
Блог*
Что-то про (не)рациональную трату средств
Доукомплектовался
(на самом деле заказал вместе со всеми остальными книгами, но конкретно эта шла дольше всех остальных)
(на самом деле заказал вместе со всеми остальными книгами, но конкретно эта шла дольше всех остальных)
👍8🤮8❤2😁2
Forwarded from Меня заставили создать канал
This media is not supported in your browser
VIEW IN TELEGRAM
🔥3👍1👎1
Forwarded from Меня заставили создать канал
Меня заставили создать канал
🔲 Sticker
У Телеграма есть ограничение на видеостикеры: они должны длиться не больше 3 секунд. А это полный Bad Apple в одном стикере.
Почитайте как сделано.
tl;dr:
- Телеграм читает длину видео из заголовков, а их можно подменить
- Ограничение в 256 КБ никуда не девается, так что Bad Apple пришлось нещадно жать
- Находчивый автор сделал и пак с полным фильмом Шрек в 45 стикерах
Почитайте как сделано.
tl;dr:
- Телеграм читает длину видео из заголовков, а их можно подменить
- Ограничение в 256 КБ никуда не девается, так что Bad Apple пришлось нещадно жать
- Находчивый автор сделал и пак с полным фильмом Шрек в 45 стикерах
Telegram
Название съел Вениамин
Вчера в одном чате айти чате обнаружил видеостикер, который на первый взгляд не представляет из себя ничего интересного, но длится целых 8 секунд, при этом находится в паке и корректно отображается на всех клиентах, хотя согласно официальным гайдлайнам телеги…
🔥4😁4👍2
Forwarded from Ю ли я? 🤔
(время кошуточек)
Массив произвольной длины и с фиксированными типами.
Кортеж фиксированной длины и с произвольными типами.
Массив — это ртеж?
Массив произвольной длины и с фиксированными типами.
Кортеж фиксированной длины и с произвольными типами.
Массив — это ртеж?
😁16🤨4👍1🔥1