August 30, 2022

On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:

>

C++ is meant as an advancement of C. And it's used as one. Dmd was written in C++ until version 2.069, and countless other programs, both open and closed source still use it. It makes sense - it's a superset of C (well, almost), so one can always fall back to C features when the more complex features of C++ don't justify themselves.

I think there is a large group of programmers who are looking for a successor to C. C is attractive for several reasons. The limited set of features is a benefit sometimes, because you don't overthink your design and many libraries in C can interoperate with each other easily (compare with D where you have to reason OOP vs more functional style, @nogc vs GC or even betterC). Code completion will almost always work because there are no templates to get in your way (macros can be messy though). The ABI is well defined, so you can easily interact with your code from other languages. The WASM story is developing well too.

However, C is showing it's age. Manual memory management without any help from runtime/static analysis is passé. Lack of function and operator overloading is annoying. Arrays which decay to pointers and arrays that don't remember their length eat countless manhours trying to debug those issues.

Out of the newcoming languages, Zig is trying to fit that niche the most. I can't get over the syntax, but I'd really like to try it someday, when it reaches 1.0 version.

August 31, 2022
On 31/08/2022 8:02 AM, JN wrote:
> However, C is showing it's age.

Nah, C was never state of the art.

C was a bad language in the 1970's and its still a bad language today.

It did not succeed due to its feature set, but its syntax.

Other languages like ML existed within a few years of C which have significantly more powerful features (as in, D still can't match it for some things)!
August 30, 2022

On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:

>

C++ is meant as an advancement of C. And it's used as one. Dmd was written in C++ until version 2.069, and countless other programs, both open and closed source still use it. It makes sense - it's a superset of C (well, almost), so one can always fall back to C features when the more complex features of C++ don't justify themselves.

Yet, many of the most well-known and successful programmers don't see it like that. Can it be that C++ is so complex that even conservative use of it makes your codebase so unreadable that even the archaic C is a better choice? Think how crazy this is - the cream of of our profession resort to pointer / length pairs over std::vector, and copy-pasting the module name to every public declaration over using namespaces.

There has to be HUGE downsides in C++ for this competent people to resort to this drastic avoidance. They do say what the downsides of C++ are about: too big a language to learn well, so code ends up using features the reader does not know. Still, if this is the case one would think it had been long since generally aknowledged: C++ guidebooks would tell to avoid less-known language features absent strong reasons, and later languages ought to have more pressure to be more minimalist like Go and less "CISC" like D or Rust. Yet, complex D features like ranges (okay, more of a Phobos feature), operator overloading, CTFE, objects and templates don't seem to be commonly hated.

This inconsistency in our attitude towards language complexity is interesting in my opinion. I want to hear your opinions, would you rather use C or C++ in your job if you had to pick one ("it depends"-answers okay). But most importantly, why? What do you make of that C++ complexity seems to be so appreciated and so at contempt at the same time?

C and C++ is very complicated, I recently had to choose between C and C++, but I ended up choosing D instead. the reasons why are.

  1. to many baskets not enough eggs.
  2. Community designed complexity.
  • To many baskets not enough eggs
    C was designed to be a systems level programming language, it became a general purpose language because of community and industry effort, C++ was not designed to be anything it is an extension on C it was designed to be C plus extra features, as C++ became designed they want there cake and to eat it to, meaning that they want every good feature from many other popular languages like Haskell, or Python or whatever, however the difference between what D has done and C++ is doing that D was for the most part designed to Read fast Write fast and Run Fast, its on the home page, C++ is designed to be fast, and every other feature that C++ tries to add is just a bonus if they can even get it to work, for example I cant image C++ with a GC, however they talk about adding usability features, and it sure sounds like that would be a feature that would help their target audience, the designers talk about adding features to help scientists but its just talk unless they actually do it, and a GC would help, but they are not willing to make sacrifices to make a general purpose language, D is a general purpose language, it sacrifices Speed when it needs to when you want to just test an idea, but you can also make it as fast as C or C++. the design has clean edges even if its very broad, while C++ is also very broad but it has very rough edges.

  • Community Designed complexity
    When I tried to learn C++ the part that made me the most confused was the community, C style code tends to be faster than C++ style code, at least by my metrics and the metrics I have seen, so I want to use C to make faster programs, but I like many of the C++ libraries and some of the nice features, however when I go to learn C++ so much code is in C++ style as a beginner I really didnt want to decipher it all, so I just wanted to use C instead but then I find out about this awesome C++ library and the cycle continues, though this issue was self inflicted, all I had to do to fix the issue was to not care about how fast my code is, but that is the whole purpose of using C and C++, typically use that your code is fast. so why use C++ for ease of use, for me it was supposed to be for speed. so again like what I mentioned above its meant to be for speed but the code people write is because its "Correct" code, because that code according to someone is easier, which tends to be slower.

the community the language design in some ways.

August 31, 2022

On Tuesday, 30 August 2022 at 20:02:44 UTC, JN wrote:

>

On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:

>

C++ is meant as an advancement of C. And it's used as one. Dmd was written in C++ until version 2.069, and countless other programs, both open and closed source still use it. It makes sense - it's a superset of C (well, almost), so one can always fall back to C features when the more complex features of C++ don't justify themselves.

I think there is a large group of programmers who are looking for a successor to C. C is attractive for several reasons. The limited set of features is a benefit sometimes, because you don't overthink your design and many libraries in C can interoperate with each other easily (compare with D where you have to reason OOP vs more functional style, @nogc vs GC or even betterC). Code completion will almost always work because there are no templates to get in your way (macros can be messy though). The ABI is well defined, so you can easily interact with your code from other languages. The WASM story is developing well too.

However, C is showing it's age. Manual memory management without any help from runtime/static analysis is passé. Lack of function and operator overloading is annoying. Arrays which decay to pointers and arrays that don't remember their length eat countless manhours trying to debug those issues.

Out of the newcoming languages, Zig is trying to fit that niche the most. I can't get over the syntax, but I'd really like to try it someday, when it reaches 1.0 version.

C was already showing its age in the mid-90's, when compared againt languages like Modula-2 (1978) or Object Pascal (1986), and in what concerns language features (except for comptime), Zig is pretty much what those languages offered.

The key question remains, will the UNIX folks and embedded hardware communities, ever adopt anything other than C?

Even on the embedded world, using C99 is considered being modern, let alone something else.

August 31, 2022
On Tuesday, 30 August 2022 at 20:17:51 UTC, rikki cattermole wrote:
>
> On 31/08/2022 8:02 AM, JN wrote:
>> However, C is showing it's age.
>
> Nah, C was never state of the art.
>
> C was a bad language in the 1970's and its still a bad language today.
>
> It did not succeed due to its feature set, but its syntax.
>
> Other languages like ML existed within a few years of C which have significantly more powerful features (as in, D still can't match it for some things)!

It succeed, because of UNIX, just like JavaScript on the browser, if the OS already offers a free compiler, which uses it for everything it is writtten on, no one is going to pay for something else.

This naturally changed when Sun decided spliting SunOS into user and developer editions was a good idea.

GNU also helped as the initial GNU manifesto required C as the main language for its UNIX cloning project (later revisions added support for C++, Java, not bothering to check the current version).

Had AT&T been allowed to sell Bell Labs research from the get go, and history might have turned out quite different for anything UNIX related, when it would be a commercial product at the same price level as VAX/VMS, System 360 and others.
August 31, 2022

On Tuesday, 30 August 2022 at 13:06:30 UTC, Ola Fosheim Grøstad wrote:

>

On Monday, 29 August 2022 at 19:15:41 UTC, Dukc wrote:

>

....

>
  • C++ does not have an OS mandated ABI, which most of the time is an advantage as you can evolve and optimize more, but not for all use cases.

....

Neither does C, what is commonly called the C ABI, is the ABI from OSes written in C.

In the OSes that happen to have been written in C++, there is a C++ ABI, e.g. ARM mbed, Nokia SymbianOS,...

September 01, 2022

On Tuesday, 30 August 2022 at 11:53:40 UTC, Atila Neves wrote:

>

On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:

I'd much rather use C++ over C. As to why C programmers don't migrate, well:

https://www.youtube.com/watch?v=D7Sd8A6_fYU

Good video, thanks. So, you think it's all psychology? Considering we have popular political movements that can't IMO be explained rationally (won't say which movements I'm thinking here), potentially so. If we can be emotions-before-reason about politics, it only makes sense we can be emotions-before-reason about our tools.

Still, I hope there are more charitable reasons. We wouldn't want to declare C choosers to be fools after all. One could be what the top comment on that video says: "It wasn't the language itself, it was the people, and how they chose to use the language, and how they chose to show everyone how smart they were by using every possible feature of the language to its largest extent possible".

September 01, 2022

On Thursday, 1 September 2022 at 09:38:48 UTC, Dukc wrote:

>

On Tuesday, 30 August 2022 at 11:53:40 UTC, Atila Neves wrote:

>

[...]

Good video, thanks. So, you think it's all psychology? Considering we have popular political movements that can't IMO be explained rationally (won't say which movements I'm thinking here), potentially so. If we can be emotions-before-reason about politics, it only makes sense we can be emotions-before-reason about our tools.

[...]

Psychology does play a big role, consider that many won't touch anything past C89 + compiler extensions, and C23 has just been finalized.

September 01, 2022

On Thursday, 1 September 2022 at 11:41:08 UTC, Paulo Pinto wrote:

>

Psychology does play a big role, consider that many won't touch anything past C89 + compiler extensions, and C23 has just been finalized.

Lol, I'm stretching my imagination on what could be their reasons for that. Is not having to write int at the beginning of a function so addictive?

September 08, 2022

On Thursday, 1 September 2022 at 09:38:48 UTC, Dukc wrote:

>

On Tuesday, 30 August 2022 at 11:53:40 UTC, Atila Neves wrote:

>

On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:

I'd much rather use C++ over C. As to why C programmers don't migrate, well:

https://www.youtube.com/watch?v=D7Sd8A6_fYU

Good video, thanks. So, you think it's all psychology?

Yes, because it definitely has nothing to do with tech.

>

Considering we have popular political movements that can't IMO be explained rationally (won't say which movements I'm thinking here), potentially so. If we can be emotions-before-reason about politics, it only makes sense we can be emotions-before-reason about our tools.

It's the same thing, it's politics all the way down.

>

Still, I hope there are more charitable reasons.

Sadly, probably not.

>

We wouldn't want to declare C choosers to be fools after all.

There are reasons to choose C. Some of them will be used by people post-hoc explaining their choice even if it had nothing to do with it. The decision isn't rational, the explanation afterwards is the brain trying to make sense of the original decision. See: "I can't use a GC language because..."

>

One could be what the top comment on that video says: "It wasn't the language itself, it was the people, and how they chose to use the language, and how they chose to show everyone how smart they were by using every possible feature of the language to its largest extent possible".

That same person claims that "but the worst ANSI C I have encountered was easier to fix than the worst C++ I have encountered". Not in my experience. And that's part of the problem: we're all shaped by our own past experiences, and that's easy to see when looking at what different programmers prioritise. I think it's all a reaction to being burned before and avoiding that, but we've all been burned in very, very different ways.