#prog #article
The hunt for error -22
Детективная история про гейзенбаг и его фикс. Железо, на котором был баг — модем с двумя ядрами. Одно может использовать пользовательское firmware (в данном случае написанное на Rust), а второе может использовать только пропиетарную прошивку от производителя. Прошивка поставляется исключительно в виде набора интерфейсных заголовочных файлов и блоба скомпилированного сишного кода.
TL;DR:"No way to prevent this, says only language where this regularly happens"
The hunt for error -22
Детективная история про гейзенбаг и его фикс. Железо, на котором был баг — модем с двумя ядрами. Одно может использовать пользовательское firmware (в данном случае написанное на Rust), а второе может использовать только пропиетарную прошивку от производителя. Прошивка поставляется исключительно в виде набора интерфейсных заголовочных файлов и блоба скомпилированного сишного кода.
TL;DR:
tweedegolf.nl
The hunt for error -22 - Blog - Tweede golf
This article is a linear retrospective of how we searched for and eventually fixed a hard-to-find bug in our embedded software. If you're only interested in the outcome, then make sure to read the ...
🤡7💯4🫡2
#prog #amazingopensource
DWARF Explorer (dwex)
A cross-platform GUI utility for visualizing the DWARF debugging information in executable files, built on top of pyelftools and filebytes. Runs on Windows, MacOS X, and Linux.
Ввиду того, что написано на Python, пользоваться этим может быть не очень удобно, особенно на Windows.
DWARF Explorer (dwex)
A cross-platform GUI utility for visualizing the DWARF debugging information in executable files, built on top of pyelftools and filebytes. Runs on Windows, MacOS X, and Linux.
Ввиду того, что написано на Python, пользоваться этим может быть не очень удобно, особенно на Windows.
👍3🔥1
Блог*
Хот #prog тейк: набор примитивов, предоставляемый файловыми системами, абсолютно неадекватен для написания надёжных программ
#prog #article
Files are hard (от Dan Luu)
<...>that's equivalent to saying that as an application developer, writing to files safely is hard enough that it should be done via some kind of library and/or database, not by directly making syscalls.
Настоятельно рекомендую к прочтению целиком.
Статья ссылается на исследовательские статьи, которые, к сожалению, как правило, сильно устарели в плане того, софт каких версий они проверяют, и при этом почти всегда не имеют современных воспроизведений.
Files are hard (от Dan Luu)
<...>that's equivalent to saying that as an application developer, writing to files safely is hard enough that it should be done via some kind of library and/or database, not by directly making syscalls.
Настоятельно рекомендую к прочтению целиком.
Статья ссылается на исследовательские статьи, которые, к сожалению, как правило, сильно устарели в плане того, софт каких версий они проверяют, и при этом почти всегда не имеют современных воспроизведений.
👍6
#prog #article
When to prefer inheritance to composition
<...>So, here's when you want to use inheritance: when you need to instantiate both the parent and child classes and pass them to the same functions. That's it. That's the use case.
<...>Inheritance is a useful tool if we need to run our program under the supervision of other code, for the purpose of querying or analysing the original program. That's probably the way I use it the most, and the situation in which I miss having inheritance the most.
I don't think it'll forever be the right tool for doing this. Someone will eventually come up with a better way, and we'll generally prefer that to inheritance. The same thing happened with code reuse, subtyping, namespacing, and specialization. Inheritance was the first feature that did any of these things, all of the better approaches we now use came after.
When to prefer inheritance to composition
<...>So, here's when you want to use inheritance: when you need to instantiate both the parent and child classes and pass them to the same functions. That's it. That's the use case.
<...>Inheritance is a useful tool if we need to run our program under the supervision of other code, for the purpose of querying or analysing the original program. That's probably the way I use it the most, and the situation in which I miss having inheritance the most.
I don't think it'll forever be the right tool for doing this. Someone will eventually come up with a better way, and we'll generally prefer that to inheritance. The same thing happened with code reuse, subtyping, namespacing, and specialization. Inheritance was the first feature that did any of these things, all of the better approaches we now use came after.
🤔2
Forwarded from Pragmatic Programmer (Nikita Bishōnen)
TL;DR статьи Anthony Accomazzo о проблемах разбиения на части результатов запросов к PostgreSQL (ничего нового, но натолкнуло на окончание этого поста):
- limit/offset подход медленный (индексация не спасает) и может "терять" результаты при активных удалениях или вставках в таблицу
- Разбиение результатов по набору ключей помогает обходить эти проблемы, но не бесплатно (нужно выбирать правильный набор, запоминать вернувшийся уникальный идентификатор последней строки)
- Разбиение результатов по набору ключей, не является "постраничным" - вы можете ходить только на один шаг далее, но не можете сразу открыть седьмую страницу
- Сложности при необходимости обхода в обе стороны, потому-что начинается путанница с идентификаторами ("курсорами")
Читая статью (мне кажется она из this week in rust), вспомнил что где-то видел более интересный разбор методов разбиения результатов в PostgreSQL и использование реальных курсоров. Так и есть, нашёл ту статью от 2016 года, получается #oldbutgold 🥇.
- limit/offset подход медленный (индексация не спасает) и может "терять" результаты при активных удалениях или вставках в таблицу
- Разбиение результатов по набору ключей помогает обходить эти проблемы, но не бесплатно (нужно выбирать правильный набор, запоминать вернувшийся уникальный идентификатор последней строки)
- Разбиение результатов по набору ключей, не является "постраничным" - вы можете ходить только на один шаг далее, но не можете сразу открыть седьмую страницу
- Сложности при необходимости обхода в обе стороны, потому-что начинается путанница с идентификаторами ("курсорами")
Читая статью (мне кажется она из this week in rust), вспомнил что где-то видел более интересный разбор методов разбиения результатов в PostgreSQL и использование реальных курсоров. Так и есть, нашёл ту статью от 2016 года, получается #oldbutgold 🥇.
Sequin blog
Keyset Cursors, Not Offsets, for Postgres Pagination
Learn why keyset-based pagination outperforms traditional offset pagination in Postgres for large datasets (with practical examples).
❤3
#prog #rust #cpp #article
Type Inference in Rust and C++
<...>My feeling is that literally everything above is indicative of a trade-off pattern.
If you want to have a fancy, bespoke modern type checker with Hindley-Milner type inference semantics, you need to accept one of the following:
1. Bad performance for your type checker with a risk of exponential blow-up.
2. No features that look anything like “the compiler picks the best option out of several ones”. No function overloading, implicit conversions, etc.
Надо отдельно отметить, что deref coercion под "pick the best option out of several ones" не подпадает —
Type Inference in Rust and C++
<...>My feeling is that literally everything above is indicative of a trade-off pattern.
If you want to have a fancy, bespoke modern type checker with Hindley-Milner type inference semantics, you need to accept one of the following:
1. Bad performance for your type checker with a risk of exponential blow-up.
2. No features that look anything like “the compiler picks the best option out of several ones”. No function overloading, implicit conversions, etc.
Надо отдельно отметить, что deref coercion под "pick the best option out of several ones" не подпадает —
Target
является у трейта ассоциированным типом, а не параметром, поэтому реализаций Deref
у каждого конкретно взятого типа не более одной🤔3
#prog #cpp #article
How C++ Resolves a Function Call
Взгляд на порядок разрешения имён при вызове функции в C++ с высоты птичьего полёта, с примером, который проходит по всем шагам.
How C++ Resolves a Function Call
Взгляд на порядок разрешения имён при вызове функции в C++ с высоты птичьего полёта, с примером, который проходит по всем шагам.
👍12🤮3