How to sort rated content

If you are a web developer, or at least a webmaster, and if you have rateable content on your website, you probably almost once faced this common problem: how should I sort my content, using the collected rating data?

As a common problem, it has common but different solutions, most of which are wrong. We will analyse two cases: the up/down rating, and the 5-star rating.
Continue reading

Mastering the Ackermann Function

Yesterday I came in touch with a curious, astonishing mathematical function. It's called Ackermann function.

Mathematically speaking, it is a well-defined total function. That is, it has defined values for every integer input (= total function), and this value is not ambiguous (every input has one and one only possible output value) (= well-defined).

Speaking about computer science, this function is computable, but it's not a primitive recursive function. In other words, you can implement an algorithm to express the function using while-loops (= computable), but still you cannot write an equivalent algorithm using only do-loops (= not primitive recursive). I suggest you to try this statement.

The function has this form:

As you can see, it's form is fairly simple. But, even if it seems simple, its values explode quickly. A(4, 2), for example, has more than 19.000 digits.

Ackermann Function on the complex plane

Representation of the Ackermann Function on the complex plane

What I want to talk about is the possible implementation of such a function by means of a computer algorithm. I will use Python for the next examples, but the description is language-independent.

Continue reading

Apple updates the (Mobile) Apple Store

It seems almost clear to me that Apple is betting on iOS and it future. Almost exclusively on iOS, I would say. And at the same time the old Apple "core business" is being left behind. Slowly.

Just look at the recent updates. iPhone OS 3.1.3 for iPhones and iPos Touch's. Then iPad and the consequent iPhone OS 3.2. Then the new iPhone 4 and the developers' beta preview of the new iOS 4. Then again a recent fix with iOS 4.0.1 and a preview of the next iOS 4.1. The mobile market seems to be a very profitable one. To the extent that Apple is betting everything on iOS and very little on Mac OS & Co. Let's see why.

We can recognise this to be true if we carefully look at the Apple Store. All the recent updates are about:

  • MacBook Pro
  • Mac Mini
  • iMac
  • Mac Pro
  • Apple Cinema Display

All the updates mainly interested internal hardware upgrade, with no significant updates to the product as a whole. Apple has always been late, speaking about the internal hardware of their products. Just think about Sony. They sell VAIO's (I once owned one, will never go back to it) which cost almost half the cost of a MacBook and have almost twice-powerful hardware (speaking about internal CPU, GPU, RAM memory and HD bundles).

They are trying to get back on track. But even with the latest updates, Apple has just put a little redesign to the internal hardware configuration. Some new Core i3, i5 and i7 processors appear (about 8 months later than the competitors). Some new nVidia graphics card are replacing the older ones, but these models too are already old. A discrete nVidia 330M for a top line product as the MacBook Pro seems ridiculous to me. Yes, they made really big improvements to the MBP screen, introducing a new Hi-Res display for the 15" model. A great move, I admit.

But the "packaging" is always the same, and the price has unexpectedly risen. Only the Mac Mini has gone through a complete redesign, to couple its design to that of the Apple TV. I prefer not to talk about it, since it is one of my greatest dreams, but since I'm in Italy I would pay 799 EUR for it (~ 1.049 USD) instead of 699 USD. Unbelievable.

The packaging is always the same, I just said. The MacBook Pro's have not changed since the last year. The iMac has not changed since the last two years. Even the Mac Pro will not change. These products' design could surely be improved, but Mother Apple is focusing on something completely different.

In this new touch-based world, they release the new Magic Trackpad. It's cool. But useless, in my opinion: why would I use a trackpad when I'm using an iMac? That said, it surely will sell a lot.

And in this Apple-centric market, they release the new Battery Charger. Apple can sell you everything you need to play internet, music, videos and games. Everything.

They're pushing through these new routes. They're pushing through frequent iOS updates. Frequent mobile devices updates. Frequent complementary mobile devices introductions. But they are loosing grip on the whole Mac OS world.

I hope they do not abandon Mac OS in the middle of a road.
I still hope to withstand the miracle of a Mac OS XI.
I hope they will not convince me to do everything I am used to through an iPad.
At least, as long as they do not give me one for free.

Follow the White *Rabbit* iPhone 4

Apple has recently stated that they are experiencing difficulties in building and delivering the white iPhone 4 model, due to a problem (probably) related to the new front Gorilla Glass painting procedure.

The late-to-come white model is going to destroy people's expectations, especially of those one who have waited till now just to buy this glamour model. We still do not know when will we be able to grab the white one, and probably we will not for a long time.

Once again, we have to wait for Apple to reveal when this delay will come to an end.

Antennagate: Apple avoids the problem and loses in 5 moves

Everyone should know, by now. The latest Apple creation, the astonishing new iPhone 4, has some really big issues. The main is certainly the so called "death-grip": depending on how you hold the phone, it eventually loses signal and drops calls. As Apple said, "X marks the spot", the spot being the little gap between two external antennas on the outer edge of the new iPhone.

I will try to demonstrate that Apple is avoiding the problem giving void answer and trying to pilot the customers' and press opinion towards wrong concepts.

I will not post here the (really) many video demonstrating how you can make calls drop just using one finger, but I suggest you to search for them on YouTube. This is what actually happens: if you short-circuit the two antennas using your hand (or finger) the antenna reception gets weaker, signal drops from 5 or 4 bars to 1 or 0, and eventually the call drops.
Continue reading