Thursday, June 12, 2014

Apple Computers Denial Costs Resources to the Planet

We are a breed of human beings committed to develop applications; these must be practical, efficient and easy to use. Several hundred thousand of us—probably more in the region of several million—are pursuing the ultimate application. If only one of them reaches the goal—perhaps shared by several thousand—that will be enough for final users; they do not need more developers working on something they already have!

The really BIG names like Google, Apple, Microsoft—and other big names—revolve around entities financially much smaller than them. Who keeps the standards of JavaScript up to date? All I know is that, as a developer of a WEB application, I must be constantly visiting developers.mozilla—or something similar. That is where I find answers.

But some environments are definitely better than others. As developers, we need to cope up with representing numbers—accounting and other sorts. As you, the reader, may already know by now, a quantity like this:

34497.6771

Will be represented in different ways, depending on the region of the world where the web page visitor is located:

  • USA: 34,497.68 (Notice the rounding)
  • UK: 34.497,68 (Rounding, again, but commas and periods have been exchanged)

France, Germany or Spain follow rules that are different from the rules followed by countries in America, Asia or Africa.

And that is the part about representing numbers. Just think about the part representing Dates!

Computers store dates and numbers in binary structures. As web visitors open pages from different parts of the world, numbers and dates are expected to appear according the reader’s geographical location.

JavaScript is where the Web Page intelligence is constructed. Developers must write really efficient JavaScript code to interpret correctly what Internet browsers are receiving from servers located anywhere in the world.

And for representing values of numbers and dates, JavaScript offers a fantastically brilliant function:

toLocaleString(Arg1, Arg2)

If developers read carefully developers.mozilla instructions, it will all work just fine! Right?

Wrong!

It will not work fine simply because people at Apple Computers, those who designed iPhones and iPads and the iOS (operating system) that runs them, decided to laugh at regional needs!

And people at Microsoft decided to make things more difficult for code writers, by ignoring function Intl. (an object) in their JavaScript implementation.

The following function works well in MSIE, Chrome and FireFox; however, it is simply ignored by Safari:

parseFloat(p.rows[i][p.fields[j].alias]).toLocaleString(ltag,lpat);

The purpose of that line of code is simply to present—print, show—a number value in the proper way, according to where the page is being shown. That code effectively shows the proper format when using any of the following browsers:

  • Chrome (under Android, Windows 8.+)
  • FireFox (under Android, Windows 8.+)
  • MSIE (under Windows 8.+ in a PC)

Both, Chrome and FireFox fail when their iOS versions are used, including MACs.

The same JavaScript function is ignored by Safari under any platform. We need to conclude that the implementation of JavaScript under iOS devices is something that was developed under the supervision of persons like Steve Jobs. I have to wonder: was he mad at regional differences? Neglecting proper attention to the representation of numbers and dates, processed by the JavaScript engine, is a serious denial, especially considering the millions they make by the minute.

And Microsoft… What about Microsoft? Here we go:

If the following code is entered in a JavaScript function of globally, then, the next code can also be used, instead of the first one mentioned earlier.

var nfr = new Intl.NumberFormat(ltag,lpat);

Then any JavaScript coding could have included the following code part (more efficient):

nfr.format(parseFloat(p.rows[i][p.fields[j].alias]));

Instead of this part (less efficient):

parseFloat(p.rows[i][p.fields[j].alias]).toLocaleString(ltag,lpat);

Which is less efficient and takes up more CPU time. Fortunately, we are talking about the CPU of the machine where the web browser is being used. But because Microsoft decided not to implement object Intl, the millions of web browsers opened all over the world, must use more CPU power, that somebody—the Planet, the rest of us—must pay for.

To Google Chrome: Is it so difficult to provide your application for iOS devices (iPhone, iPad, iPod) along with your implementation of JavaScript?

To Apple Safari: Is it impossible to put 2 programmers to implement the proper JavaScript functions for representing numbers and dates correctly in your computers and devices?

To Microsoft Internet Explorer: Those hundreds of programmers in Redmond are incapable of implementing the correct Intl function in your browser?

It is the time of millions of programmers and developers that is stolen daily by the negligence and lack of responsibility of those to-make-money organizations.

That is one of the mechanisms that make the small human individual remain economically small; just one more reason to advocate for the zeitgeisty idea of ending the money model for good!