yyrkoon

More C versus C++

36 posts in this topic

Here's some more C++ magic which seems applicable to embedded programming.

I think he optimized for speed instead of space (using tons of mov instead of a loop to initialize sprite bitmaps). But a lot of impressive optimization by the compiler.

On the downside, I didn't understand half the constructs he was using. I guess I need to relearn C++ :huh:

via embedded.fm podcast

L.R.A and yyrkoon like this

Share this post


Link to post
Share on other sites
On 3/12/2017 at 3:23 PM, chicken said:

Here's some more C++ magic which seems applicable to embedded programming.

I think he optimized for speed instead of space (using tons of mov instead of a loop to initialize sprite bitmaps). But a lot of impressive optimization by the compiler.

On the downside, I didn't understand half the constructs he was using. I guess I need to relearn C++ :huh:

via embedded.fm podcast

Didn't know you posted, heh been super busy with the day job building a monitoring system for the company, in addition to building an update system( for our own software )from scratch . . . pretty interesting stuff, and I learned A  LOT about systemd services + timers, but without actually getting into the architecture of it all. It's a nightmare trying to visualize all this in your head.

Chicken, I've come to realize that that for myself, C is the only real way to go with embedded design. I personally find C++ good for when you need to use a lot of strings, and perhaps other various constructs, it can be ok to work with. But when you need all out performance, C will usually be the best option. Unless you're super proficient with C++, and you write all of, or at least all of the important code from scratch. Same goes for C though really. An example would be my two process application where I needed to share a file between the two halves, and I wrote my own binary file lock. Because the C std API calls were all way too slow.

 

EDIT:

Oh, and you can bet I will eventually get around to watching the video.

chicken likes this

Share this post


Link to post
Share on other sites

I don't try to convince anybody. I'm way too busy myself to unlearn bare metal C.

But I thought the video will be relevant for people that venture down the rabbit hole.

yyrkoon likes this

Share this post


Link to post
Share on other sites
15 minutes ago, chicken said:

I don't try to convince anybody. I'm way too busy myself to unlearn bare metal C.

But I thought the video will be relevant for people that venture down the rabbit hole.

Sure, I get it. Like you, I guess I am just more used to using C most of the time, but I still like many aspects of C++, as well as other languages.

It's kind of funny, I was watching a youtube video the other day before bed, and I forget the speakers name( He's pretty well known, I should remember his name, but I dont - I'm not a "fanboy" that way ), where he was explaining why C++ was what he considered the better choice for embedded software development. Then he showed a chart from the last 10-15 years. Which showed C graphing upwards, while C++ was trending downwards . . . Ah right, Dan Saks, but his contention is that C++ is better than C, and I completely disagree with that. I think every language has it's place, and for different people, that will skew one direction or another.

But there is a reason why you will never, at least within the near future, see any C++ code in the Linux kernel.

 

 

chicken likes this

Share this post


Link to post
Share on other sites
5 hours ago, veryalive said:

The Dan Saks video is brilliant!

Thank you for posting.

 

You're welcome, I suppose. Personally, I did not like the video much. Much of it was talking about BS that has nothing to do with programming, and the assumptions he posed were no where close to how I see things. It was not until the questions part of the video, that someone else even came close to why I prefer C instead of C++ most of the time . . .

Question: " What do you do when someone says C++ is far more complex than C . . ."

Dan Saks: "Uh . . . nothing . . . it's true . . ."

I also do not agree with his philosophy that "If you're arguing, you're losing". I say if you're not arguing, you're not learning. But, I suppose his idea of an argument is adversarial in nature ? No idea really . . .

EDIT:

I also found it rather pompous that he thinks he knows other people better than they know themselves. As if programmers are also people, but still do not have half a brain to think with on their own. This "Framing" garbage might be vaguely true, but anyone who took English for a few years in Grade through High school knows how to read, and make sense of what they've read. Much of what he discussed also seemed very contrived to me. Almost like he was trying to "frame" his own conversation in a way that makes himself think it's good. But the problem with all of that, is that I have a brain of my own, and the ability to use it to reason for myself. e.g. I do not need someone to tell me what something means, and I can, and will form my own opinions of things. That, and I'm no one special, in that I'm not the only one with this "magical ability"( Apparently ) to see through what I consider BS.

As far as his testing results . . .yeah, I do not believe it. But I'm far more likely to believe all that, than the other crap he was spewing.

Share this post


Link to post
Share on other sites
On 3/12/2017 at 3:23 PM, chicken said:

Here's some more C++ magic which seems applicable to embedded programming.

I think he optimized for speed instead of space (using tons of mov instead of a loop to initialize sprite bitmaps). But a lot of impressive optimization by the compiler.

On the downside, I didn't understand half the constructs he was using. I guess I need to relearn C++ :huh:

via embedded.fm podcast

Chicken, watched it, and thought it was pretty cool. So, I do not know if you read all of oPossum's, and Rickta's talks in the past about templates and the const keyword. But yeah the stuff this guys touched on that talked about those two points did not surprise me. But some of the other stuff did. But maybe the contructs you talked about not understanding were Lamba's ? My understanding which I freely admit will be very limited is that Lambda as essentially templated functions that are used on the spot they were created. Without having to flesh out all the gory class structure before hand ? Question mark at the end there because I have a vague memory of something *someone* in *some* video was talking about when explaining Lamda's, and I'm not sure my understanding of what a Lamda is would be correct.

I guess my understanding was close, but not really close enough to be factual. Basically a *Lambda* is an Anonymous function that does not have a function definition. e.g. a function that is used on the spot, and is pretty much a throw away function. Only used in one part of the code.

Share this post


Link to post
Share on other sites
1 hour ago, yyrkoon said:

Much of it was talking about BS that has nothing to do with programming, and the assumptions he posed were no where close to how I see things. It was not until the questions part of the video, that someone else even came close to why I prefer C instead of C++ most of the time . . .

Question: " What do you do when someone says C++ is far more complex than C . . ."

Dan Saks: "Uh . . . nothing . . . it's true . . ."

.

.

.

.

As far as his testing results . . .yeah, I do not believe it. But I'm far more likely to believe all that, than the other crap he was spewing.

Most of his talk was not about C++, but about how to social engineer others into adopting in a non-supportive environment. It was a religious rather than technical exposition, as many Java talks, for example, also are. 

 

As to the data, I buy it. The technical points made are that strong typing reduces run time bugs is true, under the umbrella that only certain flavours of bug are caught, but these flavours lead indirectly to bugs of kinds not caught directly. Another advantage of strong typing is that, properly used, it can let the compiler do better optimization. His test case,  a lightweight class, is probably where the advantages are greatest, but this is where, for many embedded applications, the other benefits to C++ are most available. I am not convinced that many of the 'more advanced' C++ tools and abstractions will give the same benefits, other than, with proper design, reduced debugging.With improper design (as one of the questioners put it, 'naive') there are likely to be losses. Some tools impose run time penalties that are unavoidable (often space rather than time) even with strong typing, but many of the standard tools (vector, for example) minimize this hit and save enough in other ways to be a net gain.

 

Well designed standard tools pretty much always beat implementation specific, since they are designed (usually) by a specialist whose sole point is to get the best performance (by some metric) on the specific hardware. C++ provides a LOT of these tools. There are cases where a special purpose tool is better, but these are often brittle when changes are required, and the next revision has a net loss, either in performance (time or space) or in increased debugging.

For reference, I tend to be a 'well written C is valid C++' kind of programmer, and use the C++ tools sparingly, especially in embedded work, and am NOT a C++ guru. I am, in fact, quite out of date with regards to the state of the C++ art. I still use the tools as they are appropriate, though.

 

As for the social engineering aspects of the talk, nothing new. Read Dale Carnagie for the same. It is an effective model for understanding others and working with them. Nothing that hasn't been in writing for a good century, and known much longer, though in this case there is the extra fancy four quadrant graph of belief presentation.

yyrkoon likes this

Share this post


Link to post
Share on other sites
2 hours ago, enl said:

Most of his talk was not about C++, but about how to social engineer others into adopting in a non-supportive environment. It was a religious rather than technical exposition, as many Java talks, for example, also are. 

 

As to the data, I buy it. The technical points made are that strong typing reduces run time bugs is true, under the umbrella that only certain flavours of bug are caught, but these flavours lead indirectly to bugs of kinds not caught directly. Another advantage of strong typing is that, properly used, it can let the compiler do better optimization. His test case,  a lightweight class, is probably where the advantages are greatest, but this is where, for many embedded applications, the other benefits to C++ are most available. I am not convinced that many of the 'more advanced' C++ tools and abstractions will give the same benefits, other than, with proper design, reduced debugging.With improper design (as one of the questioners put it, 'naive') there are likely to be losses. Some tools impose run time penalties that are unavoidable (often space rather than time) even with strong typing, but many of the standard tools (vector, for example) minimize this hit and save enough in other ways to be a net gain.

 

Well designed standard tools pretty much always beat implementation specific, since they are designed (usually) by a specialist whose sole point is to get the best performance (by some metric) on the specific hardware. C++ provides a LOT of these tools. There are cases where a special purpose tool is better, but these are often brittle when changes are required, and the next revision has a net loss, either in performance (time or space) or in increased debugging.

For reference, I tend to be a 'well written C is valid C++' kind of programmer, and use the C++ tools sparingly, especially in embedded work, and am NOT a C++ guru. I am, in fact, quite out of date with regards to the state of the C++ art. I still use the tools as they are appropriate, though.

 

As for the social engineering aspects of the talk, nothing new. Read Dale Carnagie for the same. It is an effective model for understanding others and working with them. Nothing that hasn't been in writing for a good century, and known much longer, though in this case there is the extra fancy four quadrant graph of belief presentation.

 

Here is what I took away from this video. Dan Saks is a wind bag, that knows nothing about programming. Someone who also envisions himself as some kind of psychologist, at which he also does a very poor job. I'll probably never watch another video with him in it, or read anythign written by him from this day forward.

My time is much too precious to me now days, to be watching videos about programming, that aren't really about programming. I mean seriously, how old is this guy that he has to worry about which language people are using ? I don't see him telling Java programmers they should be using C++. Which by the way, makes a whole hell of a lot more sense to me, than the topic of this video.

 

EDIT:

By the way, I'm not C++ guru either. For that matter, I would not say I'm a C guru, but I am the most proficient with C.

 

Share this post


Link to post
Share on other sites

I will however probably start watching more videos from Jason Turner, I like his style, and so far what I've seen. He covers stuff that is interesting to me. Which I've only watched this one video, and part of another. Thanks @chicken

Share this post


Link to post
Share on other sites

So as for Jason Turner, I like his focused talks, but am on the fence where his personal youtube videos are concerned. Pretty much as he mentioned in one of his talks. He codes too much, and it gets pretty boring. Going to start watching some of his later videos and see if it gets better.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now