Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Introducing BoxLang : A new JVM language for pr...

Introducing BoxLang : A new JVM language for productivity and modularity!

Just like life, our code must adapt to the ever changing world we live in. From one day coding for the web, to the next for our tablets or APIs or for running serverless applications. Multi-runtime development is the future of coding, the future is to be dynamic. Let us introduce you to BoxLang.

Dynamic. Modular. Productive.

BoxLang redefines development with its dynamic nature, empowering developers to craft expressive and functional code effortlessly. Its modular architecture prioritizes flexibility, allowing for seamless integration into existing ecosystems.

Interoperability at its Core

With 100% interoperability with Java, BoxLang seamlessly bridges the gap between traditional and modern development paradigms, unlocking new possibilities for innovation and collaboration.

Multi-Runtime

From the tiny 2m operating system binary to running on our pure Java web server, CommandBox, Jakarta EE, AWS Lambda, Microsoft Functions, Web Assembly, Android and more. BoxLang has been designed to enhance and adapt according to it's runnable runtime.

The Fusion of Modernity and Tradition

Experience the fusion of modern features inspired by CFML, Node, Ruby, Kotlin, Java, and Clojure, combined with the familiarity of Java bytecode compilation, making BoxLang a language of choice for forward-thinking developers.

Empowering Transition with Transpiler Support

Transitioning from CFML to BoxLang is seamless with our JIT transpiler, facilitating smooth migration and preserving existing code investments.

Unlocking Creativity with IDE Tools

Unleash your creativity with powerful IDE tools tailored for BoxLang, providing an intuitive development experience and streamlining your workflow. Join us as we embark on a journey to redefine JVM development. Welcome to the era of BoxLang.

Ortus Solutions

June 24, 2024
Tweet

More Decks by Ortus Solutions

Other Decks in Technology

Transcript

  1. LUIS F. MAJANO • CEO Ortus Solutions • Computer Engineer

    • Born in El Salvador • USA since 1995 • Boqueron in progress • www.ortussolutions.com @lmajano @ortussolutions
  2. BoxLang is a modular dynamic language for the JVM, aiming

    to make your development more productive, expressive, functional, and available everywhere. DYNAMIC : MODULAR : PRODUCTIVE
  3. • New language and runtime for the JVM (Inspired by

    a polyglot team) • We are in Open Beta, Stable release in Fall • Scripting and templating language built-in • Dynamic language with an optional type system • Modern Java interop with none of the legacy, verbosity, and limitations • Highly functional, context-aware closures, pure lambdas and more • Application Framework with many concerns (events, caching, tasks, scheduling, async, etc) • Small, lightweight, and modular • Can reuse any Java or ColdFusion/CFML library • Easy to learn What is?
  4. Who we are? • Ortus is a professional open-source company

    • Founded in 2006, USA • Created all the major frameworks for the CFML eco-system • Package manager, CLI, MVC, DI/AOP, Testing TDD/BDD, etc • Manage over 300+ libraries • 18 years of servicing di ff erent software communities • 🇺🇸USA, 🇸🇻El Salvador, and 🇪🇸 Spain
  5. • We did not wake up one day and said

    “Let’s make a language.” • We are not that crazy! Well…. Maybe a little 🤪 • The culmination of 18 years of open-source development • We could not continue to innovate and create under current language vendors • We need a way forward for us at Ortus, our clients, and community • Dynamic languages on the JVM had not evolved recently • A language of the times Why?
  6. Goals & Vision • Be dynamic, modular, lightweight, and fast

    • Be 100% interoperable with Java • Be modern, functional, and fl uent (Think mixing CFML, Node, Kotlin, Java, and Clojure) • Modularity at its core • Take advantage of the modern JVM • TDD: Fully tested source code • Be able to support multiple runtimes • Have multiple transpilers CFML -> BoxLang, Groovy -> BoxLang X -> BoxLang • IDE and Tools • Compete in today’s language environments
  7. Multi-Runtime Architecture Any OS Docker MiniServer CommandBox Servlet Lambda Azure

    Android WebAssembly Coming Soon Coming Soon Coming Soon 6 MB 9 MB 6 MB 15 MB 15 MB 160 MB
  8. Wanna play? • try.boxlang.io • Internet playground for BoxLang •

    First Production BoxLang application • Powered by our AWS Lambda Runtime • Skinnable • Embeddable on any Site (Soon)
  9. AWS Lambda Runtime • Every request can fi re up

    its very own Lambda request • That means: • We never have to worry about how many instances we have • We never have to worry about queueing • We never have to worry about bad actors accessing other people’s fi les • We can easily update our Lambda runtime and all instances will be running new code • Lambdas have tiers too (staging, production, development) • Scale up as big or as small as we want
  10. Scopes // scripting + templates name = “boxlang” // Functions

    have a local + arguments + surrounding scopes function save( name ){ var transactional = true // pass scopes around saveData( arguments ) } // Treat scopes like maps function getMemento(){ return variables .filter( key, value -> !isCustomFunction( value ) ) } // Classes have three encapsulation scopes Class{ this.publicVar = “public” variables.privateVar = “private” static.field = 123 } • All variables are inside of scopes • Scopes backed by concurrent maps • Each execution context can have di ff erent scopes • Scripts • Variables • Functions • Arguments, local, + surrounding scopes • Classes • This (public), variables (private), static • Global Scopes • Application, request, server, session, etc
  11. Enhanced Types with Member functions fruits = [ "apple", "bananas",

    "pears" ] println( fruits.len() ) data = fruits .append( "orange" ) .filter( item -> item.findNoCase( "an" ) ) .each( item -> println( item ) ) .toJSON() "apple,bananas,pears" .listToArray() .filter( item -> item.findNoCase( "an" ) ) .each( item -> println( item ) ) person = { fname: "box", lname: "lang", age: 1 } person.fullName = () => person.fname & person.lname println( person.fullName() ) • All Java types plus: • Arrays (1 based index - Human Based) • Structs (ordered, unordered, weak, soft, etc) • Queries (Typed Columns) • DateTime (java.time) • Numeric ( fl oat, short, int, double, bigdecimal) • XML (Enhanced Maps) • All auto-castable, dynamic and functional • Fluent and Functional via member functions
  12. Functions // Java public int sum( int a, int b){

    return a + b; } // BoxLang no types function sum( a, b ){ return a + b } // Optional types Numeric function sum( numeric a, numeric b ){ return a + b } int function sum( int a, int b ){ return a + b } • All functions `public` by default • All return types `any` by default • All argument types `any` by default • What is any???? • 2 types of type inference • Compile-Time • Runtime • Auto-casting • Type promotions • Type Coercion
  13. Functions Arguments // Java Public void repeat( String str, int

    count, String separator ){} repeat( “hello”, 2, “;” ) // BoxLang repeat( required str, count:5, separator=“;” ){} // Call with defaults repeat( “hello” ) // Call with argument binding myMap = { str : “test”, separator : “,” } repeat( argumentCollection:myMap ) • Required arguments • Default values • Argument binding • Structs (Maps) • Arrays
  14. Functions Variables // Java int a = 1; String b

    = “xyz”; Map test = new HashMap(); List<String> myList = new ArrayList(); // BoxLang var a = 1 b = “xyz” map = { age : 0, today : now() } myList = [ “1”, 2, “3”, 4 ] orderedMap = [ age : 0, today : now() ] anotherFunction( local ) • No need to `var` in functions (automatic) • All go into a `local` scope • Inferred variables • Mix types if you want • Struct and array literals • Ordered Struct literals
  15. Variable re-assignments // Java int age = 30; age =

    “MyAge”; // ERORR // BoxLang age = 30 age = “Thirty Years Old!” final age = 800 • Variable re-assignments • Changing values and types are ok! • Unless you mark them as ` fi nal`
  16. Variable casting // Java String name = (String) myMap.get( key

    ); Double seconds = 4; Instant.now().toSeconds( seconds.toLongValue() ); // BoxLang name = myMap.get( key ) println( name ) seconds = 4 Instant.now().toSeconds( 4 castAs “long” ) • Auto-casting detection • Explicit casting if needed • castAs operator
  17. Variable Immutability/Mutability myArray = [1,2,3,4] myArray.append( more data ) myAsyncFunction(

    myArray.toImmutable() ) println( myArray ) myArray.toMutable().append( “hello” ) • `toImmutable()` memember method • `toMutable()` as well • Arrays • Queries • Structs
  18. Null Coalescene Operator ?: // Java Int getLength( String myString

    ){ if( myString != null ){ return myString.length() } return 0; } function getLength( myString ){ return myString.length() ?: 0 } • Any falsey expression can be used • Entire left hand expression detection
  19. String Interpolation function toString(){ return “Song{id=“#id#”, title=“#title#”, author=“#author#”} } function

    buildTemplate(){ return “””{ Id : “#id#”, Title : “#title#”, Author : “#getAuthor(id)#” }“”” } myMap = { id: createUUID(), title: “title”, author: “Luis” } buildTemplate( argumentCollection : myMap ) • Tired of string concatenation • Not anymore! • Anything between #expression# • “”” For big strings! • Combine with scopes to do bindings!
  20. Closures & Lambdas & UDFs function toString(){ return “Song{id=“#id#”, title=“#title#”,

    author=“#author#”} } variables.toString = variables.getString function delayFunction(){ return () => dowork() } runAsync( () -> startWork() ) .then( result => computeMoreWork( result ) ) .then( result => sendOrder( result ) ) • Context-aware closures • Pure functions: lambdas • UDFs
  21. Classes Class{ Property firstName; Property lastName; Property numeric age setter=false;

    } Person = new Person( “Luis”, “Majano”, “45” ) println( person.getFirstName() ) person.toJSON() • Automatic constructor • Automatic toString(), equals() and hashCode() • Automatic getters and setters • Automatic toJson()
  22. $bx - MetaProgramming Person = new Person() writedump( person.$bx.meta )

    callJavaClass( person.$bx.$class ) Class{ Property importantData; Variables .$bx .registerChangeListener( “importantData”, (Key, newValue, oldValue) => clearCache() ) } myMap = { name : “Luis”, born : now() } myMap .$bx .registerChangeListener( (key, newValue, oldValue) => doSomething() ) • Available on ANY object • Includes • Metadata • Class Representation • Meta Methods • Change listeners • Inject properties • Remove properties • Inject methods • Remove Method
  23. Templating Language • Made CFML famous • Best of JSP,

    Blade and ColdFusion/CFML • Create your own `<bx:MyTag>` easily • Import collections of tags • Use BIFs • Nesting • Data Encapsulation • Much More < b x : o u t p u t > < d i v c l a s s = "b x - d u m p "> < t a b l e c l a s s = "b x - t a b l e S t " t i t l e = "# p o s I n C o d e # "> < c a p t i o n c l a s s = "b x - d h S t " r o l e = "b u t t o n " t a b i n d e x = "0 " o p e n > < s t r o n g > Q u e r y : # v a r . r e c o r d c o u n t # r o w s < / s t r o n g > < / c a p t i o n > < t h e a d > < t r > < b x : l o o p a r r a y = "# v a r . c o l u m n L i s t . l i s t T o A r r a y ( ) # " i t e m = "c o l u m n "> < t h > # e n c o d e F o r H T M L ( c o l u m n ) # < / t h > < / b x : l o o p > < / t r > < / t h e a d > < t b o d y > < b x : l o o p q u e r y = "# v a r # " i t e m = "r o w "> < t r > < b x : l o o p a r r a y = "# v a r . c o l u m n L i s t . l i s t T o A r r a y ( ) # " i n d e x = "c o l u m n "> < t d > # e n c o d e F o r H T M L ( v a r [ c o l u m n ] ) # < / t d > < / b x : l o o p > < / t r > < / b x : l o o p > < / t b o d y > < / t a b l e > < / d i v > < / b x : o u t p u t >
  24. < b x : i m p o r t

    p r e f i x = "j a v a " n a m e = "o r t u s . b o x l a n g . r u n t i m e . t y p e s . e x c e p t i o n s . E x c e p t i o n U t i l "> < ! - - - T h r o w a b l e t e m p l a t e - - - > < b x : o u t p u t > < b x : s e t i s B X E r r o r = v a r i n s t a n c e o f "o r t u s . b o x l a n g . r u n t i m e . t y p e s . e x c e p t i o n s . B o x L a n g E x c e p t i o n "> < t a b l e b o r d e r = ' 1 ' c e l l p a d d i n g = ' 3 ' c e l l s p a c i n g = ' 0 ' t i t l e = "# p o s I n C o d e # "> < b x : i f i s B X E r r o r > < t r > < t h c o l s p a n = "2 "> E r r o r : # e n c o d e F o r H T M L ( v a r . g e t T y p e ( ) ) # < / t h > < / t r > < b x : e l s e > < t r > < t h c o l s p a n = "2 "> E r r o r : # v a r . g e t C l a s s ( ) . g e t N a m e ( ) # < / t h > < / t r > < / b x : i f > < t r > < t d > M e s s a g e < / t d > < t d > # e n c o d e F o r H T M L ( v a r . g e t M e s s a g e ( ) ) # < / t d > < / t r > < b x : i f i s B X E r r o r > < t r > < t d > D e t a i l < / t d > < t d > # e n c o d e F o r H T M L ( v a r . g e t D e t a i l ( ) ) # < / t d > < / t r > < t r > < t d > T a g C o n g t e x t < / t d > < t d > < b x : d u m p v a r = "# v a r . g e t T a g C o n t e x t ( ) # "> < / t d > < / t r > < / b x : i f > < b x : i f v a r . g e t C a u s e ( ) ! = n u l l > < t r > < t d > C a u s e < / t d > < t d > < b x : d u m p v a r = "# v a r . g e t C a u s e ( ) # "> < / t d > < / t r > < / b x : i f > < t r > < t d > S t a c k T r a c e < / t d > < t d > < p r e > # e n c o d e F o r H T M L ( E x c e p t i o n U t i l . g e t S t a c k T r a c e A s S t r i n g ( v a r ) ) # < / p r e > < / t d > < / t r > < / t a b l e > < / b x : o u t p u t >
  25. t h e C o l l e c t

    i o n = v a r ; i f ( v a r i n s t a n c e o f ' C G I S c o p e ' ) { t h e C o l l e c t i o n = v a r . g e t D u m p K e y s ( ) ; } f o r ( k e y i n t h e C o l l e c t i o n ) { ` ` ` < b x : i f N O T i s C u s t o m F u n c t i o n ( v a r [ k e y ] ) > < t r > < t h s c o p e = "r o w " c l a s s = "b x - d h S t " v a l i g n = "t o p " > # e n c o d e F o r H T M L ( k e y ) # < / t h > < t d > < b x : s e t d u m p ( v a r [ k e y ] ) > < / t d > < / t r > < / b x : i f > ` ` ` } Tag Islands • Template anywhere in script • Leverage the ``` • Great for emails, templating, you name it
  26. BoxLang Framework RUNTIME Application Service Async Service Cache Service Component

    Service Datasource Service Function Service Interceptor Service Module Service Scheduler Service
  27. Enterprise Caching Engine & Aggregator • Inspired by CacheBox •

    Enterprise Caching Engine • Extensible • Custom providers • Custom object stores • Listeners • Stats • Powers all internal caching
  28. Application Framework • Inspired by Java contexts • Create in

    fi nite segregated applications in a single deployment by using one fi le • Application.bx • Life Cycle methods: • applicationStart(), applicationEnd(), sessionStart(), sessionEnd(), requestStart(), request(), requestEnd(), onError(), etc. • Data Sources, class loading, application scopes, security, settings, etc. • Sub applications • Highly con fi gurable and Highly portable
  29. Scheduling & Task Framework • Schedulers are portable, fl uent,

    and human • Write them in BoxLang or Java • Task & Completable Futures framework from the JDK • Access to any executor in Java • Run schedules at the OS • Importer from Adobe/Lucee (Soon) • Task Visualizer (BoxLang Admin, BoxLang Debugger)
  30. Modern Dynamic Language • Dynamically typed just like CFML, but

    we go further… • JDK21+ Minimum • Fully JSR-223 Compliant • Clojure + BoxLang in development by Sean Cor fi eld • No re fl ection, we use InvokeDynamic for everything • DynamicObject: Any Object can be Dynamic! • All OO Constructs • Interfaces, superinterfaces and default method implementations • Abstract classes and methods • Static scope and methods on classes and interfaces • Use all-new JDK features and types • Collection of Dynamic Casters and Helpers
  31. Tooling Overview • BoxLang IDE • Language Debugger & LSP

    • Run classes with a main() • Run Scripts • Run / Manage Servers • Code Converters, Code Formatters • Code Quality • Visualizers
  32. Tooling Overview • CLI Tools • REPL: CLI code execution

    • Shebang Scripts: #!/usr/bin/env boxlang • File Runner: Run fi les • Schedule Runner: Run schedulers • Transpiler: Convert CFML to BoxLang • Compiler: BoxLang to Bytecode • Feature Audit: BIF and Tag report usage • Packager: Compile and package your modules or BoxLang apps
  33. Tooling - BoxLang IDE • Modern development fl ow •

    Inline documentation • Webservers panel • Works for BL and CFML • Run BL/CF code directly within VSCode • Debugger & Language Server • Committed to ongoing support and development - new features are on the way!
  34. Tooling - BoxLang Debugger • Purpose built • Integrates with

    VSCode via Microsoft’s DAP • Can debug both the CLI runtime and web server • You’ll never use writeDump() again!
  35. Tooling - BoxLang Language Server • Built with BoxLang! •

    The BoxLang runtime was built with the LSP in mind • Full access to the BoxLang syntax parser/compiler • Access to all BoxLang con fi guration, datasources, mappings, etc… • Extensible via BoxLang modules • Foundational for modern language toolchains • Intellisense • Static analysis • More coming soon…
  36. Java Interop • Interact with Java naturally • It’s just

    part of the language; no more separation • Type inference, auto-casting, type promotions and coercion • Long -> Doubles, Doubles ->Longs, etc • BoxLang Function -> Java Lambdas • You can import, extend, implement, annotate from Java Java Interop
  37. Java Interop • Concept of object resolvers: java, bx, custom

    • New BoxLang Scripting: MyScript.bxs • Components become Classes: MyClass.bx • All bx/bxm/bxs are runnable via the OS • Classes can have a main() runnable convention • BoxLang annotations Runnable Classes
  38. Multi-Parsers : BoxLang + CFML + ??? • Our way

    to split with the old and bring in the new • Transpile CFML into BoxLang • BoxLang is a NEW clean slate • Compat module for Adobe/Lucee • Multi-Step Compiler • Bx -> Java Source -> ByteCode (DebugMode) • Bx -> Bytecode (Almost done) • In Planning • Groovy to BoxLang • ??? To BoxLang Choose your path wisely! .cfc, .cfm .bx, bxs, bxm
  39. BL-AST • AST Visitors for custom tooling • Feature Audits

    • Transpiler • Pretty Printer • Code Quality • getClassMetadata()
  40. Event-Driven Language • Interceptors for the language, application, and request

    • The best way to scale the language • Listen to the entire or speci fi c language life-cycles • Modules can listen/collaborate events • boxAnnounce(), boxAnnounceAsync() : CompletableFuture Event Channels Event Producers Event Event Event Event Consumers Event Event Event
  41. Tested & Documented • TDD/BDD at the core of the

    language • 3500+ Tests Already • Test not only Java but BoxLang • Native BoxLang Assert constructs built-in • Fully Documented • Generated API Docs • boxlang.ortusbooks.com
  42. Modular Needs Modern Runtimes Have Various Needs!
 ( and CFML/PHP/Python/Ruby/Etc

    paradigms are outdated ) • Web Applications - HTTP Request/Response Data • Tasks and Queues - Watchers, Event Handling, Async • Lambda and CLI - fast start and blazing speeds! • iOS/Android - Low resource footprint, event handling • Web Assembly – Transpilation and Sandboxing
  43. BoxLang Modules • Inspired by our HMVC Framework: ColdBox •

    Core Runtime with lightest possible footprint • Taps into the language life-cycle • Write them in Java or BoxLang or Both! • Executable as CLI packages • Integrates with Maven/Gradle
  44. BoxLang Modular By Design! • Modular ecosystem, delivered by FORGEBOX

    (www.forgebox.io) • Core modules for DBMS’, Alternate Runtimes ( e.g. Lambda ), Mail, Encryption, CFML compatibility and more! • Write your own functions, components ( tags ), schedulers, JDBC Drivers, interceptions and more! • Module has an isolated class loading machinery • Boundless potential for community contribution and engagement! • Foment third-party vendors • FORGEBOX eCommerce Marketplace later this year
  45. BoxLang Extends BoxLang In fl uence core runtime behavior with

    BIFs, 
 Member Functions, Tags, Interceptors, and More!
  46. But there’s more! • BoxLang is fully JSR-223 Compliant and

    Modular • Allows ANY Java language to embed and use BoxLang • Allows ANY JSR-223 compliant language to run in BoxLang • Power of Modules: bx-jython • Full Python runtime embedded into BoxLang • Script, load python classes, modules, etc.