https://github.com/shybyte/exercises-in-programming-style-rust
Exercises in Programming Style - Rust Version
https://github.com/shybyte/exercises-in-programming-style-rust
exercises programming-paradigms rust
Last synced: 13 days ago
JSON representation
Exercises in Programming Style - Rust Version
- Host: GitHub
- URL: https://github.com/shybyte/exercises-in-programming-style-rust
- Owner: shybyte
- License: mit
- Created: 2017-05-15T05:19:42.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T07:32:22.000Z (about 9 years ago)
- Last Synced: 2025-01-03T20:27:55.884Z (over 1 year ago)
- Topics: exercises, programming-paradigms, rust
- Language: Rust
- Size: 276 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Exercises in Programming Style - Rust Version [](https://travis-ci.org/shybyte/exercises-in-programming-style-rust)
Comprehensive collection of well-known, and not so well-known, programming styles using a simple computational task, *term frequency*.
This is the Rust Version. For the original python version and the companion book see
[https://github.com/crista/exercises-in-programming-style](https://github.com/crista/exercises-in-programming-style).
## List of Exercises
### Part 1 - Historical
Feel the pain of programming in 1970.
* Good old times - Minimal memory and no identifiers
* Go Forth - Working on a stack
### Part 2 - Basic Styles
It happens every day. You have seen it already.
* [Monolithic](src/bin/03-monolith.md) - One big program with no named abstractions and no clever library usage
* [Cookbook](src/bin/04-cookbook.md) - Procedural code with global state
* [Pipeline](src/bin/05-pipeline.md) - (Impure) Nested Functions
* [Code Golf](src/bin/06-code-golf.md) - Short code by clever std library usage
### Part 3 - Function Composition
Combine functions in interesting ways.
* [Infinite Mirror](src/bin/07-infinite-mirror.md) - Recursively, call yourself.
* Kick Forward - Callback style like in good old javascript
* [The One](src/bin/09-the-one.md) - Use a kind of a Monad to create a pipeline, Functional composition
### Part 4 - Objects and Object Interaction
Stateful encapsulated things talk with other encapsulated stateful things.
* [Things](src/bin/10-things.md) - Object-oriented
* Letterbox - Communication by untyped messages between objects
* Closed Maps - An Object is just a Map of functions
* Abstract Things - Objects implement Interfaces (Traits)
* Hollywood - Objects need to register at a fancy framework, which calls the objects
* Bulletin Board - Objects communicate via an Eventbus
### Part 5 - Reflection and Metaprogramming
When code knows about itself and hacks itself.
* Introspective - Code know about itself
* Reflective - Code can modify itself
* Aspects - Add general aspects like logging to existing code, without modifying the source code
* Plugins - Load external code without recompiling
### Part 6 - Adversity
How to prevent errors or deal with it.
* Constructivist - Check Arguments. If something goes wrong, use fallbacks and defaults
* Tantrum - Check Arguments. Handle problems when the occur by (logging and) forwarding the error to the caller
* Passive Aggressive - Check Arguments. Forward problems to the caller as default (Exceptions)
* Declared Intentions - Declare and enforce types
* Quarantine - Handle IO differently (Kind of IO monad)
### Part 7 - Data-Centric
It's about relations between data.
* Persistent Table - Put data in a (relational) database and query it
* Spreadsheet - Like dependent cells in a excel sheet
* Lazy Rivers - Streams of data instead of loading everything into memory at once
### Part 8 - Concurrency
Doing work in parallel.
* Actors - Like Letterbox but things have independent threads of execution
* Dataspaces - Concurrent units read/store data in synchronized common data spaces
* Map Reduce - Divide data in blocks, map over it (parallelized) und reduce it to result
* Double Map Reduce - Like Map Reduce, but result of first map step is regrouped for a second parallelized map step which makes reduce trivial or unnecessary
### Part 9 - Interactivity
Interacting with an user or client.
* Trinity - The famous MVC = Model-View-Controller Pattern
* Restful - Client accesses resources on server by using uniform resource identifiers
### Part 10 - Rusty
Do it in the Rusty Way.
* [Rusty](src/bin/42-rusty.md) - Idiomatic efficient Rust solution with complete error handling
## Run one variant
```
cargo run --bin 06-code-golf test-data/input/simple.txt
```
## Run and test everything
```
./test.sh
```
## License
MIT
## Copyright
Copyright (c) 2017 Marco Stahl