Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Arias95496yI remember having to do that for a school assignment, but never got the hang of x86 asm
-
I'm kind of jealous. I know a bit of assembly but it's one of those things I wish I would have invested more time into.
-
LuxARTS16636y@gnulinuxer4fun Why? If you need to share your code or modify an old one you have to spent time analyzing the code. That's a waste of time. With comments (good comments) that time is spent in the job. Also, commenting the code will make the documentation process easier and faster (see Doxygen).
-
LuxARTS16636y@Haxk20 I use asm for ARM devices and it's not too difficult. X86 it's harder for me.
-
@LuxARTS
You know - function names should be enough to read the code. Whats best, in your opinion?
a)
void doStuff () { //calculates the sum of pressed keys
aaa (); //initialize
bbb (); //make sure input is correct
ccc (); //calculate
}
b)
void calculateSumOfKeysPressed () { //calculates the sum of pressed keys
initialize (); //initialize
checkInput (); //make sure input is correct
sumUp (); //calculate
}
c)
void calculateSumOfKeysPressed () {
initialize ();
checkInput ();
sumUp ();
}
I'd argue that c is the best, because its quickly skimmed through and very expressive -
@gnulinuxer4fun yep, because all functions consist of other function calls... Stop being a purist ahole, comments help.
-
@beegC0de ZE INTERNET and a lot of watching compiler output and many nice internet friends
-
@aviophile Well what if... you put everything inside a function? If you have the need to comment, it means that you code uncleanly - or (in rare occasions) it means that something is really hard to get... in THIS case, you may put in a comment
-
LuxARTS16636y@gnulinuxer4fun of course the option C is the best but that's because you wrote the function names. Comments are notes to understand the algorithms blocks inside the functions. Plus, commenting inline it's for short notes. Having the documentation in the code it's a lot easier to read and understand.
-
nightowl7086yIt's quite useful to know/have some experience with assembly language. I wouldn't question why you are doing it to yourself, as long as you are either enjoying it and/or gaining knowledge from it!
I always find a great sense of accomplishment from achieving even a relatively small goal in assembly language. Such as the time I wrote some code that could invoke a C routine with arguments provided in an array (like JavaScript's "apply" function method). Was used in something I wrote that attached to a process as a debugger, copied some of the stack and then executed a routine locally with the same arguments.
Didn't use it for much in the end, but was enjoyable doing weird things in code! -
@Haxk20 that's an interesting opinion. I usually prefer arm or mips. X86 is just painfully large and complicated imho. But to each their own.
-
@maushax I'm surprised I haven't yet found an internet forum / debate board dedicated to clean code.
-
@gnulinuxer4fun it's rare, generally github is more a collection of counterexamples.
-
@BinaryByter Comments are super useful in a professional environment.
A project evolves over time and has a tendency to get messy. It helps yourself but more importantly the following devs to stay clean.
I know it's a bit hard to get it before being fully immersed into a professionnal work environment but do yourself (and others) a favor and get used to it before. -
@Cultist If your time can keep the code clean, comments will mess up the code. Just comment WHY you do things, if that question isnt obvious
Bootloaders in asm ;_;
why am I doing this to myself?
rant