Skip to content

Latest commit

 

History

History
119 lines (100 loc) · 3.88 KB

index.md

File metadata and controls

119 lines (100 loc) · 3.88 KB
layout title tags
default
Noze.io - Evented I/O streams for Swift
nodejs swift server side streams

Noze.io is an attempt to carry over the Node.js ideas into pure Swift. It uses libdispatch for event-driven, non-blocking I/O. Noze.io is built around type-safe back-pressure aware pull-streams (using Swift generics) operating on batches of items. Instead of working with just bytes, deal with batches of Unicode lines or database records or HTML responses or - you get the idea. Be efficient: Stream everything and ßatch.

Note: Consider this deprecated. Noze.io works on top of GCD and is overall really inefficient and slow for various reasons. Macro.swift is an effort the eventually rewrite it on top of SwiftNIO.

A focus is to keep the API similar to Node. Not always possible - Swift is not JavaScript - but pretty close. It comes with rechargeables included, Noze.io is self-contained and doesn't require any extra dependencies. No extra C modules, pure Swift.
Haz awezome modules such as: cows, leftpad, express, and redis.

Noze.io works in Cocoa environments as well as on Linux. It uses Swift 3 or 4 on macOS or tuxOS. Head over to our Start page for install instructions.

Is it a good idea? You tell us. Not sure, but we think it might be, because: a) While Swift looks like JavaScript, it is actually a very high performance, statically typed and AOT-compiled language, b) Code often looks better in Swift, mostly due to the trailing-closure syntax, c) No monkey patching while still providing extensions. There are cons too.

Shows us some code!

There is a reasonably large collection of simple, focused: Noze.io examples. But here you go, the "standard" Node example, a HelloWorld httpd:

import http

http.createServer { req, res in 
  res.writeHead(200, [ "Content-Type": "text/html" ])
  res.end("<h1>Hello World</h1>")
}
.listen(1337)

An echo daemon, just piping the in-end of a socket into its own out-end:

import net

net.createServer { sock in
  sock.write("Welcome to Noze.io!\r\n")
  sock | sock
}
.listen(1337)

More complex stuff including a Todo-MVC backend can be found in the Noze.io examples. Like what you see? Head over to our Start page to get started.


{% for post in site.posts %}
  <h1><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></h1>

  <div class="entry">
    {{ post.excerpt }}
  </div>
  
  <div class="date">
    <table border="0" width="100%"> <!-- old skool -->
      <tr>
        <td>{{ post.date | date: "%B %e, %Y" }}</td>
        <td style="text-align:right;"><a href="{{ site.baseurl }}{{ post.url }}" class="read-more">Read More</a></td>
      </tr>
    </table>
  </div>
</article>

{% endfor %}