You know your programming language sucks, when...



  • ...it implements boolean values as floats. Yes, that's right, floats! Who does THAT, you ask? Povray's scene description language! To quote the documentation (http://www.povray.org/documentation/view/3.6.1/228/):

    When POV-Ray needs a logical or boolean value it interprets any non-zero float as true and zero as false. Because float comparisons are subject to rounding errors POV-Ray accepts values extremely close to zero as being false when doing boolean functions. Typically values whose absolute values are less than a preset value epsilon are considered false for logical expressions. The value of epsilon is system dependent but is generally about 1.0e-10. Two floats a and b are considered to be equal if abs(a-b) < epsilon.

    Has anyone of you used this language? If so, I feel your pain...



  • Clearly this is future-proofing for when POVRay implements probability waves.



  • It's not a programming language.  It's a scene-description language.  It's no more a programming language than SQL is.



  • The name might be a bit confusing, but it is turing complete. It's just not a general purpose language like C or Java...



  • Well, at least you have a boolean in that language. There are, however, 'real' languages (as opposed to esoteric or fun languages) out there which don't have this...e.g. the one I have to work with, [url=http://en.wikipedia.org/wiki/ABAP]ABAP[/url]. It has some pretty cool features (internal tables, integrated persistence, advanced development infrastructure, integrated system-wide data dictionary and many more), but having booleans isn't one of them. Add into this that there are some really large applications (e.g. [url=http://en.wikipedia.org/wiki/SAP_R/3]SAP R/3[/url]) being built with this language, there are at least 50 different definitions of boolean. There is a 'standard' include with a boolean definition (as 'X'/''), but most developer don't even know about it and re-define it again. 

    Commonplace is the usage of a c(1) field (character field, length 1) with the values 'X' for true and '' for false ('', ' ' and SPACE being equivalent in ABAP) or '+' for true, '-' for false, and '' for undefined. As you might notice, these two versions cannot be converted without a larger if-statement. However, sometimes the definitions get 'enhanced' in following releases, e.g. field "product has subitems" with values 'X' (yes), '' (no) and 'C' (subitems can be configured) ...


  • Garbage Person

    @Netdiver said:

    Well, at least you have a boolean in that language. There are, however, 'real' languages (as opposed to esoteric or fun languages) out there which don't have this...e.g. the one I have to work with, ABAP.

    And suddenly, the SAP GUI doesn't seem nearly half as horrible as the monstrosities that must underlie it.

    (Has SAP ever even HEARD of UI design principles?)



  • They should really have used doubles, you never know how many files may not be found.

     <Mandatory_old_tired_TRWTF\/Enterprisey\/XML_comment>
    TRWTF is they don't create an object for the boolean, with a 32 bit pointer to the memory location, and auto-generate an xml representation upon initialization within a data member of the object.  For simplicity, this should include a listener interface, so you can register a BooleanChangeEventListener class with the boolean, incase it gets updated and another class needs to know.
     </Mandatory_old_tired_TRWTF\/Enterprisey\/XML_comment>

    Personally I really hate it when languages do things like this.  Sometimes you want to setup an array of booleans to carry out some heavily optimized logical/filtering operations, and simply porting code will cause massive bloat.

     I suppose this is an even larger WTF than that, since they choose floats over integers - complete with "really really really close to true" conditions having to be accounted for.

     Povray ~= WTF:  True+/- 1.0e-12



  • @Weng said:

    (Has SAP ever even HEARD of UI design principles?)

    Yes, they have.  They just chose to implement their own instead of following the universally-accepted standards that came from Xerox PARC and the Apple Lisa.  My favourite is the SAP scrollbars.  Everyone presses the wrong button the first 5 times they try to use the scroll bar.  Then they stop trying.



  •  This is not necessarily a WTF, given the purpose of POV-Ray. [I am not an expert on this topic, so bear with me if I am wrong]

     When you describe a scene using intersections and unions and stuff like that, this kind of definition can make sense. You could interpret their definition of boolean as "are these two points/planes/whatever close enough to be basically the same? (yes/no)"

     Just my 2 cent.



  • @tobi-wan-kenobi said:

     This is not necessarily a WTF, given the purpose of POV-Ray. [I am not an expert on this topic, so bear with me if I am wrong]

     When you describe a scene using intersections and unions and stuff like that, this kind of definition can make sense. You could interpret their definition of boolean as "are these two points/planes/whatever close enough to be basically the same? (yes/no)"

     Just my 2 cent.

    You can add my own 0,02 € to that.


  • @Zecc said:

    @tobi-wan-kenobi said:


     Just my 2 cent.

    You can add my own 0,02 € to that.


    And if you add my £0.02 GBP then you're up to $0.09 already...


  • Because float comparisons are subject to rounding errors POV-Ray accepts values extremely close to zero as being false when doing boolean functions.

    A new take on "Fuzzy logic"!



  • Of all this, I just want to know the rationalle. Is there a critical reason why they used floats? Maybe at some point they needed to use float answers that were < 1 but would indicate a true value and they could not write a function that accepts a float and does this crazy boolean logic on it. Maybe its a language made by guys who said "C looks simple enough, I bet I can make a language better than that..."

    Other than that I am just curious as to why. There must be a reason... somewhere...



  • So you weren't convinced by what tobi-wan-kenobi said?

    I think it makes perfect sense. It is a kind of "fuzzy logic", a geometrical one: "does it intersect? well, it's close enough"

    Again, just my 0,02€  (show correct UTF-8, dammit!)



  • I worked on a version of 'Pick BASIC' (http://en.wikipedia.org/wiki/Pick_operating_system) which implemented a configuration option WIDE-ZERO.
    All numeric comparisons were considered equal if the difference was less than the system-wide WIDE-ZERO value.

    Oh, and I did know. 



  • @Rick said:

    (http://en.wikipedia.org/wiki/Pick_operating_system)
     

    Whoo hoo! Bad linking FTW!



  • You're forgetting that POV-Ray doesn't define many datatypes. Floats, vectors (which are just lists of floats), and text strings. That's it.

    Sure it could define a boolean, but why?  POV-Ray wasn't designed to do a whole lot of branching. If the overhead problems with using floats as booleans become a major issue, you're doing something wrong. Heck, you want to know what if statements look like in POV-Ray?


    #declare this_variable = 1;

    #if (this_variable == 1) {

    //let's draw a sphere because this_variable is totally 1 

    sphere { <0,2,0>,1

        pigment { color rgb <1,0,0> }

        // etc.

    }

    #else

    //this_variable isn't 1 so we'll draw a box instead

    box { <-1,-1,-1>,<1,1,1>

        pigment { color rgb <0,1,0> }

        // etc.

    }

    #end 


    Yep, all variable and branching work is handled as preprocessor directives when POV-Ray tokenizes the input file. The raytracer never even sees them.



  • @dlikhten said:

    Of all this, I just want to know the rationalle. Is there a critical reason why they used floats?

    The POV-Ray scene description language is meant for describing 3D computer-graphics scenes. The fact that it's a turing-complete programming language is a side-effect of making it useful for that purpose. Hence, it only has one numeric datatype: double-precision floating point numbers.



  • @wittgenstein said:

    Yes, that's right, floats!
     

    Like Ivory SOAP ...

    I didn't read that it implements boolean values as floats but rather it can evaluate floats as boolean. Hell even VB can do that ;-)



  • This seems to be somewhat common in the way several 3D packages interpret values.  Mind you, its usually on unit conversion specifically, and not storage.  Maya, for example, can interpret a float as a boolean, this way you can use something like the TranslateX channel on an object to control an on and off switch or something.

    And just to back up the "at least it has booleans" remark, MEL, the Maya Expression Language used for scripting everything in Maya has no actual Boolean type.  It uses an Int, 0 being false and 1+ being true.  What's fun(ny) is you can use 0, 1, true, false, on, off, yes, and no as possible representations of the boolean state.  What's really strange is it usually makes sense when these interchangable words are used, so they're not really all that WTFy. 


Log in to reply