News for hackers. Stuff that matters.

torrent

Seems to be a similiar problem field as writing blocking functions that call async functions in C# and co-existence of synchronous and asynchronous code.

There are numerous recommendations such as

https://learn.microsoft.com/en-us/archive/msdn-magazine/2015...

Final phase is "I hope these techniques will help you adopt async into your existing applications in a way that works best for you."

Sad perspective for C programmers who need to wait 10+ years until they get half-backen versions of some useful C++ features.
Re:Can C++ be 10x Simpler and Safer? on Saturday November 12, 2022 @06:25PM (#33578265)
> why people literally do not and cannot get it right 100% of the time. Thinking so is pure hubris.

Sure we all don't get it right 100% on the first write. For this reason we test and iterate. Equally you could say that it is pure hubris that a language will enable you to make your code right 100% of the time.

You mean the vector::operator[] is an example of fast-and-potentially-UB ? I don't see any UB if the constraints are met (keeping the index within valid range).

If they are not willing in a specific case they for sure had specific reasons not to be.

Re:Can C++ be 10x Simpler and Safer? on Saturday November 12, 2022 @05:48PM (#33577950)
I think it would be more constructive to propose a constrained subset, get rid of legacy, propose default behaviours for parts that are undefined and so on. Stuff that does not belong to this subset can still be used within an unconstrained clause.

If I read e.g. "Why build Carbon?" on https://github.com/carbon-language/carbon-lang I dont find any concrete reasons or proves that show why C++ should be abandoned for something completely new but somehow very similar. There are so many question around the actual language definition like who maintains it, how is the standardization process. Who will adapt to it or to something else. ... This seems all so utopic.

I have been using C++ for many years with fantastic success. It allows me to create all I want/need from embedded to high performance projects. That you may shot you in the foot is in fact not bad. It compels you to be careful and think deeply about the design and only use what you completely understand.

With other languages your program might not crash but probably will do wrong things like eat up memory or access still references outdated data. You will find error much later in the process when it costs multiple magnitudes more.

Re:Can C++ be 10x Simpler and Safer? on Saturday November 12, 2022 @05:21PM (#33577749)
Syntax is mostly a matter of taste. Preference of taste and style changes with time and trends. Why should "name : type" ee preferred to "type name"? Just because others do it? Why and this unnecessary, additional ':'?

> C++ has this issue of every few years looking entirely different So what. The style you have been using does the job then just keep it. There is no obligation switch to use new stuff. You should stick with that what proved to be successful.

Re:Can C++ be 10x Simpler and Safer? on Saturday November 12, 2022 @05:11PM (#33577656)
> I mean, the almost-simplest abstraction possible the std::vector has potential UB right in its [] operator.

It's your responsibility to pass the allowed range of value to a function. It a function description tells you to e.g. pass only non-null pointers or only even integers then it's your fault if you don't do it. Inside the function there may me asserts but there is no need to such checks in general.

There's just sooooo much that you have to get 100% right as a programmer > It's simply the job of the programmer to get it 100% right. No language can do this job for you.

Re:Rust Weird Expressions on Tuesday May 18, 2021 @04:57PM (#27201001)
having segfault is the best you can have: it tells you explicitly that something is wrong with your program. in other languages the same kind of error may result in stale data and the GC does not collect the data and the memory consumption grows slowly. You will notice the problem much later.

Np language can solve the inability of writing a correct program. Do you believe if your Rust program compiles it is free of errors??

Re:Rust Weird Expressions on Tuesday May 18, 2021 @04:50PM (#27200895)
After your battle with the compiler is over and it compiles it does not mean your program is correct! If you now what you you have no issues with C++. It's not the language. It's the design, approach and attitude
Re:Modern C++ Won't Save Us (2019) on Monday April 26, 2021 @11:45AM (#26943790)
The typical, well known blog pattern for writing against C++: Show some buggy code an then conclude that C++ is wrong. Instead of asking: Who is wrong, the programmer trying to speak the language or the language itself? As always: Only use what you understand how it works. Instead of directly escalating it to cardinal questions of language superiority he had better used his time constructively and wrote a tutorial on how to correctly use things like string_view and span, that are a typed reference to memory that exceed the live time of the string_view.
Re:Ask HN: A good C++ multi-dimensional array library? on Saturday October 26, 2013 @07:15PM (#6619848)
Hateing the idea of array of arraya is like hating recursivity.
Re:Ask HN: A good C++ multi-dimensional array library? on Wednesday October 23, 2013 @03:10PM (#6600941)
I dont know which operations you are going to do with the arrays but what about just use a array of arrays or matrices of matrices of matrices of...?