V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
haoliang
V2EX  ›  编程

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

  •  
  •   haoliang · 2022-01-30 14:06:17 +08:00 · 1383 次点击
    这是一个创建于 819 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如这些问题:

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

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

    • 这两个问题都没能很好地解决,看起来语言实现还不够成熟
    • 官方并没有给出明确的后续改进安排,也就是短期内无解

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

    haoliang
        1
    haoliang  
    OP
       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
        2
    haoliang  
    OP
       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()
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5673 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 06:07 · PVG 14:07 · LAX 23:07 · JFK 02:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.