Is C++ the worst 1st programming language for maths majors?

In our department we have a 1-semester course called “Introduction to scientific programming”, that is taught to the 1st year undergrads. It is C++-based. I am arguing for years that it is a real waste, and only good for getting people dazed and confused, and that instead something like Python should be used.

The choice of Python is basically due to it being interpreted, (largely) untyped, and higher level than C/C++.
(And last but not least, free, unlike Maple, Matlab, and Mathematica, which might be marginally more useful to a maths major).

Here is a ranking of programming languages in industry. Inevitably biased in some ways, I suppose it still demonstrates that claimed “superiority” of C++ is nowhere to be seen…

Advertisements

Tags: ,

9 Responses to “Is C++ the worst 1st programming language for maths majors?”

  1. Vishal Lama Says:

    In my humble opinion, Python is way better than C++ as a first programming language for math majors! I mean, Python is object-oriented anyway, and on top of that, it is a lot more fun. There are tons of really good Python libraries that beginners could use to build quite sophisticated programs without needing much introduction. There is also a bit of functional programming one could do in Python. And, this could be useful for learning some basic functional programming ideas if those same math majors choose to learn Lisp or Haskell, later on. Also, there are some pretty good freely available online learning resources on Python. Lastly, I will just mention that after about a couple of months’ exposure to Python, it is quite remarkable how much programming one can get done in it with so much less effort compared to C++ or even Java.

  2. Eric Brown Says:

    Hi Dima,

    You’re right, C++ can be awfully complicated, and I do like Python and Mathematica.

    I have found that as soon as one needs to do if/else logic over many elements, the interpreted languages are in trouble.

    My strategy is to learn at least two languages. I usually work in Mathematica which can call C or C++. Optionally, I use simple C wrappers to call blazingly fast Fortran.

    The major problem seems to come when trying to use one language for all tasks.

  3. Dima Says:

    While I like Mathematica, it is way too expensive (license costs!) to use it for teaching large classes, in our case, 250+ people. And one cannot force students to buy it for themselves, either.

  4. Ken Gonzales Says:

    Before I learned R and other stat packages, I would use C. The advantage with C is its speed, compared to stat packages. But yes, its far too complicated to performed complicated tasks unlike environments like R that have a huge library of predefined functions, add on packages, etc. I don’t think math majors will be using much of C++ in their careers. If the goal of teaching them the language is to give them a “basic” view of what programming is, then I bet the purpose is defeated.

  5. 2010 in review – Happy New Year! « Equatorial Mathematics Says:

    […] The busiest day of the year was May 11th with 79 views. The most popular post that day was Is C++ the worst 1st programming language for maths majors?. […]

  6. Mykell Says:

    I’m a computer scientist and I can tell you that there are waaaaaaaaaaaaaaaaaaaay worse languages than C++.

    • Dima Says:

      well, I was talking about languages to be used in the 1st programming course… Certainly, there are Cobol, Fortran-VI, PL/1, and other monsters out there, but I doubt they are used anywhere for such purposes.

  7. un anonim Says:

    why Python ? just because it’s on the hype ? maybe next year a new language called “Fruit” will appear, and everybody’ll be mad about that, should that be taught ?

    I think Perl would be pretty good as a language to be taught 🙂
    Perl and C are needed anyway so .. you can’t escape a higher level
    and a lower level language.

    • Dima Says:

      perl is a write-only language, if you ask me. All perl code I ever dealt with was totally unreadable. And again, we are talking about the FIRST language to be taught to MATHEMATICIANS. It’s not possible to use more than one language in such a 1-semester course, and it cannot be too low-level, in order not to obscure the things by details.
      And Python is not a hype – it’s quite popular and mature.
      If I could chose freely I’d go for a Lisp instead, actually…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: