C++ has operator overloading. Java does not. Java folks just say the operation overloading is really bad, that it provides bad abstraction and leads to very unreliable and difficult to manage code. That’s why Java doesn’t have operators overloading.
Last time I wrote about common problem with the random function. PostgreSQL has only the random(). There is no function like random(from, to) or random(length), which returns a random text of the given length.
This time I just needed a function which returns a random text of the given length. Then it can be used like this: SELECT random_text(42). The random text will be used as a slug in a web application, so I need only numbers and letters and let’s also have only uppercase.
Let’s create a PL/pgSQL procedure for returning a random text with the given length.
There is a common problem with many homemade random functions. All
languages which I know have some kind of random() function. This function returns a floating point number within the range [0.0, 1.0) with uniform distribution of values.
The random generators can have different distribution of the values, but in this entry I will just write about the uniformly distributed generator.
Some time ago I was asked about long running transactions. Is that
really so bad and how long should a transaction run? I will try to reply
that question now, as it returns all the time. The answer is not so
trivial, as usually when you ask about databases.
Last time I was checking speed of Java
primitives. It
turned out that Integer is much slower than int. This time I want to
check how much slower is the String concatenation compared
to the StringBuffer and the StringBuilder.