HackerTrans
TopNewTrendsCommentsPastAskShowJobs

6equj5

no profile record

Submissions

Show HN: Generic dynamic array in almost 2k lines of C

github.com
1 points·by 6equj5·3 lata temu·0 comments

comments

6equj5
·2 lata temu·discuss
> 229 If a builder builds a house for someone, and does not construct it properly, and the house which he built falls and kills its owner, then that builder shall be put to death.

http://faculty.collin.edu/mbailey/hammurabi%27s%20laws.htm
6equj5
·2 lata temu·discuss
And you're not opposed to try-catch boilerplate?
6equj5
·2 lata temu·discuss
> And yet, most of the time when somebody even realises they shouldn't write codecs (and file compression and various other similar technologies) in C++ their next guess is Rust which while obviously an improvement over C++ is hardly a good choice for this work either.

Not C++ nor Rust?! What then, tia? C? Ada??
6equj5
·4 lata temu·discuss
To me, the point of it is just to be more explicit and ease maintenance, like `typedef int meters_t`, but more extensible. Compare `int foo_len` to `meters_t foo_len`.

Explicitness: Consider the ambiguousness of `int foo_len` when you're swapping between meters and feet (but use `int` for both).

Ease maintenance: If you want to change the type you use to represent meters (say from `int` to `size_t`, since it might be wise to make it unsigned), compare going through the code and changing each meter-related instance of `int` vs. just changing the `meters_t` struct declaration.

More extensible: Compared to `typedef int meters_t`, using a struct is useful if you ever have to add to the struct. (Maybe a second numeric member representing the conversion to some other unit of length or something.)

For "meters", this doesn't really apply, but using a struct also prevents you from accidentally trying to do math with numeric types that you shouldn't do math with (like ID numbers or something): https://stackoverflow.com/a/18876104/9959012

Also, you probably shouldn't use `_t` at the end since that should be reserved by the C standard and by POSIX: https://stackoverflow.com/a/231807/9959012
6equj5
·4 lata temu·discuss
Even John Carmack thinks "writing good code" is impossible: https://youtu.be/I845O57ZSy4?t=1351 ; p
6equj5
·4 lata temu·discuss
I can second Effective Modern C++: https://www.oreilly.com/library/view/effective-modern-c/9781...

The most amazing thing about it is how it manages to be so entertaining to read (the last thing I expected from a C++ textbook and a thing that made getting through it way easier)!

>I'm not sure if there's an even more recent edition that covers C++17 and C++20

Sadly, there is not. Scott for-the-most-part retired in 2015: https://scottmeyers.blogspot.com/2015/12/good-to-go.html
6equj5
·4 lata temu·discuss
Check out this one: https://en.wikipedia.org/wiki/Valonia_ventricosa
6equj5
·4 lata temu·discuss
>A thought has been lately put forward, which may or may not have truth in it. What if — instead of Jupiter being a world, inhabited by animals and people, as is often supposed, with a small distant sun and five dim moons to give them light — what if Jupiter is himself in some sort a second sun to his moons, and what if those "moons" are really inhabited planets? It may be so. That is all we can say. The idea is not an impossible one. (p. 207)

And that's still all we can say about at least one of them[0]. :)

0: https://en.wikipedia.org/wiki/Europa_(moon)#Habitability_pot...
6equj5
·4 lata temu·discuss
Hopefully playing games on every platform that supports a browser[0].

0: https://wasm.continuation-labs.com/d3demo/
6equj5
·4 lata temu·discuss
Firefox, µBlock Origin, and NoScript: the holy trinity. ;p
6equj5
·4 lata temu·discuss
>anti-fingerprinting options that can be enabled through `about:config`

For reference: `privacy.resistFingerprinting`
6equj5
·4 lata temu·discuss
>I don't know how this would look

Probably something like KDE's clipboard? ; p

https://i.imgur.com/zXTLzoO.png
6equj5
·5 lat temu·discuss
About 2 years for me, and it already feels like: https://youtu.be/tXLVXtAI46o?t=5

The big green guy is the new Logitech software suite that I need to use to set the sidetone on my new headset, which asks you at install time whether you want to enable telemetry yet doesn't actually let you proceed until "yes" is checked, and which is completely redundant to yet distinct from the old suite (which new versions of the same headset model don't work with) and works less well. The other aliens are update pop-ups.