× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 1/20/2014 4:41 AM, frank kolmann wrote:

I am not sure that C achieves the low level flexibility of assembler,
mainly what was achieved is to allow the introduction of the most
difficult to detect coding errors.

Perhaps I can share a slightly different experience with C, et al. I
use it for programming PIC microprocessors, TI MSP430 microprocessors
and so on. Before I used C, I programmed these devices in their native
assembly language. I very much perceive C as a slightly souped up
assembler.

The necessity of coding at a character level causes C programmers
to constantly to resort to tricks, I am compiling for
myself a list of these tricks.

For business programming, I use a lot of ILE RPG. If I were to try to
program in C using RPG idioms, I'd surely think of the C patterns as
'tricks'. But C is not RPG with a funny accent - it's a separate
language with separate idioms, patterns and ways to do things.

for example this code moves one alpha field to another, go figure,
{while ( *s++ = *t++) ; } ( actually I understand this code , I am
learning, yea!!)

This is exactly how I'd do this in assembler. Set a register (pointer)
to the start of the target and the start of the destination, then
increment the registers until reaching the end of the source, copying
the memory location from source to destination. Additional code needed
for the assembly version would be whether to pad the destination,
truncate it or (like C) simply put x'00' after the last source byte.
Then there's the buffer overflow problem of a source longer than the
destination...

Anyway, my point isn't to denigrate your experience - changing idioms
after a long time in one language is hard! What helped me was the
realisation that I should think of C as a language with little in common
with RPG or Fortran. If you took Latin in school then you spent a long
time conjugating verbs. That idiom is sort of interchangeable between
the various Romance languages, but less so for the Germanic languages
and the wheels come off if you're trying to learn Chinese. (Ask me how
I know...)

I learnt C by working with embedded microprocessors, so I'm not sure I
have any useful advice for someone else learning C aside from: Don't
translate from RPG to C, rather think in C. To that end, have you
looked at Bruce Eckel's 'Thinking in C'?
http://www.mindviewinc.com/CDs/ThinkingInC/

--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.