Posts Tagged ‘Java’

Zookeeper C# Client with IKVM .NET

September 27, 2014 3 comments

Why ?

A lot of big data technology created with JVM. The language are vary from plain old Java, Scala and Clojure. There are a huge number of Apache project for this kind of stuff. The infrastructure for building a serious data product is amazingly mature in Java world.

The server is in Java . Ok. fine. But do we have to code in Java too ? At least as a client using the server ?. I know that JVM is awesome, but the language is not so well compare to C#. Especially the latest one C# 5. But for now we have to admit that .NET world is very lack of Server solution.

I always try to find a client library in C#/.NET but seems that it’s not really mature or has been already dead before birth. I will give you an example for this one.


Zookeeper is for the distributed zoo

Zookeeper has been used as a distributed process control. If you still remember the operating system 101 about process, threads, inter-process communication so this one should be easy for you to learn. If you familiar using lock or any synchronization mechanism like mutex, semaphore etc, just think this as way to do to coordinate multiple server synchronization. And it’s only expose a simple primitive like a file system. This is amazing and flexible. At the same time also make you do a lot of works to get the stuff working.


So we know that Zookeeper is good, it used by a lot of big data technology like Storm, Kafka, etc. So we need to find a client library to use it right ? Good luck finding it for .NET. There are a couple of library for doing that stuff but it’s either old or not up to date.

A couple of sample of that kind of library is :

Read more…


6. Java vs C# (Extension Method)

January 31, 2010 5 comments

kita bisa menambakan method seolah2 method tersebut terletak di kelas tersebut.

namespace ExtensionMethods
    public static class MyExtensions
        public static int WordCount(this String str)
            return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length;

kita bisa menggunakannya sebagai berikut

using ExtensionMethods;
string s = "Hello Extension Methods";
int i = s.WordCount(); // seolah2 ada method WordCount pada string.

klo make java harus gini …

public class StringUtils
        public static int WordCount(String str)
              // something like this lah in java
             // return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length;

manggilanya seperti ini

String s = "Hello Extension Methods";
int i = StringUtils.WordCount(s);

jelas c# lebih mudah dibaca dengan extension method…..

Categories: Uncategorized Tags: , ,

5. Java vs C# Lamda Expression

January 31, 2010 Leave a comment

Lamda expression membuat code delegate jadi lebih singkat

int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int oddNumbers = numbers.Count(n => (n % 2 == 1)); // find the lambda expression here? and there's extension method too

mungkin ada yg bertanya2 darimana method Count yg ada di array integer? Itu extension method. Aku akan jelasin di postingan berikut

klo make java kita harus buat interface lagi dan melewatkannya sebagai strategy.

interface INumberSpesification {
    boolean isSatisfiedBy(int number);

class OddNumberSpesification extends INumberSpesification {
    public boolean isSatisfiedBy(int number) {
         return n % 2 == 1;

class Numbers {
    int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
    public int count(INumberSpesification a) {
        // foreach numbers cek dengan a.isSatisfiedBy(_element).
        // jika benar maka increment count
        // return count

simple is beauty. simple is fast.
more code more bugs

Categories: Uncategorized Tags: , ,

4. Java vs C# (Head to Head) LINQ

January 31, 2010 Leave a comment

klo di java mw cari elemen pada array yg lazim dilakukan adalah looping dan mengecek sampai kriteria yg diinginkan ketemu.

alangkah indahnya klo misalnya kita bisa query dari object….

LINQ is the absolute winner here…

public class Student
    public string First { get; set; }
    public string Last { get; set; }
    public int ID { get; set; }
    public List<int> Scores;

// Create a data source by using a collection initializer.
static List<Student> students = new List<Student>
   new Student {First="Svetlana", Last="Omelchenko", ID=111, Scores= new List<int> {97, 92, 81, 60}},
   new Student {First="Claire", Last="O’Donnell", ID=112, Scores= new List<int> {75, 84, 91, 39}},
   new Student {First="Sven", Last="Mortensen", ID=113, Scores= new List<int> {88, 94, 65, 91}},
   new Student {First="Cesar", Last="Garcia", ID=114, Scores= new List<int> {97, 89, 85, 82}},
   new Student {First="Debra", Last="Garcia", ID=115, Scores= new List<int> {35, 72, 91, 70}},
   new Student {First="Fadi", Last="Fakhouri", ID=116, Scores= new List<int> {99, 86, 90, 94}},
   new Student {First="Hanying", Last="Feng", ID=117, Scores= new List<int> {93, 92, 80, 87}},
   new Student {First="Hugo", Last="Garcia", ID=118, Scores= new List<int> {92, 90, 83, 78}},
   new Student {First="Lance", Last="Tucker", ID=119, Scores= new List<int> {68, 79, 88, 92}},
   new Student {First="Terry", Last="Adams", ID=120, Scores= new List<int> {99, 82, 81, 79}},
   new Student {First="Eugene", Last="Zabokritski", ID=121, Scores= new List<int> {96, 85, 91, 60}},
   new Student {First="Michael", Last="Tucker", ID=122, Scores= new List<int> {94, 92, 91, 91} }

kita bisa melakukan query dari data pada list tersebut dengan LINQ.

caranya adalah sebagai berikut..

// Create the query.
// studentQuery is an IEnumerable<Student>
var smartStudentQuery =
    from student in students
    where student.Scores[0] > 90
    select student;

sudah pasti lebih mudah dengan LINQ klo mw cari2 di tumpukan object….

Categories: Uncategorized Tags: , ,

3. Java vs C# (Delegates and Events)

January 31, 2010 Leave a comment

Di c# jelas lebih mudah mengimplementasikan Observer pattern dengan adanya delegates dan event.

Klo di Java? harus buatin interface2 lagi. Konsep2 yg dipake sama dengan konsep listener yg ada di swing.

jelas c# lebih simple…

Categories: Uncategorized Tags: , ,