Tag: Java

  • My take on named parameters in Java

    Named parameters allows calling a function using parameter names with their corresponding values instead of using values at given position. This feature is slightly different from language to language, and some of them lack this feature at all. Among additional behaviors we emphasize the possibility of specifying default parameter values and the possibility to specify…

  • Java Recursive Generics

    From time to time I like to take a look at Java JDK source code to learn more about how the contributors think about various topics. While I was looking into how enum is implemented, I noticed something very familiar in the declaration of Enum class, the class which is responsible with enum implementation in…

  • Tail Call Recursion in Java with ASM

    One kind of optimization offered by some compilers is tail call optimization. This optimization does not bring much, since the programmer can always tailor his code without recursion, especially in an imperative language. On the other side, recursive code often times more elegant, so why we don’t let the compiler do the nasty stuff when…

  • Fast Parallel Sieve of Eratosthenes in Java

    Recently I was playing a little with prime numbers and I needed a prime number generator for which I wrote a sieve of Eratosthenes in Java. Since I wanted all primes up to 10^9, I became a little impatient about the time taken to generate those primes. So I started to optimize it incrementally. Also…

  • Java foreach or not

    There are a lot of opinions regarding the for each construct and some of them are plain wrong. I am usually not bothered by wrong opinions, but this is a simple issue which can be clarified. I was triggered by two articles on Medium which appears first when you search google for “java foreach performance”…