Posts tagged 'groovy'

JVM Hello World with Groovy

For those that haven't seen it yet, the JVM Advent folks posted a great Groovy and Data Science blog post several days ago as part of the 2022 JVM Advent series. If you have an interest in Data Science, we recommend you check that out before continuing with this post. Today's post in the JVM Advent series is looking at the world of bytecode... [Read more...]

Adventures with GroovyFX

This blog looks at a GroovyFX version of a ToDo application originally written in JavaFX . First we start with a ToDoCategory enum of our ToDo categories: We will have a ToDoItem class containing the todo task, the previously mentioned category and the due date. @Canonical @JsonIncludeProperties ([ 'task' , 'category' , ... [Read more...]

Fun with obfuscated Groovy

An interesting tweet appeared in my feed this morning: And of course it prints the same thing in Groovy: char p( int i) { ( char ) ( 72.5 + i * ( 17488.589319014318 + i * (- 54923.96120078333 + i * ( 72666.96791801952 + i * (- 54398.97479321991 + i * ( 25980.955221285272 + i * (- 8426.37914599868 ... [Read more...]

Whiskey Clustering with Groovy and Apache Ignite

In a previous blog post , we looked at using Apache Wayang  (incubating) and Apache Spark to scale up the k-means clustering algorithm. Let's look at another useful technology for scaling up this problem, Apache Ignite . They recently released a new version , but earlier versions are also fine for our example. Before we start, a quick... [Read more...]

Groovy Dates And Times Cheat Sheet

Java has had a Date class from the very beginning and Groovy supports using it and several related classes like Calendar . Throughout this blog post we refer to those classes as the legacy date classes . Groovy enhances the experience of using the legacy date classes with simpler mechanisms for formatting, parsing and extracting fields from the... [Read more...]

Fruity Eclipse Collections

This blog post continues on to some degree from the previous post , but instead of deep learning, we'll look at clustering using k-means after first exploring some top methods of Eclipse Collections with fruit emoji examples. Eclipse Collections Fruit Salad First, we'll define a Fruit enum (it adds one additional fruit compared to the... [Read more...]

Deep Learning and Eclipse Collections

DeepLearning4J and Eclipse Collections revisited In previous blogs, we have covered Eclipse Collections and Deep Learning . Recently, a couple of the highly recommended katas for Eclipse Collections have been revamped to include "pet" and "fruit" emojis for a little bit of extra fun. What could be better than Learning Eclipse... [Read more...]

Deck of cards with Groovy, JDK collections and Ecl...

Once again, Donald Raab has produced an interesting blog post on Eclipse Collections ; this one shows some code for modelling and manipulating cards with Java 17 and Eclipse Collections. His related katas are highly recommended. Here is the same example in Groovy (4.0.5 was used here) with just a few tweaks: enum Rank { ACE , TWO , THREE , ... [Read more...]

Encryption and decryption with Groovy

Inspired by this recent blog entry , here is an example showing how to encrypt and decrypt with Groovy. Using the JDK crypto classes First, we need some text to encrypt. We'll use an excerpt of the one from the aforementioned blog post: var text = 'Contrary to popular belief, Lorem Ipsum is not simply random text. \ It has roots in... [Read more...]

Calculating Fibonacci with Groovy revisited

In a recent post , we looked at using Matrices with Groovy including using matrices to calculate Fibonacci terms. But do you need that complexity to calculate Fibonacci? Not, not at all. You can do various one-liners for that scenario (to repeat the calculation from that post): Stream. iterate ([ 1 , 1 ], f -> [f[ 1 ], f.sum()]).limit( 8... [Read more...]

Solving cryptarithmetic puzzles with Groovy and co...

Introduction When writing solutions to problems, we frequently strive to hide away implementation details. In Object-oriented (OO) programming, we might build a rich hierarchy of classes with well-thought out methods so that our final solution can be expressed in terms of simple nouns and verbs (methods and class instances) in our domain model. When... [Read more...]

Groovy List Processing Cheat Sheet

Declaring lists Several styles are supported for declaring lists: var pets = [ 'cat' , 'canary' , 'dog' , 'fish' , 'gerbil' ] // idiomatic Groovy var nums = [ 1 , 2 , 3 , 4 ] as LinkedList // use 'as' for other kinds of list var primes = List. of ( 2 , 3 , 5 ,... [Read more...]

Matrix calculations with Groovy, Apache Commons Ma...

This blogs looks at performing matrix calculations with Groovy using various libraries:  Apache Commons Math , ojAlgo , EJML , and Nd4j  (part of Eclipse Deeplearning4j ). We'll also take a quick look at using the incubating Vector API for matrix calculations (JEPs  338 , 414 ,  417 ,  426 ). Fibonacci The Fibonacci... [Read more...]

Life on Mars: Units of Measurement systems, Groovy...

The Mars Climate Orbiter was launched in 1998 as part of a multi-faceted Mars exploration program. It was lost due to a trajectory calculation error when nearing Mars. An investigation attributed the failure to a measurement mismatch between two software systems: metric units were used by NASA and US customary units were used by spacecraft builder... [Read more...]

Natural Language Processing with Groovy, OpenNLP, ...

Natural Language Processing is certainly a large and sometimes complex topic with many aspects. Some of those aspects deserve entire blogs in their own right. For this blog, we will briefly look at a few simple use cases illustrating where you might be able to use NLP technology in your own project. Language Detection Knowing what language some... [Read more...]

Detecting objects with Groovy, the Deep Java Libra...

This blog posts looks at using Apache Groovy with the Deep Java Library (DJL) and backed by the Apache MXNet engine to detect objects within an image. (Apache MXNet is an incubating project at the ASF .) Deep Learning Deep learning falls under the branches of machine learning and artificial intelligence . It involves multiple layers... [Read more...]

Working with SQL databases with Groovy and GraalVM

During the week, there was an interesting video and blog post on the latest GraalVM 22.2 Release. The release has numerous new features and improvements including: smaller native executables the ability to generate heap dumps in native executables experimental native image debugging within IntelliJ IDEA the ability to embed a Software Bill of... [Read more...]

Reading and Writing CSV files with Groovy

In this post, we'll look at reading and writing CSV files using Groovy. Aren't CSV files just text files? For simple cases, we can treat CSV files no differently than we would other text files. Suppose we have the following data that we would like to write to a CSV file: def data = [ [ 'place' , 'firstname' , ... [Read more...]

Groovy release train: 4.0.4, 3.0.12, 2.5.18

It's been a productive time for the Apache Groovy project recently. We recently released versions 4.0.4, 3.0.12 and 2.5.18 with 42, 21 and 15 fixes and improvements respectively. Two quick highlights for the 4.0.4 release before getting into more details about the release. Eric Milles has been interacting for many months with the team from the ... [Read more...]

Comparators and Sorting in Groovy

This blog post is inspired by the Comparator examples in the excellent Collections Refuelled talk and blog by Stuart Marks. That blog from 2017 highlights improvements in the Java collections library in Java 8 and 9 including numerous Comparator improvements. It is now 5 years old but still highly recommended for anyone using the Java collections... [Read more...]

Search blogs.apache.org

Today's active blogs

Popular blog tags

Related sites

Navigation