LWN.net Logo

PHP: a fractal of bad design (fuzzy notepad)

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 7:51 UTC (Tue) by koch (subscriber, #55163)
Parent article: PHP: a fractal of bad design (fuzzy notepad)

I think PHP is the go-to language for people who have real projects they want to get done. I think this comment on BlitzMax, a BASIC environment for developing games is a nice insight. BlitzMax is used by people who wants to make games, not to program. PHP is used by people who wants to make sites, not to program.

BASIC is, like PHP, a horrible language, but it is used by people getting amazing things done without getting derailed about architecture, monads, or whatnot. I think, in addition to pointing at all the uglyness, low-entry alternatives should be pointed out. Why is PHP so successful? Can a decent language with the same level of popularity be created?


(Log in to post comments)

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 8:11 UTC (Tue) by slashdot (guest, #22014) [Link]

Java fits all this, and also has the best IDE overall (Eclipse JDT).

Use it.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 8:24 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

Surely, you're joking. The best IDE is IntelliJ IDEA.

And actually, I'll be switching to Kotlin ( http://confluence.jetbrains.net/display/Kotlin/Welcome ) once it's properly released. It's already WAY better than Java and already has outstanding IDE support (unlike Scala or other "me-too" JVM languages).

This thread now misses only emacs vs. vi flamewars. So somebody should post something about how emacs is obsoleted by modern IDEs to kick off another flamwar.

Ooops. I just did it.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 13:51 UTC (Tue) by SEJeff (subscriber, #51588) [Link]

Ok lets settle this once and for all... The best ide is vim and everyone knows it. vim + ctags/cscope = <3

In seriousness: This is one of the most off topic and awful bunch of comments I've ever seen on lwn. It even has one idiot saying mildly racist (against asians) comments. It is about time for the editors to step in and get this back into lwn land where people are civil and discussion is mostly technical. This isn't /. people, this is lwn.

Lets keep it in on topic folks.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 15:51 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

That's the power of PHP - it can even turn LWN into Slashdot!

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 14:37 UTC (Wed) by Thanatopsis (guest, #14019) [Link]

Very True. However you forgot to include DDD for debugging.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 8:58 UTC (Tue) by gidoca (subscriber, #62438) [Link]

I don't think it does, not for web development anyway. Way too much boilerplate code to get _anything_ running. I think one of the main reasons PHP is so popular with beginners is that you can write <?php phpinfo() ?> into a file and it works.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 9:03 UTC (Tue) by slashdot (guest, #22014) [Link]

JSP allows you to do exactly that:

<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

This is not necessarily a good idea for larger projects though.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 11:16 UTC (Tue) by alankila (subscriber, #47141) [Link]

JSP -- probably best avoided if at all possible. I inherited an application that used JSP once, and find it an embarrassing piece of technology.

I personally use wicket for everything. But there's a bit of boilerplate there: you have to subclass WebApplication, and you must at the very least define the class which implements the web page rendered at the root of the website. Then you must give an implementation of that Page (the class file can be empty), then you get to write HTML.

I think that templates should have no evaluation capability whatsoever. In wicket's case, dynamic elements are marked with an xml attribute called wicket:id, for instance <div wicket:id="foo"/>, and then it's up to the Page to choose what is rendered into the element identified by name foo. The state of page is entirely on server side. Components can be replaced in the page tree to generate different kind of elements on the page dynamically in response to user interaction. For instance, foo could start out without content, but become replaced with a modal dialog instead when user interacts with some button or link on the page.

The real problem is with understanding the evaluation model. Wicket gives you an impression that you are actually working with a desktop application, because page instances are kept alive on server and access to the same page will automatically preserve the state of the members, so you get state saving for free. That means improved chance to write secure code, as you don't have to write things into form hiddens, or put them into session hashmap where multiple tabs/windows in same session could trample all over each other. But most astonishingly: page instances are versioned, and requests so if the user uses back button, wicket actually resurrects an earlier version of the page to handle that request, which cleanly allows user to back out from choices made earlier (provided they did not cause permanent state changes to components outside wicket).

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 13:07 UTC (Tue) by canatella (subscriber, #6745) [Link]

At the time, installing apache + php + mysql was just a simple apt-get away. Running jsp required finding and installing the sun jre just to see that for this you needed the sdk then setting up tomcat (not that simple), learn how to setup all those xml files needed, generate a war file to be able to deploy your application. And nobody was providing cheap hosting for java application.

So yes for a newbie/amateur, PHP was the easy/quick solution.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 19:24 UTC (Tue) by drag (subscriber, #31333) [Link]

For the longest time php + mysql was your only option. It wasn't until VPS got cheaper that people could really start playing around with things like ruby on rails or python without a bunch of headaches.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 13:02 UTC (Wed) by ekj (guest, #1524) [Link]

Yeah. And this advantage shouldn't be underestimated. I tend to use django these days.

But for an average non-programmer with some el-cheapo web-hosting, the steps needed and the concepts to learn *before* he can run "hello world" can easily consume a week, that is, if his host supports django at all.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 11:34 UTC (Wed) by robert_s (subscriber, #42402) [Link]

Stop. If you think Java is a good language something is going very wrong with your life.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 18:07 UTC (Wed) by juliank (subscriber, #45896) [Link]

What's the problem with the Java language?

* Syntax?
* Semantics?
* Standard APIs?
* The virtual machine?

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 20, 2012 23:10 UTC (Fri) by mathstuf (subscriber, #69389) [Link]

After an attempt at doing some Android development, the main things that bugged me (in no particular order). I do not claim to have a high familiarity with Java, but these things didn't have obvious solutions.

- Eclipse (Using it from vim via eclim is…bearable; I haven't been able to get gvim embedded at all)
- No typedef mechanism
- Excessively wordy API symbols
- One-class-per-file restriction
- Functions aren't first-class types
- as{Int,Double} Cursor methods (Just store the actual type; the DB already knows this (or should…)!)

That said, some things that Java does right:

- I wish final was in C++ (const doesn't really work for vectors unless you required C++11)

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 20, 2012 23:16 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

Try IntelliJ IDEA. It's so much better than Eclipse and has VI emulation (IdeaVIM plugin). The community version of IDEA (it's OpenSource under GPL) is more than enough for Android devel.

Aaand, IDEA developers are now creating a very nice language - Kotlin, which is compatible with Java and works fine on Android. And unlike most of other JVM-based langs it has splendid IDE support from the start (it was developed as IDEA plugin at first).

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 22, 2012 2:35 UTC (Sun) by mathstuf (subscriber, #69389) [Link]

It's packaged for Fedora, but seems to be languishing[1] :/ . As for Kotlin, I'm a big fan of explicit nullables.

[1]http://koji.fedoraproject.org/koji/packageinfo?packageID=...

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 22, 2012 2:48 UTC (Sun) by Cyberax (✭ supporter ✭, #52523) [Link]

Just download it from their site. It's not hard to setup (just un-tar it and run idea.sh).

Yeah, I really like the explicit nullable ('Maybe' monad from Haskell!), it's much nicer to use than Scala's clusterf#$k with Options. Besides, Kotlin developers are now busy annotating the standard library with nullables.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 11:12 UTC (Tue) by nmav (subscriber, #34036) [Link]

Very nice and sensible comment.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 16:15 UTC (Tue) by HelloWorld (guest, #56129) [Link]

> I think PHP is the go-to language for people who have real projects they want to get done.
The exact opposite is true. People ridicule PHP because it's actually a royal PITA for anyone trying to get something meaningful done. It's unproductive, it's error-prone, yet people keep making up this nonsense about PHP being better to get things done. I'll probably never understand why...

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 17, 2012 17:59 UTC (Tue) by Zizzle (guest, #67739) [Link]

PHP lets people get busy writing gaping security holes you mean.

Non-programmers screwing up a game is one thing. No one gets hurt.

Me entering my credit card details for a purchase into a PHP web app written by a non-programmer is another thing.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 5:59 UTC (Wed) by koch (subscriber, #55163) [Link]

I agree that using PHP is terribly bad, but what is the "obvious" alternative for someone who has a good idea? The problem is, good ideas doesn't necessarily come from programmers, but from people who wants to get started on some good idea.

Of course, it will bite them in the future, and many many of the things you cite can be avoided using a language with sane semantics, but what? Java cited above is hardly entry-level. ASP/.net or whatever it's called is probably the real-world alternative. I don't know how good/bad this is, but it's probably no worse than PHP.

Agreed, entering credit card detail written by a non-programmer in any language is certainly a bad idea. But not all good-idea sites needs to accept data like this.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 8:28 UTC (Wed) by HelloWorld (guest, #56129) [Link]

> I agree that using PHP is terribly bad, but what is the "obvious" alternative for someone who has a good idea?
There are tons of them, such as Ruby on Rails.

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 17:58 UTC (Wed) by roskegg (subscriber, #105) [Link]

Ruby has its set of security problems. Django+Python is a better option. Personally I favor newLISP for almost everything. It is a really sweet and consistent little language, comes with a built in web server. http://newlisp.org/

PHP: a fractal of bad design (fuzzy notepad)

Posted Apr 18, 2012 19:25 UTC (Wed) by HelloWorld (guest, #56129) [Link]

> Ruby has its set of security problems.
I didn't say Ruby doesn't have problems, but it doesn't have nearly as many as PHP.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds