News for hackers. Stuff that matters.
Re:Metabase: Why we picked Clojure by lectrick on Friday December 04, 2015 @12:16PM (#10677554)
Yes, Java is a mature language.

But any perusal of rosettacode.org is fairly indicative that other languages, while less mature, have adopted some good ideas.

For example, here's Quicksort in both Java and Elixir:

    public static <E extends Comparable<? super E>> List<E> quickSort(List<E> arr) {
    if (!arr.isEmpty()) {
        E pivot = arr.get(0); //This pivot can change to get faster results
     
     
        List<E> less = new LinkedList<E>();
        List<E> pivotList = new LinkedList<E>();
        List<E> more = new LinkedList<E>();
     
        // Partition
        for (E i: arr) {
            if (i.compareTo(pivot) < 0)
                less.add(i);
            else if (i.compareTo(pivot) > 0)
                more.add(i);
            else
                pivotList.add(i);
        }
     
        // Recursively sort sublists
        less = quickSort(less);
        more = quickSort(more);
     
        // Concatenate results
        less.addAll(pivotList);
        less.addAll(more);
        return less;
     }
    return arr;
     
    }
now Elixir:

    defmodule QuickSort do
      def qsort([]) do
        []
      end
      def qsort([pivot | rest]) do
        { left, right } = Enum.partition(rest, fn(x) -> x < pivot end)
        qsort(left) ++ [pivot] ++ qsort(right)
      end
    end
The advantage here is NOT just an "economy of typing."

There are no comments on this comment yet.