original article: 
[https://atilanevesoncode.wordpress.com/2018/12/31/comparing-pythagorean-triples-in-c-d-and-rust](https://atilanevesoncode.wordpress.com/2018/12/31/comparing-pythagorean-triples-in-c-d-and-rust)/

here's nim version I proposed: see 
[https://github.com/atilaneves/pythagoras/pull/4](https://github.com/atilaneves/pythagoras/pull/4)

sample results from the article for simple version: 
    
    
    Simple          CT (ms)  RT (ms)
    
    clang debug      59       599
    clang release    69       154
    dmd debug        11       369
    dmd release      11       153
    ldc debug        31       599
    ldc release      38       153
    rustc0 debug    100      8445
    rustc0 release  103       349
    rustc1 debug             6650
    rustc1 release            217
    
    
    Run

looks like nim release version of simple.d compiles faster and runs a tiny bit 
faster than D version ldc release of simple.d

# note

one thing I don't like about the way I wrote nim version of simple.d is how I 
translated this: 
    
    
    for (int z = 1; ; ++z)
      foo
    
    
    Run

into this: 
    
    
    var z = 1
    while true:
      foo
      z.inc
    
    
    Run

it's bad for 2 reasons:

  * z is in outer scope instead of in a nested scope
  * z.inc is AFTER foo; this is bad both for cognitive load and correctness, 
especially when foo gets complex (eg if it has break inside it, etc)


Reply via email to