This Month with Nim: November and December 2022

New Cliche version

Author: Juan Carlos

New Cliche version:

  • Added support for bool.
  • Reads enum, Positive, Natural, BiggestInt, BiggestFloat, int, float directly from command line.
  • Fallbacks for values: static default ➡️ env var ➡️ command line.
  • Uses parseInt for int, parseFloat for float, parseEnum for enum, etc.
import std/strutils
import cliche
# Use
type Food = enum PIZZA, TACO  # Enum from CLI.
# let real = commandLineParams()
let fake = @["--a=1", "--v_1=9.9", "--v2=1", "--v3=2", "--v4=X", "--v5=t", "--v6=5", "--v7=true", "--food=PIZZA"]
fake.getOpt (a: int.high, v_1: 3.14, v2: 9'u64, v3: -9'i64, v4: "a", v5: '4', v6: 9.Positive, v7: false, missing: 42, food: TACO)
doAssert a == 1  # int
doAssert v_1 == 9.9  # float
doAssert v2 == 1'u64  # uint64
doAssert v3 == 2'i64  # int64
doAssert v4 == "X"  # string
doAssert v5 == 't'  # char
doAssert v6 == 5.Positive  # Positive
doAssert v7 == true  # bool
doAssert missing == 42 # missing is not in fake, fallback to default value 42.
doAssert food is Food and food == PIZZA  # food is Food.PIZZA

WebRTC for Nim

Author: Juan Carlos

New WebRTC for Nim (Web Real-Time Communications) just landed:

From stdlib only uses JsObject, Blob, Node, Future types.

Nimrun Action

Author: Juan Carlos

GitHub Action to compile and run Nim source code from GitHub issue comments code blocks.


Author: pietroppeter

p5nim is a wrapper for p5js nim library. I have picked up the old bindings which were not working with a more recent nim, fixed them and starting to improve them. In particular I make it easy to call p5js with nimib. I have also started to add a wrapper for p5sound (additional library to use sound).

p5js is a great library to create visualization, generative art, games and generally speaking creative coding. It has a specific focus on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else! Great learning material has been published: the coding train, the nature of code. The community around p5js is very active (you can look for #p5js tag on mastodon, twitter, …) and welcoming with examples often sharing the source on openprocessing.

The goal of p5nim is to continue improving the wrapper and provide examples of p5js code ported to p5nim. You are much welcome to contribute new examples! The website is still a bit clunky but it will be improved. It is now available to install on nimble with nimble install p5nim. Here is a very nice example of animated art (live+source):

Want to see your project here next month?

Follow this to add your project to the next month’s blog post.