Spring Into PHP 5 229
Michael J. Ross writes "A professional programmer could at any time be tasked with developing a nontrivial application using a language or Web technology with which he or she is unfamiliar. A common response is to quickly scan code snippets in Internet newsgroups and online tutorials, copy and paste code that looks applicable to the task at hand, and then lose valuable time trying to make it all work and control what was created -- not unlike Dr. Frankenstein's experience. A smarter approach is to learn the language basics in sequence as rapidly as possible, not getting bogged down in excessive sample code. For developers seeking to learn PHP using the latter approach, Steven Holzner's Spring Into PHP 5, published by Addison-Wesley, would be an excellent choice." Read on for the rest of Ross's review.
Spring Into PHP 5 | |
author | Steven Holzner |
pages | 340 |
publisher | Addison-Wesley |
rating | 8 |
reviewer | Michael J. Ross |
ISBN | 0131498622 |
summary | A comprehensive and no-nonsense primer on the basics of PHP. |
This title is another entry in Addison-Wesley's promising "Spring Into" series, which, as suggested by the name, is aimed at developers who want to jump into a new technology and get up to speed as quickly as possible, but without missing any of the essentials. In the case of Holzner's PHP book, this goal is pursued by presenting the information in so-called "chunks," with each spanning just a few pages. Every chunk attempts to cover only one or a few related ideas, and is designed to build upon earlier chunks. The bulk of the explanation takes the form of code samples, which fortunately are short enough in length and clear enough in composition to be easily digestible. This is in stark contrast to far too many other programming books on the market, whose code samples can span multiple pages, making it difficult for the reader to discern all of the ideas that the author is trying to get across -- especially when the reader has to flip back and forth between pages. Even worse is how some authors (such as Deitel and Deitel) use lengthy code listings -- sometimes even complete applications -- to demonstrate many ideas at once, which can be quite confusing, especially for the newbie reading about a challenging language for the first time. As Holzner notes in his preface, his book is example-oriented, with dozens of tested code samples. But none are overwhelming.
Spring Into PHP 5 was published on 12 April 2005. It is organized into nine chapters, covering a range of topics: PHP essentials; operators and flow control; strings and arrays; functions; PHP in HTML pages; Web forms and input validation; object-oriented programming and file handling; PHP and databases; cookies, user sessions, FTP, e-mail, and hit counters. The book has two appendices. The first one, on PHP language elements, is remarkably complete, considering that it only fills 18 pages. Owners of the book will likely find themselves turning to this material quite frequently. The second appendix lists the most commonly used functions in PHP, particularly those dealing with arrays, strings, and files. These two appendices combined go a long way to making this book more than an approachable primer -- it could serve as a reference book for the language for any reader not required to dig into the more obscure intricacies of PHP. Readers with those needs will have to use more detailed sources, such as the online PHP Manual.
Each one of Holzner's chapters explains the core concepts, using the bite-sized chunks mentioned earlier. This approach is somewhat similar to the "recipes" found in many books published by O'Reilly Media, and it works well here for introducing a computer language. Holzner's writing style is clear yet never condescending, and concise yet never cryptic. The intended reader only really needs an understanding of simple HTML and how to edit text files, to make this book worthwhile and usable. The book is meaty with information, and yet not too lengthy. This is a refreshing change of pace from countless other computer language books that are bloated with redundant sample code and overly wide margins, apparently in an attempt to entice the consumer with maximum page count per dollar.
Some programming books try to move the novice along at too rapid a pace, which can get quite discouraging if and when the reader is unable to follow the discussion, and particularly if trying to follow the author in building a working example. But a far more common mistake among programming books, is to drag out the process with humongous code listings or redundant verbiage (such as following the senseless rule of telling the reader something three times -- a technique that makes far more sense for speechwriting). Holzner sets and maintains an excellent pace, partly by keeping the code snippets reasonably sized, and partly through his modular approach of presenting ideas in chunks.
The physical book itself is well made and attractive, with a readable font face and size, and intelligent use of bolding to highlight those lines of code upon which the reader should focus. My only complaint in terms of the presentation, is that the gray background used for the code samples could be lightened up a bit, to make the text itself stand out more, especially the bold text. All of the screenshots are in black-and-white, which works just fine, as there would be no value in using color in the majority of the sample Web pages.
The author does an excellent job of explaining and illustrating all of the most commonly used and needed elements of the language. But he provides little guidance as to when a particular technique or approach should be used over another. For instance, when explaining how the programmer can use PHP to connect to a MySQL database, the author presents two alternatives -- direct layer and Pear::DB -- but no recommendations as to the choice of one over the other. On the other hand, one might argue that to include recommendations of techniques, as well as language best practices, would require the book to be much longer than it is, which would detract from the book's goal of getting a programmer up to speed on PHP in an efficient manner. The serious programmer who wishes to take PHP to the next level, can be expected to read more advanced books, to learn from expert PHP developers posting in online newsgroups, and to learn from experience as the programmer creates his or her own applications.
Another potential point of criticism could be that the book does not adequately explain how to use PHP with the various available database systems, only covering MySQL (the industry's favorite for use with PHP). But the database chapter, number 8, provides just enough information for the beginner to get started and to try out the basics. For simple database needs, the material in that chapter might be sufficient. Yet for more extensive MySQL usage, including installation and administration, other resources will need to be consulted. This book is clearly not intended to be one of those PHP + MySQL combo books that have proven so popular during the past few years.
The publisher's Web site for the book does not appear to have any collection of errata. Here are some that I found: On page 6, in the NOTE, "scripts can be used" should read "scripts cannot be used." On page 20, "#/ message to the user" should read "# message to the user." On page 49, in Table 2-4, in the last line, the formatting is partly wrong. Examples 3-1 through 4-14 contain incorrect indentation. On page 158, the last line in the $_FILES['userfile'] values is missing $_FILES['userfile']['error']. In Examples 5-19 and 5-20, the <head> and <h1> tags are missing ": Take 1." On page 169, the formatting of Example 6-2 is inconsistent with the others.
Aside from the errata, there were some other weaknesses -- none of them serious: The chapter summaries are useless, like in most other technical books, as there's not enough details to be instructive, and more details would make them even more redundant and space-consuming. On page 176, in Figure 6-6's caption, "Navigating" should be "Redirected." On page 197, the discussion of HTTP authentication is too brief to enable the typical reader to implement it. For instance, there is no mention of where to set $_SERVER[ 'PHP_AUTH_USER' ] to make it work. Chapter 7, on object-oriented programming and file handling, should be split into two chapters. Combining them makes no sense, and the author does not even transition from the first topic to the second.
Like others in the "Spring Into" series, this title is reasonably priced, at only $29.99 list for over 300 pages of quality material. The publisher, Addison-Wesley, has a page on their Web site devoted to the book, which includes a book description, a table of contents, an index, source code from the book, and a link for downloading a sample chapter (in PDF format), namely, Chapter 3, which covers strings and arrays. The site also has a link to a bonus chapter (also in PDF) that explains how to draw graphics interactively on a Web server and then send them back to the browser. Oddly enough, the page's title is "Spring Into PHP 5 - $20.99," but there's no indication as to how to get the book for only $20.99. That could simply be a typo. But there is a link to purchase the book online for $26.99. For those looking to spring into Web server-side development in general, or PHP in particular, it would be money well spent.
Michael J. Ross is a freelance writer, computer consultant, and the editor of the free newsletter for PristinePlanet.com. You can purchase Spring Into PHP 5 from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
wtf? (Score:2, Insightful)
Pretty Home Pages (Score:2, Informative)
echo "TD> blah blah blah
echo "TD> and so on
echo "/TR";
echo "/TABLE";
ick.
And I remember somewhere it said PHP stands for "Pretty Home Pages"
wtf indeed.
Re:Pretty Home Pages (Score:2)
It used to stand for "Personal Home Page".
Re:wtf? (Score:2)
Still, professional programmers probably don't use PHP at all - i've never met one who does.
Re:wtf? (Score:4, Insightful)
So then, all the enterprise PHP you see out there (that's right I said enterprise PHP) must be written by amatures?) So like...Yahoo is just a bunch of retards? [yahoo.com] Do you not notice how much of the really advanced web-apps are php these days? It's like some guy who writes machine code saying..."yeah....perl is just for dummies". Cmon Idiot!
A better point would be that PHP is so easy to learn and flexable enough to do POORLY, that anyone with a logical brain, a book, and a text editer can "code" a simple widget.
PHP is here to stay. Get over it!
Re:wtf? (Score:2)
Oh good, I was hoping this book review could serve as a springboard for Yet Another Language Advocacy Flamewar. Thanks for not letting me down, SolitaryMan.
You jackass.
Re:wtf? (Score:2, Informative)
Re:wtf? (Score:2)
php_flag register_globals 1
To buy or not to buy, the reviewer doesn't know! (Score:2, Troll)
So, even though most people use PHP + MySQL and books of the type have been popular this one doesn't do that.
Another potential point of criticism could be that the book does not adequately explain how to use PHP with the various available database systems, only covering MySQL (the industry's favorite for use with PHP).
But yet it does explain MySQL? Which is it? I'm not going t
Re:To buy or not to buy, the reviewer doesn't know (Score:2, Interesting)
Re:To buy or not to buy, the reviewer doesn't know (Score:2)
Are you inferring that the reviewer thought the book was a joke and that I should assume that from what he wrote?
I took a look at the header above his confused review and saw that he rated it an 8 (I assume out of 10). If you are really inferring that I shouldn't take his review "seriously" and that I should instead assume he was joking around about the book perhaps he should have rated it
Re:To buy or not to buy, the reviewer doesn't know (Score:2)
Parent post: "But yet it does explain MySQL? Which is it? I'm not going to buy the book if the reviewer can't figure it out."
The reviewer is saying the book explains how to use PHP with the database program MySQL, but not with other database programs such as Lotus Notes or Oracle.
Re:To buy or not to buy, the reviewer doesn't know (Score:2)
This book is clearly not intended to be one of those PHP + MySQL combo books that have proven so popular during the past few years.
So, if it's not meant to be a PHP + MySQL book and it's not showing the other options what exactly is the book doing? The reviewer doesn't know.
Thanks for proving my point.
Re:To buy or not to buy, the reviewer doesn't know (Score:2)
"The book is clearly not intended to be one of those PHP + MySQL combo books" : The book does not have a heavy focus on MySQL.
"For simple database needs, the material in that chapter might be sufficient. Yet for more extensive MySQL usage, including installation and administration, other resources will need to be consulted." : The book covers MySQL, but not in too much depth.
"...the book does not adequately explain how to use PHP with the
Re:To buy or not to buy, the reviewer doesn't know (Score:3, Interesting)
But yet it does explain MySQL? Which is it? I'm not going to buy the book if the reviewer can't figure it out.
In other words, the book isn't centered around
A smarter approach? Learn the idioms and toolkits (Score:3, Insightful)
In my experience a language becomes useful when you also learn the frequent idioms and know the available toolkits.
Re:A smarter approach? Learn the idioms and toolki (Score:2)
Idioms? Don't you mean memes?
(I'm making fun of the over-use of the word 'meme' round these parts, for those that are wondering what I am saying here.)
Re:A smarter approach? Learn the idioms and toolki (Score:2)
Re:A smarter approach? Learn the idioms and toolki (Score:2)
What are you talking about?
Bogged down by sample code?? (Score:5, Insightful)
Excuse me? Maybe I'm an anomoly, but I can't think of a better way to learn a language than by example. This suspiciously sounds like and excuse to cover up the fact that the book doesn't offer adequate material to show how one can code in real-world environments.
When I look for a good programming book, be it an introduction, advanced tutorial or reference, the use of lots of examples is one of the main standards by which I judge the value of the publication.
Re:Bogged down by sample code?? (Score:2, Insightful)
Re:Bogged down by sample code?? (Score:3, Funny)
Though I imagine for a beginner those nasty regexs of invalid code could bog you down a bit...
Re:Bogged down by sample code?? (Score:2, Informative)
PHP vs Ruby On Rails (Score:2, Interesting)
Re:PHP vs Ruby On Rails (Score:2, Informative)
Now you could compare Ruby to PHP or Rails to an mvc PHP framework like Cake.
But PHP against Ruby on Rails is Apples vs Oranges.
Re:PHP vs Ruby On Rails (Score:2)
1) PHP is the most common. I don't care what the Slashdot summary says, I like being able to find code snippets that have already solved the problem I have.
2) Corollary, PHP runs everywhere. Whatever the hell webhost the client went with, it probably already has PHP installed.
3) PHP is blindingly simple. If you're coming into web programming from desktop programming, you already speak C, and PHP is like C with anyt
Re:PHP vs Ruby On Rails (Score:2)
PHP is blindingly simple. If you're coming into web programming from desktop programming, you already speak C, and PHP is like C with anything remotely complicated taken out.
"@" is a special character in PHP, used before a function call, to supress errors from being directly printed. That is about as un-simple as you can get in my opinion. There are all sorts of strange, inconsistent, or overly-specific aspects to the language. PHP is not even remotely like C, except for the { }.
i've gotta say.... (Score:2)
Re:i've gotta say.... (Score:3, Interesting)
I use php for most everything now, especially since php-cli came out. I even write my shell scripts in it now.
A few weeks ago I had to write a site that would allow users to input obituaries (I work in newspapers) and send off an XML feed and any binary images to an FTP server. The cool part is that the SAME script can be run from a command lin
Re:i've gotta say.... (Score:2)
Proposal for new Slashdot topic/section: (Score:2)
Re:Proposal for new Slashdot topic/section: (Score:2)
PHP's effect on Linux's reputation. (Score:3, Interesting)
Now it's no secret that PHP has suffered from some pretty serious security issues as of late, such as the XML-RPC flaw. Then there are the routine problems of poorly developed blog and CMS systems being defaced. Many of these problems are attributed to inexperienced users writing what amounts to completely horrible code.
While the developers of PHP itself are very talented and quite respected, the users of PHP are starting to cause problems for the Linux community as a whole. Each time a site is defaced due to some poorly written PHP script, it is often portrayed as a vulnerability with Linux itself. Of course that is more often than not a complete falsity, as the fault does not lie in any way with the Linux kernel or its developers.
So while Linux advocates often promote the use of PHP for developing webapps on Linux, PHP is starting to become more of a liability. Every site running Linux and PHP that gets defaced due to terribly written PHP scripts reflects very poorly on Linux's public image. Now I have to ask: what is the Linux community willing to do about this problem?
Would they even be willing to go so far as to demand that the PHP developers include functionality to severely limit the ability of faulty scripts to run? It's quite difficult to say at this point. But if changes aren't made fairly soon, then things could degrade very quickly.
Re:PHP's effect on Linux's reputation. (Score:3, Insightful)
It also makes claims of a solution which is incomplete. WTF? 'Would they even be willing to go so far as to demand that the PHP developers include functionality to severely limit the ability of faulty scripts to run?'
Demand to make C programs unable to be hacked.
Demand that perl programs are unable to be hacked.
Demand that assembly programs are unable to be hacked.
How about looking at
Re:PHP's effect on Linux's reputation. (Score:3, Funny)
I know! Linux advocates should promote the use of PHP for developing webapps on Windows!
Re:PHP's effect on Linux's reputation. (Score:3, Funny)
Re:PHP's effect on Linux's reputation. (Score:4, Insightful)
Re:PHP's effect on Linux's reputation. (Score:2)
Linux advocates often suggest that Linux is a very secure server platform. Indeed, Linux itself often is. But such advocates often advocate the use of a language like PHP for web development. Each time a well-publicized PHP flaw or script is exploited, it tarnishes the reputation of Linux due to the close association between the two.
So what is in
Do we need another entry level book? (Score:3, Insightful)
I am not knocking this book by any means. It is probably very good. But can't any developer who knows a C-ish syntax language pick up PHP basics quickly? I learned it in a day or two just by analogy with C/Perl/etc. How much need/demand is there for entry level books like this?
Where computer books have value to me is when they teach me something that would take hours/days/weeks to learn by trial-and-error. Something non-trivial that can't be guessed from reading the doc. (Like setting up user authentication or something.) That's when I start thinking about spending cash on books which have value by saving me time and especially frustration. (The PHP Cookbook, for example.)
A rather large claim (Score:2)
A smarter approach is to learn the language basics in sequence as rapidly as possible, not getting bogged down in excessive sample code.
Define "excessive". And why is that way smarter?
Learning by example is a pretty common pedagogic approach after all.
Wait a minute.... (Score:2, Funny)
color me stunned!
-mix
Tasked (Score:2, Funny)
tasked
Must be an MBA.
I've just started to read this book... (Score:5, Informative)
Overall, this is a pretty good idea for a book, but the editors/author should not have rushed it to press - the quality of the book appears to have suffered.
I would strongly encourage a potential buyer of this book to spend several minutes with the book and see if the style suits your manner of learnig. Personally, I prefer the O'Reilly Learning series [oreilly.com] approach to teaching a topic, but preferences vary.
And I'll say it again... (Score:4, Insightful)
Arguably, there are a few books written which at first seem to be written well. Hell, who isn't tempted to pick up a book now and again which has names such as "Rasmus" and "Andi" etc stamped across the front in large gaping print. But these books are just as useless as those written by lesser-known authors, and shouldn't be used because of the same failings of other books: They're error-prone, and almost immediately deprecated. PHP changes rapidly, very rapidly. Possibly too rapidly for its own good, but that's another discussion entirely. Point being that you can't commit changes to the cvs repository of a book as you can to the PHP manual, and as such any printed book will fall far short of being as up to date as the PHP manual.
If you need a resource to "teach you PHP quickly" there is generally only one chapter you need to read in its entirety, and that is php.net/langref. Anyone willing to take the time to do that can pick up the (extremely easy and basic) syntax of PHP within 2 to 4 hours. From there all one need do is hit the extension documentation pages of any API they may wish to use, such as php.net/mysql, php.net/pcre, etc.
I love PHP (Score:2, Insightful)
I'm a huge PHP fan.
But even I'm getting sick of these PHP reviews.
other PHP books (Score:2)
I recently got, and am slowly going through, "Beginning PHP 5 and MySQL: From Novice to Professional," and it's okay, but no more than that. A strange ordering of what's taught when, but it's working thus far. I hope it works
Cargo cult programming (Score:2)
This is what I call "Cargo cult programming" -- when you copy something that worked somewhere else, make what look to be the appropriate changes, and hope.
Although not admirable, I have done this a number of times. (JCL! Argh!) Sometimes you just need to make a minor change to a program in a language you don't know.
The Jargon file has a slightly different d
PHP5 would cost us $15,000 to run (Score:3, Interesting)
PHP5 DOES runs great if you run it through Zend Platform (an opcode accelerator), which costs $1500 a year per dual-CPU server. There are free alternatives to this (eAccelerator and APC), but none of them optimize the new PHP5 class syntax like Zend, and talk of instability is common. Do some simple memory benchmarks and you will see (just load your classes, you dont even run any code it to see it guzzle memory!!).
For us to run PHP5, it would cost over $15,000 per year, which is more than our servers are worth!
I feel held at ransom by Zend. Small shops like us are left out in the cold. We are abandoning it and switching to mod_perl and Catalyst on CentOS4.
PHP does not feel "free" the way Perl or Apache are. I guess it is Zend's language after all.
Re:I enjoy PHP ... (Score:4, Insightful)
Who are you trying to impress? Why don't you just write whatever PHP you need to get the job done, no one cares if your code looks more advanced, it drives me nuts when people have this mentality in my office.
Re:I enjoy PHP ... (Score:2)
Yeah, that crap drives me nuts. What are these "advanced concepts" anyway? "For" loops?
Re:I enjoy PHP ... (Score:2)
It's funny to look back at that ancient code in horror and wonder how I managed to get anything working at all. Some of my code you wouldn't know it worked if you read it before running i
Re:I enjoy PHP ... (Score:3, Insightful)
So you intentionally make your code hard to read/maintain so that you can justify your salary? If you really think your code "looks more advanced", chances are it's not.
Is one of these more advanced than the other? Or does it just look that way to someone that's never seen a ternay operator before?
Re:I enjoy PHP ... (Score:3, Informative)
What I truly *meant* was: so many people out there are writing very basic-looking code, that, while it works, it's not optimal. It's not as efficient as it *could* be, and in my experience, writing more efficient code, especially code that's "hardened" or more secure, takes more advanced programming skills than a lot of the code I see out there. So, learning complex ideas, which you may NOT learn in these "learn ___ quickly"
Re:I enjoy PHP ... (Score:2, Informative)
Re:I enjoy PHP ... (Score:2)
Advanced!=Complex!=Dirty (Score:2)
Beginners tend to use global variables and long, imperative structures for pretty much everything no matter what language they're using.
They also tend to use the same control structures for everything until they start understanding other ones. And forget about OOP or functions. These things are advanced.
What they end up with is something that's supremely simple, but very, very dirty. The code doesn't scale at all. It almost has to be completely rewritten by hand
Re:I enjoy PHP ... (Score:3, Funny)
This is GOTO, an elegant statement for a more civilized age.
Re:PHP now obsolete? (Score:2, Insightful)
1. Professional developers are still creating websites using font tags and other deprecated nonsense.
2. Programmers are writing extensive web applications entirely in Perl cgi, often taking months to do simple tasks that PHP or ASP can do in days.
3. Existing sites are built on technologies that may be ten years old. They don't update their software every time a new technology, framework, or component comes out. They have to support old stuff in addition to building new stuff.
Re:PHP now obsolete? (Score:3, Insightful)
Myth #4349: Perl takes longer to develop than PHP
Obviously you've never heard of CPAN or done anything more than pull some data out of a database and put it on a webpage. Anyone doing anything more than that on the web has to know something besides PHP since doing anything complex in PHP simply isn't very easy at all.
Personally I really hope the PHP fad will be ov
Re:PHP now obsolete? (Score:3, Interesting)
Having seen horribly written Perl used in the wrong situation, I know that Perl can take longer to develop than PHP to do some things. Maybe it could have been sped up by using CPAN modules, but the entire application could have been built in a matter of days. The Perl version probably took a month to build, based on the sheer amount of c
Re:PHP now obsolete? (Score:2)
The entire application probably could have been built in a matter of days using perl too.
Re:PHP now obsolete? (Score:3, Interesting)
FYI, PHP is a serious language. If it weren't so many people/companies wouldn't be using it. (and I mean beyond inexperienced users.. Yahoo for a example...)
btw, I have an intrest in Rudy, my current favorite language to use for admin purposes is Python. Some have claimed that a language cannot speed up the process of development. They have not used Python. I
Re:PHP now obsolete? (Score:2)
Re:PHP now obsolete? (Score:2)
That's the kind of statement that needs to be qualified. Ruby is arguably the best interpretted language out there. Rails is the MVC design pattern plus some nice tools. What's not to like?
Re:PHP now obsolete? (Score:2)
Having done some rather large and complex projects with PHP, your comment leaves me very curious.
What complex thing(s) is/are difficult to do in PHP? (I'll draw the line at stuff like rendering 3D, since the language clearly isn't meant for stuff like that)
I've had excellent results
1) Developing semi-distributed, (borrowing a buzzword) RIA [macromedia.com] type application using
Re:PHP now obsolete? (Score:2)
Huh? I don't think the move from Perl cgi to php will turn months of work into days. The development time is relatively close, even if you ignore all of the templating solutions for perl.
I understand people have their preferences one way or another, perl, python, php, whatever. But let's not pretend that the mere choice of language can mean the difference between months and days.
I am more likely to buy it if you're really talking about a big change
Re:PHP now obsolete? (Score:2)
Well, PHP has ten years' worth of installed code out there (some good, some bad, some ugly). Ruby on Rails has the buzz among progressive web developers, but how many job postings are there asking for RoR experience? How many major web sites are built on RoR?
Not that I think vanilla PHP is a very good solution for anything but rapid prototyping. But add in some extensions like Pear::DB, Smarty, and php.MVC, and PHP becomes not only a reasonably elegant development pla
Re:PHP now obsolete? (Score:2)
Re:PHP now obsolete? (Score:2)
Re:I don't even know where to begin... (Score:2)
Or do you mean that python is more sophisticated than PHP? Just pretend I never said anything.
Re:I don't even know where to begin... (Score:2)
Everyone always says that, and to a certain extent it's true.
However, everyone I know who's actually tried it, including myself, is surprised at how often what they write does what they expect the first time.
It was really amazing. And in practice, usually editors handle the whitespace quite nicely. Python may not be right for every task, but it's been a wonderful tool to have available.
Re:I don't even know where to begin... (Score:2)
Of course, YMMV. I recommend to anyone interested in trying a new language that they give python a chance, and suspend their disbelief of the whitespace-is-significant syntax.
Everyone I've known that's tried using python for a fitting task has been impressed with the ease of development.
That being said, it's not the
Re:I don't even know where to begin... (Score:2)
Oh, it screws it up royally. And don't get me started on linefeeds between windows and unix. And the whole "lambda" function concept...actually, I'm going to have to fight you. I think that's dumber than the whitespace thing, and that's saying something.
Other than that, though, python has some advantages as a
Clarify for me. (Score:2)
Re:I don't even know where to begin... (Score:2)
Re:I don't even know where to begin... (Score:2)
If you're working in an interpreter and copy/pasting from a script, the interpreter (at least those I used) would generally screw up the linefeeds when I'd try to copy part of the script and
Re:I don't even know where to begin... (Score:2)
This is your shell screwing up, not the python interperter. It has nothing to do with the language at all.
And while your experience may vary, I find that the whitespace blocks cause no problems, and all my Python code is more readable than my C or C++ code. Go figure.
Re:I don't even know where to begin... (Score:2)
Re:I don't even know where to begin... (Score:2)
Re:I don't even know where to begin... (Score:2)
I agree, sure it might seem a nice way to enforce nice code style, but in reality it's a pain.
I'd like to see python with traditional ( {
Re:PHP now obsolete? (Score:2)
I haven't heard PHP's syntax described that way before. To me, it seems neither simple (think python, C) nor powerful (think ruby, perl).
Re:PHP now obsolete? (Score:2)
Well, it's simple in that you have a very limited set of data types and operators. Basically, you just have pointers, chars, ints, functions, and structs. And the operators are basically: add, mult, div, mod, subtract, dereference, function call. Everything else is in libraries, standard or otherwise. (This was not meant to be a formal exhaustive list, but a general characterization). So it's a minimalist language. I guess it's debatable
Re:PHP now obsolete? (Score:2)
The article cites a survey [evansdata.com] from Evans Data Corp. that claims PHP use is declining but the rest of the article doesn't support that conclusion.
Re:PHP is good but.... (Score:2, Insightful)
I figure that OOP is not the magic bullet many proclaim it to be. That some tasks fit the OOP model very well and others fit the functional model very well. And that PHP is a good language for certain applications, such as your blog.
Re:PHP is good but.... (Score:2, Insightful)
PHP isn't a functional language. It's a procedural/imperative language.
Who has proclaimed OOP to be a magic bullet? Less of the straw men, please. I can't remember ever hearing anybody claim anything was a magic bullet seriously.
Re:Posting anon to protect the guilty (Score:2, Insightful)
Can you name me a language that DOES have "mechanisms to enforce any kind of good web application design practices"? I'm not sure I can think of anything built into a language (i.e. not just an add-on library which, of course, PHP could provide) that does do this.
"Almost invariably, PHP apps are initially designed by people who are newcomers to programming and the web."
I've seen many state this and have suspected it m
Re:Posting anon to protect the guilty (Score:3, Insightful)
Good for you. What are the advantages of doing what you're doing that obsolete PHP in every instance?
Scalability. The ability to share objects and information between threads, so that they can be used throughout an application and not just within a request or session is vital for large high-performance websites. It is simply
Re:Posting anon to protect the guilty (Score:3, Insightful)
It is. I've worked on a site (NB: NOT my URL!) that handles greater traffic than that, with a large number of DB requests on a large proportion of pages. NOT written in PHP. But not even running on a box of its own
It is not practical for anything but the simplest and smallest of data items. If it were, sites like E-Bay and high-volume stock markets would
Re:Posting anon to protect the guilty (Score:2)
Gonzo is back again. Sweet jebus you are dense.
This is totally unfair. The poster is asking questions I would expect from someone experienced with the PHP way of working. They are intelligent questions.
So what you are telling me is, it's ok to hit the server for a piece of data that isn't changing soon or is complex to get? Lemme guess, calculate and store it in another table? Ugh. Amature.
It is not that simple. Fetching data for each
Re:Posting anon to protect the guilty (Score:3, Insightful)
After all your praising of Hibernate, how can you recommend this? Hibernate is an elegant and robust ORM that isolates your code from database specifics and allows you to write highly portable applications. Ruby on Rails requires exactly the kind of embedded SQL you don't like if you are to do an
Re:Posting anon to protect the guilty (Score:2)
How do you know you are using a Java website?
The minute it starts trying to force a loading of a runtime environment or jar files and screws up the back button or other standard controls I want to leave.
The runtime environment and jar files are only loaded once - when the application server starts. From then on, these do not occur, so have no impact on anythin
Re:Posting anon to protect the guilty (Score:2)
Re:Posting anon to protect the guilty (Score:2)
No - it is nothing to do with applets. He was talking about the frameworks available in Java to render HTML and handle web forms.
Re:Posting anon to protect the guilty (Score:2)
Re:Posting anon to protect the guilty (Score:4, Informative)
OO isn't a silver bullet. You almost always trade performance for development time and maintainability when you use it. That's not a bad thing and PHP minimizes the performance hit well enough to make it useful. In PHP its nice when the developer sticks to one or the other, though its obvious that most people don't because PHP is easy and the people writing it tend to be new to programming.
Strong typing isn't a silver bullet either, and I don't see how it makes your code more reliable. PHP tends to die when you perform numeric calculations on a string or vice-versa so problems can be fixed before going to production. I'd prefer it handle more like Perl where usually it does the "right thing" (it doesn't die at the very least).
Here's my problem list that I hoped would be fixed or at least improved in 5. (no such luck it seems)
Error handling is one of my biggest beefs with PHP. There are simply too many options and none of them are sane. Why can't we have a class as an error handler? Why is it that the error messages are spewed the screen as HTML by default? Why doesn't the command line mode revert to text only error messages? Why doesn't PHP just use the server error log like other languages and give you options to change it if you need to? That's what its there for!
References: Worse than PHP 4's objects are its references. Why can't I have references to objects or code? Why can't I pass a reference to any user defined or built-in function? (it used to work for user defined functions then they depricated it)? Seriously why does the function care if it has a reference or a value? To be fair I've heard some of these things have been fixed in 5 but I've still not found definitively if you can have code or object references.
Scoping: I suspect part of the problem with references are due to limitations in scoping. On the surface, having all locally scoped variables and specifying when you want to use a global one makes sense and keeps new programmers out of trouble. The problem is it leads to undefined variables everywhere when the programming forgets to use 'global $foo' in a function. This is also a problem that can be hard to spot initially because PHP doesn't bother to warn you if you've done that. The 'global' keyword also looks like a declaration so when I was first learning the language it was extremely confusing. PHP would be much more tolerable if they adopted something similar to Perl's strict mode where you declare your variable in the global, package, or local scope and it dies when you have variables that are undefined. This method is much better than having silently undefined variables.
Namespace polution: Why are there 14 billion functions I'll never use all in the same scope? Its silly. C came up with the idea of including what you need 35 years ago! Why are we regressing? Even if you don't like having separate namespaces, at the very least functions that go together could all be in a common file to be included and then you only import functions you need. And no OO won't solve this problem because all the core functions are still imported in, even in PHP 5.
Compiled modules: Why do I have to recompile PHP if I want to add image functions or some other module written in C?
HTML Centric: PHP centers around HTML (see my beef about the error messages above) This is a real annoyance if you want to output other things. Also the default embedding in presentation is irritating too. It was a bad idea with ASP, it was a bad idea with ColdFusion and its still a bad idea now and while the developers keep saying "you no longer have to embed it", so what? Make it where it can't be embeded. (yeah yeah, backward compatability and all that) Sure you can cause other languages to print out HTML using print statements, but its not the same. PHP is designed around embedding it within HTML. Print statements make obvious the need for templates. PHP makes a mess without making it obvious un
Re:Posting anon to protect the guilty (Score:2)
1. It has mechanisms to allow you to program extremely tight web apps in one of several frameworks and programming models. This includes very Java-like MVC if you want or the very awesome Prado.
2. PHP does not tie you down to an OO paradigm, but lets programmers choose to implement an app using structured code, OO code or a hybrid of the two. This lets programmers code the way they feel comfortable.
By the way, PEAR is not a strong point for PHP. It's a useful progr
Re:From the Incredibly Obvious Dept... (Score:2)
If that's the case why aren't people out learning real programming languages instead of messing with PHP?
(yes you may mark it flamebait now)
You might not want to migrate. (Score:3, Insightful)
http://books.slashdot.org/comments.pl?sid=158685&c id=13297391 [slashdot.org]
So at this point, it just doesn't sound like a transition may be a very good idea for a site that is already functional and running well.
Re:About to migrate... any tips? (Score:2)
Re:PHP 5 is trash (Score:2)
Let me be the first to say that your benchmarking methodology sucks. Does that 1.7MB of RAM consist of 1.6MB of constant overhead + .1MB of script usage? Who knows - you certainly don't seem to have bothered to test it. Does eAccelerator use the extra memory for results caching that result in higher throughput and overall lower resource usage? Again, you don't seem to have gotten past "it's teh bloat" so we have no way to venture a guess bas