Blog

New BoxLang Feature: Static Functional Binding to BIFs

Maria Jose Herrera July 29, 2024

Spread the word

Maria Jose Herrera

July 29, 2024

Spread the word


Share your thoughts

Elevate Your Functional Programming with BoxLang!

Functional programming and higher-order functions (that receive or return other functions) give us powerful ways to transform data on the fly with concise syntax. If I have an array of strings and want them all uppercased, I can write this:

[ "luis", "brad", "jon" ].map( name -> uCase( name ) )

In the example above, omitting the parentheses around our lambda argument name is supported by ACF, but not by Lucee. BoxLang, of course, allows this! We’re also using the lightweight lambda syntax with a “skinny arrow” (->). This has no scope binding like closures and performs faster.

Review Original Post

But wait, there’s more! You don’t have to declare a closure or lambda inline; you can reference another unary function object like this (unary means accepting a single argument):

function makeUpperCase( String arg ) {
  return uCase( arg )
}
[ "luis", "brad", "jon" ].map( makeUpperCase )

This requires even more boilerplate than the first option. Have you ever wished you could just pass in the uCase BIF (Built-In Function) directly? Introducing static functional binding to BIFs!

Try BoxLang

Static Functional Binding to BIFs

There’s already a precedent for binding to static methods on classes (whether Box Classes or Java classes) like this:

ClassName::methodName

Now, we’re introducing a variation for statically referencing a method from a global scope where we omit the class name entirely:

::methodName

This expression yields an invocable BoxLang function that can be executed just like our makeUpperCase() example above. Here’s what our final form looks like:

[ "luis", "brad", "jon" ].map( ::uCase ) // [ "LUIS", "BRAD", "JON" ]

Nice and sweet! This works for any BIF accepting a single argument in map() or each() functional constructs.

[1.2, 2.3, 3.4].map( ::ceiling );    // [ 2, 3, 4 ]

["brad","luis","jon"].map( ::hash ); // [ "884354eb56db3323cbce63a5e177ecac", "502ff82f7f1f8218dd41201fe4353687", "006cb570acdab0e0bfc8e3dcb7bb4edf" 

You can even use BIFs that accept two arguments with a higher-order function that accepts a BiConsumer. (This example reduces a query object down to an array of structs in a very small amount of code)

myQry = queryNew( "name,position", "varchar,varchar", [ ["Luis","CEO"], ["Jon","Architect"], ["Brad","Chaos Monkey"] ]);

myQry.reduce( ::arrayAppend, [] ) // Array of structs for each row...

Conclusion

We hope this new feature unlocks some exciting productivity boosts for you. It’s available right now on the bleeding edge or this Friday in the next beta release and applies to BoxLang source files. Dive in and see how static functional binding can simplify your code and enhance your development experience!

Try BoxLang

Add Your Comment

Recent Entries

Discover the tools, tricks, and techniques every modern CFML and BoxLang developer needs!

Discover the tools, tricks, and techniques every modern CFML and BoxLang developer needs!

Into the Box 2026 is officially on the horizon, and it’s shaping up to be our most impactful conference yet.

Our mission this year is simple: **Make modernization approachable for everyone.** Whether you’re a seasoned ColdFusion veteran or a developer just starting your BoxLang journey, we’ve priced this event to ensure the entire community can join us in person.

Victor Campos
Victor Campos
March 05, 2026
From Lucee to Modern JVM Architectures for German Enterprises

From Lucee to Modern JVM Architectures for German Enterprises

How German companies running Lucee and CFML can evolve toward cloud-native JVM platforms

Across Germany, many enterprises rely on Lucee and CFML-based applications to run critical internal systems, customer portals, and business workflows.

Germany has one of the most active Lucee communities in Europe, supported by long-standing adoption of CFML across industries such as:

  • Manufacturing
  • Logistics
  • <...

Cristobal Escobar
Cristobal Escobar
March 04, 2026
BoxLang 1.11.0 Release

BoxLang 1.11.0 Release

We're proud to announce BoxLang 1.11.0, a highly focused performance and stability release that delivers measurable speed improvements across every BoxLang application, with zero code changes required. The team invested deeply in bytecode generation, class loading, lock management, and type casting to produce one of the most impactful runtime optimization releases to date. Alongside the performance wave, this release resolves critical concurrency bugs, hardens DateTime handling, and ships powerful new developer tooling.

Luis Majano
Luis Majano
March 04, 2026