- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is horrible, but the unserialise(serialise()); can have some use if you need an exact copy of a class and all its references.
For example:
class A{
var $b;
function __construct(){
$this->b = new B; }
function setB($input){
$this->b->b_var = $input; }
}
class B{
var $b_var = 'old Val'; }
$A = new A;
$C = clone $a;
$A->setB('new var');
echo $A->b->b_var; echo $C->b->b_var; //Both will be new var as B is referenced
Serialising will clone all the referenced objects too to get around this god awful shit storm
Admin
This might work with some forms of C "objects", but with C++ virtual methods it might get messy (depending on implementation details). And in Java you can't just cast between arbitrary types.
It might help to actually think before posting.
Admin
Admin
Well okay, I'll take a shot at this.
First there are the classics. SmallTalk is something of a gold standard of well-designed languages. Although there are certain dialects of assembly language which which are a disaster (e.g. x86) the assembly language for the SPARC processor line is usually held up as an example of a good assembly language. It was actually used for teaching assembly back when I was in school despite the relatively limited popularity of the processors themselves.
As for more recent languages, Lua is often mentioned as an example of a well-designed language and fairly popular in at least one domain (embedded scripting) so surely it is a good language.
Let me go out on a limb a bit and suggest Python as another good language. Some people don't like the rules about whitespace but even those people say it's more of a matter of taste. Aside from that I don't hear a lot of complaints about it. I use it myself without constantly running into dumbness (as for example happens all the time when I write PHP). It seems to be a good language.
I have also heard Haskell described as the best functional language, though I admit that I know very little about it.
Admin
Presumably he was looking for the profile in order to find and beat this person.
Admin
Admin
Admin
By natural language standards it's about average, in that essentially all natural languages have an undecidable grammar, making them effectively impossible to parse in the general case, whereas the only programming language (that anyone takes seriously) with an undecidable grammar is C++.
So perhaps I'm spoiled by writing parsers.
Spanish is about as geographically diverse, but within each dialect, there's an unambiguous way to pronounce each valid spelling of a word. Or, as Davos says, "why is there a 'G' in 'night'"?
That's the joke. And that's why PHP, despite being terrible, will continue to be used for the majority of web apps for the forseeable future, whereas your nice clean Haskell or whatever will wallow in obscurity next to Esperanto.
Oh well there's your problem. The Romance languages are generally better maintained.
Admin
Admin
Does language design matter? I think it does, and I think the point of language design is to produce a language which encourages good usage and makes it easier to write well than to write poorly.
PHP fails to do this, by any standard. The design of the language makes it very difficult to write good code, and in fact encourages lousy code. This is well documented*, and not even worth arguing about.
*For example, you can start here: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
or here: http://www.php.net/manual/en/
Admin
I wouldn't know about grammar but inconsistencies in pronunciation are abundant even in one spelling system on one geographical location. Just try to read this beautiful poem aloud in whatever local english dialect you like: http://pauillac.inria.fr/~xleroy/stuff/english-pronunciation.html
Admin
It's a fair cop.
Admin
Speaking as a PHP developer I saw this and my immediate reaction was 'Well sure, if you hate yourself you could do this'... sadly my second reaction was 'Did they really have to use serialize to do this' php objects are just glorified arrays so I'm pretty certain the same could be accomplished with a bit of casting, possibly through StdClass. Heck dude, if you want to shoot your foot off at least use the right gun.
Admin
I think you'll get: "Class....dismissed!"
Admin
English sort of came into being. A programming language, theoretically, was designed by someone who had a purpose in mind. So, bad analogy. Use a car analogy next time.
Admin
Do we blame bad drivers on BMW?
Admin
This is nothing new. The fact that people have been doing this has been making me nauseous for years.
Admin
No, we blame them on cell phones and texting and wankery of that sort.
Admin
PHP just sort of came into being though. It is a large combination of "Hey! Look at what I can do! Isn't that neat?"
Admin
Haskell. It's the Dvorak of programming languages.
Admin
It'd be pretty easy. You just remove this function and replace all of its reference with the proper implementation.
Admin
Depending on what you mean by "why", the answer is either "French printing presses" or "resistance to spelling reforms and no centralized spelling authority".
Admin
Shireen: "There just is."
Admin
Good analogy, dude!
Admin
i've found this in a codebase:
Admin
That's Sir Davos to you!
Admin
Nope, Audi. :)
Admin
I just hope no one fails to see the point.
Admin
That's Ser Davos, you nonbeliever who will burn in the red flame!
Admin
If they miss it, they're probably True Believers...
Admin
(Wow, it was really hard to type that badly)
Admin
Pfft... reinterpret_cast has been doing this for ages.
Admin
The worst part about this code is the use of the '&' which treats the object passed in as a reference and changes it invisibly to outside code. I have never seen an actual use case where this would be preferable to the more maintainable non-referential usage like $object = changeClass($object, $newClass);
Not that the rest is any better...
Admin
Whoah, stop the flashbacks! This was much easier to do in FORTRAN back in the day, just screw up a COMMON declaration. Set f = 1.0 in one place, read i = 17448304640 somewhere else. Or use a bad FORMAT declaration to read integer, float, or character data into a variable of a different data type. No CAST required, just a momentary confusion (probably caused by experiencing the 60s).
Admin
I'm trying to think of Laser Disc, Betamax, and HD-DVD jokes that I can work in...
Admin
Whoa, dude, step back. Betamax was totally better than VHS.
Admin
Have you ever read the chaos? http://www.mipmip.org/tidbits/pronunciation.shtml English pronunciation is very inconsistent!
Admin
Indeed. And HD DVD was better than Blu-ray. Just saying.
Admin
I have been reading the DailyWTF for years now and have seen the plethora of bad code such as 1000 "If" statements instead of a while loop. And stupid things such as using code calling a Database to do stuff that should have just been done in the code. But this code takes the WTF cake. I don't see its application but I can imagine that it is part of a much larger architectural WTF.
The only possible excuse is that it is compensating for a WTF from another library and that in fact this is a brilliant workaround.
Admin
I think you missed the point that he was trying to make (you nailed the first one).
There are languages that have very easy and consistent pronunciation rules. And, by "pronunciation rules", he and I do not refer to the accent that various geographical places have. With very few and rule-based exceptions, languages such as Italian, Spanish, and pretty much every Slavic-based language (probably some others to) - are easy to understandably read by anyone who can grasp their very basic rule: each letter has one and only one sound.
English, however, is a mess when it comes to this. Just when you manage to find 2 examples to build a rule for yourself, you encounter a word spelled in the same pattern with totally whacked pronunciation compared to the first 2.
Admin
This was covered here: http://phpmanualmasterpieces.tumblr.com/post/33239208258/drop-the-ball
Admin
And people do blame English, at least to some extent. The truth of the matter is that there's plenty of blame to go around. People who program badly in PHP deserve some of it -- but at the same time, it is possible to make a bad tool.
Depends on what you mean by "take seriously." Perl is even worse than C++ in some important ways.And while I wouldn't say I take Perl seriously, it is fairly widely-used. (Fortunately it seems to be that it's being supplanted by Python.)
Admin
Let's rename PHP to RGWI: Rube Goldberg Web Interpreter.
Admin
I believe the proper term for this type of operation is Transmogrify
Admin
Admin
Best take that seriously, bro. JAPHs are just perl's way of saying "don't fuck with me. I can do this shit with one hand, and I might still be over here writing a haiku in your inittab"
I take perl seriously. When I see that .pl extension, I don't know what's going to happen, but I know it's not going to be good.
Admin
Ugly Duckling Typing
Admin
$last = new Last() ;
$magicFSMClass->changeClass($last, "Frist");
Admin
I ran into a meta-WTF when trying to read the RSS feed on feedly. It decided to render all the html formatting in the code block. Of course this is valid PHP code, so it wasn't immediately clear to me that the WTF wasn't embedding tons of redundant span elements in their comments.
Admin