• (cs) in reply to Confused
    Confused:
    chubertdev:
    trtrwtf:
    chubertdev:
    Haskell. It's the Dvorak of programming languages.

    Good analogy, dude!

    I just hope no one fails to see the point.

    Since I don't know much about Haskell, nor use Dvorak, what is the point?

    PoC

  • trtrwtf (unregistered) in reply to Confused
    Confused:
    chubertdev:
    trtrwtf:
    chubertdev:
    Haskell. It's the Dvorak of programming languages.

    Good analogy, dude!

    I just hope no one fails to see the point.

    Since I don't know much about Haskell, nor use Dvorak, what is the point?

    Nobody uses either of them, except for about ten people who get red in the face insisting that they're the end-all of programming languages and keyboard layouts.

  • (cs) in reply to sztupy
    sztupy:
    Don't worry, it does exactly what you expect from PHP:
    Thank you; looking at this example, I am starting to wonder if there is such a thing as incompatible classes at all. After all, as someone already pointed out, objects in PHP are essentially glorified arrays, to the extent that you can just add member variables - so any variable that has no equivalent in the target class simply becomes another private addition, which is perfectly valid in PHP.

    Having said that, there is some sanity left:

    class A {}
    abstract class B {}
    
    changeClass(new A(),'B');
    
    Do we get an abstract object?

    Nope: Fatal error: Cannot instantiate abstract class B.

  • (cs)

    On a completely random note, I found this comment in the code I'm working on:

    //find a better way to find the children

    This is one of the few professions where that kind of comment is ok.

  • SirBacon (unregistered) in reply to raylu

    Even older at http://stackoverflow.com/a/1147414

  • Spewin Coffee (unregistered)

    There is nothing wrong with PHP. There IS something wrong with the person who wrote that though. Someone might want to stick him in a psych ward just to be safe.

  • neminem (unregistered) in reply to chubertdev
    chubertdev:
    On a completely random note, I found this comment in the code I'm working on:
    //find a better way to find the children

    This is one of the few professions where that kind of comment is ok.

    Private eyes, police in kidnapping-related divisions... to a lesser extent based on your opinion of the profession, advertisers that market to kids... yeah, I suppose that's still only a few.

  • (cs) in reply to SirBacon
    SirBacon:
    Even older at http://stackoverflow.com/a/1147414

    8 years old, awesome.

    http://www.php.net/manual/en/language.types.type-juggling.php

  • (cs) in reply to Spewin Coffee
    Spewin Coffee:
    There is nothing wrong with PHP. There *IS* something wrong with the person who wrote that though. Someone might want to stick him in a psych ward just to be safe.

    Are you also a used car salesman?

  • Axio (unregistered) in reply to trtrwtf

    Nobody uses either of them, except for about ten people who get red in the face insisting that they're the end-all of programming languages and keyboard layouts.

    I use both, but don't fit your description.

  • (cs)
    Crud x = new Crud();
    changeClass(x,"When");
    changeClass(x,"You");
    changeClass(x,"Start");
    changeClass(x,"With");
    changeClass(x,"Crud");
    changeClass(x,"Code");
    changeClass(x,"Guess");
    changeClass(x,"What");
    changeClass(x,"No");
    changeClass(x,"Matter");
    changeClass(x,"What");
    changeClass(x,"It");
    changeClass(x,"Still");
    changeClass(x,"Comes");
    changeClass(x,"Up");
    changeClass(x,"Crud");
    
  • (cs) in reply to PotOGold
    PotOGold:
    I had to do this in Java when the names of XML exported classes had to be changed (including the package name). This was required to provide for backward compatibility. Usually, backward compat is less hard to do - the deserializer just hast to have access to stub methods providing the old interface, but once the name of a class has to change (because code would be really ugly otherwise or the old class structure was a WTF - as was the case in my example) it might become dirty. So: This might be a WTF, but it might also be the right solution for certain use-cases. Just because you never came across it yourself does not make it a WTF.
    TRWTF is using built-in Java serialization when there are so many better and more resilient solutions available, like JSON.
  • (cs) in reply to Brain damage
    Brain damage:
    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).

    On some FORTRAN compilers you could even screw up the value of a literal constant by passing one to a subroutine that modified its arguments. Pass-by-reference is a wondrous thing.

  • fgfg (unregistered)

    Three pages of discussions about language and nobody has made the ... wait for it ... obligatory XKCD reference!

    http://xkcd.com/191/

  • The Irritainer (unregistered)

    Noooooo, this is soo bad on so many levels!!

  • QJo (unregistered) in reply to chubertdev
    chubertdev:
    On a completely random note, I found this comment in the code I'm working on:
    //find a better way to find the children

    This is one of the few professions where that kind of comment is ok.

    I can imagine the furore that could erupt when discussing in a coffee shop over a telephone the solution to a problem whereby certain processes have spawned unwanted child processes:

    "Okay, Midge, this is what I want you to do. First, kill all the children. All of them. Then remove the parents, and make sure they can never spawn again. Got it? I know I can depend on you to clean up this mess ..."

  • The Evil Greebo (unregistered)

    You can paint stripes on a horse, but it doesn't make it a zebra.

  • Yazeran (unregistered) in reply to QJo
    QJo:
    chubertdev:
    On a completely random note, I found this comment in the code I'm working on:
    //find a better way to find the children

    This is one of the few professions where that kind of comment is ok.

    I can imagine the furore that could erupt when discussing in a coffee shop over a telephone the solution to a problem whereby certain processes have spawned unwanted child processes:

    "Okay, Midge, this is what I want you to do. First, kill all the children. All of them. Then remove the parents, and make sure they can never spawn again. Got it? I know I can depend on you to clean up this mess ..."

    Oh man, you almost owe me a new keyboard..

    I can only say, that add a few sentences of the sort: 'First check for zombies and nuke them all, then proceed with the live children...' would really draw attention.. :-)

    Yours

    Yazeran.

    Plan: To go to Mars one day with a hammer.

  • Krzysiek (unregistered) in reply to 50% Opacity
    50% Opacity:
    nom:
    and no consistent set of pronunciation rules.

    The pronunciation of words varies from place to place, but this is the case with any language that is spoken among geographically divers people which do not all communicate each and every day with each other. English suffers from this a lot since it's probably the most geographically diverse language to date. Since there's only one, no, sorry, two spelling systems, you're bound to come across inconsistencies.

    The problem is not pronounciation being different from place to place. The problem is pronounciation of letter sequences being different in different contexts. For example "ough" has many pronounciations: http://en.wikipedia.org/wiki/Ough_%28orthography%29

  • Rodnas (unregistered)

    ze googles. they do nothing

  • (cs) in reply to The Evil Greebo
    The Evil Greebo:
    You can paint stripes on a horse, but it doesn't make it a zebra.
    How do you know? I bet you've never even Tried to paint a horse. On the basis of all the available evidence (eg "Zebras look like someones painted stripes on a horse") I'm dubious of your claim.
  • nmare (unregistered) in reply to Shoreline

    This kind of comment usually come from ASP programmers who never accepted that most ASP projects have been converted into PHP in the early 2000's because at that time the asp side performance was horrible. (And this is still the case in my advice).

  • Julius Caesar (unregistered) in reply to Shoreline

    Latin. It's been all downhill since then.

  • (cs) in reply to QJo
    QJo:
    chubertdev:
    On a completely random note, I found this comment in the code I'm working on:
    //find a better way to find the children

    This is one of the few professions where that kind of comment is ok.

    I can imagine the furore that could erupt when discussing in a coffee shop over a telephone the solution to a problem whereby certain processes have spawned unwanted child processes:

    "Okay, Midge, this is what I want you to do. First, kill all the children. All of them. Then remove the parents, and make sure they can never spawn again. Got it? I know I can depend on you to clean up this mess ..."

    Well played, good sir.

  • foxyshadis (unregistered) in reply to flabdablet
    flabdablet:
    Brain damage:
    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).

    On some FORTRAN compilers you could even screw up the value of a literal constant by passing one to a subroutine that modified its arguments. Pass-by-reference is a wondrous thing.

    Python3 has this amusing "feature" ever since literals became objects. Your coworkers have the right to waterboard you if you ever attempt to use this, however.

  • Someone (unregistered) in reply to foxyshadis
    foxyshadis:
    Python3 has this amusing "feature" ever since literals became objects. Your coworkers have the right to waterboard you if you ever attempt to use this, however.
    How? Are you referring to how you can use ctypes to mess with stuff? (95% sure that doesn't need Py3, but whatever.)

    It did lead to a pretty amusing quote on the Python mailing list:

    > But this I don't understand: > >>>> 5+0 > 4 >>>> 5+1 > 4 >>>> 5+2 > 6

    That's easy:

    5+0 is actually 4+0, because 5 == 4, so 5+0 gives 4. 5+1 is actually 4+1, which is 5, but 5 is again 4. 5+2 is 4+2 which is 6.

    http://mail.python.org/pipermail/python-list/2012-July/626284.html

  • QJo (unregistered) in reply to eViLegion
    eViLegion:
    The Evil Greebo:
    You can paint stripes on a horse, but it doesn't make it a zebra.
    How do you know? I bet you've never even Tried to paint a horse. On the basis of all the available evidence (eg "Zebras look like someones painted stripes on a horse") I'm dubious of your claim.

    Was there not a movie a few decades ago (some take on Tarzan with a female lead IIRC) where the protagonist rode on a zebra? Except it was really a horse with stripes painted on.

  • The Evil Greebo (unregistered) in reply to eViLegion
    eViLegion:
    The Evil Greebo:
    You can paint stripes on a horse, but it doesn't make it a zebra.
    How do you know? I bet you've never even Tried to paint a horse. On the basis of all the available evidence (eg "Zebras look like someones painted stripes on a horse") I'm dubious of your claim.
    YOU DON'T KNOW ME, MAN!

    YOU DON'T KNOW WHERE I'VE BEEN!!!

  • Andy (unregistered) in reply to Shoreline

    The one I like of course! All others are frauds used by children. MY language of choice is the only one used by professionals to get "Real Work Done"(TM)!

  • (cs)

    Hey, I can use this. PHP's DB_FETCHMODE_OBJECT gives me a generic object, not an object of the type that I am trying to read from the SQL database. So the serialize() trick may be just the thing to convert a (darned) generic object to a wonderful specific object. Thanks.

  • anin (unregistered) in reply to Anon

    says c++ shitty code writer...

  • Thomas (unregistered)

    TRWTF is that the PHPdoc should read "@param string $newClassName" instead of "@param object $newClassName", right?

  • Kaan (unregistered) in reply to anonymous_coder()

    Interpreted languages allow you to do things like this. Changing the name of a class during runtime is a bit stupid. I can't really think of a reason why I would have to do it. But this kind of flexibility is great. The fact that you consider that bit of code unholy and think that this is somehow related to PHP's simplistic implementation of Inheritance and lack of templates, says you don't have much experience with scripting languages. Good luck finding a job in 5 years.

  • (cs) in reply to Kaan
    Kaan:
    Interpreted languages allow you to do things like this. Changing the name of a class during runtime is a bit stupid. I can't really think of a reason why I would have to do it. But this kind of flexibility is great. The fact that you consider that bit of code unholy and think that this is somehow related to PHP's simplistic implementation of Inheritance and lack of templates, says you don't have much experience with scripting languages. Good luck finding a job in 5 years.

    I'm not entirely certain how your statements compile. Maybe you are suffering from a symptom of only coding with scripting languages?

    You say that "changing the name of a class during runtime is a bit stupid" and that you "can't really think of a reason why" but follow with "this kind of flexibility is great."

    Those seem to be contradictory statements... To be fair, I tend to stick with strongly typed languages and logical constructs so I might be misinterpreting your script...

  • Dvorak, H. (unregistered) in reply to Axio
    Axio:
    > Nobody uses either of them, except for about ten people who get red in the face insisting that they're the end-all of programming languages and keyboard layouts.

    I use both, but don't fit your description.

    I was thinking of a joke, but then I looked at the captcha: jumentum

  • Jeff (unregistered) in reply to Vb

    Nuclear weapons can be useful in certain cases too, or so some believe, but you wouldn't want to try to adapt them to, say, urban renewal.

  • Fen (unregistered) in reply to nom

    WTF, it works!!!

    >>> class A():
    ...     def a(self):
    ...             print self._a
    ... 
    >>> a = A()
    >>> a._a = 'hello'
    >>> a.a()
    hello
    >>> class B():
    ...     def b(self):
    ...             print 'b: ', self._a
    ... 
    >>> a.__class__ = B
    >>> a.b()
    b:  oi
    >>> a.a()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: B instance has no attribute 'a'
    

Leave a comment on “Pot o' Gold”

Log In or post as a guest

Replying to comment #410841:

« Return to Article