Preparation for learning PHP - easiest programming language for a beginner to learn?

Ding Ding. We have a winner.

However, I wouldn’t suggest learning javascript first. PHP 5.3 is probably the easiest jumping in point to the enterprise world. It is a relevant language to get fast results and caters to design patterns you will find in the enterprise b/c of namespaces and somewhat decent object model.

JavaScript is a different animal…much more so than most other languages. Hence the differing opinions on what to exactly consider it.

I haven’t run into node.js before. It’s certainly an interesting concept and appears to address the interesting issue of scaling resources. But–it’s not a ready-to-install application like apache or tomcat.

Yes, technically when you get down to it, most languages either fall into the scripting languages category, interpreted languages category, or the compiled languages category. But that doesn’t mean all languages strictly fall into one category or another, as the way they are designed, the attributes they have, and the platforms they run on can make it unclear as to what it is.

So yes, javascript can be an interpreted language. And yes, it can also be a scripting language. It has elements of both depending upon where it’s being used and what it’s being used for.

All this debate on what makes a programming language is rather entertaining.

However, it’s not to the point. Learning to program is like learning to fix. If you want to fix cars, I wouldn’t recommend learning to fix wheelbarrows. Sure, fixing wheelbarrows might have similar tools, and you still use those tools in a similar way (A spanner still goes anticlockwise to undo a bolt) but their overall use is different.

Of course, the better you are at fixing cars, the better your chances at fixing a wheelbarrow. Someone who’s good at DIY will probably pick up motorcycle maintenance faster than someone who isn’t.

If you want to be able to develop websites, learn PHP first. It’s well documented and will get you a good start into the programming world. Come up with problems and then find as many solutions as you can. Explore it. Then explore. Then learn Javascript. I suggest PHP before Javascript because many people who do it the other way around take longer to grasp what PHP is actually doing behind the scenes.

Then move onto whatever floats your boat, I suppose.

Off Topic:

Unless of course you want to program for ships. Then floating your boat should be the top priority.

I wouldn’t recommend Javascript as a first language because of it uses prototypical inheritance instead of classical inheritance. That is, the way object oriented programming works in javascript can throw you for a real curve ball. Scope is also very tricky in all dialects of EMCA. While these are advanced issues, they are front and center in javascript whereas in PHP they are less pronounced - and PHP uses classical inheritance like most languages.

Another reason not to take on the javascript bear first is how intimately tied it is to the DOM model. You can’t readily learn javascript until you have a concrete grasp of HTML and CSS.

That said, when the time comes to pick it up it won’t be too hard. As with PHP it’s a member of the Algol family of languages (C and it’s variants and Java also fall in this family). This means the basic syntax of code and control structures remains unchanged between languages for the most part (PHP being the odd man out by using the ‘\’, ‘->’ and ‘::’ operators where other languages use the ‘.’ operator.

Thanks everyone for your replies and suggestions.

Thanks for the tip deathshadow60, when buying books I always check the publication date. I agree that you can’t learn everything from a book, I intend to learn from a book and by actually playing round with the code.

Thanks StarLion, would you have any suggestions as to how I could go about doing that?

Javascript’s scoping issues are not that different in declaration visually than that of python which is for all intents and purposes one of the most popular programming languages in the world. In fact it is pretty easy to adopt conventions to avoid scoping issues that make it easy to go from one language to another. Here is an example of something you might see a java dev or python dev write in javascript.


var object = {

aVariable: "",
aHiddenVariable: "",

init: function() {
    var self = this;

    self.aVariable = self.doSomething('idTag');
    self.aHiddenVariable = self.doSomething(self, another-'idTag');
},

doSomthing: function(self, id) {
    id = self.doSomePrivateThing(id);
  
    return document.getElementByID(id);
},

doSomePrivateThing: function(something) {
    return "prefixSomeText" + something;
},

doAnotherThingMoreCheeky: function(elementID, hiddenNode, normalNode) {
    var tag = "#" + elementID;

    $(tag).bind('keyup', function() {
    if(typeof hiddenNode != "null") {
        hiddenNode.value = this.value;
    }
    normalNode.value = this.value;

    return;
});
}
 
}

object.init();
object.doAnotherThingMoreCheeky('idTag', object.aHiddenVariable, object.aVariable);

That isn’t too convoluted at all. Defining self as this in the init and passing it arround makes it easy not to get into conflicts inside jquery functions where this is the dom element you are working on.

It doesn’t look too, too different than python.


class object:
    __init__(self):
        self.aVariable = ""
        self.aHiddenVariable = ""

    def doSomething(self, something):
        return self.aMethodCall(something)    

    def doSomethingMoreCheeky(self, somethingA, somethingB):
        if(self.aVariable != null):
            aHiddenVariable = somethingA
        aVariable = somethingB
        return

    def aMethodCall(self, something):
        return //do some logic here    

The syntax of C vs python whitespace indentation are different but passing self around (basically catching the instance) isn’t that dirty. I think people complaining in the javascript world might just think Java, .NET and PHP simply are ‘right’ and ‘clean’ while javascript and python are ‘dirty’.

Of course python passes the instance to a method and you need to recieve it. You could easily use “this” or “that” or “lalalacandyland” to assign the instance a name. Javascript’s scoping issues are quite different and you could easily just use the native “this” or even use the object name since it is at a global as soon as you assign.

But that is neither here nor there. The fact remains that looking at the two’s sources, following established conventions, will not be too far off in regards to scoping issues at first glance. Some people only do self when they need to scope and that is ok too… javascript has implicit fascets but another person coming in behind you might not be a) a js developer and b) get cought up in this.hell

But meh… it doesn’t stop you from learning programming. You just don’t learn very many design patterns in javascript or ECMAScript which is hopefully the goal of any programmer because it allows you to interact with other developers and make reusable, extensible components.

I would suggest you start with C++. That is what I started with and it really gives you a good foundation for learning any other language. Once you have the fundamentals down, you will find that’s it really not that hard to pick up other languages.

Well the best way to learn, I find personally, is to try and do something.

You got a collection of baseball cards? Why not learn how to create a webpage for showing off the cards you have.

You play a sport? A webpage about your favorite team.

Pick something you -enjoy-, and make a project out of it.
Take some time before you even look at a piece of PHP, and plan things out.
Make a drawing of what you want each page of your site to do, and which page links to what. (I have a whiteboard that I use for brainstorming. Easy to erase when you change your mind - and every programmer does!)

If you really want to force yourself into a programming mind, take one page, and think through the logic of it. Let’s take an example.

If I made a page about… my sport’s team’s record this year. What would I want to do.

Well i’d have the header.
Then in the content section, I want to show the schedule. Maybe a table view.
And in that table view, a Win or Loss column.
But I want it to stand out a bit. So if the team won that game, I want the W to be blue. If they lost, I want the L to be red.
Oh, and at the bottom, I want to show a display with the Win/Loss numbers.

Now you’ve got a page plan - start trying to create it. If you run into something you dont know how to do, my first step would be to (pardon the acronymical swear) RTFM. Type into your browser: php.net/thingyourtryingtodo. Not sure how an if works? php.net/if . Want an array definition? php.net/array .

If that doesnt work, come back here, and ask for help. Be specific; be ready to show your code (Make an effort yourself, even if it’s pseudocode), and dont forget to obfuscate any passwords.

I started with PHP back when I was learning to program, and I tried to learn the syntax without actually understanding the basic theory behind it. I learned the syntax well but I didn’t know how to implement it. Once I understood the theory, it was much easier for me to grasp the syntax and it made more sense.

After you’ve learned the basics, go with a C based language. They make a good starting point as they are strict and not as loose as other languages are.

And? Last time I checked this isn’t the python forum. Most popular programming languages in the world? For each python job I see 10 C++ and 20 PHP jobs so, erm, no. It’s a niche language at best.

My point isn’t changed by your argument - rather reinforced. How javascript handles scope is different from most other ALGOL languages and this will be a stumbling block at first. It also different from most of the major languages (which python emphatically is NOT a major language - I would be surprised if it’s market share exceeded 10%).

You also didn’t address my main reason for not recommending Javascript as a starting language - it’s deployment of prototypical inheritance - a trait that is almost unique to it (I think SmallTalk is the only other language that uses that model). Classical object oriented inheritance is hard enough to learn without dealing without trying to learn prototypical inheritance at the same time.

(That said, prototypical inheritance is a lot more powerful and can even emulate classical inheritance, but grasping it takes a bit).

Bwahahaaa… oh man, you slay me. “C” and “strict/not loose” in the same sentence??? HAHAHA… Oh man, what a riot.

Your kidding, right?

Sorry, “Wirth” fan here, to me C is so sloppy and loose it’s no wonder 90% of the stuff written in it is buggy as all hell.

I guess I opened a can of worms here :). IMHO C# and C++ are very good starting points as they teach you good solid techniques and overall the basics of how to program. And for the most part C is a strongly-typed language

Also just FYI, alot of the scripting languages we have today are based off C :).

You are absolutely mad if you think Python isn’t a major language. How on earth could you ever, ever come up with some sort of idea? Python is behind nearly most new administration scripts in Unixland, dependency management program and virtual machine automation today.

You also didn’t address my main reason for not recommending Javascript as a starting language - it’s deployment of prototypical inheritance - a trait that is almost unique to it (I think SmallTalk is the only other language that uses that model). Classical object oriented inheritance is hard enough to learn without dealing without trying to learn prototypical inheritance at the same time.

(That said, prototypical inheritance is a lot more powerful and can even emulate classical inheritance, but grasping it takes a bit).

I wasn’t addressing prototypal inheritance because I wasn’t intending to. I was commenting on your comment about javascript’s scoping issue. Prototypal inheritance … who cares. Only people who hate javascript even talk about it. The same way only people who complain about assigning this to something else in js complain about it being dirty and a hastle.

But get real if you think Python is a second class language you are insane.

EVE Online
TRAC
Django
Pythons
Twisted Python
Bazzar
Hg ( Mecurial )
BitBucket Hg hoster
Anaconda - Fedora Installer
YUM - RPM management
Industrial Light and Magic use Python in their 3D modeling tools
BitTorrent - which alone blows your comment out of the water…
DropBox
Ubuntu Software Center

and the list goes on.

Sorry but you are just plain wrong.

There’s this attitude that if it’s not your favorite pet language, it doesn’t exist and nobody actually uses it.

indeed.

I mean half of amazon runs on python… facebook… again python… I guess those are niche cases though in his eyes.

See my list for Pascal – “Outdated fossil” indeed.

It’s ok to not like the language (I think python, ruby and anything with “ASP” in the name is total trash) – but to say it’s outdated, irrelevant, or any other disparagement about it’s popularity is just asinine. (says the guy who goes “wait, people still use coldfusion?!?” – we’re all guilty of it at some point!)

Oh, and on the subject of prototypal inheritance – it’s different, but not so different it should be a deal-breaker compared to classical constructors. That’s such a minor nit-pick given how every C syntax language basically has objects shoe-horned into them “any old way”. I’ve yet to see one that had objects make anywhere near as much sense as they do in Smalltalk, Oberon or Object Pascal (or should I call OP by it’s real name – SIMULA). Hell, even Lua does it better than most C syntax languages… but then I’d sooner program ALGOL than deal with C syntax languages; just for some unfathomable reason the needlessly cryptic C syntax has become the industry norm and what you’re EXPECTED to work with in most cases. It’s why as much as I dislike python or ruby, at least they’re trying to shake things up a bit syntactically.

The old adage, just because it’s popular doesn’t make it any good – See Wordpress, Dreamweaver, phpBB…

My main problem with prototypal is destructors end up broken due to the lack of true pointers – to go hand in hand with the lack of true pointers (one of PHP’s shortcomings) making doing the USEFUL stuff with objects (like linked lists, btree’s) painful at best, impossible at worst. “instancing” has to be one of the WORST concepts added to programming languages – I say destroy something, I want it gone NOW! null all reference pointers! Not the “Oh something is still pointing at it somewhere so we can’t do that, so we’ll just decrement the reference count instead” idiocy.

Languages are just tools. Whether it is cobol, coldfusion or C++ the only downside to a language is usually human errors when designing software and opinions people pick up when they hit a mental limitation they cannot overcome without understanding the foundation of the language they are using.

It is like the OOP guys bashing C, or overlooking it for something more ‘modern’ OOP language, when C is very capable of writing OOP code. You might not get polymorphism but that is not in itself inclusive of OOP.

You by all means can write OOP code in C. An easy way to get methods in structs is to just have to pass pointers to your struct in a function. Otherwise, under the hood a C++ struct compiles down similarly to a standard C struct written to do what I stated above.

The biggest difference you will find compilation wise is that the size of a struct with an extra variable will be bigger than the C++ struct that doesn’t need the extra variable for its method.

Meh, languages are tools. As long as there is a compiler for your target platform and your code is written well then who cares who uses what :shrugs:

Facebook is on PHP.

Look at job listings. For every python job there are dozens for C, PHP and Java. So yes, niche language.