最近尝试 nim lang,从随手搜到一些问题中看到的官方回复、行动来看,开发不是很活跃呀

2022-01-30 14:06:17 +08:00
 haoliang

比如这些问题:

之所以决定尝试 nim 是因为我一直使用 python ,看 nim 的语法觉得上手会比较快;能够编译到 javascript , 在个人 web 项目中应该可以更好维护。

我在尝试之前定下的小目标是用 nim 实现个异步的 i3ipc ,然后做个 web 前端实现对 i3wm 的远程控制,看到上面的两个问题我有些犹豫要不要继续了:

不知道大家对这个语言了解多吗,有啥可以分享的经验没?

1408 次点击
所在节点    编程
2 条回复
haoliang
2022-02-11 14:39:10 +08:00
单纯从代码表现力来说,我真是爱了

```
import std/[asyncdispatch, times, sugar, sequtils]


proc main: int =
proc ticker(ident, stop, interval: int) {.async.} =
var remain = stop
while remain > 0:
await interval.sleepAsync
echo ident, " ", now()
dec remain

let futs = collect(newSeq):
for ident in 1..3:
ticker ident, 3, 1000

waitFor futs.foldl(a and b)


when isMainModule:
quit main()
```
haoliang
2022-02-11 14:40:58 +08:00
上面的格式不对,重发一次

```nim
import std/[asyncdispatch, times, sugar, sequtils]


proc main: int =
proc ticker(ident, stop, interval: int) {.async.} =
var remain = stop
while remain > 0:
await interval.sleepAsync
echo ident, " ", now()
dec remain

let futs = collect(newSeq):
for ident in 1..3:
ticker ident, 3, 1000

waitFor futs.foldl(a and b)


when isMainModule:
quit main()
```

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/831409

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX