Page 5 of 5 FirstFirst ... 345
Results 41 to 44 of 44

Thread: My first C prog

  1. #41
    Join Date
    Aug 2005
    Beans
    182
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: My first C prog

    Wow. I'm loving my job right now. No system admins (save for the UNIX / VAX admins, but they're really good), no direct customers. Just me, a JTAG probe, a logic analyzer and hardware...

    Nothing like a good day of debugging PCI Bus Errors
    Linux User #395848
    Blog: http://digitalnotions.net

  2. #42
    Join Date
    Dec 2005
    Location
    Atlanta, GA USA
    Beans
    200
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: My first C prog

    Man, this thread got hijacked a long time ago. IMO, the difference between a scientist and engineer are irrelevant to a novice programmer. Personally, I did find it interesting to read everyones comments.

    Let me first say, I'm not well versed in any language, but do enjoy programming and sysadmin tasks. I can read code and understand it better than I can write it and execute it (I probably don't practice writing it enough, coming up w/ trivial tasks is harder than I thought). I'm more of a web guy, so enjoy things like PHP and now Ruby. I also manage some Ubuntu servers, and have been practicing writing scripts w/ Ruby for sysadmin tasks.

    I'm currently working on one that will backup a MySQL db and copy some files across to a backup server (I know nothing cool, I'm sure someone could whip something up, faster than I could start irb). This allowed me to become familiar w/ Ubuntu and ruby at the same time.

    While there are some great all around languages, I think its important (and I could be completely wrong here) to identify what it is you'll be using the language for and find the one that suits your needs. I chose ruby b/c I thought it was easier to read than PHP. Also, PHP is a web scripting language, and is not meant for CLI tasks (but I know it can be used for this as well).

    Someone mention that documentation for Ruby (or any modern programming language) is scarce. Someone also stated that Google is your friend. I disagree w/ the statement that docs are not available, and agree w/ Google being your friend. Del.icio.us is your friend as well. Sitepoint.com has a free book on Ruby on Rails, which has a decent intro to Ruby.

    Even though I bought the book, Beginning Ruby by Peter Cooper, I still find myself struggling w/ certain aspects of programming. Its become a huge wall. Most of what I've learn so far is from books and the internet. No formal learning, which I think would help me a lot. Understanding your learning style is also important.

    Good luck to you.

    [OFFTOPIC]

    For those that are interested, or care to reply. My difficulties w/ programming involve identify things that should be included in a script/program. I guess you can say its the planning. Identifying what needs to be variables and things like that. I'm not sure if I'm getting my point across, but I hope someone understands me, and could possibly help.

    [/OFFTOPIC]

  3. #43
    Join Date
    Feb 2007
    Beans
    236

    Re: My first C prog

    Quote Originally Posted by aks44 View Post
    C++ code has exceptions (mainly to report errors) and they break the control flow, so you have to deal with *several* possible execution paths at the same time.
    You're right on the money there. Many, many C++ programmers have the mistaken idea that C++ handles a lot more "resource tracking" entirely on its own than C does, and therefore C++ is easier than C. That is so only if the C++ programmer doesn't take error handling into account (especially, as you note, wrt exceptions due to errors). The result is C++ code that leaks resources, or worse, when put into a shared library that some app uses, causes that app to terminate due to an unhandled exception.

    I write lots and lots of shared libraries, and the absolute worst thing to do in a shared library is to cause the app to abort. (Incidentally, anyone who puts a call to exit() in a shared lib should be shot dead... with no questions asked).

    The majority of C++ code I've seen, particularly open source stuff, does not do proper error handling. Consequently, I have more faith in C projects because error handling tends to be more straightforward, and therefore, more prevalent. I tend to eschew using any shared lib written in C++. There are almost guaranteed to be issues like the example you cited with cout throwing an exception when it fails, whereas printf() doesn't, and the C++ programmer failing to take the former into account.

  4. #44
    Join Date
    May 2007
    Location
    Paris, France
    Beans
    927
    Distro
    Kubuntu 7.04 Feisty Fawn

    Re: My first C prog

    Quote Originally Posted by j_g View Post
    Many, many C++ programmers have the mistaken idea that C++ handles a lot more "resource tracking" entirely on its own than C does, and therefore C++ is easier than C. That is so only if the C++ programmer doesn't take error handling into account (especially, as you note, wrt exceptions due to errors). The result is C++ code that leaks resources, or worse, when put into a shared library that some app uses, causes that app to terminate due to an unhandled exception.
    The "easy" solution WRT to resource leaks when facing exceptions is using RAII. This way you just CAN'T have it wrong, and it really cleans up the code.

    FWIW last time I checked in our project at work, we only had a few (a dozen or so) deletes out of something like 250kloc. std::auto_ptr and boost::*_ptr are probably your best friends in C++.
    Not even tinfoil can save us now...

Page 5 of 5 FirstFirst ... 345

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •