Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Monday, July 16, 2012

Redis key-value database


Redis is a key-value database. It is similar to memcached but the dataset is not volatile, and values can be strings, exactly like in memcached, but also lists and sets with atomic operations to push/pop elements.
In order to be very fast but at the same time persistent the whole dataset is taken in memory and from time to time and/or when a number of changes to the dataset are performed it is written asynchronously on disk. You may lost the last few queries that is acceptable in many applications but it is as fast as an in memory DB (Redis supports non-blocking master-slave replication in order to solve this problem by redundancy).
Compression and other interesting features are a work in progress. Redis is written in ANSI C and works in most POSIX systems like Linux, *BSD, Mac OS X, and so on. Redis is free software released under the very liberal BSD license.
It is possible to think at Redis as a data structures server, it is not just another key-value DB, see all the commands supported by Redis to get the first feeling. Redis supports operations like atomic push and pop of elements on lists, taking ranges of elements from this lists at once, trimming of lists, server-side intersections of sets and even sorting data! To show our points we wrote a simple Twitter clone with PHP + Redis: it's a very simple but still a real world example of web application, the article explains step by step how to write scalable applications with Redis.
Supported languages: PHP, Java, Ruby, Python, Perl, Tcl, Erlang, Scala, Lua etc.

Devis's blog
read more...

Friday, April 27, 2012

Scala for Java programmers

There are many languages that target to the Java Virtual Machine (JVM) -- not just the scripting and dynamically typed ones. How about learning another statically typed language that is compiled JVM and seamlessly integrates to the Java platform? The latest mantra is "One Great VM, Many Languages", Right? :-)

We will look at - Scala? - a functional, object-oriented and concurrent language that runs on the Java platform. Note: this is not a language comparison exercise [i.e., X versus Y comparison to "conclude" which one is better!]. Rather, it is an attempt to give head-start to the Java programmers who want to learn other languages that run on the Java platform. So, the aim is same as it was for my blog past entries such as Java, Groovy and (J)Ruby, Java, JavaScript and Jython - except that we are now looking at a statically typed language...
read more...

Why Use Scala over Java

Scala does two things extremely well which Java (currently) does not.
1. Solve functional problems
  • At the most basic level, Scala has fully fledged closures with collections support. This means you no longer have to write boiler plate code such as (shamelessly ripped off a DZone post)
    public List<Item> bought(User user)
    {
        List<Item> result = new ArrayList();
        for (Item item : currentItems)
        {
            if (user.bought(item))
            {
                result.add(item);
            }
        }
        return result;
    }
    
But instead write something like:
def bought(user: User) = items.filter(user bought _)
  • There's more functional love, but I'm not qualified to talk about it since I currently still suck at functional programming :)
2. Solve concurrency in a safer way
  • Scala has an actors model (+ some other goodness) which is inheritly safer than Java's mutable data + locks on Thread model (no matter how good the libs are getting, Java is still hindered by the language).
I can't honestly think of too much else that makes Scala stand head and shoulders above Java. Lots of small gains and improvements yes, but also far more rope to hang yourself with. YMMV
read more...