When PHP Actually Is Your First Programming Language
reidburke.com
reidburke.com
It's also worthwhile to learn a lot of other languages. Do it as soon as possible in your career, especially Lisp and C. No matter what language you may use, you'll probably benefit from knowing these two. The danger with any "first language" is that you may never learn a second.
Also, learning Scheme as a first language almost guarantees you'll have to learn a second language. ;)
My primary bread-and-butter language is Javascript. When done "right", Javascript is a very expressive functional/prototypal object oriented language with a lot of very interesting features. If you can do it in lisp, you can do it in Javascript: http://foohack.com/tests/ycomb.html
I've seen in myself and in coworkers, the best Javascripters know at least a little lisp, and as their lisp skills increase, so do their javascript skills. I suspect it would have the same effect on Ruby or SML or Erlang programmers.
Their attitude towards boilerplate code tends to change as well, and they begin seek solutions that are as concise and expressive as possible.
Lisp is unique because it effectively has no syntax. You write the abstract syntax tree directly. By removing the scaffolding, Lisp exposes the programmer to the fundamental nature of any programming language in a way that no other programming language does.
That's why C and Lisp are the best languages to learn, as early as possible: if you know these two pretty well, you're in a good position to master any language you might come across.
Misc is a promising cousin of Lisp: http://will.thimbleby.net/misc/ I've played with it a little, but not enough to really have a strong opinion of it.
This seems odd to me. Working with Haskell for a while changed how I think about state. I usually avoid (non-trivially) mutable objects now, and instead return a modified copy of an object. (For an example, see the process method here: http://git.jrock.us/?p=Template-Refine.git;a=blob;f=lib/Temp... )
Also, Haskell's type classes (and CL's CLOS) are a different approach to OO compared to Smalltalk-style "send a message to the object". It is definitely good to be able to think about OO both ways.
I think the key is learning well at least few kinds of languages. C (is a must), an object oriented language (Java), then a scripting language (Python, Lua, Ruby, Javascript, or Perl), then a pure functional language.
Of course, often in real life, often you end up using what is being dictated to you, but a good programmer should be aware of what's out there.
Also, can of worms and all, but the borders between "an OO language" and "a scripting language" are quite thin. You could learn OO from Python or (I suspect) Ruby. OO design made quite a bit more sense to me when it didn't have to work around flaws in C, C++, and Java's type systems.
PHP's strength is it's so damn easy to write useful, simple scripts. And it's so fast to provide feedback, and it works with an existing metaphor many people understand (upload file to FTP, hit it in your web browser, bob's your uncle).
I found it very, very difficult to learn OO as the stdlib at the time was full of nothing but functions. I think you learn a hell of a lot from working with well designed APIs, and let us be brutally honest, PHP's stdlib is about as well designed as a shit-moulded santa claus.
I tried learning Java well enough to get some kind of commercial project off the ground but was befuddled, book after book why it took so damn much code to do _anything_. Though I did learn a lot about OO from reading these books, I never got an opportunity to get stuck into any Java to learn how to do things, at the time I perceived as the 'right way'.
But unlike PHP to get anything off the ground in Java, you had to install Tomcat, write about 20 lines of something and set up a web container and god knows what else. Compare this to plonking <?= $_GET['test'] ?> in a text file, call it 'blah.php' and hit it. Instant feedback.
Since then I've been working with Ruby for about 3 years, and I've finally got my head around how to write decent code, and it's mostly been because of exposure and experience with nice APIs, and being able to work with the higher level patterns that you are just simply not exposed to with rudimentary PHP.
Sure, today you have CakePHP, the Zend Framework but they only popped up in the last couple of years, and mostly in response to Rails' influence.
In between Rails and PHP I had toted with Perl and Python and enjoyed them thoroughly. I would suggest writing as much damn code as you can in a bunch of popular, and different languages, and you'll be fine :) I'm still yet to play with LISP and OCaml, though I'm keen to have a crack at Lua...
But if you want to be a generic programmer or get in to the field, it will save a lot of time and hassle if you start out with C/C++/Java. Those cover all the major concepts to begin with, and switching to PHP or any similar language would be very quick if not instantaneous.
Then again, I think it's even a better idea to start with something fun and something you really and feel like you are getting rather than jumping to something really complicated.
There is no one-size-fits-all language to start with, it depends from person to person.
I don't care much for programming: I'm much more interested in design. As such, I really don't think I'll need to learn anything beyond PHP and Javascript. Are there things that I, and people like me, will run into because we don't know any better from other languages?
The other problem is that both Javascript and PHP encourage implicit casts, which are great but lead to subtle issues you probably won't understand unless you learn a stricter language.
Yup. All those people saying it's bad - there is only one problem with it - it's too easy, and too many people use it.
Rather than repeat myself: http://news.ycombinator.com/item?id=324895
That's just blatantly false. They're probably good languages to know because they are collectively the lingua franca of programming at the moment, but there is quite a bit they never touch upon. Learning Scheme, Haskell, Prolog, or Forth would introduce you to ideas you would never encounter while using C & co.
The problem though is that almost every thing written in PHP looks like shit. So PHP programmers trying to learn a good writing style by looking at PHPbb or similar are shooting themselves in the foot. Aha! I could put PHP code in the database and run it by 'eval' - smart idea! Must be really secure templating / programming design since this is such a big project... And what's up with wordpress, a more programmer hostile templating engine is hard to find still people use it.
(just don't use BASIC)
There is NOTHING wrong with any of that! Making something more complicated does not make it better.
PS: I use a very strong templating library personally. It's called PHP.
When done right, all of those things have a place. My point is usually (with PHP at least) it's not done right.
I think the confusion here is that strong OOP is actually simpler. Breaking code into smaller chunks (such as objects) makes it more modular and easier to understand. That's the point.
I laugh so hard.