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

This is a discussion on Is C/C++ suitable for an econ student? within the General Discussions forums, part of the Community Boards category; I'll probably be flogged alive on this forum, but I honestly can't see the connection between C++ and economy. Certainly ...

  1. #16
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    I'll probably be flogged alive on this forum, but I honestly can't see the connection between C++ and economy. Certainly not in a way that I couldn't see with Java, or C#, or Visual Basic or,... you get the idea.

    Frankly, were I in your shoes, and not wanting to be a programmer, but still wanting to get a good enough grip on programming knowledge to give me some added tools as an economist, I'd choose something that would offer me a more practical approach. Java or C# being today good candidates and already packed with all sorts of libraries that will simply just reduce the time between deciding what program you need and finishing your program. These are also more permissive tools. C++ is very demanding on the programmer, in that it demands a very good grasp of the language in order to produce a finished product of good quality.

    I'd stay away from C++ if, like you say, you don't want to become a programmer.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #17
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    Quote Originally Posted by MK27 View Post
    Dynamic arrays in the higher level interpreted languages -- perl, python, etc, where an array is an array, it's dynamic, it's managed for you, and that's it -- are allocated in power of two blocks. I've seen plenty of tests demonstrating these things will execute as fast as a compiled C/C++ equivalent, tho of course many many people are still in howling fantoid denial about this.

    He's an economist. He doesn't need to learn about memory management. Unless you really want to write software or something, it's a waste of time.
    He'd learn everything he needs to know by reading what you quoted, which is why I posted it.

  3. #18
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    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

  4. #19
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    Quote Originally Posted by MK27 View Post
    Dynamic arrays in the higher level interpreted languages -- perl, python, etc, where an array is an array, it's dynamic, it's managed for you, and that's it -- are allocated in power of two blocks. I've seen plenty of tests demonstrating these things will execute as fast as a compiled C/C++ equivalent, tho of course many many people are still in howling fantoid denial about this.
    Maximizing MATLAB Performance (Programming and Data Types) - straight from MathWorks

    Code:
    % test1.m
    clear
    tic
    for x=1:100000
    y(x)=sin(x);
    end
    toc
    Code:
    % test2.m, same as test1.m but with array preallocation
    clear
    tic
    y=zeros(1,100000); % equivalent of calloc()
    for x=1:100000
    y(x)=sin(x);
    end
    toc
    Code:
    % test3.m, vectorized, just for reference
    clear
    tic
    x=1:100000;
    y=sin(x);
    toc
    Code:
    octave:1> test1
    Elapsed time is 6.54621 seconds.
    octave:2> test1
    Elapsed time is 6.5474 seconds.
    octave:3> test1
    Elapsed time is 6.57896 seconds.
    octave:4> test2
    Elapsed time is 6.15879 seconds.
    octave:5> test2
    Elapsed time is 6.16064 seconds.
    octave:6> test2
    Elapsed time is 6.12372 seconds.
    octave:7> test3
    Elapsed time is 0.0375661 seconds.
    octave:8> test3
    Elapsed time is 0.0275859 seconds.
    octave:9> test3
    Elapsed time is 0.039516 seconds.
    octave:10>

  5. #20
    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

Page 2 of 2 FirstFirst 12
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, 02:56 AM
  3. LinkList Sorting in C
    By simly01 in forum C Programming
    Replies: 3
    Last Post: 11-25-2002, 12: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21