This Month with Nim: August 2021

HTTP Harpoon

Author: Juan

  • Same API as stdlib HttpClient.
  • 1 file, 0 dependencies, 300 lines, pure Nim.
  • No Curl nor LibCurl dependencies.
  • Async and sync client.
  • Works with ARC and ORC. Works with strictFuncs.
  • Uses Uri type for URL.
  • GET and POST from JSON to JSON directly.
  • downloadFile that takes openArray of URLs.
  • HTTP Headers can be compile-time immutable const.
  • Proxy support, with Auth.
  • Response has isIpv6: bool attribute.
  • Timeout support for Async and Sync.
  • Option to skip parsing headers or status code or body, if you don’t need them.
  • HTTP Methods use HttpMethod enum, not strings. Status code use HttpCode not integers.
  • Share a Socket with multiple clients, reuse Socket.
  • There’s no open/close functions for the client, just call get() or post().
  • Works with Threads, Tasks, and other Async implementations.
  • Uses very few symbols from stdlib, very future proof.
  • runnableExamples with doAssert for everything.
  • Documentation online.

Goodboy Galaxy

Authors: @exelotl and @hot_pengu

Goodboy Galaxy is an exploration-focused platform game in development for Game Boy Advance, PC and Nintendo Switch.

This month, the developers launched a Kickstarter campaign to fund the game’s development and bring it to real GBA carts. The campaign exceeded all expectations, meeting its funding goal in less than 8 hours! A free demo (Chapter Zero) is available to play right now in your browser, in an emulator, or on a real GBA.

The game is written in Nim using the Natu library, and has been worked on for about two years (during the developers’ free time). If you’d like to learn more about the development process, see their forum post, and the NimConf video from last year.

CPython

Author: Juan

  • Hijacks the Python 3.10+ standard library for Nim.
  • A whole new standard library becomes usable for Nim, without Nim having to spend any resources.
  • Showcases the easy and transparent interoperability of Nim (Python’s CTypes is a lot harder, etc).
  • Code is very simple and easy to hack for new users, no complex Macros, just DRY templates.
  • Each file is completely self-contained standalone, you can copy just one file to your project and use it.
  • Same API as Python standard library, same function names, same argument names, same module filenames, same imports, any Python documentation becomes a documentation you can use with Nim.
  • It is also a place to pile up “Nim-ified” Python stuff, anything that people are interested in can be added in the future (games?, science?, etc), if you are interested, Pull Requests are welcome!

Example: Pet the Turtle

  • This draws a star in a GUI window, meant for kids or people learning programming:
import cpython/turtle

title "Nim Turtle"
shape "turtle"
shapesize 2, 2, 8
color "green", "yellow"
speed "fast"
beginFill()

while true:
  forward 200
  left 170
  if position() < (1.0, 1.0):
    break

endFill()
mainLoop()

Want to see your project here next month?

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