Readit News logoReadit News
1ris commented on Qsort.h – Quicksort as a C macro (2019)   github.com/svpv/qsort... · Posted by u/olitech
WalterBright · 3 years ago
The C preprocessor was an easy and compact way to extend C back when memory was really really tight. You can't even fit a C++98 compiler into DOS's memory space, but you can fit a C compiler in 64K. (Well, an earlier version of C.)

C has been adding generics anyway, like _Generic.

1ris · 3 years ago
>C has been adding generics anyway, like _Generic.

"_Generic" added function overloads to c, not generics. The naming is exceptionally poor.

The submission is an example of generic programming. It an implementatin of something that works on all types that fullfill certain constrains. In this case comparable and swapable. "All types" include user defined types.

"_Generic" does something completely different. The C++ equvivalent would be std::conditional_v<std::is_same<T, int>, myIntFunc, std::conditional<std::is_same<T, double>, myDoubleFunc ............ The exact opposite of a generic, I'd argue, as myIntFunc and myDoubleFunc do depend on the type. You might use the preprocessor to create these functions that differ only in type, but then again, you might do what OP did.

1ris commented on C was not created as an abstract machine   utcc.utoronto.ca/~cks/spa... · Posted by u/pabs3
jb1991 · 3 years ago
The strict aliasing rule that you point out is not part of the “just memory” part, but rather the “syntax sugar” part. Now you can debate if it’s the right kind of sugar, however.
1ris · 3 years ago
No, The strict aliasing part of the semantic of the memory. “syntax sugar” is, per definition, part of the syntax.
1ris commented on C was not created as an abstract machine   utcc.utoronto.ca/~cks/spa... · Posted by u/pabs3
jb1991 · 3 years ago
Wise man once said: "C is just memory, with syntax sugar."
1ris · 3 years ago
for a definiton of "just memory" that includes the strict aliasing rule. Certainly not a buffer of bytes, what most people would assume when they hear "just memory".
1ris commented on Rust vs. C++ Formatting   brevzin.github.io/c++/202... · Posted by u/vitaut
kevin_thibedeau · 3 years ago
> Can you get a type of a argument in C?

You can get it indirectly using _Generic().

1ris · 3 years ago
Sorry my bad. Yes, it works for proper function arguments. Does this work for variadic arguments? Parent seems to suggest, but i'm not aware of any mechanism for this.
1ris commented on Rust vs. C++ Formatting   brevzin.github.io/c++/202... · Posted by u/vitaut
asguy · 3 years ago
> If you don't care about the limits of the tech you won't be able exceed what you think is possible.

Did you propose/implement/release something better than printf?

> I'm time and time again amused how anti intellectual and outright hostile to technological progress the programming profession is. programmers, out of all of them.

Perfect is the enemy of good. Some people talk about getting work done, some people get the actual work done and move on.

1ris · 3 years ago
>Did you propose/implement/release something better than printf?

This is what the article is about? Things much better that printf are a dime a dozed and available since 20 years.

>Some people talk about getting work done,

Like this article does? While you busy arguing that you could do the same thing, but much worse?

1ris commented on Rust vs. C++ Formatting   brevzin.github.io/c++/202... · Posted by u/vitaut
tialaramex · 3 years ago
C++ did have variadic functions because it inherited them from C.

What it didn't inherit from C was a way to write variadic functions with variadic types, so that had to be home grown.

1ris · 3 years ago
Do you mean this feature [0]? I'm not aware of any differences in c and c++ about this. Can you get a type of a argument in C? How? At compile time, or at runtime? Both sound very un-C-like to me. cppreference is usually excellent documentation but it doesn't mention something like this.

I don't considers this to be "proper" variadic arguments, because a functions argument has to have a type. and these, as far as I'm aware of don't have one. This is about a powerfull as passing a void**. This is essentially memcopying multiple differently typed into a char* buffer and then passing that buffer. You can than correctly copies them back you have pretty much the same behaviour. Both methodss obviously lacks important aspects of the language abstraction of a function parameter and i don't what that feature can bring to the table that the previous techniques don't.

[0] https://en.cppreference.com/w/cpp/utility/variadic

1ris commented on Rust vs. C++ Formatting   brevzin.github.io/c++/202... · Posted by u/vitaut
Kranar · 3 years ago
Boost had a type-safe printf function dating back to October 10th, 2002:

https://www.boost.org/doc/libs/1_31_0/libs/format/

1ris · 3 years ago
And outstreams where not that bad, aswell. Sure, the operator overloading looks a bit rough. But that's IMHO a pragmatic choice if you want to offer customisation points and didn't have variadic functions yet. They where introduced only in c++11.
1ris commented on Rust vs. C++ Formatting   brevzin.github.io/c++/202... · Posted by u/vitaut
asguy · 3 years ago
It always had printf: https://cplusplus.com/reference/cstdio/printf/

Edit: It's almost like the whole world got a lot of work done with the tools they already had.

1ris · 3 years ago
printf is a bad joke of a formatting function.

When i want to print a string i don't want to worry about the security implications of that. With printf i have to. [0]

And i certainly don't want a turing complete contraption. [1] Also looking at log4j.

And even if everything is correct, it's has to parse a string at runtime. I consider that alone unaesthetic.

>Edit: It's almost like the whole world got a lot of work done with the tools they already had.

The best metaphor i know for this attitude is "stacking chairs to reach to moon". If you don't care about the limits of the tech you will be stuck within it.

I'm time and time again amused how anti intellectual and outright hostile to technological progress the programming profession is. programmers, out of all of them.

[0] https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=printf

[1] https://news.ycombinator.com/item?id=25691598

1ris commented on Heat pumps of the 1800s are becoming the technology of the future   knowablemagazine.org/arti... · Posted by u/adrian_mrd
nickpeterson · 3 years ago
Why can’t my whole home participate in this technology? It would seem an ok fit for things like freezers, refrigerators, hot water heaters, etc.

When it’s freezing cold outside, it seems crazy that I warm the air of my house and then use electricity to keep the fridge cooler than the air I just heated.

Someone needs to make a standard for moving heat/cool through all appliances in a house…

1ris · 3 years ago
I think you are looking for (one specific implementation of) Cold district heating.

It can be implemented as a single line of force water flow with 20-25 Celsius. It is viable as both a heat source and a heat sink at the same time.

This thing can be connected to both your coolers and heaters, and thus transfere heat from one to another. Maybe you could even get you desktop computer into the loop.

Usually it implemented on a lager scale, but i don't see why this would work scaled down.

1ris commented on Na-S Battery: Low-cost with four times the capacity of lithium   sydney.edu.au/news-opinio... · Posted by u/giuliomagnifico
willnonya · 3 years ago
Both of those can be bad at once you know...

A lithium mine is much more devastating to the environment than an oil well or franking. That doesn't mean either of these are really good options despite what either side wants to pretend.

1ris · 3 years ago
Both can be bad, and both are bad.

But it looks like a lot of people assume they are just as bad without any quantitate or qualitative assessment.

Lithium mining is way less bad than oil extraction in both dimensions. If that lithium can offset oil consumption it looks particular good.

u/1ris

KarmaCake day2242February 24, 2014View Original