News for hackers. Stuff that matters.
Re:I learnt C++ in 2018 and have no regrets by seanhandley on Monday January 07, 2019 @10:29AM (#18845872)
> Within C++ is a smaller, simpler, safer language struggling to get out.” - Bjarne Stroustrup

Ah, yes. I think they called it "C".

Re:I learnt C++ in 2018 and have no regrets by wues on Monday January 07, 2019 @11:00AM (#18846221)
C compatibility was the very reason for which C++ is bigger, more complicated and less safe than a similar language not compatible with C could be.
Re:I learnt C++ in 2018 and have no regrets by Const-me on Monday January 07, 2019 @02:07PM (#18848765)
Objective C and D both have excellent C compatibility. C# has very good one. I think all 3 languages are easier to use.
Re:I learnt C++ in 2018 and have no regrets by wues on Monday January 07, 2019 @08:40PM (#18852243)
They all may have excellent C compatibility, but this is not the point. The point is that without C compatibility C++ could be smaller and simpler, and yet still meeting the same goals and covering the same use cases. Objective C has Smalltalkish object system glued to C base. Fundamental C++ techniques like RAII not possible there. D has GC. C# runs in a VM. I would not call a language with any of those features very similar to C++.

OTOH if not for C compatibility we would not have this discussion, since we would most likely never heard of C++.

Re:I learnt C++ in 2018 and have no regrets by wbl on Monday January 07, 2019 @11:57AM (#18846935)
Really? C++ accidentally has a Turing complete templating layer. I suppose one could point to Common Lisp but if you think that is simple....
Re:I learnt C++ in 2018 and have no regrets by TeMPOraL on Tuesday January 08, 2019 @02:10AM (#18853887)
Well, Common Lisp is simple. Except maybe the Metaobject Protocol (which ultimately didn't make it into standard, but it sort of still is). And except eval-when. Eval-when is magic.
Re:I learnt C++ in 2018 and have no regrets by wues on Monday January 07, 2019 @08:42PM (#18852268)
I never said that this language would be simple. Just simpler than C++ we know.
Re:I learnt C++ in 2018 and have no regrets by frutiger on Monday January 07, 2019 @10:51AM (#18846098)
I'm having some difficulty imagining that C is safer than C++.
Re:I learnt C++ in 2018 and have no regrets by kgabis on Monday January 07, 2019 @11:29AM (#18846571)
Well, it is. Every f*up you can have in C, you can also have in C++.
Re:I learnt C++ in 2018 and have no regrets by mhh__ on Monday January 07, 2019 @02:24PM (#18848970)
Only if you write unidiomatic (Read crap) C++.

In modern C++ it is very much possible to write fast and safe code, but the tradeoff is now put into the amount of stuff the developer needs to know to be productive (Which in my experience isn't as bad as people like to go on about on here/reddit, even if it still pretty shoddy)

Re:I learnt C++ in 2018 and have no regrets by smallstepforman on Monday January 07, 2019 @10:23PM (#18852849)
> Only if you write unidiomatic (Read crap) C++.

Thats a bit unfair. A recent headache for my C++ project was mixing audio buffers. The buffers are cached to avoid repeated reads, the channel count differs, the sample rate can differ, the output rate can differ, and mixing has gain limiters applied etc. Lots of buffers, lots of copying, lots of boundary cases (eg. sample #1 doesnt start until t=100ms, sample #2 ends before sample #1, etc).

I struggled for days getting all the buffer copying right (raw pointers to many interrim buffers). You may think that my problems were due to using "crap c++ in unidiomatic way". However, I challenge you to find a better, and as efficient method to accomplish the same goal. The end MixAudio() function looks like plain old C code from the early 80's, but how else can you tackle this problem in a modern way?

Re:I learnt C++ in 2018 and have no regrets by zvrba on Tuesday January 08, 2019 @02:11AM (#18853888)
> I struggled for days getting all the buffer copying right (raw pointers to many interrim buffers).

It seems like you struggled with math (indexing logic) rather than C++.

> how else can you tackle this problem in a modern way?

You could try to write an iterator that takes into account sample rate, channel count, etc. That way the logic for handling buffer formats and iteration over samples is encapsulated into a single reusable component.

Re:I learnt C++ in 2018 and have no regrets by mhh__ on Tuesday January 08, 2019 @04:32AM (#18854418)
I'm not entirely sure - only just learning audio programming atm, but the way to approach would be to encapsulate then use encapsulation and ranges/iterators.

Efficiency should be roughly the same, especially given that you can optimise loops (and other code) with just as much access.

Re:I learnt C++ in 2018 and have no regrets by Koshkin on Monday January 07, 2019 @12:50PM (#18847749)
Sure, but with C++ there's fewer reasons to do so.
Re:I learnt C++ in 2018 and have no regrets by anderspitman on Monday January 07, 2019 @04:24PM (#18850276)
Stroustrup likes to say it's harder to shoot yourself in the foot with C++, but when you do it tends to blow off the whole leg.
Re:I learnt C++ in 2018 and have no regrets by pornel on Monday January 07, 2019 @01:18PM (#18848147)
Jokes aside, I think D is it. And with the `-betterC` switch it even has replicated that C subset, but without actual legacy baggage.