haoliang
V2EX  ›  编程

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

  •  
  •   haoliang · Jan 30, 2022 · 2131 views
    This topic created in 1564 days ago, the information mentioned may be changed or developed.

    比如这些问题:

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

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

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

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

    haoliang
        1
    haoliang  
    OP
       Feb 11, 2022
    单纯从代码表现力来说,我真是爱了

    ```
    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
       Feb 11, 2022
    上面的格式不对,重发一次

    ```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()
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3298 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 12:34 · PVG 20:34 · LAX 05:34 · JFK 08:34
    ♥ Do have faith in what you're doing.