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

Php or c++ ?

  1. Jun 28, 2008 #1
    Hi,
    I was thinking of learning c++ as it would help me in my first year at university. However, someone told me that i should learn php first as it is easier and then learn php.

    Is that true?
    If not then are there any good tutorials on the internet for C++?

    Thanks.
     
  2. jcsd
  3. Jun 28, 2008 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    PHP is essentially only useful for web design. (If you wanted to learn a php-like language, consider Perl, which is more general-purpose.)

    C++ is a difficult language full of nuances and opportunities to make mistakes. I'd suggest python over both -- it's an easy-to-use, powerful, general purpose language.

    - Warren
     
  4. Jun 28, 2008 #3
    python....rings a bell...is it like a 'baby version' of c++ ?
     
  5. Jun 28, 2008 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    No. Python is several generations ahead of C++, and has almost nothing in common with it in terms of syntax or features.

    - Warren
     
  6. Jun 28, 2008 #5

    Borek

    User Avatar

    Staff: Mentor

    For sure don't start with php. It is too specialized and oriented on one particular task. Once you will know how to program in general, php will be a breeze (and could be you will find it limited).
     
  7. Jun 28, 2008 #6
    Thanks.

    So which language would u recommend me to start off with?
     
  8. Jun 28, 2008 #7

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    If you are going to learn a language on your own, absolutely not C++. It's syntax is a bit quirky, it has a rather steep learning curve, and if you learn it on your own you almost certainly will learn some bad habits that will be hard to unlearn. Learning C++ is best done in a context where someone can show you the ropes and where you can ask someone for help.

    Much better would be to go with a kinder, gentler language. Python has already been mentioned. I'll mention two more: Ruby and Erlang. My personal recommendation: Ruby.
     
  9. Jun 28, 2008 #8

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Ruby is an interesting language, but I do not yet consider it to be "general purpose." Most importantly, it does not have bindings to any GUI toolkits. In other words, you can't make windows and buttons and dialog boxes and so on in Ruby, something which many new programmers desire.

    Futhermore, Ruby seems destined to get stuck in the world of web design, and it borrows too much of the horribly-designed Perl syntax for me to stomach.

    Python has almost all the same basic features as Ruby (except continuations and a few other seldom-used constructs), is used by a much wider audience, and will be much more useful for University-level tasks like scientific or numeric computing. (I'm assuming the OP is pursuing some form of technical degree.)

    I'm not against Ruby, nor am I trying to turn this into a language war. :biggrin: I just think some of the things Ruby lacks (like GUI bindings) make it a poor choice for a first language, and I wanted the OP to know about that before digging into either language.

    - Warren
     
  10. Jun 28, 2008 #9

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Python's big advantage ( apart from being a very powerful, easy to learn and easy to read language ) is the number of scientific add-in libraries - eg scipy / numpy
     
  11. Jun 28, 2008 #10

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    What about Java vs Python?

    I am more interested in scientific calculations and in simulations (for example, simulations of fluctuations on a spin lattices a sa function of the temperature and so on). What would you suggest?
     
  12. Jun 28, 2008 #11

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    If you are doing the sort of problems where the computer gets it's own building you are going to be using fortran - it's what supercomputers are built for.
    Python is fast enough for most things ( the scientific libs are written in 'C') even if they aren't which would you rather do, spend 10mins writing the program and have it run for an hour - or spend an hour writing a program that runs in 10mins! Computers are cheap programmers are expensive.

    And the final reason is that all the cool kids do Python, Java is for people that think TPS reports matter.
     
  13. Jun 28, 2008 #12

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    :biggrin:

    I am not planning to do super computations (i.e. computations for research), mostly for animations for pedagogical purposes.

    I definitely would rather spend 10 mins writing it and letting the computer do the rest of the work!

    I guess my question was if Python is easy to program for (simple) simulations.

    Thanks
     
  14. Jun 28, 2008 #13

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Java is just a cleaner version of C++. It had its heydey, and may even still be the most-used language, but it's rapidly declining in popularity.

    Python is in an entirely different category. I would strongly suggest Python for any kind of scientific computation, if you don't want to use commercial products like MATLAB. Python continues to gain popularity and reputability -- Google selected Python as the de facto language for it's entire Google Apps product, for example.

    You almost can't go wrong with it, in my opinion!

    - Warren
     
  15. Jun 28, 2008 #14

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Speaking as a computer engineer with 15 years of computer programming experience (wow, I suddenly feel old), I can tell you that Python is the easiest language to read and write that I have ever seen. It is absolutely a pleasure to work with.

    - Warren
     
  16. Jun 28, 2008 #15

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thank you Warren. Is it easy to make simulations (like a GUI allowing to set parameters and watch some physical systems evolving in time)?
     
  17. Jun 28, 2008 #16

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Python supports openGL so you can do complex graphics. The main gui toolkits are wxPython or pyQT (python ports or wxWidgets and QT respectively)

    Another common approach is to write images and use some external tool to showthemas a movie - this is necessary when it takes a while to generate each new stage/image. Python has the PIL - python imaging library to make this easy
     
  18. Jun 29, 2008 #17

    Borek

    User Avatar

    Staff: Mentor

    Sometimes it is much easier to tell which language not to use, than to recommend something. I have heard a lot of positive comments on Python, but I have no hands on experience. C++ is not a good idea as a first language, it is better to have some idea about programming before switching to C++ (and/or C).

    20 years ago, in Turbo Pascal times, Pascal would be my language of choice, but these times are long gone.
     
  19. Jun 29, 2008 #18
    I actually think C++ might be a better language to learn than other OOP languages where everything is treated as an object, such as ruby. This is because C++ supports multiple paradigms in addition to OOP, like generic and procedural programming. You can be "eased" into programming with procedural programming, which imo is easier to learn than OOP and less confusing. While java claims to support procedural it is actually not very well implemented.

    Many books on C++ start you off with procedural and ease you into the OOP elements, and this is a good way to learn. At such a point, you will be more easily to adapt to Java. (I learned the basics of C++ in combination with java, and wish I had started with C++ first.)
     
  20. Jun 29, 2008 #19

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    OrbitalPower,

    Python supports procedural programming, and is easier in virtually every respect than C++.

    Java is rapidly becoming a dead-end language, and it's the most rigid and verbose of all the languages mentioned in this thread.

    - Warren
     
  21. Jun 29, 2008 #20

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    One of the hardest things for a beginner programmer is just getting started. Once that has been accomplished the beginning programmer needs to learn about some simple logic and data structures. A beginner language should be simple enough so that getting started is easy, complex enough to enable learning of logic and data structures, and clean so that the intricacies of the language don't hinder learning.

    C++ certainly has no problems dealing with the complexity issue. However, it does not do a good job with the "just getting started" problem and it does a terrible job with the clean/compact problem.

    I'm not a huge fan of Python, but I would recommend Python over C++ as a beginner language any day.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Php or c++ ?
  1. PHP Help ? (Replies: 16)

  2. PHP - limiting output (Replies: 7)

Loading...