Skip to content

Conversation

@bentsherman
Copy link
Member

Initial attempt to upgrade to Groovy 5.

Benefits:

  • new collection functions like zip (can be added to Nextflow standard library)
  • pattern matching for instanceof (can be added to Nextflow language)
  • use _ for placeholder variables (can be added to Nextflow language)

Changes:

  • Had to remove generic type arguments from instanceof checks as the Groovy parser doesn't allow it anymore

  • Had to add @Slf4j to some inner classes to make log work in that class. not sure if this is a bug or just a breaking change

Current issues:

  • Groovy complained about a few implementers of CacheFunnel, even though I didn't see anything wrong. Converting CacheFunnel to Java fixed the issue for one but not the other

  • Multiple issues with the type checker that I'm pretty sure are just Groovy bugs, particularly CmdLog and DumpOp

  • The type checker does not recognize target in TaskConfig as a Map, seems like a bug. I wonder if it's an edge case since target is defined in super class as private and a Delegate

Overall it looks like Groovy 5 beta still has a few compiler bugs to sort out. But I'm excited to get it working so that I can bring the new pattern matching features into the Nextflow language.

@bentsherman bentsherman requested a review from a team as a code owner June 25, 2025 19:33
@netlify
Copy link

netlify bot commented Jun 25, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 5f0a0c6
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/685c4ef8f0e52800088d8c64

@bentsherman bentsherman marked this pull request as draft June 25, 2025 19:33
@pditommaso
Copy link
Member

Worth following this discussion, it looks like there are not negligile perf issue with Groovy 5 and invoke dynamic apache/grails-core#15293

@bentsherman
Copy link
Member Author

Interesting, it looks similar to the issues they had with Groovy 4.

It looks like one commenter avoided the perf issues by using @CompileStatic and converting code to Java. Since most of the Nextflow codebase is already statically compiled, I suspect we won't be affected as much. But we'll have to run a benchmark to know for sure

Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 177a5a8
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/695d94301190d60008879e84

Comment on lines +303 to +304
// ERROR: Cannot call java.lang.Integer#compareTo(java.lang.Integer) with arguments [java.lang.Object]
while( (line=reader.readLine()) && c++ < MAX_LINES ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried changing the type of c and MAX_LINES to Integer but I get this type checking error regardless. Seems like a Groovy type checker bug

Comment on lines +84 to 85
// ERROR: Cannot find matching static method nextflow.extension.CH#createBy(groovyx.gpars.dataflow.DataflowWriteChannel)
final target = CH.createBy(source)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my limited knowledge of how the Groovy type checker does type inference with instanceof, it seems to be applying the instanceof check incorrectly, treating source as type DataflowWriteChannel through the entire method instead of just the if statement. Likely a Groovy bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants