News for hackers. Stuff that matters.
Re:Java StringBuffer and StringBuilder performance by dragonwriter on Monday June 13, 2016 @06:03PM (#11898098)
I don't know, treating anything that is not a number as NaN (and mathematical operations on it as producing NaN) seems to be exactly semantically correct.

I mean, really, all NaN is in any language is a signal that a mathematical operation was used with a set of inputs for which the operation does not produce a defined numerical result. In a sense, this is always a sign of an insufficiently expressive type system that can't prevent you from feeding a bad value (or bad combination of values) to the operation.

Re:Java StringBuffer and StringBuilder performance by jdmichal on Monday June 13, 2016 @06:10PM (#11898141)
I said it was a sensible response to a non-sensible operation. The operation of flooring "banana" is not semantically-correct. The fact that IEEE floating point numbers happens to have a value that provides a sensible result to this operation is a bit of a fluke. What if the return value was an integer type, which is perfectly valid considering that the floor operation always provides an integer result?
Re:Java StringBuffer and StringBuilder performance by kbenson on Monday June 13, 2016 @06:22PM (#11898220)
What is sensible is first based on the language definition, not your opinion. If the language defines it explicitly and has well defined rules, there's nothing non-sensible about it. Consider the following, which fall well within the definition of how Perl handles implicit conversion of strings to numeric types, and is well known to Perl programmers:

    # perl -E 'say "1zero"+0 '
    1
    # perl -E 'say "zero1"+0 '
    0
Re:Java StringBuffer and StringBuilder performance by jdmichal on Monday June 13, 2016 @06:32PM (#11898289)
No, I'm pretty sure that the question "what's the mathematical floor of banana" doesn't make any sense, no matter what the language definition is. The fact that some (dynamic) languages even allow you to ask the question is the entire point being made by kodablah in regards to typing as a safety mechanism. The fact that some smaller subset of languages even attempt (and fail) to make sense of the operation (weak typing) is just diving straight off the deep-end of safety.
Re:Java StringBuffer and StringBuilder performance by kbenson on Monday June 13, 2016 @06:49PM (#11898394)
I'm not sure there's a point in continuing this when I've defined, multiple times, the definition of safety I'm working under for the purposes of this discussion and my point, and you willfully ignore it to argue something entirely different time and again. I'm not interesting in discussing the merits of dynamic vs static languages, nor weak vs strong typing, when this started out as if you have a language feature that might cause a crash under normal, expected allowed behavior within the language, and one that will not cause a crash a a very small performance draw for that specific operation, I think defaulting to the non-crashing operation is the correct choice. Feel free to speak to that point if you would like to continue, because I don't see how the current tangent applies.
Re:Java StringBuffer and StringBuilder performance by jdmichal on Monday June 13, 2016 @07:01PM (#11898462)
The entire point of this "tangent" (which it isn't) is that the same reason you would make the choice to use the "unsafe" variant are the same reasons you would argue to not use a type-safe language. Or, rather, if you're default inclination is to always choose safety over other factors, then why not apply the same logic to languages? The fact is that you seem to be drawing an arbitrary line at language-use in your logic here.