<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nim :: 标签 :: yafeng 的博客</title><link>http://yafengabc.github.io/tags/nim/index.html</link><description/><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Sat, 19 Sep 2026 14:36:30 +0800</lastBuildDate><atom:link href="http://yafengabc.github.io/tags/nim/index.xml" rel="self" type="application/rss+xml"/><item><title>Go vs Nim 性能实测：10 项算法、GMP 大数与 6 种 GC 的全景对比</title><link>http://yafengabc.github.io/go-vs-nim-benchmark/index.html</link><pubDate>Sat, 19 Sep 2026 12:30:00 +0800</pubDate><guid>http://yafengabc.github.io/go-vs-nim-benchmark/index.html</guid><description>用 10 项常规算法、4 项大数运算、GMP 四端对比、百万位 π 和 6 种 GC 模式，把 Go 1.26 与 Nim 2.2 完整比了一遍：谁快、快多少、为什么，以及按负载该怎么选型。</description></item><item><title>Nim 入门之基于对话框的简单的GUI程序的编写</title><link>http://yafengabc.github.io/cnblogs/p17229429/index.html</link><pubDate>Sat, 18 Mar 2023 09:55:00 +0800</pubDate><guid>http://yafengabc.github.io/cnblogs/p17229429/index.html</guid><description>最近Golang玩的很嗨，现代的C语言不是盖的。唯一有点不爽的就是golang是专为高并发设计的，每次启动都一堆线程。在htop下看着很不爽。有没有一种写起来爽，又是编译型语言，速度也可以的语言呢？&#10;当然有，Nim算是其中之一吧。并且这个语言比较像Python，也是缩进语法的语言。先来个例子感受下语法：&#10;import time def fib(n): if n==0: return 0 if n==1: return 1 return fib(n-1)+fib(n-2) t=time.time() print(fib(40)) print(time.time()-t) 错了错了，这是python。下边才是Nim&#10;import times proc fib(n:int):int= if n==0: return 0 if n==1: return 1 return fib(n-1)+fib(n-2) var t=times.cpuTime() echo fib(40) echo times.cputime()-t 可以看到是不是有点像Golang跟python的结合体？&#10;顺便贴一下测试结果：&#10;[yafeng@SongSrv fibn]$ python fib.py 102334155 69.87282729148865 [yafeng@SongSrv fibn]$ pypy3 fib.py 102334155 13.181118726730347 [yafeng@SongSrv fibn]$ go run fib.go 102334155 1.237680831s [yafeng@SongSrv fibn]$ g++ fib.cpp &amp;&amp; ./a.out 102334155 1.99962 sec [yafeng@SongSrv fibn]$ g++ -O3 fib.cpp &amp;&amp; ./a.out秒， 102334155 0.373478 sec [yafeng@SongSrv fibn]$ nim r fib.nim 102334155 3.16008495 [yafeng@SongSrv fibn]$ nim -d:release r fib.nim 102334155 1.067569256 [yafeng@SongSrv fibn]$ nim -d:danger r fib.nim 102334155 0.017291094 python 70秒，pypy 13秒，go 1.2秒，g++不优化2秒，优化0.3秒。</description></item></channel></rss>