Skip to content

Oak 0.2!

Compare
Choose a tag to compare
@thesephist thesephist released this 15 Mar 12:10
· 38 commits to main since this release

There's been a huge wave of improvements, fixes, and additions since v0.1 less than two months ago. The highlights include a static site generation system for the Oak website, expanded standard library modules, a much-improved and optimized Oak-to-JavaScript compiler, a built-in syntax highlighter, and oak eval / oak pipe commands.

std := import('std')
Oak := { version: '0.1' }
Oak |> std.merge({ version: '0.2' })

Standard library additions

  • std.(take, takeLast) in the standard 'std' module
  • std.stdin to read all of standard input in the 'std' module
  • std.loop can now return meaningful values from within the loop
  • str.trimStart and str.trimEnd now have forms with optional second argument, which will trim all whitespace to match the behavior of str.trim
  • sqrt, hypot, scale, bearing, orient, prod, clamp in the standard 'math' module
  • Statistics functions mean, median, stddev in the standard 'math' module
  • t.approx for comparing floating-point values in the 'test' module
  • fmt.format now also accepts format string variables that key into objects, rather than integer-index into the argument list. This means expressions like fmt.format('{{ name }}: {{ age }}, userProfile) work.

Improvements

  • Boolean combinators & and | now short-circuit in Oak
  • oak cat for syntax highlighting Oak files in the command line
  • oak eval and oak pipe for evaluating Oak code from the UNIX command line
  • The try() built-in function for interoperability with JavaScript's checked exceptions
  • Many rounds of optimizations went into the oak build --web compiler, including a few passes focused on bundle size.
  • The oak binary can now evaluate Oak code from standard input.
  • The router in the 'http' module now accepts any HTTP header, including OPTIONS, HEAD, and others.
  • The standard testing module 'test' how uses debug.inspect to pretty-print outputs of failing tests for more readable test results.
  • Tokens from syntax.Tokenizer now contain their byte offset position in the source file, in addition to line and column numbers.
  • The input() built-in function now reads from a single global buffer, and is capable of reading large files from standard input.

Fixes

  • Fixed infinite recursion from circular imports in bundles generated by oak build.
  • Deleting keys with o.key := _ now always works in JavaScript contexts.
  • str.(lower, upper) are more idiomatic and faster.
  • str.(upper?, lower?, digit?, space?, startsWith?, endsWith?) are faster.
  • Fix malformed format strings crashing fmt.format.
  • Guard against XSS vulnerabilities in the 'md' standard library module.
  • oak build --web now uses the JavaScript null coalescing operator ?? for safer and smaller bundles.
  • Fix some parser crashes caused by malformed Oak syntax input.
  • Improve error messages from syntax.Parser to always include the syntax error position.
  • The req() built-in function now correctly returns an error event instead of crashing if the HTTP connection fails to establish.

oaklang.org is live!

The Oak website has gotten to a point where I can officially say it's not "incomplete". There's still not much documentation on the site about the language or the standard libraries, but there is: