Readit News logoReadit News
Asooka commented on The Cost of a Closure in C   thephd.dev/the-cost-of-a-... · Posted by u/ingve
CerryuDu · 2 days ago
That's all there is to it. I don't understand the whole obsession with closures.

I've used lambdas extensively in modern C++. I hate them with a passion.

I've also used OCaml. An awesome language where this stuff is super natural and beautiful.

I don't understand why people want to shoehorn functional programming into C. C++ was terrible already, and is now worse for it.

> we’re going to be focusing on and looking specifically at Closures in C and C++, since this is going to be about trying to work with and – eventually – standardize something for ISO C that works for everyone.

Sigh. My heart sinks.

Asooka · 2 days ago
It does seem needlessly complex. I think a better idea is to just have a type that is a pair of pointer-sized words. That pattern crops up again and again - context pointer and function pointer, array and its size, memory allocation and effective size, etc. The problem with having both pieces in separate variables is that it is very easy to lose track of what is where. If you have it in a single bundle it is a lot simpler to use. The exact design needs a lot more consideration for sure, because I would like something simpler than writing anonymous structs everywhere (which I can already do), but at the same time flexible enough for most use cases.
Asooka commented on My favourite small hash table   corsix.org/content/my-fav... · Posted by u/speckx
nitnelave · 4 days ago
The alignment constraint is different, which they use to be able to load both as a 64-bit integer and compare to 0 (the empty slot).

You could work around that with a union or casts with explicit alignment constraints, but this is the shortest way to express that.

Asooka · 4 days ago
In that case you can use bit fields in a union:

    union slot {
        uint64_t keyvalue;
        struct {
            uint64_t key: 32;
            uint64_t value: 32;
        };
    };
Since both members of the union are effectively the exact same type, there is no issue. C99: "If the member used to access the contents of a union is not the same as the member last used to store a value, the object representation of the value that was stored is reinterpreted as an object representation of the new type". Meaning, you can initialise keyvalue and that will initialise both key and value, so writing "union slot s{0}" initialises everything to 0. One issue is that the exact layout for bit fields is implementation defined, so if you absolutely need to know where key and value are in memory, you will have to read GCC's manual (or just experiment). Another is that you cannot take the address of key or value individually, but if your code was already using uint64_t, you probably don't need to.

Edit: Note also that you can cast a pointer to slot to a pointer to uint64_t and that does not break strict aliasing rules.

Asooka commented on Perl's decline was cultural   beatworm.co.uk/blog/compu... · Posted by u/todsacerdoti
jordanb · 7 days ago
I always found the Perl "community" to be really off-putting with all the monk and wizard nonsense. Then there was the whole one-liner thing that was all about being clever and obscure. Everything about Python came off as being much more serious and normal for a young nerd who wasn't a theater kid.
Asooka · 7 days ago
I never interacted with any of that, to me Perl was always "Bash with text processing built-in and no string interpolation pitfalls". I reach for it when I need to write one to two page long utility scripts. Python is too willing to deprecate features (plus the whole 2 to 3 fiasco burned me badly), so I only use it for things I know I will maintain. Perl is for writing a shell script that will run unchanged in perpetuity.
Asooka commented on Nimony (Nim 3.0) Design Principles   nim-lang.org/araq/nimony.... · Posted by u/andsoitis
Symmetry · 9 days ago
Specifically, C comes form a world where allowing for machines that didn't use 2's compliment (or 8 bit bytes) was an active concern.
Asooka · 8 days ago
Back when those machines existed, UB meant "the precise behaviour is not specified by the standard, the specific compiler for the specific machine chooses what happens" rather than the modern "a well-formed program does not invoke UB". For what it is worth, I compile all my code with -fwrapv et. al.
Asooka commented on Constant-time support coming to LLVM: Protecting cryptographic code   blog.trailofbits.com/2025... · Posted by u/ahlCVA
frabert · 19 days ago
This has been a sore point in a lot of discussions regarding compiler optimizations and cryptographic code, how compilers and compiler engineers are sabotaging the efforts of cryptographers in making sure there are no side-channels in their code. The issue has never been the compiler, and has always been the language: there was never a way to express the right intention from within C (or most other languages, really).

This primitive we're trying to introduce is meant to make up for this shortcoming without having to introduce additional rules in the standard.

Asooka · 18 days ago
There really ought to be a subset of C that lets you write portable assembly. One where only a defined set of optimisations are allowed and required to be performed, "inline" means always inline, the "register" and "auto" keywords have their original meanings, every stack variable is allocated unless otherwise indicated, every expression has defined evaluation order, every read/write from/to an address is carried out, nothing is ever reordered, and undefined behaviour is switched to machine-specific behaviour. Currently if you need that level of control, your only option is writing it in assembly, which gets painful when you need to support multiple architectures, or want fancy features like autocomplete or structs and functions.
Asooka commented on Germany: States Pass Porn Filters for Operating Systems   heise.de/en/news/Youth-Pr... · Posted by u/trallnag
rPlayer6554 · 23 days ago
*This does not seem like a censorship measure.* It seems like it requires OSs to give parents an easy way to filter porn.

I struggle with porn addiction. When I really fall back into it I act out 5-10 times a day. I can’t stop even if I want to. It distracts from work and from my real life relationships and girlfriend.

Everyone on HN loves to rag on social media because it’s so toxic. What about porn? If social media makes it easy to compare my “boring” life with “beautiful” influencer lives, why wouldn’t porn make my normal girlfriend and normal sex seem boring. Part of that is how young I found porn when my brain was still developing and forming how it processed sex and relationships. Porn makes me feel so depressed.

I am sure other people handle porn and social media better than me. And that’s ok, I respect that. *But even if you think porn is ok as an adult, can’t you see why adults should be able to have more control over what their kids see.* Yes if they are motivated kids will find it - I learned a lot of the engineering skills I have now getting around my parents blocker. *Not every kid is that good and this might help many.* If it’s not required to be on in the OS, what’s the harm?

P.S. if you struggle with something similar to me, look up SA, SAA, or SLAA.

Asooka · 23 days ago
Reads like paid copypasta. In the unlikely case you're sincere, have you tried testosterone blockers medication? I checked out SLAA (SA and SAA yielded no results) and while learning to control yourself is nice, why should you have those urges in the first place if they are making your life miserable. I find most porn kind of boring and even icky. I would never get tired of seeing pretty women (especially naked), but porn itself is kind of meh.
Asooka commented on Germany: States Pass Porn Filters for Operating Systems   heise.de/en/news/Youth-Pr... · Posted by u/trallnag
trallnag · 23 days ago
What stops a kid from saying "I am an adult" via this header without some draconian client-side enforcement?
Asooka · 23 days ago
You add draconian client-side enforcement via parent controls. You can even mandate that stores ask for whom the device will be and provision it accordingly with the flag being automatically removed in the future when the person is of age.
Asooka commented on Germany: States Pass Porn Filters for Operating Systems   heise.de/en/news/Youth-Pr... · Posted by u/trallnag
adrian_b · 23 days ago
Every time when I see how these censorship laws are pushed, I cannot understand how it is possible that anyone of those who vote for them can believe that such laws can achieve their stated goal of "protecting the innocent children".

Actually I cannot believe that the voters, or at least most of them, are so stupid that they no longer remember what they were doing as children, so I can only assume that the real purpose of the laws is not the claimed purpose, but something much more sinister.

I am male, so I do not know about what young girls think, so perhaps they are innocent and they might be protected by censorship, but I am certain that the "innocence" of young boys cannot be protected by such laws, even if they were technically successful.

I have grown in a country occupied by communists, like Poland. There existed absolutely no pornography whatsoever. There were no erotic movies, no erotic books, no erotic magazines.

So one might have believed that the "innocence" of young children was "protected", but such a belief was terribly wrong.

Due to the lack of any other kind of entertainment, a favorite pass-time was telling jokes, many of which had a strong pornographic content. I have no idea which were the sources of the jokes, but there existed a huge number of them. Starting from the age of 10 years, it was very frequent among boys to tell such jokes or listen to them.

The content of the jokes included pretty much everything that can be seen in a pornographic movie today and any young "innocent" boy was very familiar with such content, even if most did not understand the meaning of many parts of the content, for lack of explanatory images.

Of course, no boy would admit in the presence of adults of being aware of such things, but I would have expected that someone being now adult would remember his lack of "innocence" when young and would understand how futile is to expect that "innocence" can be "protected" by technical censorship, when the only means that could ensure "innocence" would be to be locked permanently in a prison cell, to avoid contact with any other humans.

Asooka · 23 days ago
> Actually I cannot believe that the voters, or at least most of them, are so stupid

The majority of USAians voted for Trump. It would be the height of hubris to think of our average voter as noticeably smarter than one from the USA.

Asooka commented on Germany: States Pass Porn Filters for Operating Systems   heise.de/en/news/Youth-Pr... · Posted by u/trallnag
yubblegum · 23 days ago
Porn is damaging at multiple levels, specially for young adults to say nothing of "children".

+Should be clear is that exposing children to porn or normalizing porn in no way promotes "healthy economies" either.

Asooka · 23 days ago
Mass surveillance is far more damaging. Also there are several porn block solutions on offer for parents to install on their children's devices. There is absolutely zero need for the government to be regulating mass surveillance on everyone to block porn for children. We are replacing the damage caused by porn on a small handful of people who are predisposed to get addicted and got exposed to it at a young age due to bad parenting, with damaging all of society with mass surveillance, which is not even guaranteed to stop kids from seeing porn.
Asooka commented on I didn't reverse-engineer the protocol for my blood pressure monitor in 24 hours   james.belchamber.com/arti... · Posted by u/jamesbelchamber
nrhrjrjrjtntbt · a month ago
Nice, using home-brew style incomprehensible nomenclature
Asooka · a month ago
Well, things have to be named something. At least "Bottles" are related to "Wine" in a way that makes sense for a name for isolated Wine environments. It is also unique enough that Google will give you the answer quickly.

u/Asooka

KarmaCake day1733June 22, 2016View Original