I’ve been doing a bit of Java work lately; I built a quick prototype in PHP and needed to convert it into Java. And I was shocked at a few things that are trivial in PHP but more difficult in Java. An example: I have text which may or may not (but probably does) contain HTML, and I want to simply remove all the tags to create “unformatted text”. In PHP this is as simple as
$unformatted_text = strip_tags($text_with_html);
Easy! It’s just one line! Now how’s it work in Java? I won’t go into detail in this post, but you can read a solution on stackoverflow. It involves downloading and importing a third party package (is javax third party?) that allows you to parse the HTML, and you need to be sure to set a somewhat obscure argument that will ignore all tags. This isn’t difficult, it’s just more work, and it gets in the way of my getting things done.
Another example I came across in the same project is encoding and decoding JSON. Again, PHP has built in functions json_encode and json_decode. Java, again, you need to download and import third party packages.
I’m not complaining. These aren’t deal breakers. I’m just very surprised. When I first began working with PHP, I didn’t really like the language (Have you ever created an anonymous function in PHP? And those dollar signs in front of variables, the hell?) But now I realize how much I’ve taken PHP for granted. Web development with PHP is easy.