Should I Learn PHP Before C++ for University?

In summary, the conversation discusses various programming languages and their suitability for beginners. The experts recommend starting with Python for its easy-to-use and powerful features, while also mentioning other languages such as Ruby and Erlang. Java is also mentioned, but it is considered less popular and declining in popularity. Python is highly recommended for scientific computations and simulations, and is used by Google for their Apps product. The experts also mention that Python has a large community and plenty of resources available for learning and using the language. In conclusion, Python is a great language for beginners to start with, especially for scientific and technical tasks.
  • #1
hasnain721
40
0
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.
 
Technology news on Phys.org
  • #2
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
 
  • #3
chroot said:
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

python...rings a bell...is it like a 'baby version' of c++ ?
 
  • #4
No. Python is several generations ahead of C++, and has almost nothing in common with it in terms of syntax or features.

- Warren
 
  • #5
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).
 
  • #6
Borek said:
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).

Thanks.

So which language would u recommend me to start off with?
 
  • #7
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.
 
  • #8
D H said:
My personal recommendation: Ruby.

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
 
  • #9
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
 
  • #10
mgb_phys said:
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

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?
 
  • #11
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.
 
  • #12
mgb_phys said:
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.

: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
 
  • #13
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
 
  • #14
nrqed said:
I guess my question was if Python is easy to program for (simple) simulations.

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
 
  • #15
chroot said:
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

Thank you Warren. Is it easy to make simulations (like a GUI allowing to set parameters and watch some physical systems evolving in time)?
 
  • #16
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
 
  • #17
hasnain721 said:
So which language would u recommend me to start off with?

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.
 
  • #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.)
 
  • #19
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
 
  • #20
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.
 
  • #21
I think the "best" language I've ever used is Ada, it is quite unusual nowadays but I know it was the standard language in many organizations (e.g. DoD) for writing critical apps for a number of years (because it is very easy to debug).
Ada 95 was used to teach programming at my university and even although I had used Pascal, C, C++ etc before I attended those courses I DID learn a lot, mainly because Ada was designed to essentially force you to pick up good habits (Ada supports strong typing etc). It is a very well-structured and consistent language (some would say a boring language...).

Note that I would not recommend anyone to use Ada to write anything that will actually be used, but it is a good language and if you understand Ada you can quite easily learn more "quirky" languages like C, C++, Fortran etc (although I guess that is true of most languages, once you know one you can learn others quite easily).

Java is a "fun" language because it is easy to write applications with a nice GUI, but I am not convinced it is a good language for beginners.
 
  • #22
Jumping right into C++ as your first programming language is not the best plan...

I would suggest learning Python first, it will give you a solid base for programming and also get you into good programming habits. I suggest you grab a book; get a UNIX based OS and get to programming. After you get a good foundation in Python your road to programming is much smoother, after this I would strongly suggest you learn a dialect of Lisp (preferably Common Lisp or Scheme). Lisp will change your perspective on programming, it is by far the language that I learned the most from. After this you should be ready to get into C which will lead you good on into C++. If you want before starting C/C++ it will be excellent if you have the time to learn a bit of Java, the syntax is quite similar to C++. Have fun and explore the shear power and might of C++, the raw speed of C++ is amazing. After you have all these languages under your belt dive deeper, Assembly, Prolog, MS, Haskell, there are tons of educational languages out there take advantage of them.

-Ink
 
  • #23
The languages that I have used, with some comments:

BASIC: Fun when I was 10. Not very useful.

C: Frustrating to get used to, but it's the paradigm that many language syntaxes are built on. If you learn C, you can learn anything else (and breathe a sigh of relief when you use a more advanced language and don't have to worry about malloc()-ing everything anymore). C was my introduction to compiled (vs. intepreted) languages.

C++: Slightly less frustrating than C. Slightly.

Fortran: Hated every second of it. The only reason this language still exists is the massive amounts of legacy code being used by the aerospace industry. It is clumsy and pedantic. Fortran fans extoll the virtues of Fortran for mathematical calculations; however, every mathematical calculation I can think of would be easier to implement in C. And that's saying something.

JavaScript: Limited to web design, and confusing as all get-out. It seems features were added pretty much randomly, whenever Netscape felt like they were needed. Very inconsistent (but very necessary, if you do web design).

Java: Everything is an object. Programming in Java feels like playing with LEGOs! Good if you want to learn OOP principles fast. Less confusing to learn than C++. However, as noted by everyone else, Java is going out of style.

Perl: Perl's highly-flexible syntax is a blessing and a curse. You can write your own programs in a few short lines, but good luck trying to read anyone else's. Very useful if you do text-processing. I have always loved Perl's regular expression engine, and used it extensively. Perl is useful for Web applications as well as standard command line stuff, and can draw GUIs well enough.

Python: Had to use it for a class, didn't really get into it (I was on a Perl kick at the time). But it's quite useful; does everything Perl can do, with a much more consistent syntax.

Lisp/Scheme: Lisp is a programming language from another planet. It is what's known as a "functional language", which is a drastically different paradigm than the procedural style of C-like languages (i.e., most of those listed above). It is an implementation of Church's Lambda Calculus, which means that functions execute according to parenthetical nesting, rather than proceeding down one line at a time. It's a highly mathematical structure, and I found it very beautiful, but it took a bit of thinking to figure out how to do things, because I was used to the more procedural style of other languages.

PHP: As mentioned, this is for web design only. Not recommended as a first language. It's also rather inconsistent, especially across versions, which is frustrating when designing web applications that might end up running on PHP 4, 5 or 6. The language is slowly approaching a structure that makes more sense, but most web hosts are a few versions behind. The worst thing about PHP is that it can't make up its mind whether it should be strongly-typed or not; in many ways, it would be more useful if it were. As it is, types get converted between each other on the fly, and often with unpredictable or undesirable results (is some variable an empty string or a zero, or a string containing the character '0'?, etc.). On the other hand, it seems to be pretty easy to throw things together with PHP, until you run into a situation where you actually care what type something is and/or how something is being interpolated.
 
  • #24
Ben Niehoff said:
Fortran: Hated every second of it. Fortran fans extoll the virtues of Fortran for mathematical calculations; however, every mathematical calculation I can think of would be easier to implement in C. And that's saying something.
That's just wrong. Just two of many reasons why Fortran fans stick to the language are exponentiation and arrays. Fortran has an exponentiation operator. C does not. C's pow function is a very poor substitute. Fortran flat out does a better job with arrays than does C. C++ comes closer if you define matrix and vector classes, but the result is clunky and slow compared to Fortran.

BTW, last time I used Fortran was twenty+ years ago. Some Fortran afficianados are hard core. Very hard core. That C will not create an exponentiation operator because it is too far from the underlying machine is just silly. It is perfectly valid in C to say 'x=y', where x and y are very complex data structures. C's arrays have always been viewed as a weak point of the language by Fortran fans, and for good reason.
Perl: Perl's highly-flexible syntax is a blessing and a curse. You can write your own programs in a few short lines, but good luck trying to read anyone else's. Very useful if you do text-processing. I have always loved Perl's regular expression engine, and used it extensively.
I love perl, particular its regular expressions, but hate its syntax. Perl is vulgar. We use $%@# in any other context to denote a cuss word.
Lisp/Scheme: Lisp is a programming language from another planet.
No. Lisp is just in low Earth orbit. Forth is in geosynchronous orbit, Prolog is a language from another planet, and APL is from another universe.
 
  • #25
Ben Niehoff said:
Python: Had to use it for a class, didn't really get into it (I was on a Perl kick at the time). But it's quite useful; does everything Perl can do, with a much more consistent syntax.

In saying the above I'm guessing that you don't really know how messy Perl can get when you program something over 30 lines. And then coming back to a Perl program longer than 30 lines after a month will make you just puke your guts.
 
  • #26
C++ or Java would be good starting ones. I started out on C++ in 10th grade it really is not that hard, plus it is common same with java.
 
  • #27
Benzsk8 said:
C++ or Java would be good starting ones. I started out on C++ in 10th grade it really is not that hard, plus it is common same with java.

C++ is one of the most difficult languages in existence. Have you read the whole thread?

- Warren
 
  • #28
Fortran is also optimisable in ways that a C/C++ compiler can't match.
Because Fortran doesn't have pointers it can be sure at compile time how the elements of an array wil be accesed - this allows it to parallize automatically across a multiprocessor or vecter processor. If you have heavy number crunching to do - don't dismiss it.
Of course the tools suck and you end up working on a code base that's older than your parents - but that's notthe language's fault!
 
  • #29
Inkcoder said:
In saying the above I'm guessing that you don't really know how messy Perl can get when you program something over 30 lines. And then coming back to a Perl program longer than 30 lines after a month will make you just puke your guts.

I'm confused, because the text that you quoted has nothing to do with this assertion.

Anyway, I've been using Perl for 8 years, and have written programs of 1000s of lines of code. I know how messy it gets. In fact, I mentioned that very observation in my post.
 
  • #30
chroot said:
C++ is one of the most difficult languages in existence.

Although it's ultimately a subjective matter, I disagree completely with this. I find C++ to be considerably easier both to learn and use than, say, C.
 
  • #31
shoehorn said:
Although it's ultimately a subjective matter, I disagree completely with this. I find C++ to be considerably easier both to learn and use than, say, C.

Without wishing to be insulting or start a flame war - then you are almost certainly not using it fully or correctly.

C has a single programming paradigm ( I can't believe I just used that word ) = procedures and only one major gotcha = pointers, and is decribed in a 200 page book.
C++ supports procedural, object orientated and functional programming, has innumerable gotchas across RTTI, multiple inheritance, templates. It comes with a very complex standard library + STL + BOOST. Even a description of these fills half a bookshelf.

C++ is a better language for most large programming projects, but it isn't the palce to learn programming. C is an excellent introduction to how computers work and I believe knowing it is necessary to call yourself a programmer in whatever language. But I'm not sure it's where I would recommend someone start learning programming today.
 
  • #32
mgb_phys said:
Without wishing to be insulting or start a flame war - then you are almost certainly not using it fully or correctly.

Then I'll stop the possibility of starting a flame war by pointing out that you're completely incorrect about this. :smile:
 
  • #33
To toss my hat into the ring, C++ was my first real programming language. I also don't see any reason to learn C before learning C++ except if you actually intend to use C for something (i.e., don't learn C just as a stepping stone to C++)
 
  • #34
I started out learning C++ without having done any programming aside from QBASIC when I was a kid. Be prepared that when you start out nothing makes much sense but slowly you will pick up the terminology and begin to understand things.

You've just go to keep cramming in information and some of it will stick.
 
  • #35
I started on Turbo Pascal in college and it made life very easy. It also gives you good habbits. Then they moved us on to VB6 and I lost everything. I also started learning C which isn't to bad, but not great for starting.
 

Similar threads

  • Programming and Computer Science
Replies
21
Views
5K
  • Programming and Computer Science
Replies
6
Views
1K
Replies
3
Views
2K
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
4
Replies
107
Views
5K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
22
Views
1K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
3K
Back
Top