If the debuggers captured a candid shot of you coding, what quirky behavior, habit, or unusual thing would they discover?
Follow the CodeNewbie Org and #codenewbie for more discussions and online camaraderie!
If the debuggers captured a candid shot of you coding, what quirky behavior, habit, or unusual thing would they discover?
Follow the CodeNewbie Org and #codenewbie for more discussions and online camaraderie!
For further actions, you may consider blocking this person and/or reporting abuse
Kuvam Bhardwaj -
Crypto.Andy (DEV) -
Chakir Ayoub -
Shafayet Hossain -
Top comments (13)
In JS, to add +1 value I don't usually use the ++ operand, instead I use += 1...
It just feels more semantic to me, haha.
I'd be fine with both of those but I also relish in exploiting post-increment.
*dst++ = *src++
yesssWhat it does??
It's a string-copying idom in C. Full context:
It's equivalent to:
It's really not something to make a habit of but in this specific context, C string copying, it's a common idiom.
See also sjmulder.nl/2023/casey-interview-2...
Haha, I don't think I'll be learning C in this life, but I'm surprised by people who have the strength to learn it. Kudos.
Fair enough! I learnt it years ago downporting a little C++ game for practice and finding that it forced me to write simpler and more to-the-point code. Essentially: data-oriented programming. Those concepts are useful in other languages too!
Great! If you know C I would bet that you know a few other languages.
Speaking of debuggers, I like typing
debugger;
statements into JS/TS code while debugging. They cause the debugger to break much more reliably (sometimes an issue with TS), are easy to find, and they move with the code as I make changes. I can't remember ever seeing anyone else type enter adebugger;
statement into their code.Oh yes that's very useful! I do it sometimes. Usually it's easier to just click the line in the debugger but with JavaScript it can be a chore to find it in the inspector. Then adding a 'debugger;' line can be helpful.
print(100, value) .... print(200, value)
instead of using the debugger.git diff
on each file and observe the changes before committing.I feel like print statements are great for debugging, they're good at showing the order of things or changes over time.
For git, try
git add -p
. Lets you review and stage one change at a time. Or justgit diff
(for unstaged changes) orgit diff --cached
(for staged changes), then you don't need to run 10 diff commands in sequence.I use <big> and <b> tags in HTML to highlight a paragraph between other paragraphs:
India's Hindi Film Industry's one of the legendary actors Amitabh Bachchan is also known as "Big B". (However, I am not a fan of him, I just use these tags when defining a class in a CSS file is "costlier". (When such text is written only one or two times.) (I know that <big> tag is deprecated. But it is still working in web browsers, and it is never going away (from how much I know HTML and the web browsers 😄). And even if it is removed, it isn't significant and it will not produce any error, it will simply be ignored by the browsers.)
When writing C, I declare my variables at the start of the function like it's 1989. I just like that separation between storage and logic.