1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Programming for Engineers

  1. Jun 23, 2008 #1
    I have no programming experience and I have decided that it will be beneficial to my (future) career in engineering to become a proficient programmer. I was thinking about starting with C or C++. Is this a good idea, and if so, which of the two should I learn? I have heard that the main difference between the two is that C is a procedural language whilst C++ is an object-oriented language. However, I don't know what the implications of this are for a beginning programmer. My plan was to go as follows:

    C or C++
    Matlab/Mathematica
    Java
    Python (if necessary?)
    Learn to use UNIX/Linux
     
  2. jcsd
  3. Jun 23, 2008 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Matlab/Mathematica - if you want to get the answer
    python+numby - if you want to get the answer without paying
    C++ - if you want to get a job in software
    Java - if you want to get a dead end job in software
    Fortran - if you want to continue working on that 300,000 line model your superviser started in the 60s.
     
  4. Jun 23, 2008 #3

    jtbell

    User Avatar

    Staff: Mentor

    As regards C versus C++, a better way to state the difference is that C++ is based on C, but adds features for object-oriented programming, along with a powerful standard library for dealing with character strings and various kinds of collections of data. For example, a C++ vector is sort of an "array on steroids." You can use a vector for the same kinds of things that you would use a C-style array for, but vectors are more convenient to use in many ways.

    I would favor starting out with C++ over C even if you don't do any object-oriented programming, because of the C++ standard library. But make sure you get a book that actually uses the standard library consistently, and isn't a C-style book that simply tacks on a chapter about the standard library at the end.
     
  5. Jun 23, 2008 #4
    Any decent engineering program requires an introductory programming course, usually in either C/C++ or Java. The best choice for beginners is hotly debated among programmers, but any of these three will be a good practical place to start. C is going to be a little easier to pick up, since it doesn't have any OOP concepts to master, but you'll eventually want to pick up those skills.

    As an engineer, Matlab/Mathmatica are vital skills, but the packages you'd need for practice are very expensive. I would wait until you get to school so that you can use the pre-installed versions on campus for free. There's clone packages out there, but I haven't found any I'm particularly fond of.
     
  6. Jun 23, 2008 #5
    Thanks for the advice so far. I think I will try to learn C++ first. [References to software piracy removed] What specific features of Matlab are you refering to?
     
    Last edited by a moderator: Jun 23, 2008
  7. Jun 23, 2008 #6

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    C++ is a language of nuance. In other words, there are many ways to screw up a C++ program in subtle, hard-to-debug ways. It's also very syntactically burdensome. It's not an easy language.

    Of all the languages you mentioned, MATLAB and Python will probably be the most immediately useful to you. C++ is one of those languages that most people should be familiar with simply because of its ubiquity, but I wouldn't learn it first unless you have a pressing reason to do so.

    Ignore Java, it's dying (and rightly so). It's also so similar to C++ that there's really very little to gain from learning it.

    - Warren
     
  8. Jun 23, 2008 #7
    This was a very valuable thread for me to read.
    I'm a sophomore aiming for Civil/Environmental, but I'm hoping to learn control systems on my own time. My University uses Java throughout the EE program, but I think I will learn C++ instead. I did take a Programming theory course using VB.Net that took me up through Arrays and Some basic file storage/retrieval code, but I want to take my skills to the next level.

    I also used Mathematica in my Physics I & II w/Calculus courses to help solve problems assigned to us that were beyond Calculus II. I'm hoping to pick up the student edition soon (It's about $120 I believe).

    Are there any books or software packages that people here recommend for learning C++?
     
  9. Jun 23, 2008 #8
    Hmm, I hear this for the first time (this might be because I have not been very interested in Java or its future during the last years). Could you elaborate on this a little bit ?
     
  10. Jun 23, 2008 #9
  11. Jun 23, 2008 #10
    I would start with an object-oriented language. C++, Java or C#, it doesn't matter: the concepts are the same for all three languages. C++ might be more difficult to learn as it's more low-level (pointers is a difficult concept when you've just started programming). Java or C# doesn't matter although you may choose Java for it's platform independence (when you choose C# you're bound to Microsoft).
    When you know either of these languages, you can pick up another language very easily. As long as you grasp the concepts.
     
  12. Jun 23, 2008 #11

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Java is still the most popular language in the world, but it is rapidly losing mindshare. Various websites keep track of usage statistics; do some googling.

    - Warren
     
  13. Jun 23, 2008 #12
    I am looking at Accelerated C++: Programming By Example, and I am concerned about one thing. A couple of reviews say that there are a lot of errata, but then one person replied that the latest printing (16th printing) has corrected all the errors. However, Amazon and everywhere else I am looking only has the edition from the year 2000. Would the print edition be updated even though the text is still from 2000? I don't want to purchase the book if it has a lot of errors in it.
     
  14. Jun 23, 2008 #13
    Learn C++ along with learning how to use linux. Doing them at the same time is very complimentary, since you don't need to know anything about programming to use linux (but the more you learn about linux the more ideas you'll have for things to program), nor do you need to know anything about linux to program (but the more programming you learn, the more you'll want to explore your system).
     
  15. Jun 23, 2008 #14

    Defennder

    User Avatar
    Homework Helper

    I'm using C++ How to Program by Deitel & Deitel, though not the latest edition of the book. I find it really helpful and informative, though if you already have a background in C, you'll probably want to skip the first 5 chapters or so, referencing it only if the programming style in later chapters is not clear to you.

    I own Accelerated C++ as well, but I find the Deitel textbook a lot easier to understand, though it's noticeably thicker than the former.
     
  16. Jun 24, 2008 #15
    Sorry to bump this thread, but I really want to find a good C++ book that is

    1. Up-to-Date (I hear libraries change frequently?)
    2. Free of errors (As a beginner, I would likely not know when I came across an error)

    So if as many people could list what, in their opinion, is the best C++ book I would greatly appreciate it.

    As I stated above, "I am looking at Accelerated C++: Programming By Example, and I am concerned about one thing. A couple of reviews say that there are a lot of errata, but then one person replied that the latest printing (16th printing) has corrected all the errors. However, Amazon and everywhere else I am looking only has the edition from the year 2000. Would the print edition be updated even though the text is still from 2000? I don't want to purchase the book if it has a lot of errors in it. "

    I've also read poor reviews for Deitel's book
     
  17. Jun 24, 2008 #16
    I wouldn't worry so much either about a few poor reviews or libraries changing. Math changes all the time, but you can still learn calculus out of a centuries old textbook!

    The great thing about learning to program is that it's an experimental process. A good programming textbook is one that introduces the syntax and then starts filling your toolbox, but even if there's typos you should never be copying anything out of it verbatim.
     
  18. Jun 25, 2008 #17

    jtbell

    User Avatar

    Staff: Mentor

    The C++ standard (including the definition of the standard library) has not changed significantly since 1998, as far as I know. The standard library that comes with a particular compiler may change, but this should be in the direction of better conformance with the standard. Of course, non-standard libraries may be another matter.

    "Printings" are different from "editions." New printings fix errata. New editions have major additions, changes or reorganizations of the text. I'd expect Amazon to provide the lastest printing of the book. The C++ standard has not changed significantly since the "Accelerated C++" first appeared, so there should be no problem with that book being up to date.
     
  19. Jun 25, 2008 #18
    Recommend Python and Matlab. Very nice, very useful. C/C++ are ugly languages, why put yourself through that pain?

    I also recommend you learn a functional programming language - scheme, for example. You might never use it again, but just knowing it will make you a much better programmer with any other language.

    Also, a note on Matlab. Matlab is all about arrays and vectorization, and if you use it right you can produce very efficient, minimal, and readable code. However the developers have put in standard methods from other languages such as for loops, as a crutch when vectorization just can't be used. Unfortunately, this causes many people to not bother learning about vectorization in the first place, and use Matlab like a non-vectorized language. This is a big mistake. Learn vectorization.
     
  20. Jun 25, 2008 #19
    Buy Control Systems Engineering by NISE, and if you have any questions ask me. Use matlab for controls, not c++
     
  21. Jun 25, 2008 #20
    Astroman: Just in case you receive an old printing, here is a list of the errors they corrected, so even in this case not all is lost: http://www.acceleratedcpp.com/details/errata.html

    (quite a huge number for such a small book, but at least they cared enough to correct them...)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?