Purpose
Tiny C Projects presents a good idea for any language: write small applications in a language to practice techniques for bigger ones. Below is a list of “tiny” projects I may pursue to brush up skills in languages I know well (e.g. C, Python, Ruby), get up to speed in languages I don’t know as well (e.g. JavaScript, modern C++), or learn languages I don’t know at all (e.g. Go, Julia, Rust).
BTW, a “tiny” project should be as simple as the Lua scripts I added to
some
blog
posts
or the code in the duplicate-files
.*
scripts.
Project Table
A checkmark (✓) indicates a project that’s complete. An “x” or “?” indicates a project that is (or may be) unnecessary.
Name | Blurb | c | cpp | go | jl | lua | js | py | rb | rs | ts | other |
---|---|---|---|---|---|---|---|---|---|---|---|---|
duplicate-files | find duplicate files | ✓ | ✓ | |||||||||
eltn | read an ELTN text | |||||||||||
fountain | parse a Fountain text | |||||||||||
hyperspace | calculate hyperspace travel times | |||||||||||
json | read a JSON stream | ? | ? | ? | ? | ? | ? | ? | ? | ? | java | |
mintest | minimal testing framework | x | ? | x | x | x | x | x | x | x | ||
orrery | simulate solar system(s) | |||||||||||
starmap | 3D map of fictional or real stars | |||||||||||
termui | UI elements in a terminal window | ✓ | ||||||||||
timelog | simple time usage log | sh | ||||||||||
utf8 | encode/decode UTF-8 | |||||||||||
warp | calculate warp speeds | ✓ |
Testing
Note that every project should include test code proving it works. Known testing libraries/frameworks include:
Language | Test Frameworks |
---|---|
C | minctest1, criterion |
C++ | Boost testing framework, minctest1 |
Go | builtin testing framework |
Java | JUnit |
JavaScript | minctest-node1, mocha, jest |
Lua | minctest-lua1 |
Python | unittest |
Ruby | minitest, RSpec, Test::Unit |
Rust | test modules |
TypeScript | JS testing frameworks, Alsatian, fast-check, Oscar, Testy.Ts, tsUnit |
Third party test frameworks must be FOSS and ideally have no dependencies on build systems, IDEs, or external libraries.
File-related projects could get hard to test.
Descriptions
ELTN
Parse ELTN into nested associative arrays (Lua tables, Python dictionaries, Ruby Hashes, etc.).
Extra Credit:
- Write nested structures (not necessarily associative arrays) back out to ELTN.
- Create a “builder” to construct a valid ELTN object.
- Implement a Pull Parser.
Fountain
Parse the Fountain format for screenplays. The end result should be an HTML file using a pre-defined stylesheet.
Extra Credit:
Hyperspace
Calculate the travel time in a fictional hyperspace between two stars. Hyperspace distance is a yet-to-be-determined function of the following:
- Distance in real space (see Star Map, below).
- Gravitational density, the distance and mass of stars along the path. The more gravity in a region, the twistier and longer the paths get.
- Path uncertainty, the variance in travel times between the same two stars due to faulty maps, unexpected cosmic events, and sheer weirdness. It’s expressed as a bell curve with a long tail; the soonest one can arrive is moments after one left, but the latest one can arrive could be weeks, months, years … centuries … The further away from mapped and well-frequented areas, the longer the tail grows.
Once we have a mathematical model, the end product will be one table or equation expressing hyperspace “velocity” as a function of gravitational density, and a second calculating the error in travel times (faster and slower) out to two sigmas.
Extra Credit:
- Combine with Star Map, below, to assess the gravitational density and path uncertainty in each sector or even along each route.
- Calculate the probability of a hyperspace disaster on a route, proportional to distance traveled and other factors TBD.
- Add in “hyperspace bypasses” that make travel between specific stars much faster and more sure.
- Swap in different density / probability functions to reflect a cluster with a lot of established paths within the core – especially between an artifact at (0,0,0) and other stars – but few if any paths outside it.
- Determine the actual travel time based on the probabilistic travel time such that the average, variance, and standard deviation line up. Use either a normally distributed random number generator or a quantity of simulated (or real!) two-, three-, and/or six-sided dice.2
JSON
Parse JSON into a tree of Objects
(Lua tables, Python dictionaries, Ruby Hashes, etc.)
and Arrays (Lua tables again, Python lists, Ruby Arrays).
null
may need special handling in most
languages to distinguish it from an empty Object entry.
Extra Credit:
- Emit JSON from the parse tree.
- Create a “builder” to construct a valid JSON object.
- Implement a Pull Parser.
Orrery
Simulate the orbital mechanics of our Solar System, and fictional ones.
Extra Credit:
- Read in configuration file describing a solar system.
- Include eccentricity (i.e. elipses instead of circles).
- Include moons, rings, asteroid belts and other features.
- Animate planets whirling around a sun, to whatever detail possible.
Mintest
For languages without a standard unit-testing framework, write one. Something that creates command-line programs that print messages is fine.
Star Map
Generate and store a fictional stellar map, with stars specified by randomly generated names and x, y, and z coordinates.
Extra Credit:
- Use real stellar coordinates, with Sol at (0,0,0)
- Use cylindrical and spherical coordinates
- Break into “hexes” like star maps in Traveller
- Add space lanes or hyperspace paths as in Traveller 1977, Diaspora clusters, or Coriolis portals
- Calculate realspace distance between two stars.
- Calculate hyperspace distance between two stars.
Term-UI
Implement the following UI elements using ASCII characters:
- Progress Bar
- Spinner
Extra Credit:
- Add colors.
- Don’t use
termcap
, just ASCII characters andstdio.h
or equivalent. - Tie into eventual Estimator project.
TimeLog
Implement a command-line program that lets the user log their activities. For example, the following command
timelog.sh add timelog entry to +tinyproj @blog"
adds the following line to $LOGDIR/timelog.txt
:
2023-04-13_10:27:21-05:00:00 START add timelog entry to +tinyproj @blog
(Quotes optional but recommended for special characters.)
By convention a word prefixed with a ‘+’ is the name of a project and
@
indicates a “context”. Both may correlate to a TODO list.
See the todo.txt
file format,
the todo.txt
CLI,
and http://todotxt.org.
With no arguments the script will log something like the following:
2023-04-13_11:02:52-05:00:00 STOP
Extra Credit:
-
Implement backend scripts that process
timelog.txt
to summarize time spent on each +project and in each @context. Include time spent without a recorded project or context. Time between a STOP and the next START are not counted. (Presumably the user is at lunch, in a meeting, napping, playing WoW, etc.) -
Implement as a GUI app in a small window that has
- a text box, perhaps with a history function
- a combo box of prior +projects and @contexts
- a LOG button to write the log, maybe triggered by the ENTER key.
-
Implement a Web app designed like the GUI app that can fit in a small popup window. It will update a log file same function on a remote server.
As a Web application it may need some simple security to keep script kiddies from spamming the log, e.g. a login and password to initialize and an authorization token that changes with each request (to prevent replay attacks). The backend may be files with semaphores or a full database.
UTF-8
Read in bytes as characters encoded in UTF-8, and write characters out as UTF-8 bytes. Detect invalid sequences.
Extra Credit:
- Use native I/O objects.
- Be more efficient than native libraries, if any.
Warp
Calculate speeds and travel times based on a fictional “Warp Factor” defined as:
W = 1 + (log(v[c]) / X)
or conversely
v[c] = exp(X * (W-1))
where v[c]
is the velocity relative to the speed of light c,
log
is the natural log (ln(y)),
exp
is its inverse (e^y),
X
is a fictional “Xin Constant” (set to the golden ratio 1.618),
and w
is the Warp Factor.
Warp 0 is about 0.20c, Warp 1 is c, and Warp N is about 5^(N-1).
Extra Credit:
- Calculate travel times for various distances, including the diameter of the Milky Way Galaxy.
- Combine with Star Map, above, to calculate travel times between nearest stars at Warp Factor 5 (13.6 hr/LY).