There are many programming and computer books out there and I’ve read many. Some were good, some were bad, some just plain fucking terrible. But some books out there are so good that they become classics and a standard for other books and “must reads” for everyone interested in the topic. The book “The Linux […]
The group_by method from Ruby’s Enumerable mixin (and compared with Scala)
A few weeks ago I wrote about the groupBy method from Scala’s collection library. Today I will port those example to Ruby for which there is also such a method, just with s slightly different name (group_by instead of groupBy). For the idea behind the method, see the post about Scala’s version. Here I will […]
A little functional Java – the map function
Functional programming is getting a lot of interested nowadays. Languages like Clojure or Scala are on the rise and even languages like Haskell which where formerly considered to be mostly academic are getting more and more popular. And more and more Java programmers are thinking about functional programming. Java 8 will get lambda expressions which […]
- Concurrency
- ...
How to use java.util.concurrent.CountDownLatch
With some applications that use several threads there are situations where one thread can only start after some others have completed. For example, image a program that downloads a bunch of web pages, zips them and send then the zip file via email. If you program this in a multithreaded way, the thread that zips […]
BitSets in Scala are much more fun than in Java
Recently I played with BitSets in Java because I needed an efficient way to store huge amounts of long values. For Java there is the java.util.BitSet class. It is a very efficient implementation when you only need to store bit values. Here is a trivial example on how to use it: import java.util.BitSet; public class […]
Using DirectoryStreams in Java 7
Java 7 comes with lot’s of new stuff for IO. The new interfaces and classes added to the java.nio package contain lot’s of useful functionality for working with files and other things like asynchronous IO. Here I want to show you a little bit about the interface DirectoryStream which is very useful when you want […]
- Concurrency
- ...
How to make Java classes immutable
Immutable classes have been a hot topic lately. The rise of functional languages who operate mostly on immutable data and the advantage of immutable data when using multiple threads (correct immutable classes are thread safe) have also created a new interest in immutable data in Java. While some languages like Scala encourage (but do not […]
File system events with Java 7
In the last post, I showed how to listen to Linux file system events using C, Ruby and Python. In this post, we look at Java 7. Java 7 has several new classes in the java.nio.file package that let you listen to file system events. The number of events available is not as extensive as […]
Linux file system events with C, Python and Ruby
Some applications (like file managers, monitoring tools, etc) need to know about events in the file system, for example when a file was created, opened or deleted. With Linux, you can use the inotify mechanism to react to those events (with kernel 2.6.13 or above). In this article, I show you examples for it’s usage […]