Shop OBEX P1 Docs P2 Docs Learn Events
Learning C --- Book and PDFs versus on-line tutorials - Page 2 — Parallax Forums

Learning C --- Book and PDFs versus on-line tutorials

2

Comments

  • RossHRossH Posts: 5,519
    edited 2012-10-05 03:05
    Heater. wrote: »
    %$#%$#%$#@%

    Heater! Wash your mouth out!
  • Heater.Heater. Posts: 21,230
    edited 2012-10-05 16:16
    Phew! Wipes brow.

    I just realized I posted that link to the site with a really bad taste name in reply to a forum moderator. So far without reprimand. Still I maintain there is a lot of good and educational stuff there.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-05 16:23
    The poorly named site does have a lot of good information. It is too bad about the name and the first page is a shock to the sensibilities!!
  • Heater.Heater. Posts: 21,230
    edited 2012-10-05 16:53
    I discovered that site a few weeks back and was a little taken a back. Since then I have decided it is a most excellent and well chosen name.

    You see, if you are in the programming businesss for long enough you soon find that every few years comes a new programming methodology, a new silver bullet to cure your companies software creation problems. In recent times we have "extreme programming", "agile programming " and so on. These are invariably promoted by "gurus" who will sell training courses to your bosses, and you bosses will expect you to attend and play the game.

    Of course 99% of it is all Smile. (There I said it). And Mr Shaw is just rebelling against it.

    It just so happens that last week my boss was emailed some promo for "scrum master" training courses and he passed it on to me asking "What do you think about this?" (He is not any kind of engineer). I just replied with a link to the ever so polite site of Mr Shaw:)
  • rod1963rod1963 Posts: 752
    edited 2012-10-05 20:54
    Learned C programming via Borland's examples and the book "Learn C Now!" back in the 80's..

    I wouldn't recommend K&R's book to a novice.

    A book data structures and algorithms would be nice after learning the basics. Lots of them out there, pick up a used one.

    Lastly, I'd include the book Code Complete. You'll learn good coding habits and clarity of expression. It's a easy read, full of good stuff, especially if you want others to use your code and not curse you for coding like drunken unpaid intern at Foxconn.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-06 03:42
    Okay, if Borland was still amongst the living that would be quite helpful.

    Try to be realistic about today's beginners. The publishing world has moved on from C as the demand for new books on an older programming language with a 1989 standard doesn't appeal to them. They want high revenue with a new language that is in high demand.

    Thus, turning to classics and out-of-print texts seems plausible. Even good Linux support for C on-line is years in the background and writers of on-line documentation have moved on and into other topics. Besides, a lot of self-annoited santimonious tutorial writers just need a good spanking for rather bad style and recycling opinions without thought. Technology has removed editors from between writers and the public.

    I am blatantly trying to promote a C revival here. Join in.

    "pick up a used one" says a lot. But even second hand bookstores tend to send old programming books to the pulp recycler as they generally just sit in the store and take up space.

    Holly's document is good, but 271 pages. Kernighan published a tutorial very early on that is still worth reading, only 22 pages. He very clearly divides his text into what everyone must know and additional features to learn thereafter. But this is before ANSI C, circa 1989.

    http://www.lysator.liu.se/c/bwk-tutor.html

    Studying programming languages can be very difficult for the beginner because programmer's keep changing things and justify them in rather lofty jargon.

    If Parallax is to prosper, the beginner has to have a clear path toward becoming competent. I don't think starting with C++ will work.
  • ChaosUKChaosUK Posts: 5
    edited 2012-10-06 09:03
    Im going to try and learn C and picked up a book that looks good for beginners, its called C Primer Plus by Stephen Prata.
    Its aimed at beginners and I like it because it has loads of exercises at the end of each chapter to practice.

    There is also free video training here - http://www.wibit.net/curriculum/the_c_lineage/programming_in_c

    And a free course starting soon from Harvard covers C programming - https://www.edx.org/courses/HarvardX/CS50x/2012/about
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-06 09:36
    @ChaosUK
    Good stuff, but try to give Kernighan's C Tutorial (which I mentioned above in #37) just one good read as it is only 22 pages of easy reading from one of the founding fathers. It may provide you with a feeling for what he really wanted the language to be and how little it is.

    The first 16 pages or so are most important seem to provide everything that a Basic language would.
  • Heater.Heater. Posts: 21,230
    edited 2012-10-06 10:02
    Loopy,
    If Parallax is to prosper, the beginner has to have a clear path toward becoming competent. I don't think starting with C++ will work.

    It works very well. Don't forget the language of the Arduino is C++. A lot of beginners have started with that to great effect.

    The clever part is that they have provided an IDE that hides a lot of C++ "mess" from the beginner and they have written excellent tutorial and reference materials that carefully only present the simple essentials while not mentioning the advanced and confusing features. Also they carefully never say that the Arduino is programmed in C++ as that might frighten people away:)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-06 13:01
    Well if you have to hide the C++ mess, I am a bit frightened as well. I am beginning to belive that programers can convince themselves of anything.

    So far may limited study (no actual use) of Arduino seems to give me the impression of it being limited to using C within C++, much like what Propeller GCC suggests users that want to only use can C can easily do.

    Does the Arduino really exploit things like dynamic memory, garbage collecting, and OOP in ways that are C++ rather than little old C?
  • ChaosUKChaosUK Posts: 5
    edited 2012-10-06 13:39
    @ChaosUK
    Good stuff, but try to give Kernighan's C Tutorial (which I mentioned above in #37) just one good read as it is only 22 pages of easy reading from one of the founding fathers. It may provide you with a feeling for what he really wanted the language to be and how little it is.

    The first 16 pages or so are most important seem to provide everything that a Basic language would.

    I'll check that out to, cheers.
  • Heater.Heater. Posts: 21,230
    edited 2012-10-06 14:33
    Loopy,
    Does the Arduino really exploit things like dynamic memory, garbage collecting, and OOP in ways that are C++ rather than little old C?

    Dynamic memory allocation and garbage collection, probably not. Some OOP features definitely yes. I forget the exact details now but for example for the serial port the user might write something like "serial.tx("Hello")".

    So basically they provide objects in the same way as Spin does. Statically allocated. However it does mean you can pass a pointer to a serial object around to sub objects and such. Which is something people are always asking for in Spin.

    Other advance OOP and C++ things like inheritence, operator overloading, templates etc etc ect don't ever get a mention in the Arduino documentation.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-07 03:01
    Heater. wrote: »
    Other advance OOP and C++ things like inheritence, operator overloading, templates etc etc ect don't ever get a mention in the Arduino documentation.

    I had my suspicions. You have confirmed them.

    It appears that Arduino also felt that C++ might overwhelm novice users and lead them unknowing astray. The fact that the Arduino IDE hides the 'int main(void)' and adds it after the fact to compile with a conventional public-domain C compiler indicates that choose to greatly simplify the learning process.

    BUT they just may be pulling too many punches as they disconnect themselves from good previously and currently published reference material. I believe and hope that by learning how ANCI C adapts to different platforms, one learns more than just the language for a specific task - one develops a wider view of what programming is and why it varies.

    The results with Arduino are that many novices might view the idea of learning C as unnecessary or even as loathsome. They might lock on to 'the Arduino Way'. Popular micro-controllers on the internet have a way of collecting a lot of odd perceptions of programming if they stylize themselves as a special case of a rather generic standard.

    I suspect that Parallax was quite wise to launch the Propeller with SPIN as a completely different animal rather than to do something less inspired. But of course we now have the Arduino, and the Propeller has not one, but two ANSI C compilers - Catalina C and PropellerGCC. IMHO The evolution is healthy and helpful for all learners. One might get a better feel for both hardware and language nuances.

    To me, it seems like an ANSI C revival is occuring as new young people are studying it for the first time. And affordable chips make it all very interesting and fun.

    I started a detailed reading of the PDF that Holly mentioned above. It seems quite respectable and up-to-date while not trying to slip C++ into the study of C. Besides, it is open sourced and free.

    I was able to locally but an ATmega8535, but the shops do not have any ATmega8 or ATmega16 chips. At first I was thinking I would clone an Arduino with it, but there is very little reason to as it is well supported in C and Arduino-style of C may just be a distraction. I think you can see how this goes - either you focus or you get lost in keeping up with endless variations until you have to abandon some platforms and projects to get anything accomplished.

    I must say that the community support over at AVR Freaks is in some ways not up to the level of Parallax Forums and the Arduino Forums go even further as they seem to feel that using Arduino code on an ATmega8535 is some sort of betrayal. The ATmega8535 may just sit around for quite awhile while I explore C on the Propeller.
  • TorTor Posts: 2,010
    edited 2012-10-07 04:52
    About C++.. well, I'm a long-time C programmer, I write lots of C. I also use object-oriented languages, I like the concept of objects (although it's just another tool in the toolbox). But I admit to not choose C++ when I want to use an object-oriented language. I maintain C++ code when I have to, but even though I'm extremely familiar with C I find C++, frankly, disgusting. Sorry. And if the mess of C++ has to be hidden from the Arduino users then that should give a hint too. Every other C-derived object oriented language (and there are a bunch) look better to me.

    And if it isn't nice, or elegant, I won't program in it - there's no joy.

    -Tor
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-07 05:09
    Hmmm.... I think we already have you on record for that in another thread about comparing C and C++.

    But it is an honor to have you visiting us. (Am I correct in assuming Tor is as in Torvalds? It is just a hunch and I have been know to be wrong.)

    I'd never thought about it before, but joy is a very valid criteria - nobody like drudgery. Thank you.
  • TorTor Posts: 2,010
    edited 2012-10-07 05:21
    Ah, no, no Torvalds! Look at my Location - I'm in Norway. And Tor is my actual name. No connection at all (he's Finnish of course) other than that I was a Linux user from back when the kernel version was some 0. version. Well, and an email or two back then when all us early adopters were alpha testers.

    Yeah, I probably must have let slip my dislike of C++ before.. so I'll stick a note above my monitor
    [*] about that, there's no need for me to keep repeating it! :)

    -Tor
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-07 05:28
    There is a good reason I call myself Loopy. I tend to get confused a bit. In the thread on C and C++, I posted a link to a site where Linux Torvalds clearly stated his disgust for C++.

    Please feel welcome, I just can't keep Norway, Finland, and Sweden straight. Forgive me, but one always hopes.
  • Heater.Heater. Posts: 21,230
    edited 2012-10-07 06:42
    I keep puzzeling over where C++ went wrong. As you learn it fron some nice tutorial every step along the way seems quite reasonable. If you read Bjarne Straustap's book "The Design and Evolution of C++" describing the rational behind the language features it all make perfect sense.

    Then when you get into programming in C++ you soon find it goes into a horrible mess. You can try to stick to language features you know and love, that look elegant and clear. You can try and be organized with your classes and such. But soon you will find that you are forced into using more and more C++ features until your code looks like line noise. It's like being caught in quick sand, the more you struggle the worse it gets.

    Often the big killer is when you decide to use some library classes to make you life easier, like STL, or boost or the Qt tool kit. Then you have no escape you are drowning in templates and hiddious looking iterators.

    It does not help that working with this stuff becomes a pain practically, compilations take ages, and error messages can be really obscure.

    Turns out the Qt guys have realized all this so now they offer the capability to easily create Qt GUI apps with Javascript (see QML).


    [h=1][/h]
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-07 07:24
    What went wrong with C++? It seems it grew in many directions all at the same time from independent innovators with different ambitions and goals.

    But what I am personally trying to do is not to tar C++ as to start at the beginning when a few programmer's had a vision and made it work well. IF you want to learn C++. C is still a stepping stone towards that goal. Everyone is free to use whatever provides that element that Tor mentions -- joy.

    I have gotten further into Holly's suggested book and it is enjoyable and informative.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2012-10-08 02:42
    Heater. wrote: »
    Phew! Wipes brow.

    I just realized I posted that link to the site with a really bad taste name in reply to a forum moderator. So far without reprimand. Still I maintain there is a lot of good and educational stuff there.

    Yes! :-)
    That's the book I meant, no wonder I couldn't find it on google searching for "C Made Difficult"...duh
    Thanks for posting the link to it, it's quite good.

    The only reason I agreed to be a moderator is because I'm in a different timezone and so I'm on the forum when
    most people in the US are asleep. Once I was on and some dodgy business in Asia posted a spam message
    for their service that could defeat the code protection on uC's so that the work could be stolen :-(
    This really irritated me as there was no moderator watching and I could not remove the spam from the forum.
    So when that intern asked if I would be interested in being a moderator I said yes so I could help remove that
    kind of thing when I found it on the forum early in the AM.

    I'd never edit someones post on the forum unless it was something so outrageous that it would sully the reputation
    of Parallax. The audience here is 99.9% male, at least, so a simple reference to a poorly named URL seems
    fine to me. If something was really sickening and in poor taste I'd probably edit it just so some young person would
    not see it since we do have the occasional young guys who read the forum.

    In any case, I'm rarely on the forum these days, I'm only on now because I'm a bit sick. I was on a flight a few days
    ago and picked up some bug from the other passengers....I hate breathing all the stale fumes on a long flight...ick.
    (This is the first break I have had in some time though so maybe it's worth the cough and fever :-)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-08 06:16
    @Holly
    I guess 'The bug stops here' really is causing you some difficulty. The latest news is that there is a new coronavirus that may or may not be SARS similar.

    Take care of yourself. Here in Southern Taiwan the weather is just beginning to turn cool and that normally means Asian flu season. Hopefully we won't have another SARS epidemic, or a bird flu epidemic, or hoof and mouth disease, or whatever (it all sounds rather Biblical, doesn't).

    You do have me wonder about this.....
    'The audience here is 99.9% male, at least, so a simple reference to a poorly named URL seems fine to me.'

    Aren't we a gender neutral forum?
  • ctwardellctwardell Posts: 1,716
    edited 2012-10-08 06:37
    Heater. wrote: »
    Phew! Wipes brow.

    I just realized I posted that link to the site with a really bad taste name in reply to a forum moderator. So far without reprimand. Still I maintain there is a lot of good and educational stuff there.

    Maybe it might be a good idea to use a tinyURL or something like that for the link with a warning that the actual site name might be offensive to some.

    C.W.
  • idbruceidbruce Posts: 6,197
    edited 2012-10-08 07:13
    @Loopy

    I probably approach learning different than most people, especially when it comes to learning programming languages. Most often, I learn out of necessity as compared to desire. In other words, I have a very specific task or goal in mind.

    Understanding the IDE and the syntax of a programming language is the two most important aspects to me. Once the syntax is understood, I simply use any available material as a reference, and I do not take the time to read or learn the material, without having a specific task in mind. Since we are on the subject of C, let's also include C++. On my bookshelf, I have 10 books that either apply to C or C++. I cannot honestly that I have read any of these books from cover to cover, but I am fully aware of the information that each book contains. If I have a specific task in mind, I know exactly which book will most likely contain the information that I need to complete my task. To think that I would be able to digest all the information contained within these ten books is absurd, so I just refer to them when necessary, and by doing so, I have become fairly competent at understanding and programming in both C and C++. I don't know it all, nor am I an expert in any particular field of C or C++, but if it is possible, and if I have the proper references available, I know enough to complete the task at hand.

    By learning this way, I have avoided wasting time on learning programming material that I will probably never use.

    Bruce
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-10-08 07:53
    It's actually pretty easy to obfuscate/simplify url links using the forum software. Instead of [ URL ] and [ /URL ], use [ URL="www.actualwebsite.com" ] Different Description Here [ /URL ] (Note: I have added spaces within the tags so it doesn't appear as a real link)

    Using Firefox, all I have to do is select/highlight the word(s) I want to be seen as the link, click the "Link" button on the message editor toolbar, paste or type in the actual url and click Okay

    Example (actually takes you to Google)

    Warning this link is to a website with great info but language may be offensive to some people
  • Heater.Heater. Posts: 21,230
    edited 2012-10-08 08:18
    @ctwardell and RDL2004,

    I appriciate your suggestions re: obfuscating links.

    However, I will not do it. If I think something is good, usefull, interesting, wholesome and true I will post it or link to it. I will censor myself somtimes if I think the above does not hold and not post at all. To try and obfuscate such things seems hypocritical, underhanded and dishonest.

    In the case in question, the web site name may be a little bit in bad taste, so what? We have all seen far worse on TV every day, our children are quite used to it. Women in the modern western world are not sheltered princesses who would be shocked by such things.

    There are many more less offensive things I might say or link to that would get me shut down immediately. In this P.C. world a casual "sexist" joke or comment on religious beliefs can get you into a whole world of pain.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-08 08:32
    I must be learning something as I now find that I understand how to make C libraries. The libraries are the strength of the Arduino as the user doesn't have to comprehend significant details of the devices unless they don't work as expected. I even suspect that I can use Arduino libraries as examples of how to construct Propeller libraries.

    I am not sure that Catalina C and Propeller GCC have developed much in the way of libraries as I can't find them when Googling.

    @idbruce
    I doesn't particularly surprise me that finishing texts is not a high priority for you. Today's computer books are often very large and verbose, and technical documentation for reference is equally large.

    I just earned early in life that if I wanted to explore a new topic, it was best done by first reading something short - say 50 to 125 pages before getting into larger texts. In this case, I have worked my way up from a 22 page tutorial by Kernighan, through "The C Programming Manual, 2ed - ANSI C", and on to Holly's recommended Wikibook "C Programming".

    By doing so, I can begin to understand what a 'malloc' really is and where it fits in. If I were to start with the Wikibook, I would be rather lost as it makes many references to issues and items that were not around in the beginning. Sure, that may be 'need-to-know' info in today's C programs. But too much of this in the beginning just is extremely daunting.
  • idbruceidbruce Posts: 6,197
    edited 2012-10-08 08:51
    Loopy

    In my opinion, C, C++, and PERL, are all very interesting and powerful programming languages. So have lots of fun.

    Bruce
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-09 01:01
    I need to backtrack and correct a bit. Catalina C has standard i/o and standard libraries for ANSI C 89 with some later features (99?). I presume that Propeller GCC is something similar.

    Catalina C has an SDcard OS file system called Catalyst that will appeal to many C users as C standard libraries tend to presume a file systems is available for many programs. This is NOT Unix, but one doesn't really require Unix, which was intended for a big multi-user configuration of a shared mainframe. (if you do require something like that, you should be using a Linux-friendly SBC - Raspberry Pi, Pandaboard, Beagleboard, Cubieboard, etc.)

    I need to actually get going with an installed Propeller C to see how these work. But what concerns me is that the Propeller and other micro-controllers seem to be rather dependent of 'non-standard i/o' and 'non-standard libraries'. So it seems that being able to independently create these items is very useful and a source of fun creativity.

    I really am running out of things to say on the topic of this thread. But I will repeat that I find a 3 step reading list to have been very helpful.

    1. "Programmng in C: A Tutorial" by Kernighan, circa 1974 - only 22 pages and gives the user a chance to acquire a good overview. Others may disagree, but I find this delightfully short and useful.

    2. "The C Programming Manual -2nd ed", by Kernighan and Richie, 1988 - 272 pages. NOT the first edition but the second as this was the beginning of ANSI C and focuses on what became the 1989 standard that Propeller C is generally targeting.

    3. "C Programming", June 12, 2012, published by Wikibooks.org; 271 pages in PDF - a modern review of programming in C with many practical details that the other two had yet to discover.

    After all that is pretty well understood, or maybe even before; search the internet for a good explanation of how to make libraries in C as this will lead to the ability for you to adapt C to your particular project's construction and additional chips.

    And yes, I know that many of you are extremely intelligent and intuitive and don't require a reading list. We all have different paths to the higher levels of computer programming.

    Good luck to all. I hope this all will inspire new users to join in. C++, Perl, Ruby, and even Python are later possibles. After all, they generally have source code in C or C++.
  • RossHRossH Posts: 5,519
    edited 2012-10-09 01:47
    I am not sure that Catalina C and Propeller GCC have developed much in the way of libraries as I can't find them when Googling.

    You mean apart from all the standard C libraries? - these are mandated by the ANSI standard, and both GCC and Catalina support the whole set. You don't really have any choice here if you want to claim to be "ANSI compatible"

    I can't speak for GCC wrt other libraries, but Catalina has lots - however, I doubt you would find them on google. Most are descirbed in the Catalina Reference Manual, while others have individual "README" files in the distribution or are documented in the corresponding header files (i.e. the ".h" files in the "include" subdirectory).

    Here is a brief list of the actual libraries provided with Catalinat:
    • libc, libci, libcix, libcx - various versions of the C standard libraries - with floating point support (libc, libcx), without floating point support (libci, libcix) and with extended file system support (libcx, libcix). But note that these libraries also all include many Propeller-specific functions (see the file "propeller.h"), and the extended versions also support direct low level FAT-based filesystem functions (see "catalina_fs.h").
    • libtiny - a tiny version of printf that can be used in conjunction with the above to reduce program size (thanks to Ted Stefanik).
    • libm, libma, libmb - various versions of the C standard floating point libraries that use none, one or two cogs (respectively)
    • libgraphics - a library to access the Parallax "Graphics" object (and TV driver). 100% compatible with the Parallax object.
    • libvgraphics - a library to access a VGA version of the above, 99% compatible with the Parallax graphics object. Only missing are "filled" objects (e.g. boxes and triangles - only "vector" or "outline" objects are supported). Suports 2 and 4 color VGA, up to 1152x864 resolution.
    • libtty - a library to access the Parallax "Full Duplex Serial" object.
    • libtty256 - as above, but with a buffer size of 256 bytes instead of 32 bytes.
    • libserial4 - a library to access the "4 serial port" object (supports 4 serial ports on one cog).
    • libthreads - a multithreading library, similar to POSIX "pthreads", but smaller and more suitable for the Propeller.
    However, you also should be aware that a lot of things that GCC supports via libraries, Catalina instead supports via plugins - which consume much less code space at run time than libraries do:
    • Gamepad plugin (see "catalina_gamepad.h"),
    • Mouse, Keyboard, TV, PC, PropTerminal and VGA plugins (all driven via the functions in "catalina_hmi.h").
    • Real-time Clock plugin (see "catalina_rtc.h")
    • SD Card plugin (see "catalina_fs.h")
    • Floating point plugins (see "catalina_float.h")
    Finally, also remember that any library that is ANSI C compliant can also be used with Catalina. Plenty available on the internet. Just remember that C has been so debased over the years by compilers that "extend" the ANSI standard - usually in an attempt to lock you into using that particular compiler. So check that they are ANSI C libraries. They will usually say so if they are. Don't bother with anything that isn't - unless you are a C guru, the effort to port it back to ANSI C is usually not worth it.

    Ross.
  • RossHRossH Posts: 5,519
    edited 2012-10-09 01:54
    Hi Lopy,

    We crosed posts! but I also need to correct one more thing:
    Catalina C has an SDcard OS file system called Catalyst that will appeal to many C users as C standard libraries tend to presume a file systems is available for many programs.

    Catalyst is not a file system - the file system support is built into any C program that is compiled to use the libc or libcx libraries, and you can access the SD Card without using Catalyst at all (e.g. if you load your program serially, from Flash, or from EEPROM). Catalyst is mainly just a program loader, that allows you to do nice things like load programs from SD using a two-phase load technique that gives you much more usable program space than is available otherwise (it loads up all the cogs first, then loads the application code, so your program can be 32k of application code even if it uses all the cogs, not the measly 16k that Spin or other single phase program loaders allow).

    Ross.
Sign In or Register to comment.