<font size=2 face="sans-serif">To add some data into the debate...</font>
<br>
<br><font size=2 face="sans-serif">The C based http_parser used by Node.js
(and original from NGINX) is approx 3K lines of code. If we think strictly
in terms of effort to implement (and ignore maintenance costs or what's
required to reach the same quality levels etc) then it shouldn't be an
unreasonable amount of effort to do a Swift implementation - and in fact
we could look at both approaches and see which is preferable (as both approaches
have been taken by Swift frameworks already).</font>
<br>
<br><font size=2 face="sans-serif">The nghttp2 library however is approx
64K lines of code (looking only at the src directory). As such, its a much
bigger task to implement, and to do so in a bug-free manner - note that
the tests are another 17K lines of code.</font>
<br>
<br><font size=2 face="sans-serif">As an aside, wrapping the nghttp2 library
is the approach being taken by Node.js for their HTTP/2 support.</font>
<br>
<br><font size=2 face="sans-serif">Chris<br>
</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Tyler Cloutier via
swift-server-dev &lt;swift-server-dev@swift.org&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Helge Heß &lt;me@helgehess.eu&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Swift Server Dev &lt;swift-server-dev@swift.org&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">06/11/2016 19:35</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">Re: [swift-server-dev]
HTTP Parser</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Sent by: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">swift-server-dev-bounces@swift.org</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=3>I would agree that wrapping the nodejs http_parser is
probably the way to go for now. There is a lot of places we could spend
our time, but given that that is an extremely well tested program at this
point, I don’t see the need to put any wood behind that arrow. Writing
a Swift wrapper around it is not difficult and frees us up to work on other
more pressing things. In fact many of us, have already </font><a href=https://github.com/SwiftOnEdge/Edge/blob/master/Sources/HTTP/Parser.swift><font size=3 color=blue><u>done
it</u></font></a><font size=3>.</font>
<br>
<br>
<br><font size=3>Tyler</font>
<br>
<br>
<br><font size=3>On Nov 4, 2016, at 2:18 PM, Helge Heß via swift-server-dev
&lt;</font><a href="mailto:swift-server-dev@swift.org"><font size=3 color=blue><u>swift-server-dev@swift.org</u></font></a><font size=3>&gt;
wrote:</font>
<br>
<br><font size=3>On 4 Nov 2016, at 21:20, Paulo Faria &lt;</font><a href=mailto:paulo@zewo.io><font size=3 color=blue><u>paulo@zewo.io</u></font></a><font size=3>&gt;
wrote:</font>
<br><font size=3>Logan, would you be kind to explain why you think we shouldn’t
touch C?</font>
<br><font size=3><br>
Well, I think the rational is pretty clear. Staying within a single language
has obvious benefits. Add to that safety features inherent to Swift designed
solutions (buffer overruns and such) as well as the relative beauty of
a modern language.<br>
<br>
http_parser is a very C thing, it makes extensive use of pointers, goto’s
and other C ‘tricks' to accomplish the performance it has. It is reasonably
small and focused code but certainly not code which is straight forward
to read&amp;understand.<br>
<br>
At the same time http_parser is a nice demo on how a high performance C
core implementation is used in a high-level language environment (Node.js).
The user of Node.js doesn’t have to deal with the C stuff at all.<br>
<br>
Anyways I stick to my original opinion:<br>
—snip---<br>
Personally I’d suggest a small wrapper around this one: </font><a href="https://github.com/nodejs/http-parser"><font size=3 color=blue><u>https://github.com/nodejs/http-parser</u></font></a><font size=3><br>
—snap—<br>
<br>
But if someone has a great Swift parser providing the key features I’m
interested in (push based, as zero copy as possible, reasonably fast),
I’m quite interested too :-&gt;<br>
<br>
hh<br>
<br>
</font>
<br><font size=3>My argument is that using a C library that we all know
works well gives us time to work on more important things, like the user-facing
API. You mentioned that we all like Swift because it’s safe, succinct
and clean. I think we can all agree with that, but that statement doesn’t
correlate to using a C lib. We wouldn’t be _implementing_ the parser in
c, we would be _using_ a existing c parser. So the work would fall into
what we’ll already have to do when dealing with C POSIX APIs, for example.
Using a C lib would be one less thing to maintain. So again we can focus
on creating safe, succinct and clean code where it really matters, the
API level.<br>
<br>
</font>
<br><font size=3>On Nov 4, 2016, at 5:18 PM, Logan Wright via swift-server-dev
&lt;</font><a href="mailto:swift-server-dev@swift.org"><font size=3 color=blue><u>swift-server-dev@swift.org</u></font></a><font size=3>&gt;
wrote:<br>
<br>
Helge, if I had my way, we wouldn't touch C in any way whatsoever for any
of the server side libraries except as an absolute last resort, but this
life is full of compromise, and I'm trying to be amicable to come up with
solutions that we can agree on.<br>
<br>
For HTTP2 as well, I'd like plans to eventually move to pure swift native
implementations rethought for the language. <br>
<br>
On Fri, Nov 4, 2016 at 3:17 PM Helge Heß via swift-server-dev &lt;</font><a href="mailto:swift-server-dev@swift.org"><font size=3 color=blue><u>swift-server-dev@swift.org</u></font></a><font size=3>&gt;
wrote:<br>
On 4 Nov 2016, at 20:11, Logan Wright via swift-server-dev &lt;</font><a href="mailto:swift-server-dev@swift.org"><font size=3 color=blue><u>swift-server-dev@swift.org</u></font></a><font size=3>&gt;
wrote:</font>
<br><font size=3>That said, even if we do end up doing that short term,
I'd like to include plans or at least intentions to do things in Swift.
I (and I'm sure many of us) generally prefer working in Swift because it's
safe, succinct, and clean. We also have several instances of existing HTTP
parsers we could pull from, it's not like we're starting from 0 as a group.<br>
<br>
For HTTP2, I think everyone is in agreement that a c library is the way
to go. I'd like to give HTTP a bit more time for opinions to come in.</font>
<br><font size=3><br>
I’m not entirely sure why you have double standards here. Why would you
come up with a safe, succinct and clean HTTP/1.x parser but not do the
same for HTTP/2?<br>
<br>
hh<br>
<br>
_______________________________________________<br>
swift-server-dev mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:swift-server-dev@swift.org"><font size=3 color=blue><u>swift-server-dev@swift.org</u></font></a><font size=3><br>
</font><a href="https://lists.swift.org/mailman/listinfo/swift-server-dev"><font size=3>https://lists.swift.org/mailman/listinfo/swift-server-dev</font></a><font size=3><br>
_______________________________________________<br>
swift-server-dev mailing list<br>
swift-server-dev@swift.org<br>
</font><a href="https://lists.swift.org/mailman/listinfo/swift-server-dev"><font size=3>https://lists.swift.org/mailman/listinfo/swift-server-dev</font></a>
<br>
<br><font size=3><br>
_______________________________________________<br>
swift-server-dev mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:swift-server-dev@swift.org"><font size=3 color=blue><u>swift-server-dev@swift.org</u></font></a><font size=3><br>
</font><a href="https://lists.swift.org/mailman/listinfo/swift-server-dev"><font size=3>https://lists.swift.org/mailman/listinfo/swift-server-dev</font></a>
<br><tt><font size=2>_______________________________________________<br>
swift-server-dev mailing list<br>
swift-server-dev@swift.org<br>
</font></tt><a href="https://lists.swift.org/mailman/listinfo/swift-server-dev"><tt><font size=2>https://lists.swift.org/mailman/listinfo/swift-server-dev</font></tt></a><tt><font size=2><br>
</font></tt>
<br>
<br>