Oak 0.2!
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'
modulestd.stdin
to read all of standard input in the'std'
modulestd.loop
can now return meaningful values from within the loopstr.trimStart
andstr.trimEnd
now have forms with optional second argument, which will trim all whitespace to match the behavior ofstr.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'
modulefmt.format
now also accepts format string variables that key into objects, rather than integer-index into the argument list. This means expressions likefmt.format('{{ name }}: {{ age }}, userProfile)
work.
Improvements
- Boolean combinators
&
and|
now short-circuit in Oak oak cat
for syntax highlighting Oak files in the command lineoak eval
andoak 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 usesdebug.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:
- A directory of syntax-highlighted standard library source files
- A blog with stories and deep-dives about Oak and Oak-based projects
- A "highlight proxy" for syntax-highlighting Oak files on the web