All Projects → dan-f → concurrent-wc

dan-f / concurrent-wc

Licence: MIT license
Testing language concurrency primitives with a file line counter

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
rust
11053 projects
ruby
36898 projects - #4 most used programming language
haskell
3896 projects
ocaml
1615 projects

concurrent-wc

This project is for comparing async and concurrency tools in different languages by implementing a simple wc -l-style utility.

spec

The wc utility should do the following:

  1. Display the number of lines for each regular file in the directory.
  2. Display the cumulative number of lines of all files in the directory.
  3. Optionally take a single command-line argument specifying a different directory.
  4. Sort the files in terms of number of lines, in descending order.
  5. 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

implementing

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.

adding a language 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.

dependencies

Each language implementation has its own dependencies.

  • wc-go requires go
  • wc-haskell requires the stack build tool
  • wc-node requires node
  • wc-ocaml requires OCaml as well as the async and core packages
  • wc-python requires python3
  • wc-ruby requires ruby
  • wc-rust requires cargo

building

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.

contributors

Thanks to the following folks!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].