Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What is a good programming language to learn for Mech E ?

  1. Aug 3, 2008 #1
    Like it says. I am studying Mechanical engineering and I would like to get familiar with so programming language. I was thinking of Java or C++. I am leaning more towards the latter. However, I have heard that they are both a little outdated. I am of the opinion that if I learned C++, regardless of what's current, it would be helpful.

    Are most languages similar? That is, am I correct to say that if a learned C++, I could pick up another language without much difficulty?

    Also, of I do go with C++, is anyone familiar with this text. https://www.amazon.com/Sams-Teach-Yourself-Days-6th/dp/0672324482

  2. jcsd
  3. Aug 3, 2008 #2
    C++!!! However, Java is replacing niches that C++ once held like in financial engineering. I don't think it'll replace really anything in engineering any time soon.

    BTW, I hate computer science. That field moves really fast!
  4. Aug 3, 2008 #3
    Yup. Once you learn one, others are really easy to pick up. The same concepts apply, and you just have to learn the quirks of the language and their syntax (what their commands are, basically).

    Either of these will work fine for a first language.

    C++ is by far more powerful than Java, but Java is definitely easier to pickup and both are popular enough that it's a personal decision which to learn first.

    So it depends on how much time you want to spend on learning it. If it's just a tool to make you more employable, go for Java. You might have to learn C++ later anyway, but by then they'll probably be paying for you to get up to speed. ;)
  5. Aug 3, 2008 #4
    Thanks people!

    Any thoughts on the Sams book?
  6. Aug 3, 2008 #5
    Not even remotely close to being plausible, never mind true.
  7. Aug 3, 2008 #6

    By the way, anything involving large scale simulations (Computational science, engineering, computational finance) requires performance. Java is easy to learn and easy to write (so is C++, imo) but it's an absolute sloth. C++ will not be replaced in these areas any time in the foreseeable future, and it certainly won't be by Java. Hell, FORTRAN is still popular among these folks!
  8. Aug 3, 2008 #7
    What is the difference between Matlab and C++ ? I mean, I see the name Matlab and naturally I think MATH. What can C++ be used for that isn't math?

    That may be a silly question:redface:
  9. Aug 3, 2008 #8


    User Avatar

    I can throw in my ramblings as a reasonably experienced programmer who does not know mech e. Maybe this is irrelevant to you, so disregard if you wish.

    C++ is an absolute mess of a language. However it is widely used and if for whatever reason your field extensively uses it, well, then you have no choice. In any case, though, I would most definitely NOT recommend it as a first language if possible.

    Java was initially conceived as a cleaned up version of C++. Personally I think it would be a much better place to start than C++ (although not ideal). The best thing about Java is not the language itself, it's the platform. Do you need to write a program that runs on Windows, Mac OS X, and Linux, that communicates over a network, that has a graphical interface, and that uses a database? In Java, no problem, libraries to help you do those things are built in. In C++?... Good luck.

    I don't approve of the "Learn X in 21 Days" type of books. Writing code is a serious endeavor. Unfortunately there are a lot of people writing awful code and a lot of awful programming books out there. If a superficial understanding can get you by for what you need, then so be it, but I don't like to do things halfway.

    The poster above says languages are easy to pick up once you know one. I mostly agree. For instance, an experienced C++ programmer is not going to have a problem learning Java. However, some languages, especially non-mainstream languages, have different paradigms that can be hard for users of other languages to wrap their heads around. When object oriented stuff first started getting popular, a lot of people had a really hard time understanding what it was all about. Some people never did.

    As far as being "outdated"... Some of this has more to do with what's trendy than anything else. Java was extremely fashionable a few years ago; much less so now, although still widely used. But its technical merits haven't really changed. It's a mundane object oriented language with extensive libraries, 8 years ago and today. The people who were saying it was the greatest thing ever a few years ago now look stupid, as do the people today saying everyone should stop using Java immediately.

    To throw in my last little tidbit... I think all these mainstream languages are crap. There are some really, really amazing languages that 95% of programmers just ignore because they won't help you get a job. ML, Haskell, and especially Lisp. There is a great little Lisp dialect called Clojure which I love to death and which is built on the Java JVM, so you have access to all the Java libraries. Unfortunately your language decision likely has more to do with what language your colleagues will be using than its technical merits, so do what you must.

    Book recommendations:

    *** C++

    Unfortunately many C++ books teach a style of C++ from before C++ was standardized 10 years ago. These are good ones:

    Accelerated C++ by Koenig and Moo. Teaches modern C++ for a beginner.

    Effective C++/More Effective C++/Effective STL by Meyers. C++ has a LOT of pitfalls. These will help you avoid them. I consider Effective C++ pretty much essential. (These will NOT teach you the language, though.)

    Exceptional C++/Exceptional C++ Style/More Exceptional C++ by Sutter. These are basically more advanced versions of the above. Read after you have a little experience.

    The C++ Programming Language by Stroustrup. The definitive book by the creator of C++. Not appropriate for a beginner though.

    *** Java

    Unfortunately I don't know a good beginner's Java book. I'm sure there are some out there but there are tons of garbage ones also. I have:

    The Java Programming Language by Gosling.

    Effective Java by Bloch. Analogous to Effective C++ above. Do not attempt to write serious Java code without having read this book.

    *** Other

    If you have time to devote to this and actually want to become good at it, I strongly recommend Structure and Interpretation of Computer Programs by Abelson and Sussman. It's actually available for free online from MIT: http://mitpress.mit.edu/sicp/ It is supposed to be for a complete beginner, although it doesn't provide as gentle an introduction as I would think ideal.
  10. Aug 3, 2008 #9
    i vote matlab. cas systems are fast enough. computer are cheap, matlab has parallel processing packages etc etc. if you spend the amount of time learning to use c++ that it requires you will have wasted a great amount of time that could've been spent studying engineering. leave the computer science to the computer scientitsts.

    matlab stands from matrix laboratory. there are so many useful things in matlab that i guarantee if you devoted as much time to learning it as you would need to devote to c++ you will be a much more capable engineer.

    i would compare solving a problem in c++ and matlab like digging a trench with a shovel versus an excavator. yes the shovel can get into corners and is neater but yea... no one digs trench with shovels now that we have excavators.
    Last edited: Aug 3, 2008
  11. Aug 3, 2008 #10


    User Avatar

    Matlab is a language and computing environment geared towards math. C++ is a general purpose language. Your web browser was probably written in C++. Microsoft Office is written in C++. Many computer games are written in C++. etc.

    EDIT: sorry, ice109, didn't mean to step on your toes with my response; it hadn't appeared when I began my reply. And I would have to agree that a specialized environment like Matlab is probably best IF it can actually do everything you need it to.
    Last edited: Aug 3, 2008
  12. Aug 4, 2008 #11
    lol you didn't cause your post didn't show when i started writing mine either
  13. Aug 4, 2008 #12
    Okay guys. Thanks!! :smile: I already bought a Matlab book before I started this thread so I guess I'll just stick to that!

    On the same token, do you think if become 'fluent' in Matlab, wouldn't C++ be a little easier to pick up?
  14. Aug 5, 2008 #13
    yes it would since programming concepts are pretty much universal
  15. Aug 5, 2008 #14
    I'm an ME and code frequently, like four hours on an average work day. My first choice would be Matlab. Its basically an industry standard for scientific computing. While ya it is based off of C, it is a bit different. And about 8,000^67,000 times more powerful then just C++.

    My second choice would by Visual Basic (Applications). Why? Its simple, easy, used in all Office applications including Excel, and will do everything as well as C++ can but keep it neat. Since computers are getting pretty cheap and powerful these days, efficient code isn't such a big issue anymore.
  16. Aug 5, 2008 #15
    I would vote Matlab, too.
    However, I think that learning proper and clean coding is more important than any language, i.e., learning OOP etc.

    Languages and software are what you make them.
    VBA is aesthetically repellent to me, but sometimes that is all you have. I would wait until you are forced, if ever to learn.

    Keep in mind this is not from an ME perspective, in fact they never seemed that interested in programming.
  17. Aug 5, 2008 #16
    Thanks for the replies guys!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook