Click here to Skip to main content
15,886,362 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: C++ trivia Pin
honey the codewitch30-Apr-21 6:00
mvahoney the codewitch30-Apr-21 6:00 
GeneralRe: C++ trivia Pin
Gary Wheeler30-Apr-21 2:43
Gary Wheeler30-Apr-21 2:43 
GeneralWSO CCC OTD 2021-04-29 Solution. Pin
OriginalGriff29-Apr-21 2:04
mveOriginalGriff29-Apr-21 2:04 
GeneralRe: WSO CCC OTD 2021-04-29 Solution. Pin
Greg Utas29-Apr-21 2:19
professionalGreg Utas29-Apr-21 2:19 
GeneralRe: WSO CCC OTD 2021-04-29 Solution. Pin
pkfox29-Apr-21 2:28
professionalpkfox29-Apr-21 2:28 
GeneralRe: WSO CCC OTD 2021-04-29 Solution. Pin
OriginalGriff29-Apr-21 2:29
mveOriginalGriff29-Apr-21 2:29 
GeneralRe: WSO CCC OTD 2021-04-29 Solution. Pin
Kornfeld Eliyahu Peter29-Apr-21 2:45
professionalKornfeld Eliyahu Peter29-Apr-21 2:45 
GeneralC++ and analysis paralysis Pin
honey the codewitch29-Apr-21 1:25
mvahoney the codewitch29-Apr-21 1:25 
For those of you that don't know,
C++ allows you to use templates to trade bigger code size for more speed or more flexibility.
C++ also allows you to use templates to reduce code size while maintaining flexibility.

It all depends on how you use it but it makes for some hairy design decisions.

I'll give you the scenario that gave rise to this missive:

I have a weird video frame buffer format I want to be able to back with an in memory bitmap.

I currently do that. However, the bitmap is not mapped in the same way as the frame buffer so on copy it has to massage the data into the framebuffer format.

It got me thinking, what if I could, in addition to specifying the in memory format of the bitmap in terms of its pixels, what if I could also tell it how to lay those pixels out in memory, rather than forcing it to go left to right, top to bottom?

It complicates the situation where you're blting/copying from a bitmap to one with a different in memory mapping, requiring additional code to be generated to handle that case.

...as well as the case where you're going between two bitmaps with the same mapping format at which point each mapping type needs an optimized blt/copy to go from bitmaps of the same type, for efficiency.

This creates a situation where you're potentially generating more code if you create or use a new bitmap mapping format because at some point you'll probably need to do transfers between and regular bitmaps, causing that generic code above to be generated, but also between bitmaps of the same mapping types causing the optimized mapping code for each to be put in the binary as well.

The advantage is you can create new framebuffers for weird video hardware, and treat them like normal bitmaps, at the expense of a larger binary, and of course some mapping overhead. But you can just do drawing operations over your framebuffer, and rather than adjusting the data post-draw during the copy to the video device, it makes it so that the buffer is created in the video hardware's format *during* the draw operations.

The question becomes, is it all worth it?

Does the code bloat overshadow the flexibility?

I can't tell until I implement it. I just won't know without trying it. There are too many factors to determine how it will play in the real world without building it out and throwing some scenarios at it.

Here's the thing.

With most languages, I wouldn't be stuck on design decisions like this simply for the fact that they do not exist. Most languages don't allow you to make decisions like these. You're stuck without the option in the first place, so you just have to dance with who brought ya.

And then I think, well, most languages are just fine without all these capabilities, so maybe I'm just spinning my wheels, or at least traversing rabbit holes that wouldn't even exist in say, C#

But then I also remember that C# code will not run on an ESP32 or similar, for good reason. I don't have RAM and cycles to waste.

Admittedly, most of the features I like using in C++ I don't strictly need. I use them to make my code more flexible, or tighter, or otherwise make it work exactly the way I want, but sometimes I think I'm just borrowing trouble - being overly perfectionist about it in ways that other languages don't even allow me to do.

Is it too much freedom and flexibility for my own good? And the fact that I have to keep asking myself that both sort of reinforces the idea that maybe it isn't so good, and also kind of freaks me out in terms of my political sensibilities given how ... libertine I tend to be. Why would I ask myself if this much freedom is too much? And does this say anything larger about where my head is at?

And then C++ starts giving me an existential crisis.
Real programmers use butterflies

GeneralRe: C++ and analysis paralysis Pin
CPallini29-Apr-21 1:33
mveCPallini29-Apr-21 1:33 
GeneralRe: C++ and analysis paralysis Pin
Gary R. Wheeler30-Apr-21 11:37
Gary R. Wheeler30-Apr-21 11:37 
GeneralRe: C++ and analysis paralysis Pin
honey the codewitch30-Apr-21 11:40
mvahoney the codewitch30-Apr-21 11:40 
GeneralRe: C++ and analysis paralysis Pin
Gary R. Wheeler30-Apr-21 11:45
Gary R. Wheeler30-Apr-21 11:45 
GeneralOh, now that's a good idea. Pin
OriginalGriff29-Apr-21 1:02
mveOriginalGriff29-Apr-21 1:02 
GeneralRe: Oh, now that's a good idea. Pin
W Balboos, GHB29-Apr-21 2:44
W Balboos, GHB29-Apr-21 2:44 
GeneralRe: Oh, now that's a good idea. Pin
theoldfool29-Apr-21 3:49
professionaltheoldfool29-Apr-21 3:49 
GeneralRe: Oh, now that's a good idea. Pin
W Balboos, GHB29-Apr-21 4:31
W Balboos, GHB29-Apr-21 4:31 
JokeMy French girlfriend hit me in the head with a baguette... Pin
Sander Rossel28-Apr-21 22:38
professionalSander Rossel28-Apr-21 22:38 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
OriginalGriff28-Apr-21 23:22
mveOriginalGriff28-Apr-21 23:22 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
Daniel Pfeffer28-Apr-21 23:23
professionalDaniel Pfeffer28-Apr-21 23:23 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
Rich Leyshon28-Apr-21 23:41
Rich Leyshon28-Apr-21 23:41 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
PIEBALDconsult29-Apr-21 3:19
mvePIEBALDconsult29-Apr-21 3:19 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
Rich Leyshon29-Apr-21 3:31
Rich Leyshon29-Apr-21 3:31 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
PIEBALDconsult29-Apr-21 3:44
mvePIEBALDconsult29-Apr-21 3:44 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
W Balboos, GHB29-Apr-21 2:46
W Balboos, GHB29-Apr-21 2:46 
GeneralRe: My French girlfriend hit me in the head with a baguette... Pin
W Balboos, GHB29-Apr-21 2:49
W Balboos, GHB29-Apr-21 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.