Walk-throughs are rare, but in a walk-through, the author is explaining the program to others. What would be better is a read-through, of the source code, with the author not present and no personal memory involved. That's all that will be available 5 years later, when all those programmers have forgotten this project, or maybe moved on entirely.
A variable name can't tell you *why* something is being done, which is what comments should do. And variables should be commented, in detail, when they are declared.
The nice thing about C^Hstandards is, there are so many of them...
Now I, on the other hand, wrote a quite excellent program just the other night, in a few hours, for which these margins are too narrow to fit. So download it here:
formatting link
QBASIC automatically capitalizes all keywords. Variables are traditionally either ambiguous (indexes of i, j, etc., but that's common enough anywhere) or NamedLikeThis. Indentation and sectioning is very easy to do. And comments are just a keystroke away ("'"), not even a double-slash, or that awful slash star star slash monstrosity.
Between the comments (with diagrams, no less) and flow of the algorithm, it's trivially apparent what's going on here.
I hope you don't format your code like you do your schematics. Dark, sloppy and poorly commented.
Err..
So, it's not C? It's...
Dutch C and English C and German C and some of them use braces on the side like this { stuff }
and some of them use braces up here { stuff } andsomeofthempackalltheoperatorswithnospacesanywhere
and some
use lots
of white space
I must say, it doesn't sound like *one* language to me.
Not even to mention C++. Yeech.
Tim
--
Deep Friar: a very philosophical monk.
Website: http://webpages.charter.net/dawill/tmoranwms
Actually C has been rather constant the last few years. It does help, for a C newbie like J.L, to read the original 'The C programming Language' by K&R. I still have it on the shelf..
Yes, but that is BASIC, I like the printf() and scanf() formatting option far to much to even ever consider BASIC again. Global vars ?
My schematics, the pictures I post of those, are my working pieces of paper, I solder thing together on those, as all the resin spots clearly show. They are exquisite as between the lines they carry the deeper understanding that lacks in the drawing program generated collection of crap lines that you so much seem to like. For those who have problems understanding my schematics, means they have limited understanding of how processes in my mind materialise, have not learned to read between the lines, and are doomed to copying blurbs from electronic publications that are full of errors and design errors too. I am sorry for you, but, maybe over time you will learn.
So how many languages do you speak and can write other then unglish?
I have it, I read it when it was new. My reaction, then and now, is that it's a language ideal for use by geniuses for very quickly hacking clever tricky stuff, and it's going to kill people.
consider BASIC again.
PRINT USING makes printf() look barbaric, which it is. BASIC is just not well suited to deep embedded systems.
Jan Panteltje expounded in news:ic1mtb$m6f$ snipped-for-privacy@news.albasani.net:
..
This is of course a "software religious" thing. I've been doing C for most of my career, and certainly it has it's place in this world.
But since the advent of GNAT (free Ada compiler) in the '90s, I've jumped ship to Ada for my open sourced projects. I even use Ada on my AVR projects now (see:
formatting link
Ada is an order of magnitude more beautiful than C and is an order of magnitude better for development of large projects.
In these days of multi-processing, Ada is much better at managing thread (task) related processing because it has language features for managing tasks. In other languages, the programmer must carefully articulate calls to thread primitives. And this is the worst place to make an error, usually resulting in a very unhappy and lengthy debugging phase of intermittant errors.
Most importantly, Ada doesn't need reformatting in order to be read. It can be pre-processed (using gnatprep), but this is non- standard. The Ada standard language doesn't hide behind a macro expansion like cpp. This also aids in readbility.
But Ada is sufficiently different as a high level language, that it takes discipline and experience to use if effectively. Many ppl are unwilling to go that extra mile. So C/C++ remains popular on embedded platforms.
IIRC the main "problem" with them was just the images were very low contrast and so hard to read on-screen. Nevertheless they were nice to see, thanks for posting them (I remember using gimp to enhance them a bit).
If you could just press a bit harder with your pencil, or photograph in brighter light, that might help! :)
In C, those formatting styles aren't part of the language spec, so understandably different people have chosen different one.
There are "pretty printers" that can modify the style from one type to another, to a certain extent. Not perfect -- kinda like machine translation of spoken languages -- but some people like it.
Personally I don't really worry about how other people style their code so long as it works; I can generally read any of them. If I'm forced to start having to debug/re-write it, though, then it'll start slowly morphing into *my own* style... :-)
Sure it is -- the compiler is just as happy with any of those styles!
Some languages do care somewhat more about formatting... FORTRAN and Python come to mind...
C++ is actually a pretty clean extension to C given what Stroustrup and friends set out to accomplish. Go look at Matlab if you want to see a somewhat uglier (but still rather impressive, given what they had to work with) implemention of objective-oriented paradigms on top of an existing procedural-type language!
There's nothing wrong with that when it works. But most of these Basics are interpreters, which will be pig-slow (especially on a PIC!) so limited in applications. And interpreters discourage commenting. A good embedded program should have a lot more comments than code.
There are situations where PowerBasic running under romdos or some such could do a perfectly good embedded system, but it would have to run on an x86 board of some sort.
Remember the Boy Scouts "Order of Siam" at your first camp out:
Oh Wha Tay Gu Siam ;-) ...Jim Thompson
-- | James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at
formatting link
| 1962 |
I'll have you know that I have never once referred to anyone here as being a member of the ignorant, hateful, ugly, mooching class.
I have always been kind, referring to them by their own chosen name... Democrats O:-)
Face it: most programmers are somewhere out on the autism spectrum. So they love puzzles and don't have the empathy to imagine someone else trying to read their code. That's why C programmers tend to not comment, and why they can get A's on "computer science" class exercizes where they don't comment at all, not a single line.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.