Click here to Skip to main content
15,886,518 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: Years ago… Pin
Single Step Debugger9-Jan-23 5:33
Single Step Debugger9-Jan-23 5:33 
QuestionWhat are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 5:49
mvahoney the codewitch8-Jan-23 5:49 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
raddevus8-Jan-23 6:06
mvaraddevus8-Jan-23 6:06 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 6:16
mvahoney the codewitch8-Jan-23 6:16 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
raddevus8-Jan-23 6:34
mvaraddevus8-Jan-23 6:34 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 7:55
mvahoney the codewitch8-Jan-23 7:55 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
raddevus8-Jan-23 11:03
mvaraddevus8-Jan-23 11:03 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 11:59
mvahoney the codewitch8-Jan-23 11:59 
I'd argue that it's *easier* to write compact code in C than it is in C++, but I challenge anyone to come up with a realistic C construct that can't be reflected using C++isms and result in functionally the same assembly code.

One thing people forget is that types don't exist. They are like concrete molds that set your data in a form, but then that mold is tossed during compilation as it's no longer needed in the resulting code.

So as long as you know what stuff generates what ASM, you can write lean C++ code.

Now if you're relying on the STL or just being casual about it, you'll definitely see C++ as more bloated.

But there's an actual pattern to creating classes that's replicated in C all the time.

Any time you see a "handle" in fact, that's a "class pointer" except in C lingo.

Now, you'll find if you want to make lean C++ code you'll be using statics a lot - any time you don't need "handles"

You'll also probably prefer the C malloc/free paradigm to new and delete for several reasons.

But within parameters, you can write C++ code that's every bit as lean as C code. You just have to know what your compiler is going to be creating.

At the end of the day, that means C is probably the best choice for enforcing lean code. But an experienced C++ developer need not do away with many of their C++ niceties for want of RAM or even program space.

off my soapbox now. Smile | :)
To err is human. Fortune favors the monsters.

GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 12:07
mvahoney the codewitch8-Jan-23 12:07 
QuestionRe: What are some stupid-useful coding tricks you rely on? Pin
CPallini8-Jan-23 7:17
mveCPallini8-Jan-23 7:17 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
raddevus8-Jan-23 7:31
mvaraddevus8-Jan-23 7:31 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
CPallini8-Jan-23 7:48
mveCPallini8-Jan-23 7:48 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 14:55
mvahoney the codewitch8-Jan-23 14:55 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
Mircea Neacsu8-Jan-23 10:27
Mircea Neacsu8-Jan-23 10:27 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
raddevus8-Jan-23 11:08
mvaraddevus8-Jan-23 11:08 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
Mircea Neacsu8-Jan-23 11:28
Mircea Neacsu8-Jan-23 11:28 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
raddevus8-Jan-23 11:40
mvaraddevus8-Jan-23 11:40 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
Marcelo Huerta9-Jan-23 6:16
Marcelo Huerta9-Jan-23 6:16 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
jmaida8-Jan-23 15:54
jmaida8-Jan-23 15:54 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
BillWoodruff8-Jan-23 20:33
professionalBillWoodruff8-Jan-23 20:33 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
Mircea Neacsu10-Jan-23 6:34
Mircea Neacsu10-Jan-23 6:34 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
Mike Hankey8-Jan-23 7:42
mveMike Hankey8-Jan-23 7:42 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
Marc Clifton8-Jan-23 11:28
mvaMarc Clifton8-Jan-23 11:28 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 12:01
mvahoney the codewitch8-Jan-23 12:01 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
Gary R. Wheeler8-Jan-23 13:53
Gary R. Wheeler8-Jan-23 13:53 

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.