A question regarding PHP with respect to c++

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

A question regarding PHP with respect to c++

Post by Charles256 »

Okay..Here's the deal. I'm currently attending a university where hte CS program is just starting to bud and it is my intent in about four years to become a teacher at said school teaching CS. But, as I was thinking about this I immediatly thought, well, what could I do to make the university better? And a thought struck me. Seeing as how c++ is a hard language to learn off the bat.. (at least it kicked my ass when it was hte first language I tried to pick up) I was thinking of would it be of benefit to teach PHP first perhaps? I know it helped me, the more loosely typed structure, the abundance of functions and tutorials to help you figure out what your doing just make it a lot easier, IMO, to pick up the first time. That, and the great error reporting you get built in. :-D I.E. "we were expecting a semi-colon, you got a comma, WTF gives?!", roughly quoted:-D

So my question to you is, what would you think if PHP was taught as your first programming language in college? I would ask this as a poll but I want a little more in depth responses..

hoo..hum...
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

It is not the language you are teaching/learning, it is the methodology and the practices. :)

C++ is probably the best to learn with as it is the "most raw" language, you have to do nearly everything, unlike PHP which in comparison, does most of it for you.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Jenk wrote:It is not the language you are teaching/learning, it is the methodology and the practices. :)

C++ is probably the best to learn with as it is the "most raw" language, you have to do nearly everything, unlike PHP which in comparison, does most of it for you.
Its funny how teaching theory goes around over time. Back in the day, Pascal was thought to be a nearly perfect teaching language for just that reason - lots of power, lots of things that students needed to "get" to do a solid program.

Then rapid-fire it was virtually replaced by Basic, because suddenly, teachers were able to get students to - gasp - actually write programs that worked without a ton of pain!

Oddly, then we moved from Basic to C, because C was so widely used that "Students should learn what they are going to use in the real world". Much like Pascal, it requires students to truly understand what they are doing, and why, to get things working.

In the last few years, in some colleges, it has become popular to switch to Java, because it has very "clean" object oriented interfaces, and relates well to teaching methodology and practices, plus its useful on the web - which is where the action is.

I hope you see the back and forth trending between the "less pain, easier to code", and "more formal, clear understanding of material" philosophies that made each change "make sense".

Personally, I think the *dramatic* decrease in the number of CS majors has a pretty solid relationship to those changes in philosophy. One thing is clear: Formal education needs to revamp CS to make it more attractive in general, and especially more attractive to women. If that means embracing languages that are simple to get started in, and tough to become an expert in (like php), so be it.

Whether that is the proper approach is a topic for a mind-numbing argument, but obviously, I think php as a teaching language has a huge amount of merit.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

Yeah. Please note I'm not trying to advocate getting rid of c++, rather I am saying teach PHP for say the first year, then c++ the second year, and some other programming theory classes.

I actually preferred learning PHP first, it made c++ make so much sense the second time around. any other input?
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Charles256 wrote:I actually preferred learning PHP first, it made c++ make so much sense the second time around. any other input?
First year CS with PHP? Ok, what do they teach? They still teaching "Data Structures and Algorithms" and "Fundamentals of Software Development" in the first year? For "Data Structures and Algorithms" I would want something more strongly typed than PHP. For the "Fundamentals of Software Development" I would want to stress OOP and while PHP could probably cover the fundamentals - I'd prefer something more suit to the subject. Something more strictly OO'ed.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

I taught myself PHP than started teaching myself c++, they didn't actually teach that at my college. they start out with c++ :)
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Post by trukfixer »

I taught myself in BASIC and Assembly on a commodore Plus/4 and 128D .. finally in around '96 I got a windows PC , quickly learned HTML, picked up a bit of perl , then got into PHP (learning a great deal from Roja) , since then, Ive also been learning python , more perl, and looking at C.. Learned a slight amount of Pike, Ruby and TCL ..

To make a long story short, in all the languages Ive learned (or learned something about) I have found that python, while it can be a genuine, first class pain in the {SMURF!} has a great deal in common between C and PHP .. it is slightly more loosely typed than C (but then again, everything is an object in python) but it is much more strict in layout, indenting, and general coding habits than either language (precise indentation is an absolute must) but like PHP, Python is relatively easy to learn , has a rich, robust set of functions (modules , objects and classes) , and uses more complete english than C.


If I were to teach a course in *any* language, the first few lessons would be focused on format and coding habits, coding practices and documenting what you are doing.. The following few lessons would be a focused discussion on logic and reasoning , and learning to think like a computer (Computers are *STUPID* - they do *EXACTLY* what you tell them to, nothing more, nothing less) once you understand how a computer see's your instructions, you learn how to see the holes you leave open (for security, unexpected bugs, etc) In other words, learning to be precisely explicit...

and then , and only then , would I start introducing them to the targeted language, whether it be oop or procedural to start with, the important thing would be getting them to apply the basics of what they had just learned in the first few lessons, rather than the language..

Programming is 90% logic and 10% syntax. once you learn the logic, the way of thinking , any language is actually quite easy to pick up well enough to debug code ( I have never written a C program, yet I am able to read the code and logic flow, because I understand how the logic works)

Flowcharting? I'd toss it out the window as soon as you'd taught the very basics of logic - it's a visual aid, nothing more...
and it does no good, when you're under fire, and standing at a terminal in the datacenter, no books, no visual aids, no refernce manuals, and trying to read an obscure bit of code, you need to know how logic works from the point of view of the computer.. and flowcharts will only be of help as a learning aid, really .. I'd never teach someone to rely on flowcharting as a primary means of writing or debugging code.

so I dont know what language I would recommend most , but I dont think PHP wouldd be my first choice , because it is so loosely structured, it lets too many people learn bad coding habits that are damned hard to break later on... and the dropouts from the classes, now know just enough php to be dangerous, but not enough to be worth a damn..

so I would lean more towards a language like python as the first language I would want to learn/teach. From, it, I can now see where I could learn much better in both php and C .. learning python, all of a sudden, certain ways that PHP has of working, (includng a lot of OOP related PHP stuff) , and so many things in C that at first seemed obscure, now make perfect sense..

Whew.. I guess I should shut up and go hide in a woodchuck hole - Roja's probably gonna be a little steamed at me--
Roja: What??!! Championing Python over php?? BLASPHEMER!
hehehe
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

When I was graduating from high school it was pretty much understood that college was going to be hard. If you were an academic lightweight you needed to go to trade school and learn to weld, or join the Army, because college was hard. You had to hit the books and study and work your brain because the subject matter was not for casual lightweights, it was hard.

So. The question is, what do you wnat your CS department to do? Do you want it to be fun? Or do you want it to teach the process and discipline of programming?

The more that the high-level language does for you, the less you have to learn. A grade schooler can learn to write programs in BASIC pretty rapidly, and will have a lot of fun in the process. But how much will that student have really have learned in the process?

If I were working on a budding CS department I wouldn't be worrying about how easy it was going to be, I would be worrying about how thorough I could make it. In fact, I think I would make it hard on purpose to make the students open and develop their minds. C++, no question.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

I don't know honestly. PHP isn't exactly a programing language, it's a scripting language #1. It has some of the same syntaxes and fundamentals, but it's still a scripting language. Thus why they start you out in c/c++, a widely known, accespted, and used programming language. With a given knowledge of C/C++, you can in turn learn any programming language using the fundamentals that C/C++ teaches you.

Now, flip flop to PHP. If i had learned PHP before c/c++ (or any of the other programming languages i've learned), I seriously believe I would be in trouble. Simply because while php has an OOP style, and it has drastically improved, it's still not a true 100% OOP style language. C, however, will teach you all the sides of OOP you could ever wonder. Also, C teaches you about memory managment which PHP will not. Where you would learn how to make something work in PHP, you won't understand how it is effecting memory unless you can understand it from a C perspective. While php has functions that allow you to do memory dumps and what not, you cannot control those memory sectors, as again it's a scripting language, not a machine language such as C.

So, I guess what I'm trying to say is, no, it wouldn't be too good of an idea to give students that are completely new to programming and the CS side of things a scripting language as their first course to programming, because it's not programming, it's scripting. If you added it as an elective to where students could branch off to learn (as they do with ASP and Perl is some colleges), that would in turn be a better method. But no, a 1, 2nd, and MAYBE not even a 3rd year student should be fooling with php until they understand teh concepts and fundamentals of what a programming langauge is really about...

PS: CS is not intended to be easy. That is why you get the big bucks when ur out of school. If CS were easy, more people would have degrees, we'd all be getting paid less, and we'd all have to be finding the *new wave* technology to join. Not everyone is out to be a CS major, but those of us who are were meant to be CS Majors. Not people who nit pick around and do silly scripting languages to just get by (and no, i'm not saying that's is your intention, just stating the facts).


just my opinion at least.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

IMO teaching PHP before C++ is similar to teaching BASIC before C... its the same thing. When you are accustomed to programming in way that never has you worry about those little details and suddenly you have to handle a completely different animal. It really tough, yeah!

Like many VB programmers have put on a petition demanding ol' VB be brought back because they can't seem to get away with VB.NET :lol: So rather than pampering them with a soft core language, let them learn it in true man's way :wink:
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

infolock wrote:I don't know honestly. PHP isn't exactly a programing language, it's a scripting language #1.
What is a programming language? What is a scripting language? Where lies the difference? Personally, i think it's pretty hard to make a formal distinction..
infolock wrote: Simply because while php has an OOP style, and it has drastically improved, it's still not a true 100% OOP style language.
What is a 100% OOP style language? And how has the implementation of the PHP object model kept you from implementing something?
infolock wrote: C, however, will teach you all the sides of OOP you could ever wonder. Also, C teaches you about memory managment which PHP will not.
Actually, apart from the early C++ macro's i haven't seen much C code that uses OO features.
infolock wrote: Where you would learn how to make something work in PHP, you won't understand how it is effecting memory unless you can understand it from a C perspective. While php has functions that allow you to do memory dumps and what not, you cannot control those memory sectors, as again it's a scripting language, not a machine language such as C.
The question is: What do you want them to learn? Machine specific stuff? Memory management? Or do you prefer to get things done, focussing on algorithms and patterns?

I think that is a reason why most colleges teach Java instead of C++ as introduction language. And in the past that language used to be (Turbo) Pascal.

Usually they also spend a couple of hours playing with a dynamic/interpreted language like perl/php and visual basic. Just to make the student notice that for each problem there may be a more appropriate solution.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Well at my college we learnt Visual Basic. I'm still learning it now, it's awful. It was the first programming language I ever learnt, but before I learnt it, I knew basic HTML and a tiny bit about PHP from merely editting scripts in the dark and testing them.

Visual Basic sucks, now I've used ASP a bit aswell, I think that sucks aswell, I hate all the literal operators, If x = 2 Then do this End If. I mean, PHP is so much easier to read, and it flows alot better to me.

I can't give that much of a view because I don't know many programming languages, but that's all I wanted to say :)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

Just for the record I'm wooping c++'s ever loving ass after coming from PHP so I'd be willing to venture it's not that hard to switch over from PHP, in opposition to hat most of you seem to think. :) The reason I say teach PHP first is because I'm a fan of getting people to think like a programmer and if I can get this person to think like a programmer then I can teach him how to dump his memory later;) Also, by the time I get to teaching PHP will be OOP probably ;) Which means we get all the objects we want. Yes, programming is supposed to be challenging but I don't see any good reason to make it any harder than it has to be and coming from nothing to c++ is a kick in the face to say the least.

On a side note my school teaches VB :-/ and I can't figure out way..then again I could be hating :)

As a side note: Perhaps instead of an easier language first perhaps just lengthening the amount of time c++ is taught... Instead of one year, make it two. Because as it stands I am considered proficient with c++ after one year and 20 homework assignments. Yeah right! People in my class can barely string together the code. Only reason I'm any better off is because...well... :: points to the stack of books and all the nights spent programming.::

hmmm...
not sure what the answer to the question is..damn it. lol
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

jayshields wrote:Well at my college we learnt Visual Basic. I'm still learning it now, it's awful.
Yeah my uni taught me VB in our first year as our introduction to programming. Bear in mind that I was on a multimedia course so I'd say 60 - 75% of the class was actually coming in from a graphic design background. Me? I was pretty open minded, which was just as well cos it turned out I pretty much sucked as a designer!

They taught us VB as a foundation for other scripting/programming later on in the course. The next language we did was Lingo for Director, and in the 2nd year (optionally) Java.

Now when some of us went to do Java most of us just could not get our heads around it! Why? Because the so called building blocks we were given in the first year were dumbed down languages that were designed with a syntax that kind of read like english for designers that wanted to pretend to program. :wink:

I don't believe that helps anybody. I mean if you look at Lingo now compared to Director 7 its moved from being like "move this here" to "sprite(1).loch = 100". The same has happened to Actionscript which now follows the ECMA-262 standard, and by the sounds of it a similar thing is going on between VB and VB.NET (I haven't checked this).

So why are these languages evolving in this direction? Because it gives more power and control to the programmer. The computer is not meant to be in charge!

At least when I learned PHP (without the help of Uni I might add - refund my tuition fees!!!) I learned a more universal prgramming syntax and can now understand Java, C etc to a point even if I don't use them often.

I think CS students should be thrown in at the deep end with C/C++. That way taking other languages up will be easier and not an uphill struggle. I know I would have appreciated it.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

timvw wrote:
infolock wrote:I don't know honestly. PHP isn't exactly a programing language, it's a scripting language #1.
What is a programming language? What is a scripting language? Where lies the difference? Personally, i think it's pretty hard to make a formal distinction..
infolock wrote: Simply because while php has an OOP style, and it has drastically improved, it's still not a true 100% OOP style language.
What is a 100% OOP style language? And how has the implementation of the PHP object model kept you from implementing something?
infolock wrote: C, however, will teach you all the sides of OOP you could ever wonder. Also, C teaches you about memory managment which PHP will not.
Actually, apart from the early C++ macro's i haven't seen much C code that uses OO features.
infolock wrote: Where you would learn how to make something work in PHP, you won't understand how it is effecting memory unless you can understand it from a C perspective. While php has functions that allow you to do memory dumps and what not, you cannot control those memory sectors, as again it's a scripting language, not a machine language such as C.
The question is: What do you want them to learn? Machine specific stuff? Memory management? Or do you prefer to get things done, focussing on algorithms and patterns?

I think that is a reason why most colleges teach Java instead of C++ as introduction language. And in the past that language used to be (Turbo) Pascal.

Usually they also spend a couple of hours playing with a dynamic/interpreted language like perl/php and visual basic. Just to make the student notice that for each problem there may be a more appropriate solution.
I could write this out, but this site goes into a much deeper response to these questions than I can personally respond with. http://home.pacbell.net/ouster/scripting.html

But simply put, a programming langauges stays at a machine level, which means it takes less processor speed to execute commands, whereas a scripting language is thrown into an interpreter, turned into machine level code, and then executed every single time the script is run.

The thing that makes understanding this better from a programmers perspective is that you are at all times on the machine level when your code executes. Thus you have to have understanding of how many cycles your app is going to put onto a processor, how much memory it's taking up, how to handle memory dumps, and so on.


As for the OOP Side of things, I guess I'm coming from a php 4.1 perspective where there is no contructor, destructor, or private/public/protected/final/static methods to apply to classes/functions/variables, and no exception handling (which is a biggie). Maybe php 5 handles these things, but I'm not sure as i havne't dove into that side of it. But from what I have heard, php 5 is a lot closer to a true OOP now. So, Maybe I opend my mouth a little too wide on that argument.

Anyways, I guess it just boils down to what it is you want to accomplish. If you want to be a scripter (which means another application takes control to interpret and execute your application using the syntaxes you throw to it) or a programmer on a machine level (which takes code such as C++ or C and compiltes it to be always ready for execution), it's up to you. But for someone to say PHP would be better to learn before C in a CS degree enviorment is wrong because you are NOT learning a language on a machine level, which is the whole purpose of learning C++. You cannot control how your machine acts, behaves, manages itself or whatever. You can only control what is on the outer shell that you could control via a termal window at best.

I'm not knocking php. I love it. I just don't think it's appropriate for a CS perspective as anything more than an elective class..
Locked