For the complete documentation index, see llms.txt. This page is also available as Markdown.

BIFs

Create custom Built-In Functions (BIFs) in BoxLang or Java for your module

BIFs are custom functions that extend BoxLang's built-in function library. Create them in pure BoxLang or Java.

Place .bx files in your module's bifs/ folder. They are auto-discovered and compiled at runtime.

File: bifs/Greet.bx

/**
 * Returns a greeting message
 *
 * @param name The name to greet (required)
 * @param greeting The greeting prefix (default: "Hello")
 *
 * @return The formatted greeting string
 */
function invoke(
    required string name,
    string greeting = "Hello"
) {
    return "#greeting#, #name#!"
}

Usage from BoxLang:

result = greet( "World" )
// → "Hello, World!"

result = greet( name = "World", greeting = "Hi" )
// → "Hi, World!"

Features:

  • ✅ No compilation — just create the file

  • ✅ Auto-discovered by folder scanning

  • ✅ Supports @BoxMember annotation for member methods

  • ✅ Full access to BoxLang runtime via injected services

Member Functions

Register BIFs as member methods on BoxLang types:

Usage: "hello".shout()"HELLO!!!"

When to Use Which

Criteria
BoxLang BIFs
Java BIFs

Complexity

Simple logic

Complex algorithms

Performance

Good for most cases

Critical paths

Dependencies

None or minimal

External JARs

Development speed

Fast iteration

Requires rebuild

Team skills

BoxLang developers

Java developers

Next Steps

  • Components — Create custom BoxLang tags

  • Interceptors — Listen to runtime events

  • Services — Global runtime services (Java only)

Last updated

Was this helpful?