![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) | |
|
Quote:
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
||
|
|
|
|
|
(permalink) | |
|
Quote:
Torben |
||
|
|
|
|
|
(permalink) |
|
This is partly why I dislike C, difficult to read, susceptible to too much interpretation, and the written text becomes more effort consuming than the original reason for the code. It should solve problems and not add to it.
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
A good programmer can program well no matter the language; a bad programmer sucks just as hard in an academically "good" language as in any other. A bad programmer will, I freely admit, have more trouble with string handling and pointers in C than in languages which shield them from having to know what's really going on behind the scenes, though. I'm not sure how C is "susceptible to interpretation", anyway. The code does what it says it does. Whether that's what the programmer intended is another question. I like C for certain problems. Others demand assembly, some are solved easiest in PHP, and others just cry out for a lisp-like language. Good commenting and consistent structure are important in all. Just my $0.02 CDN. Torben |
||
|
|
|
|
|
(permalink) |
|
Torben nailed it.
I would add that the proper choice of names and their scope is often overlooked. It is very important in writing good code. And not always easy to do.
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) | |
|
Quote:
Bad code can be written in any computer language, just like bad prose can be written in any human language. Sure some languages help protect the rookies from common mistakes, but they're not always the best tool for the job at hand. I'm not going to apologize for C's shortcomings, but I'm not going to try to program a PIC in PHP, and I'm not going to try programming a web-based shopping cart in asm (or C, for that matter). Torben * I hit post and then remembered my favourite reason to write unreadable code: obfuscated code contests! They are fun. Very fun. And usually very educational to boot. Last edited by Torben; 5th February 2008 at 08:24 AM. |
||
|
|
|
|
|
(permalink) |
|
Bad code really is due to laziness, lack of experience, or lack of education and sometimes an unfortunate combination of all three.
I find no compelling reason for C being singled out as worse than other languages other than the COBOL Cabal's(tm) campaign of fear and intimidation ;-) Here's my favourite C++ put-down: What's the difference between an extremely clever and sophisticated use of C++ versus a very badly written piece of code? Nothing... they're both entirely unreadable! You may feel that's unfair... but in C++ one can abstract oneself up one's own arsehole! Besides, I met the guy who headed up the first ANSI C++ committee and his stories were just plain scary. When it comes to the PIC... I needed to learn yet another set of assembler mnemonics like a I needed a hole in my head! I began using the 18F series as it is trivially more expensive than the 16 series and C18 gave me a productivity edge that was hard to ignore. Just my $.02AU ;-) P. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) | |
|
Quote:
Torben |
||
|
|
|
|
|
(permalink) | |
|
Quote:
I learned C well after I'd learned several assembly languages starting at the age of 13... and given I'm now 44 that's a long time ago :-) I even learned one assembly language (LSI-11/PDP-11) while at University! So I agree with Torben that everyone needs to learn at least on assembly language though I wouldn't choose PIC as my first choice. I'm NOT saying you shouldn't learn PIC assembler. Obviously if you're forced to use the 16 series then you have little option unless you're prepared to spend $$s on a compiler, and even then it's a questionable decision due to the poor performance that might ensue. You might also need to tune a routine or three on the 18F series comet to that. I'm open to learning as many languages as I must though I now choose carefully which I need to add to the 10+ I already know. As Torben says, even PHP has advantages... though I doubt those extend to using it on a PIC :-P P. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
As the 18F series provides application notes in C, it makes sense to use C for the 18F series - because what you need to know is available in C. I've got nothing against C programmers, but you are correct that I don't like C itself. There have been many posts on these forums about using C on various micro-controllers, and a great many of them are simply because the poster doesn't understand the hardware at all - you don't get the same questions from assembler users, because they are working at a lower level. The same problems occur with any high level language of course, it's just that most who post are using C - or perhaps the C compilers are lacking in documentation and sample programs?. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
It's funny, when I started this thread, it's only by chance that I used some C code as an example. White space in asm is even worse. Another really annoying thing about pics and asm is that the (latest) template files seem to use a tab setting of 5 Mike. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
Torben |
||
|
|
|
|
|
(permalink) |
|
As for C programmers you meet in here not being hardware-aware... many are in fact computing students without compiler or architecture background, or merely hoping those here will write the projects for them :-) Such people don't deserve to pass and I wouldn't employ them in a pink fit.
It is unfortunately possible to do a "computing" degree without learning either hardware architecture or compiler theory both of which would help them understand just how close to the hardware C and make the leap to using it on a PIC. P. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Magnets and Electromagnets | ElectroMaster | Electronic Theory | 11 | 27th November 2007 02:31 PM |
| PIC code problem | Gaston | Micro Controllers | 9 | 7th March 2007 02:23 AM |
| Charge batteries using tel lines | electroniks | Electronic Projects Design/Ideas/Reviews | 5 | 16th April 2006 06:54 PM |
| running sort of output lines.................... | anand_jain | Micro Controllers | 1 | 11th July 2004 02:31 AM |
| TV- Lines in the picture | Johnson777717 | General Electronics Chat | 2 | 1st April 2004 12:10 AM |