ICT: Diary
D: 28 W: 05

< May 2015 >
Sun Mon Tue Wed Thu Fri Sat
 12
3456789
10111213141516
17181920212223
24252627282930
31 

Based on notaweblog.php by joshua stein

[ ] Monday, 4 May 2015 [ ]

HookRace: a Nim blog for now.

Interest blog post on reducing a Nim binary from 160 KB to 150 Bytes.

So I used How I Start and ran my nim "hello world" program:

port:fred ~/code/nimcode> ../Nim/bin/nim c hello 
/home/fred/code/Nim/config/nim.cfg(53, 3) Hint: added path: '/home/fred/.babel/pkgs/' [Path]
/home/fred/code/Nim/config/nim.cfg(54, 3) Hint: added path: '/home/fred/.nimble/pkgs/' [Path]
Hint: used config file '../Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
[Linking]
/home/fred/code/nimcode/nimcache/stdlib_system.o(.text+0xe54e): In function `nimFloatToStr':
: warning: sprintf() is often misused, please use snprintf()
Hint: operation successful (9074 lines compiled; 0.172 sec total; 13.138MB; Debug Build) [SuccessX]
port:fred ~/code/nimcode> ./hello
Hello Nim

The wrote a slightly more complex nim program:

loop.nim
var x = 0
for i in 1 .. 1_000:
    inc x # increase x
    echo x

echo "Hello nim: ",x," greetings"
port:fred ~/code/nimcode> ../Nim/bin/nim c loop  
/home/fred/code/Nim/config/nim.cfg(53, 3) Hint: added path: '/home/fred/.babel/pkgs/' [Path]
/home/fred/code/Nim/config/nim.cfg(54, 3) Hint: added path: '/home/fred/.nimble/pkgs/' [Path]
Hint: used config file '../Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: loop [Processing]
[Linking]
/home/fred/code/nimcode/nimcache/stdlib_system.o(.text+0xe54e): In function `nimFloatToStr':
: warning: sprintf() is often misused, please use snprintf()
Hint: operation successful (9079 lines compiled; 0.336 sec total; 13.138MB; Debug Build) [SuccessX]
port:fred ~/code/nimcode> ./loop
1
...
1000
Hello nim: 1000 greetings

This program failed initially, as I used tabs in the file which gave me: Error: tabulators are not allowed replacing with spaces fixed this warning.

Need to finish the How I Start and have a play with the Nim Tutorial.

codenim


$Id: diary,v 1.38 2025/01/01 22:43:54 fred Exp $