Skip to content

Commit ef5a88d

Browse files
authored
Merge pull request #147 from nhooyr/doc
Cleanup README language
2 parents 676bb69 + ac32d3f commit ef5a88d

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,33 @@ https://github.com/gorilla/websocket
110110
This package is the community standard but it is 6 years old and over time
111111
has accumulated cruft. There are too many ways to do the same thing.
112112
Just compare the godoc of
113-
[nhooyr/websocket](https://godoc.org/nhooyr.io/websocket) side by side with
114-
[gorilla/websocket](https://godoc.org/github.com/gorilla/websocket).
113+
[nhooyr/websocket](https://godoc.org/nhooyr.io/websocket) with
114+
[gorilla/websocket](https://godoc.org/github.com/gorilla/websocket) side by side.
115115

116-
The API for nhooyr/websocket has been designed such that there is only one way to do things
117-
which makes it easy to use correctly. Not only is the API simpler, the implementation is
116+
The API for nhooyr/websocket has been designed such that there is only one way to do things.
117+
This makes it easy to use correctly. Not only is the API simpler, the implementation is
118118
only 2200 lines whereas gorilla/websocket is at 3500 lines. That's more code to maintain,
119119
more code to test, more code to document and more surface area for bugs.
120120

121-
Moreover, nhooyr/websocket has support for newer Go idioms such as context.Context and
122-
also uses net/http's Client and ResponseWriter directly for WebSocket handshakes.
123-
gorilla/websocket writes its handshakes to the underlying net.Conn which means
124-
it has to reinvent hooks for TLS and proxies and prevents support of HTTP/2.
121+
Moreover, nhooyr/websocket supports newer Go idioms such as context.Context.
122+
It also uses net/http's Client and ResponseWriter directly for WebSocket handshakes.
123+
gorilla/websocket writes its handshakes to the underlying net.Conn.
124+
Thus it has to reinvent hooks for TLS and proxies and prevents support of HTTP/2.
125125

126126
Some more advantages of nhooyr/websocket are that it supports concurrent writes and
127127
makes it very easy to close the connection with a status code and reason.
128128

129129
The ping API is also nicer. gorilla/websocket requires registering a pong handler on the Conn
130130
which results in awkward control flow. With nhooyr/websocket you use the Ping method on the Conn
131-
that sends a ping and also waits for the pong, though you must be reading from the connection
132-
for the pong to be read.
131+
that sends a ping and also waits for the pong.
133132

134133
Additionally, nhooyr.io/websocket can compile to [WASM](https://godoc.org/nhooyr.io/websocket#hdr-WASM) for the browser.
135134

136135
In terms of performance, the differences mostly depend on your application code. nhooyr/websocket
137136
reuses message buffers out of the box if you use the wsjson and wspb subpackages.
138137
As mentioned above, nhooyr/websocket also supports concurrent writers.
139138

140-
The only performance con to nhooyr/websocket is that uses one extra goroutine to support
139+
The only performance con to nhooyr/websocket is that it uses one extra goroutine to support
141140
cancellation with context.Context. This costs 2 KB of memory which is cheap compared to
142141
the benefits.
143142

@@ -161,9 +160,9 @@ effort to ensure its speed and I have applied as many of its optimizations as
161160
I could into nhooyr/websocket. Definitely check out his fantastic [blog post](https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb)
162161
about performant WebSocket servers.
163162

164-
If you want a library that gives you absolute control over everything, this is the library,
165-
but for most users, the API provided by nhooyr/websocket will fit better as it is nearly just
166-
as performant but much easier to use correctly and idiomatic.
163+
If you want a library that gives you absolute control over everything, this is the library.
164+
But for 99.9% of use cases, nhooyr/websocket will fit better. It's nearly as performant
165+
but much easier to use.
167166

168167
## Contributing
169168

0 commit comments

Comments
 (0)