Thread: Is C/C++ suitable for an econ student?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    If you feel this way: "one obvious thing I notice is that it's far more difficult than Matlab/SAS, but it's a lot more interesting" then stay with it -- that's a choice, that's how you feel about it, and no doubt it is more interesting, just obviously being more difficult it will now sap more of your mind and time.

    Are you sure you want to be an economist?
    Last edited by MK27; 05-03-2010 at 09:15 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by pantera View Post
    When I am learning C++, one obvious thing I notice is that it's far more difficult than Matlab/SAS
    Haha I bet, SAS is way different than most anything else out there, in my opinion. I learned things like C, LISP and Python and then just recently learned SAS. It's a different way of thinking for sure.

    That's cool that you do use SAS, again, I love SAS.

    I don't really agree with what you've been told though. MATLAB and SAS are 4th generation programming languages, that is, developed for specific purposes and much of the actual work abstracted by high level functions. However, MATLAB is "low-level" enough to have that complete control. If you learn MATLAB, you can minimize both human time and running time (if you really care about how long it takes to run a program, I don't know how big your data sets are). If you just google "MATLAB performance", MathWorks has a few articles telling you how to write MATLAB programs for speed, doing things like preallocating arrays as I mentioned earlier, and using parallel for loops when possible.

    I'd say, if you want to learn how to make your own programs, then go ahead and learn C++, otherwise I'd stick with MATLAB.

    MATLAB:
    - is low level enough to let you do most anything manually and define your own functions, yet has so many built-in functions that you also have the ability to take the easy way out if you want to
    - has a free clone, GNU Octave
    - wins

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Epy View Post
    MATLAB:
    - is low level enough to let you do most anything manually and define your own functions, yet has so many built-in functions that you also have the ability to take the easy way out if you want to
    - has a free clone, GNU Octave
    - wins
    Oh I wasn't questioning the value of pre-sizing arrays in MATLAB (or anywhere else, tho I that example looks somewhat "matlab specific"). Just to me it appears like it's in a niche akin to javascript or bash script -- a full fledged turing complete language, but dedicated to a specialized purpose and with limited "general" functionality. So the OP has expressed some fascination with programming concepts, maybe something like python would be good: you get the full range of normative C/C++ derived programming tools, sans the need for (much) memory management. And while python may be (lets say) sometimes 3 times slower than C++, the code base will be 3-5 times smaller. And the "speed" here is usually only going to resemble something relevant when you are dealing with hundreds of lines, in which case it might be worthwhile waiting 15 seconds to execute 200 lines of code vs. waiting 5 seconds waiting for 1000 lines, that you had to write. For stuff involving lots of disk read/writes, "execution speed" becomes purely theoretical -- like a ferrari in a 55mph zone is just a fragile overpriced gas guzzler.

    I just say this because I will often write something quickly in perl, and then later if I like it, have time, etc, go back and re-write it in C (or more recently C++, which is closer match with the OO, but less optimizable IMO). There is a big big difference in the time required to do the work, and unless you are intent on a "production" quality product or dealing with incredibly massive amounts of data, it's probably not worth it (beyond, of course, personal satisfaction as applicable).

    This is a pretty interesting site:
    http://shootout.alioth.debian.org/
    It's primary criteria is execution speed, so you get C/C++ at the top, but it includes criteria for memory usage (which drastically divides the C from the C++) and code base (where C/C++ is closer to the bottom).
    Last edited by MK27; 05-04-2010 at 08:41 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Updating in a sequential file?
    By Ronnyv1 in forum C Programming
    Replies: 1
    Last Post: 03-24-2009, 04:41 PM
  2. Database assignment is Killing me!
    By Boltrig in forum C Programming
    Replies: 2
    Last Post: 11-29-2007, 03:56 AM
  3. LinkList Sorting in C
    By simly01 in forum C Programming
    Replies: 3
    Last Post: 11-25-2002, 01:21 PM
  4. Creating a student grade book-how?
    By Hopelessly confused in forum C Programming
    Replies: 5
    Last Post: 10-03-2002, 08:43 PM