HookRace

hookrace.net · Personal blog · on HN since 2015

HookRace is a blog by a Nim developer on Nim's features, metaprogramming, game development, and shrinking binary size.

What HN saysCommenters recommend it to Nim fans, and one praises Nim's syntax, type system, macros, and performance.
46HN people shared it
35linked it in comments
49stories submitted
4.0Kstory points
1 year agolast shared
2015people per year2026

Most-shared posts

  1. 1
    Nim binary size from 160 KB to 150 Bytes
    13 people · 157 points · first shared 2015 · 66 comments on HN
  2. 2
    What is special about Nim?
    9 people · 269 points · first shared 2015 · 84 comments on HN
  3. 3
    Introduction to Metaprogramming in Nim
    9 people · 122 points · first shared 2016 · 11 comments on HN
  4. 4
    Writing a 2D Game in Nim
    7 people · 65 points · first shared 2016 · 3 comments on HN
  5. 5
    Time.gif
    3 people · 782 points · first shared 2017 · 104 comments on HN
  6. 6
    What makes Nim practical?
    3 people · 154 points · first shared 2015 · 130 comments on HN
  7. 7
    Time.gif
    3 people · first shared 2018
  8. 8
    Nimes
    3 people · first shared 2017
  9. 9
    One year of cycling to work
    2 people · 295 points · first shared 2018 · 395 comments on HN
  10. 10
    Overview of Running an Online Game for 3 Years
    2 people · 198 points · first shared 2016 · 35 comments on HN
  11. 11
    Porting a NES Emulator from Go to Nim
    2 people · 158 points · first shared 2015 · 81 comments on HN
  12. 12
    Make a Lisp in Nim
    2 people · 109 points · first shared 2015 · 44 comments on HN
  13. 13
    HANA C++ Development Environment and Processes
    2 people · 23 points · first shared 2017 · 2 comments on HN
  14. 14
    Chinese Traffic to Time.gif · HookRace Blog
    2 people · 6 points · first shared 2019 · 2 comments on HN
  15. 15
    Homepage
    2 people · first shared 2015

What HN people wrote when they linked it

atemerev · 2019-09-24
Nim is a thing of beauty. It has a well-thought syntax (some consider it to be similar to Python, but it removes many Python idiosyncrasies), state of the art type system with generics, beyond state of the art macro system, excellent performance (comparable to Rust or C), and it can work as a low-level or a high-level language. It is pragmatic: you can write functional or imperative code, neither is imposed on you. There are so many beautiful hacks I enjoy (e.g. unit tests are supposed to be included in each file, all files are compiled as executables, and you can run them to run the tests). Here is a taste of what's possible: https://hookrace.net/blog/what-is-special-about-nim/
PMunch · 2018-06-13
This tutorial obviously only scratches the surface of what is possible in Nim. If you want to dig deeper I recommend reading through the learnxinyminutes entry, along with maybe https://xmonader.github.io/nimdays to see some examples. Then of course the official tutorials. Or if you just want to dig into the crazy stuff to see what is possible https://hookrace.net/blog/introduction-to-metaprogramming-in-nim/
def- · 2017-08-12
Too bad. I only tested with Firefox, Chrome and Android. You could try http://hookrace.net:5002/ directly Edit: I have now added some cache-control directives, maybe they help
executesorder66 · 2017-04-19
If you like Nim, check out this blog. [0] [0]https://hookrace.net/
lj3 · 2016-07-21
I hadn't seen MithrilJS before. It looks great. It makes me wonder what kind of voodoo I'd be capable of if I combined it with Nim[0]. [0]: https://hookrace.net/blog/what-is-special-about-nim/#compile-to-javasc…
johncolanduoni · 2015-10-29
> Optimisers are like garbage collectors—they give you better ergonomics than, and equal average performance to the manual alternative, if you’re willing to relinquish predictability and a non-voodoo mental model of your code’s performance. This is why I'd like to see optimizers become less opaque. It would be great if we could not only suggest optimizations to the compiler (and more sophisticated ones that just inlining), but actually see the process which our code went through. One language that has some interesting things going on in this area is Nim, which lets you write your own domain-specific optimizations[1]. [1]: http://hookrace.net/blog/what-is-special-about-nim/#add-your-own-optim…
mratsim · 2019-09-23
I'm from Status, Nim's main sponsor and a blockchain company that is doing Ethereum 2.0 research and implementation in Nim. Nim had the following appeal for us: - Ethereum research is done in Python, we actually started our code with a tool called py2nim to convert a 50k lines Python codebase to Nim in less than a month (and remove cruft for 3 months but that's another story). - Nim allows us to use a single language for research and production: the Python syntax, and the fast compilation speed are very helpful. In particular researchers found the Nim codebase easy to debug as the overhead vs the Python spec was quite low (and the Python spec is using types with mypy) - Nim has a easy C FFI and is one of the rare languages that can directly use C++ libraries, including header-only template heavy libraries. - Nim allows tight control over memory allocation, stack vs heap objects, has support for Android and iOS and very low-memory devices as well. - Nim also can be very high-level - Nim is as fast as C and can resort to inline C, inline C++ or inline assembly when needed. (inline javascript or Objective C are possible as well) - You can produce WASM code via clang, emscripten, binaryen, there is even a Nes emulator demo from 2015 running in Nim compiled to WASM here: https://hookrace.net/nimes/ - Nim has a strong type-system, including generics and type-level integers, boolean and enums. - Nim has probably the best compile-time capabilities of all languages. I'm…
archargelod · 2024-04-09
Cool. That reminded me of this blog post[0], with Hello World Nim binary in just 150 bytes! [0] - https://hookrace.net/blog/nim-binary-size/
shirleyquirk · 2022-02-07
https://hookrace.net/blog/nim-binary-size/ gets hello world to parity(17k) with `-d:release --opt:size` and `strip`, and then shows how to get that down to 150 bytes.
goodpoint · 2022-01-02
With --os:standalone and panicoverride.nim it goes down to 15k And down to *150 bytes* with some hacks https://hookrace.net/blog/nim-binary-size/
ajusa · 2021-12-18
If I understood your point correctly you are talking about the binary size? Me naively compiling with `nim c -d:release` and running `strip` on it gives the server binary to be around 700kb, and it's dynamically linked to glibc. There are tricks and stuff to make this smaller [1], but it's already small enough and easy enough to deploy. Plus Nim is fast! I can load the index page of this application at 90k requests per second single-threaded on a laptop from a few years ago. [1]: https://hookrace.net/blog/nim-binary-size/
akubera · 2020-04-07
I'm reminded of this little gem: https://hookrace.net/time.gif (Relevant post https://news.ycombinator.com/item?id=14996715) But on the topic: is there actually a dearth of APIs "these days" vs peak Web-2.0, or have the major players just restricted theirs due to abuse, and thus it seems like the whole world of possibilities have veen restricted? One can easily find lists of public apis (e.g https://github.com/n0shake/Public-APIs), but perhaps the video was more about the facilitators, like Yahoo Pipes.
szemet · 2019-09-24
I guess the examples use the default std libs, and runtimes of the languages. So in this sense your D example is the misrepresentation, by directly calling libc. If these kinds of low level size optimizations are enabled then both Nim and Rust can be more than 50 times smaller than your D example ;) : 150 byte Nim: https://hookrace.net/blog/nim-binary-size/ 151 byte Rust: http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-static-lin…
0x38B · 2019-02-26
Off topic, but I really enjoyed his post about commuting to work by bike[1]. I was in Krakow, Poland, and getting around by bike was a joy. Unfortunately, here in Ukraine drivers are very aggressive and the infrastructure for biking is just not in place. 1: https://hookrace.net/blog/cycling-to-work/
FraaJad · 2018-09-27
Not exactly what you asked for, but for shipping the same app on multiple platforms, this may prove useful - https://hookrace.net/blog/writing-a-2d-platform-game-in-nim-with-sdl2/
adtac · 2018-02-25
https://hookrace.net/time.gif - the same thing, but with an endless GIF
Jach · 2017-05-22
I've worked with Nim's sdl2 interface too, it is indeed pretty straightforward, and it was easy for me to tell vim to know how to jump to the nim wrapper's source. The main pain points for me were 1) sdl2 is harder than sdl1 and 2) I thought some type conversion behavior (or lack thereof) was odd, especially when working with 'cints' (which is what the wrapper api expects everywhere). For a more flushed out example there's: https://hookrace.net/blog/writing-a-2d-platform-game-in-nim-with-sdl2/
dom96 · 2017-05-02
And Nim can be a lot smaller too https://hookrace.net/blog/nim-binary-size/
kevin_thibedeau · 2017-04-19
With TinyCC Nim can compile fast enough to serve as a simple REPL[1]. It's already packaged for consumption: https://github.com/wheineman/nrpl [1] https://hookrace.net/blog/what-makes-nim-practical/#use-as-a-scripting…
beagle3 · 2017-01-03
Nim. Main: http://nim-lang.org NES emulator (compiled to JavaScript, runs in the browser): https://hookrace.net/nimes/ Simple 2D game: https://hookrace.net/blog/writing-a-2d-platform-game-in-nim-with-sdl2/ More examples: https://nim-by-example.github.io/ Nim has pythonesque syntax, with Pascal/Delphi roots, fast compile times, portability (compiles down to C, JavaScript, LLVM), strong metaprogramming support, seamless FFI, optional GC, and a lot more. It doesn't have Rust's ultimate safety, although it has quite a bit -- e.g., it can track which thread accesses what for concurrency (in a limited but extremely useful way). I'm a fan; It looks like the fun of Python but the speed of C/C++. I haven't had a chance to start a project in Nim - hopefully, in 2017.
rch · 2016-12-10
A non-trivial number of people seem to want this, but why does it need to be called Python? Keep the syntax and C extension compatibility, but ditch the name. One could even work out a means of selectively bringing in ideas from elsewhere: - Concurrency from Erlang (http://queue.acm.org/detail.cfm?id=1454463) - String handling from Go (https://blog.golang.org/strings) - Lightweight data classes (https://kotlinlang.org/docs/reference/data-classes.html) - Syntactic macros from Nim (https://hookrace.net/blog/introduction-to-metaprogramming-in-nim/) - more from Lua, Julia, Scala, and Haskell (within reason) There are already plenty of examples of Python modules that implement significant modifications (e.g. Cython, Rpy2, Dask), so I don't think it would really feel all that different from typical Python programming.
shakna · 2016-10-06
D's binaries still aren't small[0], what with including the entire prelude without code elimination. Sure, they seem tiny alongside Electron, but a giant doesn't look big next to Jupiter. Nim competes in the same space, and seems to hit this problem a whole lot nicer. [1] [0] http://forum.dlang.org/thread/[email protected]#pos… [1] https://hookrace.net/blog/nim-binary-size/
urza · 2016-06-18
I would like to read something like this https://hookrace.net/blog/ddnet-evolution-architecture-technology/ from slither.io creator(s) About their infrastructure, sw, hw architecture.. revenue model.. etc.. could be very interesting read
dlrk · 2016-06-08
For example, You can drop into c types using e.g. cstring and cint. Turn off or direct the gc. Manage memory for individual vars using the {.untracked.} pragma, c_malloc and c_free; easy integration of c libraries for obvious reasons; get pointers to things if you need them with ptr. Have a look at some of these in the manual. Gc stuff is in the standard library somewhere. This is an example I used recently: http://forum.nim-lang.org/t/567 Don't think it counts as low level but templates and macros are also pretty powerful if you need them. http://hookrace.net/blog/introduction-to-metaprogramming-in-nim/ I was drawn to it because it is high level, expressive and safe, but you can turn all this off when you need to and keep those bits contained. I'm using it with opencl. Can't really comment on rust and have limited exposure to go.
gokr · 2016-01-26
Nothing prevents you from static linking AFAIK: https://www.schipplock.software/p/static-linking-with-nim.html Googling a bit finds more on the subject, for example to go very small: http://hookrace.net/blog/nim-binary-size/
rakoo · 2015-08-07
What about nim (http://nim-lang.org/) ? It's more python-like than CoffeeScript-like, but still looks lighter than Python, without the overuse of 'self'. It can compile to C for the server part and to Javascript for the client part. The obvious difference with your project is that it targets nim, not python, and thus cannot reuse any of the python libraries. Being so close to C it can use whatever is written in it though. Check out this page for a good feel of it: http://hookrace.net/blog/what-is-special-about-nim/
progman · 2015-05-06
> I can't help thinking that this is just the wrong way to do this. I think this is a typical example for the huge verbosity of Rust. Yes, you get safe bare metal access but for the price of a lot of coding effort for _every_ application. For comparison watch how easily syntax extensions are done in Nim. For instance, template times(x: expr, y: stmt): stmt = for i in 1..x: y 10.times: echo "Hello World" http://hookrace.net/blog/what-is-special-about-nim/

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close