Noze.io 0.2.5

Last week we announced our first public Noze.io v0.2.x branch, codename “Less than Prefect”, accompanied by the 0.2.3 release. This week we pushed a 0.2.5 release.

Changes in 0.2.5

  • Swift 3 port updates to 2016-06-06-a dev snapshot
  • streams module
    • the write stream was not properly retaining the core, leading to early exits of trivial programs e.g. ones which just contain console.log("hello")
    • AsyncIteratorSource and ASyncSinkTarget are now classes, not structs due to their use of closures and associated limitations.
    • crash fix in writeNextBlock
  • fs module:
    • readFileSync functions for bytes and strings (do not use! ;-)
    • added simple path.dirname and path.basename funcs
    • readFile callbacks now conform to the (err, result) style. Was (result, err) before.
  • http_parser module
    • we analyzed the performance as part of a Swift-vs-C shootout and incorporated some major performance enhancements
    • the API is now a little closer to the C original. The parser itself is now a struct http_parser and the callbacks are provided separately in a struct http_parser_settings
    • HTTPStatus moved to the http module
  • mustache module
    • better Dictionary KVC
    • reuse more code between Swift 2 and 3 versions
    • added support for partials
    • added support for lambdas, including nested rendering contexts
    • added asMustacheString to convert an AST back to a template String
    • HTML escaping! ;-) Values are now escaped properly.
  • json module
    • added jsonfile submodule. This carries convenience functions like jsonfile.readFile and jsonfile.writeFile.
      • due to the json module now depends on fs, but I suppose there are few Noze.io apps which do not link fs.
    • added a simple JSON.stringify (does not yet support indent and replacer)
    • added writeJSON(object:) and writeJSON(string:) methods to all byte streams
  • express module
    • move some JSON code to json module
    • make use of partials support in the enhanced mustache module, a demo is available as part of the express-simple example

Questions we received

“Is it possible to run Noze.io on a different queue but the main queue?”

Yes. This is described a little in Noze.io for people who don’t know Node. Essentially you just set core.Q to the queue you want. You may also want to core.disableAtExitHandler() and set the core.module.exitFunction. The tests make use of this capability.

“How do I properly import Noze.io into an existing Xcode project?”

There are various options to do this. If you have Swift 3, you can use the Swift Package Manager to import the Noze.io Package and swift build -X to generate an Xcode project for your package.

We also added an Xcode step-by-step example of creating a new Cocoa project which links to Noze.io: Add Noze.io to Cocoa project.

“Noze.io seems too big to me (just need streams and net). I hope in the future you’ll be able to split the projects into smaller parts”

Noze.io is already split into really tiny parts (19! individual dylibs). Yes, it is a big Xcode project and SPM package, but the the stuff it produces is a set of really small modules. You don’t need http, express or connect? Don’t link to those dylibs, they won’t add bulk to your program. In contrary, there are considerations whether the amount of dylibs should be reduced. To avoid dynamic linking overhead for short-running tools and to help the Swift optimizer.

Having said that: Once the Swift Package Manager is released (supposed to be part of the Swift 3 release), it may make sense to break out a few packages (e.g. Connect/Express). We are interested in feedback about that (is this really that useful?).

“I have to admit- you guys made really REALLY awesome work”

Well, Noze.io is already pretty neat. But honestly, there are still a lot of open ends too. But hey, thanks!

Happy WWDC 2016!

We wish you a successful WWDC 2016. Seems unlikely that Swift 3 is going to be released next week, but we’ll see :-)

hh

Written on June 11, 2016