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.
I did too - until I "got into it", then C# is a whole load easier to read (and write).
One nice thing is that it prevents "silly mistakes" whereas C just shrugs it's shoulders and goes "Eh. He knows best, I'm sure" - leaving you with a PITA debug session becuas eyou read what you meant to write instead of what you did write (or I do).
Plus, the libraries are much better organised, and it supports large projects a lot easier as well.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
I do the same thing. It's like being bilingual, when trying to read, listen or speak a second language, your mind interprets to your first language before you understand what is being communicated.
"When you are dead, you won't even know that you are dead. It's a pain only felt by others; same thing when you are stupid."
Ignorant - An individual without knowledge, but is willing to learn. Stupid - An individual without knowledge and is incapable of learning. Idiot - An individual without knowledge and allows social media to do the thinking for them.
This is what I do. If I don't understand the code, I have no idea how I'd translate it.
If you don't understand a block of code at all, you can't translate it, but translating a code section that you think you understand into another language can be a very good test of whether you really do, since it forces you to concentrate on details of the implementation that you might otherwise skip over.
My first step is almost always renaming variables to make the names sensible. If it was C code, I'd step through it in C to do so. Once the names are sensible, everything else comes easy. I've seldom dug into a codebase with good naming conventions to start with. Ungh!
Understanding an application part - what does this code do (or tries to do). Running many times on different use cases. Adding a lot of logging/trace code and learning a logs in different use cases.
Logging depends on the platform - from OutputDebugString or log file to UART-based printf on embedded device.
Trying to make some simple changes and see what happens. Running and reading a logs again.
And finally, all this doesn't help to understand 10 lines of code written by real C++ guru - template template parameters + traits + 10-20 crazy Boost base classes + SFINAE + RAII + design patters etc. Such code goes to Recycle Bin - it never works. Anyway, I will be in the Recycle Bin soon, so it doesn't matter...
Yeah. I do a lot of generic programming (GP) instead of OOP in C++ so templates are par for the course.
However, I dislike boost because of the level of abstraction. I already sideeye the STL for all the allocations it does, and I can't use it when targeting IoT because the Arduino framework doesn't make it available, probably because it can target 8 bit platforms with 8kB of RAM and 256kB of program space.
So I tend to agree. Unfortunately I find myself producing code (sans boost and often sans the STL) like that in order to get the compiler to do what I need. I wish it wasn't necessary because the code becomes so abstract it's really hard to follow.
The reason I move it between unmanaged and managed code is it forces me to restructure it. I can't just get lazy and copypasta.
In the process of restructuring it, I grok it's machinations.
Furthermore, C# has a library for pretty much everything, so no matter what I'm doing in C++, there is pretty going to be the equiv in the .NET framework that I can rely on, so I can seal it off there and I don't have to import code like say, the code to do an HTTP request from C++, if that's not directly what I'm working on. I hope what I just wrote makes sense!
Ok, thanks, my bad I don't even think of things such as .NET, it doesn't exist in my current life. If I can't find a suitable library, I have to create the functionality. It's just a completely different environment.
Besides, "cryptic" usually is a matter of who wrote it and how, not what language it happens to be in. Some of the most cryptic code I have run across was SQL written as a single line. Without parsing it, I would never have figured it out.