|
I find C much easier to understand than either C# or C++
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
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.
modified 19-Nov-21 21:01pm.
|
|
|
|
|
I've never translated code to another language to help understand it, but I've reformatted it as a way to study it line by line.
|
|
|
|
|
Greg Utas wrote: I've never translated code to another language to help understand it, but I've reformatted it as a way to study it line by line. This is what I do. If I don't understand the code, I have no idea how I'd translate it.
|
|
|
|
|
BryanFazekas wrote: 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.
|
|
|
|
|
Tequila tends to be more effective than port.
But, for the most part, I never use code written by others. I even try to avoid third-party DLLs.
Having said that... when I was trying to understand the spec for TELNET, having some working code available was quite valuable. But, understanding the code wasn't really the goal.
modified 6-Jul-21 12:25pm.
|
|
|
|
|
honey the codewitch wrote: How do you understand cryptic code?
Very slowly, with many iterations of thinking it through, interspersed with head scratching, coffee, and experiments to see if I can mentally 'reconstruct' it.
honey the codewitch wrote: It's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it.
Wow, that's an interesting way but I can see why it would work.
The only thing for me would be going from C# to C++. Memory management in C++ requires a lot more conscious design thought in C++ than it does in C#, I think.
modified 6-Jul-21 16:21pm.
|
|
|
|
|
It does but I have some patterns in how I craft the C# code that help it along. not "unsafe" or anything but using arrays instead of lists, and that sort of thing.
Real programmers use butterflies
|
|
|
|
|
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!
|
|
|
|
|
honey the codewitch wrote: Do you do this?
Rewrite.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I usually can't understand it enough to rewrite it without porting it first, but that's me.
Real programmers use butterflies
|
|
|
|
|
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...
|
|
|
|
|
11917640 Member wrote: template template parameters + traits + 10-20 crazy Boost base classes
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.
Real programmers use butterflies
|
|
|
|
|
Quote: it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. I try to port it to C code.
I'm doing a lot of this kind of work, with assembly-like C code.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
honey the codewitch wrote: I'm porting it to C# before backporting it to C++
That's an interesting way of addressing the understanding issue... I still think it is easier to port direct to C++, since C is probably closer to C++ than C#, but then, I do not speak C# much-
|
|
|
|
|
I just wish to understand how C is more cryptic than C++?
|
|
|
|
|
I never said it was.
Real programmers use butterflies
|
|
|
|
|
No, you didn't, it just seemed that way to me. I wouldn't even bother with C# in between, but that's a personal opinion, still trying to understand the logic though.
|
|
|
|
|
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!
Real programmers use butterflies
|
|
|
|
|
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.
|
|
|
|
|
Yeah. I'm not trying to imply it's a particular language that's cryptic. It's all a matter of the code.
Real programmers use butterflies
|
|
|
|
|
UnchainedZA wrote: It's just a completely different environment.
That's exactly why I do it.
Real programmers use butterflies
|
|
|
|
|
in my head i port c# to c++ and then to c, so i can really understand
|
|
|
|