«« Next » « Previous
«« Next » « Previous

Link Details

Link 67905 thumbnail
User 258151 avatar

By prodevtips
via prodevtips.com
Published: Feb 25 2008 / 11:18

Beware if you can't handle WTF style code examples. This is the worst code I've ever seen, have you seen worse?
  • 13
  • 5
  • 3243
  • 1707

Comments

Add your comment
User 258151 avatar

prodevtips replied ago:

0 votes Vote down Vote up Reply

Btw, this happened to me today, the transcript it not edited at all except for the code highlighting. And yes I am drinking beer at the moment but I'm not drunk enough yet...

User 200692 avatar

whiskeyjack replied ago:

0 votes Vote down Vote up Reply

Love it. It's inevitable that this will happen in every language at some point. I've seen some Perl and Python where some twit did the same thing.

User 233461 avatar

antych replied ago:

0 votes Vote down Vote up Reply

It mostly happens in web world of scripting languages. You want something on your website, you want it for free, so you google it, copy&paste some code and you hope it works. Often, it needs some tweaking, so you play around with it, guessing how this whole programming thing works, moving stuff around at random etc. You can hardly blame a language for allowing people to do that... you just have to remember that there's some code out there not written by developers.

User 200692 avatar

whiskeyjack replied ago:

0 votes Vote down Vote up Reply

With all due respect, this can happen in any language, scripting or not. Bad code happens in all languages. Bad practices happens in all languages. I've seen some elegant Java and C and some pure stupidity. Same for Perl, Python and PHP. Bad programmers happen. Blame the programmer, not the tool or the language.

User 233461 avatar

antych replied ago:

0 votes Vote down Vote up Reply

No it's not. You cannot just copy some crap in Java and see if it works, you need to compile it. You need tools, you have to know how to use them. This is a barrier that will stop random people from messing with it. In PHP on the other hand, site owner can look at the code and start messing with it as they often do. That makes those languages more vulnerable to people stupidity. You are talking about incompetent developers, that's a different story.

User 200692 avatar

whiskeyjack replied ago:

0 votes Vote down Vote up Reply

Again, with respect... the code looks like it'll compile. It's just a colossally stupid way to output HTML. You've NEVER seen someone in a non-scripty language do something akin to this? I call bull.

User 233461 avatar

antych replied ago:

0 votes Vote down Vote up Reply

PHP is exposed to more people than just incompetent developers. Sure you can do stupid things in Java, but after you deliver the product, the owner won't start copying & pasting random pieces of code to improve it for free. There are many obstacles, like source code access, tools, language strictness. With PHP, a smart person without any programming skills can change stuff. No clue about code reuse? No problem, copy & paste to the rescue, that's how you get a code like this.
It's not about bad practises, it's about easy access to source code and how forgiving the language is. This is how PHP got most of it's bad rep, because it's being used be people without programming skills. And they do it because they can, something you cannot say about Java for example.

User 218789 avatar

eelmore replied ago:

1 votes Vote down Vote up Reply

*shrug* Looks like every PHP code snipped I've ever seen posted online. They're all horrid.

User 233461 avatar

antych replied ago:

0 votes Vote down Vote up Reply

I wonder what are you trying to achieve by ridiculing PHP community in every possible thread. We can see you're a moron, you don't have to remind us on every occasion.

User 201118 avatar

Lars Pohlmann replied ago:

0 votes Vote down Vote up Reply

I have seen worse: my code 7 years ago ;-)

User 258151 avatar

prodevtips replied ago:

0 votes Vote down Vote up Reply

I actually am amazed that they pull these things off. This code is part of a massive application and at the moment it seems to be working OK if you believe our clients. However, as is painfully obvious, having someone else than the original coder to do something with this thing is practically impossible.

I also want to stress that this post is not something I have against the language per se. PHP is dominating and will continue to dominate the world of web dev for quite some time and there are many reasons for this domination.

User 275423 avatar

lifewithryan replied ago:

0 votes Vote down Vote up Reply

*phew*...for second there I was worried someone uncovered some of my code *wink*, then I read the article....OUCH

That being said, I've crapped out some pretty awful PHP 4 scripts in my time...ahhh never again....

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.