My name is Kamila. Let me welcome you on my homepage

You will find a handful of notes taken during my child's nap.

I write mainly about programming (EN/PL) (Java, Python, Go, JavaScript), play with generative art using p5js and I'm an author and illustrator of my children's books.

Have fun!

Modern Java in Action 8 - concurrency and reactive programming

Task appropriate for the job high parallelization : use fork-join pool and and parallel streams for highly CPU-bound calculations high interactivity: high concurrency and a need to keep a lot of IO-bound tasks on single CPU: use Future (Completable Future) or Flow API Problems and solutions Threads problems map 1:1 to OS threads (expensive to create and of limited number) much higher number than hardware threads (cores? well, it seems a core is more complex) CPUs like the Intel i7-6900K have multiple hardware threads per core, so the CPU can execute useful instructions even for short delays such as a cache miss.

Modern Java in Action 6 - Time and Date

Reasons to abandon old API java.util.Date mutable unintuitive constructor (days, months, minutes and seconds are 0-based, year represented as delta from 1900), values wrap-around cannot be internationalized java.util.Calendar not thread safe mutable (no clear semantics date change) when to use which? java.util.DateFormat not thead-safe can only parse Date, not Calendar New API java.time package Classes and interfaces in a new package java.time (modelled after Joda Time classes) provide better way of thinking about and working with time concepts.

Modern Java in Action 5 - Optional

Null problem Reasons why null is problematic: source of coding errors (missing checks) does not correctly model absence of value (null has no meaning) breaks Java philosophy of hiding pointers (null is a pointer which is NOT hidden) Handling in other languages Groovy has safe navigation operator Kotlin is known for its null-safety Haskell has Maybe typeclass Scala also has an Option class Optional Creating Three static methods may create instances of Optional:

Modern Java in Action 4 - refactoring and testing

Refatoring Here are three simple refactorings that can be used if you want to migrate your codebase to Java 8 (or higher). You may want to do so for many different reasons (readability, conciseness, code reuse, security). Refactoring anonymous classes to lambda expressions Refactoring lambda expressions to method references Refactoring imperative-style data processing to streams Recommended paper about automatic refactoing of pre-Java 8 codebases into Java8: Lambda Refactoring

Modern Java in Action 3 - collection API

New API (in Java 8) Collection classes got a few nice additions. Factory methods They create immutable collection (if you try to add/remove elements, you get UnsupportedOperationException. There is no varargs variant - this variant would require additional array allocation, which non-varargs variants don’t have. There are overloads from 1 to 10 elements. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 //static <E> List<E> of(E.