in reply to Re^2: Reasons for Using Perl 6
in thread Reasons for Using Perl 6
Consider this in Python:
The result is very small, but it should really be 0.>>> .3 - .2 - .1 -2.7755575615628914e-17
It's not better in Perl 5:
Of course, neither Python nor Perl 5 is responsible for that, it is the FP arithmetic of the underlying architecture which sucks.$ perl -E 'say .3 - .2 - .1;' -2.77555756156289e-17
Does this mean we can't do anything about it? Yes, we can, Perl 6 has this right:
Getting an accurate result for such a simple calculation is not anecdotal. It is a real and major improvement. You can compare non integers for equality and get the correct result. Don't do that with most other programming languages.> say .3 - .2 - .1; 0 > printf "%.50f\n", .3 - .2 - .1; 0.00000000000000000000000000000000000000000000000000
Yes, this improvement comes with a cost. So long as we have hardware that is inaccurate, we'll need to work around it with software, and this is bound to be somewhat slower. Personally, I think that accuracy is more important than speed.
If speed was the only criteria, none of us would use Perl, we would all write our programs in C, nay, probably in assembly. But we don't. So, most of the time, speed is not the most important factor for us.
Well, sometimes, speed matters. And I probably would not argue for accuracy if that meant that computation was really "insanely slow," as you claim. But it is not insanely slow; it is just somewhat slower, as shown in my earlier post above, and this speed issue could just be solved with a faster CPU. And, as I said earlier, there are performance enhancements almost every week (and some very big ones should be there very soon).