Forwarded from Life of Tau
🥰3🤮3😢1
#prog #go #article
Changing one character wildly improved our application's performance
(thanks @go_perf)
TL;DR:
И да, неожиданно, но даже C++ в этом плане лучше (правда, лишь начиная со стандарта C++20). В нём можно заставить компилятор сгенерировать все функции сравнения, чтобы не писать их руками:
Changing one character wildly improved our application's performance
(thanks @go_perf)
TL;DR:
type uint128 = struct {
hi uint64
lo uint64
}
func less128(a, b uint128) bool {
- return a.hi < b.hi || (a.hi == b.hi && a.lo <= b.lo)
+ return a.hi < b.hi || (a.hi == b.hi && a.lo < b.lo)
}
Из-за внесённой ошибки некоторые элементы ошибочно считались равными, из-за чего сортировка делала лишние перестановки в массиве. И вот тут я опять хочу привести в пример Rust как язык, в котором данную ошибку допустить гораздо сложнее: вместо того, чтобы вручную писать сравнение, проще добавить к определению #[derive(Ord)]
(ладно, #[derive(PartialEq, Eq, PartialOrd, Ord)]
, но это всё равно меньше, чем писать руками).И да, неожиданно, но даже C++ в этом плане лучше (правда, лишь начиная со стандарта C++20). В нём можно заставить компилятор сгенерировать все функции сравнения, чтобы не писать их руками:
#include <cstdint>
#include <compare>
struct uint128 {
uint64_t hi;
uint64_t lo;
std::strong_ordering operator<=>(const uint128&) const & = default;
};
Segment
Changing one character wildly improved our application's performance
Sometimes the only thing standing between your application and 3x better performance is a letter or two.
😁4👍1
#prog #rust #cpp #article
Can you have too many programming language features?
Bjarne Stroustrup famously said, “Within C++, there is a much smaller and cleaner language struggling to get out.” I think he regrets the quote, which he clarified is about the modern semantics of C++, held down by the outdated syntax of C. It’s such a compelling quote, though, because C++ is so messy and dirty, so we want to believe in a small clean underlying core.
The truth, however, is that there isn’t one smaller and cleaner programming language struggling to get out. There’s multiple. And from the beginning, C++ was a glomming-together of multiple ideas: a Simula-like OOP system glued awkwardly to C, without a unified motivating vision. Operator overloading was intended to help integrate the two parts, which it did but at the expense of creating its own entire sub-paradigm. And then came templates, which tried to add generic containers and algorithms but unexpectedly exploded into their own programming paradigm.
So inside C++, struggling to get out, is of course C, the original “portable assembly,” which does its very simple job well. There’s also Java/C# in there, if we take the OOP features on their own. For the operator overloading and RAII and templates, the closest I can really imagine is Rust, which I think if Bjarne was being fair, he would have to admit is close to what he specified when he clarified his quote: Rust does emphasize “programming styles, libraries and programming environments that emphasized the cleaner and more effective practices over archaic uses focused on the low-level aspects of C.”
Can you have too many programming language features?
Bjarne Stroustrup famously said, “Within C++, there is a much smaller and cleaner language struggling to get out.” I think he regrets the quote, which he clarified is about the modern semantics of C++, held down by the outdated syntax of C. It’s such a compelling quote, though, because C++ is so messy and dirty, so we want to believe in a small clean underlying core.
The truth, however, is that there isn’t one smaller and cleaner programming language struggling to get out. There’s multiple. And from the beginning, C++ was a glomming-together of multiple ideas: a Simula-like OOP system glued awkwardly to C, without a unified motivating vision. Operator overloading was intended to help integrate the two parts, which it did but at the expense of creating its own entire sub-paradigm. And then came templates, which tried to add generic containers and algorithms but unexpectedly exploded into their own programming paradigm.
So inside C++, struggling to get out, is of course C, the original “portable assembly,” which does its very simple job well. There’s also Java/C# in there, if we take the OOP features on their own. For the operator overloading and RAII and templates, the closest I can really imagine is Rust, which I think if Bjarne was being fair, he would have to admit is close to what he specified when he clarified his quote: Rust does emphasize “programming styles, libraries and programming environments that emphasized the cleaner and more effective practices over archaic uses focused on the low-level aspects of C.”
The Coded Message
Can you have too many programming language features?
There’s more than one way to do it.
Perl motto There should be one– and preferably only one –obvious way to do it.
The Zen of Python (inconsistent formatting is part of the quote) When it comes to statically-typed systems programming languages, C++…
Perl motto There should be one– and preferably only one –obvious way to do it.
The Zen of Python (inconsistent formatting is part of the quote) When it comes to statically-typed systems programming languages, C++…
👍1
Не знаю, зачем вам это, но пусть будет: сборник сервисов для отслеживания перемещений самолётов, поездов и судов (большинство — в режиме реального времени или почти реального времени).
Хабр
OSINT самолетов, пароходов и поездов
Предлагаем вашему вниманию набор инструментов от мировых профессионалов в области OSINT, которые помогут в ваших поисках информации, связанных с транспортом. Если вы решили заняться автостопом,...
❤1
Forwarded from мне не нравится реальность
Так раздражает, когда люди, которые не пользуются на постоянной основе растом критикуют его.
Не потому что раст идеален. Но потому что они критикуют его не за то. Они не знают настоящих проблем раста.
Не потому что раст идеален. Но потому что они критикуют его не за то. Они не знают настоящих проблем раста.
❤3💩1
Каналы, которые не дают возможности поставить дизлайк, выглядят так жалко
👍41👎14❤5💩4🤮2❤🔥1🤔1👌1🤣1
Блог*
Каналы, которые не дают возможности поставить дизлайк, выглядят так жалко
https://t.iss.one/chilikto/400
И, кстати, этот пост вышел значительно раньше, чем Telegram прикрутил нативные реакции
И, кстати, этот пост вышел значительно раньше, чем Telegram прикрутил нативные реакции
Telegram
Чылік
Дизлайки
Очень нравится эта функция в телеграме. Она добавляет какую-то жизнь в это всё, какое-то альтернативное мнение, какой-то конфликт. В большинстве соцсетей ты даёшь подписчикам свои творения, они дают тебе лайки и вы сидите обмазываетесь гормонами…
Очень нравится эта функция в телеграме. Она добавляет какую-то жизнь в это всё, какое-то альтернативное мнение, какой-то конфликт. В большинстве соцсетей ты даёшь подписчикам свои творения, они дают тебе лайки и вы сидите обмазываетесь гормонами…
Если бы мне давали по доллару каждый раз, когда я кому-то снюсь и я об этом узнаю, у меня было бы два доллара. Это немного, но всё же странно, что это произошло дважды.
❤4👍2
#prog #cpp #article
(Not) detecting bugs
The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most interesting tools that will be employed will be
I have simplified the program to the minimum. I am using GCC 5.3. This code compiles fine, but when I run it, it goes on and on. In this post we will see where the bug is, but more importantly, we will look at why this bug has not been detected during the compilation, and wasted a fair deal of the developer’s time.
(Not) detecting bugs
The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most interesting tools that will be employed will be
boost::zip_iterator
and std::prev
. <...>I have simplified the program to the minimum. I am using GCC 5.3. This code compiles fine, but when I run it, it goes on and on. In this post we will see where the bug is, but more importantly, we will look at why this bug has not been detected during the compilation, and wasted a fair deal of the developer’s time.
Andrzej's C++ blog
(Not) detecting bugs
The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-…
🤯3👍1
Forwarded from Архонт щітпосту | #укртґ
Я думал, это Панорама. На канале Пятница будет шоу "Отсидевшая в 16"
🥰3🤯3👎1