This project is for comparing async and concurrency tools in different
languages by implementing a simple wc -l
-style utility.
The wc
utility should do the following:
- Display the number of lines for each regular file in the directory.
- Display the cumulative number of lines of all files in the directory.
- Optionally take a single command-line argument specifying a different directory.
- Sort the files in terms of number of lines, in descending order.
- Print the running time, rounded to the nearest integer, in milliseconds
e.g.
$ ./bin/wc-go tmp
11 tmp/big.txt
1 tmp/small.txt
12 [TOTAL]
Took 1ms
The suggested implementation involves "fanning out" asynchronous tasks to read through each file in the directory and count the lines concurrently. The tasks will need to be synchronized at the end in order to compile the results and sort them for display.
As of commit c89a50e, the go implementation is the reference implementation.
The various wc
implementations should be put in sub-directories of the
top-level directory named wc-$LANGNAME
; the go implementation is located in
wc-go
. The resulting executables should be placed in bin/wc-$LANGNAME
; the
go executable is located at bin/wc-go
.
Each language implementation has its own dependencies.
wc-go
requires gowc-haskell
requires the stack build toolwc-node
requires nodewc-ocaml
requires OCaml as well as theasync
andcore
packageswc-python
requires python3wc-ruby
requires rubywc-rust
requires cargo
Just run make
from the project root. Or if you want to build a particular language implementation, run e.g. make go
or make rust
.
Thanks to the following folks!
- Daniel Friedman mailto:dfriedman58@gmail.com
- Nicolas Hahn mailto:nicolas@stonespring.org
- Max Bittman mailto:maxb.personal@gmail.com
- Henry Stanley mailto:henry@henrystanley.com