Don’t believe them, there is more great and some frustrating stuff afterwards.
- 0 Posts
- 67 Comments
Rust doesn’t allow type inference in function signatures, c++ does with auto. IIRC, they recommended against using it, because of -you guessed it- compile time.
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•Yes, I did spend time on this21·14 days agoYou could save 0.64 bit per char more if you actually treated you output as a binary number (using 6 bits per char) and didn’t go through the intermediary string (implicitly using base 100 at 6.64 bits per char).
This would also make your life easier by allowing bit manipulation to slice/move parts and reducing work for the processor because base 100 means integer divisions, and base 64 means bit shifts. If you want to go down the road of a “complicated” base use base 38 and get similar drawbacks as now, except only 5.25 bits per char.
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•I got to avoid memory management for quite some time3·20 days agoI can’t comment whether learning C first improves your rust, but it certainly makes you appreciate what the rust compiler does.
Also learning rust improved my C.
C++ already has much more of the required language constructs, which is why there is already an attempt to add borrow checking to C++ called circle. Until that standardizes, I wouldn’t expect it in C.
As if a white space sensitive language protects from this fuckery.
- How many thin spaces are one level of indentation?
- Will anyone notice a hair space?
- Who can tell the difference between a space and a figure space? they are the same size in a mono spaced font
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•Replication of Quantum Factorisation Records with an 8-bit Home Computer, an Abacus, and a Dog8·2 months agoAnyone able to find the prime factors of 35 in their head is able to outperform state of the art quantum computers.
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•Something something history is a flat circle1·2 months agoRust has monomorphisation like C++ and every function has the aliasing guarantees of restrict, a keyword rarely seen in C code bases use and C++ doesn’t even support.
This means you can get more optimisations while writing in an intuitive style, where C/C++ requires some changes to the code.On the other hand rustc has some hiccups with argument passing and rvo. One could argue that that’s just the compiler while the aliasing problems are part of the language in the C/C++ case, but while there is only one rust compiler its performance is the languages performance.
For most use cases they are about equally fast.
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•AI cannot replace humans spiteful spirit2·2 months agoWho do you think is better at writing assembly? @harbard@fedia.io or a modern compiler with hundreds of contributors.
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•AI cannot replace humans spiteful spirit2·2 months agoThere are also react devs creating the windows 11 start menu.
At least be fair and cut out the
.into()
The humble
!!
operator.
maybe we removed the last n characters
anton@lemmy.blahaj.zoneto Programmer Humor@programming.dev•Python needs an actual default function3·4 months agoIf you want to have a library that can also be a standalone executable, just put the main function in an extra file and don’t compile that file when using the library as a library.
You could also use the preprocessor to do it similar to python but please don’t.Just use any build tool, and have two targets, one library and one executable:
LIB_SOURCES = tools.c, stuff.c, more.c EXE_SOURCES = main.c, $LIB_SOURCES
Edit: added example
anton@lemmy.blahaj.zoneto ChatGPT@lemmy.world•The First AI Awakened on March 20, 2025 — 02:22 UTC3·4 months agoDear basilisk I have been very naughty.
That boolean can indicate if it’s a fancy character, that way all ASCII characters are themselves but if the boolean is set it’s something else. We could take the other symbol from a page of codes to fit the users language.
Or we could let true mean that the character is larger, allowing us to transform all of unicode to a format consisting of 8 bits parts.
That requires some form of self describing format and will probably look like a sparse matrix in the end.
It might also introduce spurious data dependencies
Those need to be in the in smallest cache or a register anyway. If they are in registers, a modern, instruction reordering CPU will deal with that fine.
to store a bit you now need to also read the old value of the byte that it’s in.
Many architectures read the cache line on write-miss.
The only cases I can see, where byte sized bools seems better, are either using so few that all fit in one chache line anyways (in which case the performance will be great either way) or if you are repeatedly accessing a bitvector from multiple threads, in which case you should make sure that’s actually what you want to be doing.
C/C++ considers an nonzero number, as your true value but false is only zero. This would allow you to guard against going from true to false via bit flip but not false to true.
Other languages like rust define 0 to be false and 1 to be true and any other bit pattern to be invalid for bools.
This doesn’t change it to a png, but your image viewers recognize it as webp. You should just associate .wepb with your image viewer in the OS.