Better HN
topnewbestaskshowjobs
Log inSign up

teo_zero

1,545 karma · joined Aug 14, 2022 (4y ago) · 937 submissions

Submissions

comment 1h ago · link · parent

> Having said that, I expect Type-C to any C23 code as well, but I haven't systematically tested that.

Fair enough. As long as it's not confused by literals like 1'000 and 0b0110, attributes in the form [[...]], new keywords as "constexpr", or a subscript qualified with "cost" or "static" in the parameters list.

> typedef creates an alias for an existing type, not a new type

Exactly. C is based on the concept that you can express (nearly) every type when you need it, even without giving it a name. In some cases you might need to create a new tag, but not a new type. Why your sum types are different? Why don't you handle them like their "sibling" structs, unions and enums? Forget the keyword "type", define the keyword "variant", rewrite your example like this:

  variant eval_error {
    DivByZero,
    Overflow
  };
You can typedef it, but it's not mandatory:

  typedef variant eval_error EE;
To allow recursive definition, use forward declaration as all the rest of C:

  variant expr;
  variant expr {
    Num(int value),
    Add(const variant expr *l, const variant expr *r),
    Mul(const variant expr *l, const variant expr *r),
    Div(const variant expr *l, const variant expr *r)
  };
It's more verbose but consistent with C syntax. And it allows one-shot declarations without naming a new type like:

  variant {Ok(float), Inf} atan(float);
Not saying it's better. Just more familiar.

> Anonymous types will need a stable name across interfaces,

I don't think so. If anonymous structs and unions don't have this property, why should variants? (But you might consider how C23 handles structs with the same tag!)

comment 16h ago · link · parent

I like it, but I have a couple of questions.

Why C11? We're in 2026, we should target C23 at least, with a forward look at C2y.

Why the keyword "type"? Can't the same functionality be added within a typedef statement? Is there a reason why "|" can't be recognized wherever a type is expected?

And finally, the name "Type-C"... Isn't it already closely associated with USB connectors?

comment 2d ago · link · parent

Thank you for the pointer. Apparently I was among those who misinterpreted swappiness!

The name suggests it is the willingness to use the swapping mechanism, while it is the willingness to use the swap partition (or file). The variables anon_prio and file_prio that the kernel uses internally are much clearer!

comment 2d ago · link · parent

> reading file-backed pages from files is slower than swapping from compressed ram

Which, in turn, is slower than not swapping at all. To avoid swapping unless absolutely needed, you set swappiness to 0. On the opposite side, to swap as soon as the kernel sees an opportunity, you tune swappiness to 200.

comment 3d ago · link · parent

> I want instant access to my rarely used pages > [...] > setting swappiness high enough (>100)

I can't follow your reasoning. On the one hand you want the fastest access, on the other you advocate for high swappiness.

I think you should want swappiness=0, then the swap device can be whatever: it will be hardly ever used.

comment 1w ago · link · parent

Isn't it because of the halting problem? Just like you can't ask an algorithm to determine if a routine will reach its end (because the algorithm itself may run forever), you can't have an algorithm tell if a piece of code is bug-free (because the algorithm itself may contain bugs).

So humans end up taking the final decisions and remain the bottleneck.

comment 1w ago · link · parent

TFA describes two coding alternatives: abstract, high-level, easy-to-read code that we give to the compiler to optimize, or low-level, CPU-specific, manually optimized code. A Python library is mentioned as the archetype of the first kind.

comment 1w ago · link · parent

Your reasoning could be applied word by word to the latest novel by Stephen King. I may know that it has been written by an army of mercenary ghost writers and nonetheless enjoy it and warmly recommend it to all my friends. Judge a book by its content, not by its author. Do the same for software.

comment 1w ago · link · parent

> Windows Terminal [...] It's such a good terminal emulator

I find it horrible. Slow, colors are inconsistent, resizes are not always propagated to apps...

What terminal do you use on Linux that makes you miss WT?

comment 1w ago · link · parent

1. I doubt anybody on HN has any interest in what your personal criteria are for reading blogs. Please, please, please let's stop polluting the comments with arguments about how a piece of software was made instead of about the thing itself.

2. I agree if you refer to TUIs that try to emulate/substitute complex GUIs, with sub-panes, dialogs, graphics, etc. I happen to love TUIs for simple text-only visualizations, though. They are usually quicker than GUIs and consistent among various OS, desktop...

comment 1w ago · link · parent

And while we're at it, a better TERM variable, not the "user-agent header" of terminals that it is now.

To be more precise, TERM contains a single name, a key to index terminfo, a database of all known terminals and their capabilities. It assumes that such database is up to date and that every app has access to it, which is not always true, especially on non-unix platforms.

However, apps have begun using the name "as is", comparing it against known strings, e.g. "xterm", which led many terminals to advertise themselves as xterm just to ensure compatibility with existing apps.

A truly meaningful substitute for TERM would be a "semantic TERM", a variable that, setting apart the name of the terminal, focuses on the capabilities it offers. Not the complete set of properties listed in terminfo (we can give most of them for granted, today), but just the subset that differentiates modern terminals, like colors, kitty's protocol, OSC133, and a few others.

comment 2w ago · link · parent

Never understood why 7 is considered difficult...

7 = ⌈ 2.2² + 2 ⌉

comment 2w ago · link · parent

> In over 50 years not a single parliamentary republic has turned authoritarian

What about Turkey? (I consider it among the parliamentary republics as it was so until 2017, when the authoritarian shift was already ongoing. In other words, the sequence has been: parliamentary, then turned authoritarian, then changed to presidential.)

comment 2w ago · link · parent

So you don't know it: you must calculate it, via an expensive strlen().

comment 2w ago · link · parent

> I can't think of a single time where you DON'T know what `count` is

A string created by strdup().

comment 3w ago · link · parent

> Import functions is done the same way [...] > May be the doc is outdated.

Same for function types? The docs still list the syntax with "->":

  & (Type) -> (RetType)

comment 3w ago · link · parent

So, new development in AI is contributed by AI more than by humans. Isn't this the exact definition of singularity?

comment 3w ago · link · parent

I think it's the opposite of & in C++, that is T! is an object, while T is a reference to an object.

comment 3w ago · link · parent

> Is it using reference passing also for primitives like integers?

That's what I assumed, but honestly I might have misunderstood the docs. This passage is not very clear:

> Copper manipulates only references to objects. Simple data types such as integers must be seen as references to stateless objects (i.e. objects that have no state in memory).

comment 3w ago · link · parent

I'd like to come up with some constructive comments, but I find everything so inconsistent and alien to me...

For example, variable declarations use the pattern <colon> <type>, as in

  var a: Int32
But literals follow the opposite syntax, as in

  a = Int32: 42
The return type of a function is introduced by : in func definitions, but by -> in imported func declarations:

  func foo(a:Int):Int
  import func bar(a:Int) -> (Int)
Other construct that I find far from my habits:

  var w, h, d = 640, 480, 2
instead of the more obvious (for me):

  var w=640, h=480, d=2
Arguments are passed by ref, not by val. Good luck with recursion!

comment 1mo ago · link · parent

You seem to reason in terms of trying at all costs to block the other players, not to maximize your gain. I agree the ultimate goal is to do better than all the others, but the tactics to get there may involve temporarily favoring other players in win-win exchanges to grow quicker, or to block a third player already far ahead, etc.

comment 1mo ago · link · parent

Nice article!

What surprises me is that the original VLC filter does not use SIMD. Sometimes I wonder why I spent my money on a "modern" CPU with a lot of new features that stay completely ignored by most software I run every day.

comment 1mo ago · link · parent

> you don't even mention the existence of Apple silicon at all?

Given the reasons she lists for not wanting Windows, I can't imagine her entering Apple's closed garden.

comment 1mo ago · link · parent

To be fair, TFA lists more reasons to avoid Windows:

> Mine include the privacy concessions during setup, the years spent waiting for Microsoft to let people put the taskbar on the side of the screen again, and the advertising.

Of course you don't have to agree on all of them, but please don't assume everyone acts only because they can't find a tutorial on the net!

comment 1mo ago · link · parent

> Cheaper, faster, smoother, quieter, wake up every day to a full "tank", less things to go wrong

I agree to everything except waking up every day to a full "tank". That's only if you have your own house. If not, you'll depend on public chargers, so you'll buy "fuel" at premium prices, possibly higher than petrol, and you'll have to move your car at the end of the recharge in the middle of the night to avoid the parking fee.

comment 1mo ago · link · parent

Doing non-trivial anything you slow down compilation, make debugging harder and increase fragility and complexity. Sometimes that's a mistake, sometimes not.

Getting rid of something because someone sometimes abuses it, is short-sighted.

comment 1mo ago · link · parent

I'm sure this research has some higher motivations behind, but I can't help foreseeing an ignobel coming soon!

comment 1mo ago · link · parent

There are a couple of constructs that you end up re-creating as soon as you need non-trivial preprocessing.

One of those is the two-stage CAT, another one is the NARG the article talks about.

__COUNTER__ is going to be added to C29, the next version of the standard, maybe there's hope for __VA_COUNT__ and __CAT__ too!

comment 1mo ago · link · parent

> unless you assume something not-strictly-portable about `(uintptr_t)p`

What's not strictly portable about it?

  padding = -(uintptr_t)p & (align - 1)
The only assumption here is that align is a power of 2, which is guaranteed if it's the result of an alignof().

comment 1mo ago · link · parent

Please be aware that pointer arithmetic is not defined on void * pointers, although many compilers allow it. You had better use char * for "data".

Also, your code is prone to overflow when you add data, used, alignment and size.

And finally, the realloc function could be reworked to do nothing if new_size is <= old_size.

12345
32