Live data from Hacker News

Nim 1.6

nim-lang.org

161–170 of 179 posts

Re: Nim 1.6

#161
post #27

> Fast compile times: a full compiler rebuild takes ~12s (Rust: 15min, gcc: 30min+, clang: 1hr+, Go: 90s) [2]. Whoa, this really surprised me!

Doesn't that depend on the size of the compiler? Nim can surely be faster than all of them, but that particular figure can't mean anything.

The Nim compiler is pretty big.

Re: Nim 1.6

#162
post #161

Earlier quoted context omitted.

Doesn't that depend on the size of the compiler? Nim can surely be faster than all of them, but that particular figure can't mean anything.

The Nim compiler is pretty big.

So what? You are not comparing the same thing.

Re: Nim 1.6

#163
post #8
post #5

Earlier quoted context omitted.

I have written a bit of both, recently re-wrote a command runner for a side-project https://gitlab.com/jarv/cmdchallenge in Nim and found it very pleasant and much less verbose, which was a nice change from GoLang while keeping type safety. A good example is parsing JSON https://nim-by-example.github.io/json/ as you can do a lot with fewer lines of code. I think the main disadvantage of Nim is that there is less out…

I really like the look of Nim but every time I dig into it I find a really strange syntax decision. For example: > The json module provides the %* operator which is used to create JSON objects I'm curious what the benefits are here of an operator over some more readable syntax. I have a dislike of languages where ascii noise seems to be favoured over readable english tokens.

The json module is old and probably wouldn't be designed this way today.

Re: Nim 1.6

#164

I wrote my first Nim app recently (an agent for reporting server data) and I must say, I like the language. It was a quick and painless learning experience. As of now my binary is about 400KB and uses about 1.3MB in memory consumption. Indeed – as others have reported – Nim feels very much like Python, while the superfast compilation time means I can test code changes quickly during the development cycle. For referen…

Have you tried Nimler? It’s pretty nice! I haven’t used it for a year or so.

Well, I wanted to try Nimler (as an alternative to Rustler) but I couldn’t get it to compile on my Mac. Something about some missing symbols if I remember correctly.

I’ll have to investigate deeper when I have the time, as it seems quite appealing to be able to rewrite the slower Elixir parts in Nim.

Re: Nim 1.6

#165
post #60

Earlier quoted context omitted.

Well no language is perfect, but Nim can be used in almost every domain because of it's compilation targets(C, C++, JS) and it's fast compile times(who needs interpretation when compile times are that fast!): * Shell scripting, I still assume most people will just use Bash tho: https://github.com/Vindaar/shell * Frontend: https://github.com/karaxnim/karax or you could bind to an existing JS library. * Backend: For so…

Also one of Ethereum's proof-of-stake clients is written in Nim: https://nimbus.team/docs/index.html

Direct link: https://github.com/status-im/nimbus-eth2

Re: Nim 1.6

#166
post #66

Earlier quoted context omitted.

The probable gaps I see are embedded and certain branches of gamedev, and shell scripting. Regardless of what Nim says in its sales pitch, it is a garbage collected language, and garbage collection is not really optional. The closest options are nothing, automatic reference counting (ARC), and automatic reference counting with cycle deletion (Nim calls this one ORC). Nothing at all might be fine for cloud lambda func…

Nim works super well for embedded. The thing is that you can turn off the garbage collector and do manual memory allocation if you want to. Or simply use ARC which works a treat on embedded. I wrote my own keyboard firmware in Nim (and did a presentation of it during NimConf 2021: https://www.youtube.com/watch?v=dcHEhO4J29U ). It runs super fast and the code size is smaller than some simple "Hello world" level progra…

Nim does work very well for embedded. From small stack only memory management, possible with value types and basic Nim proc's. Or use ARC for MCUs with 100's kB of RAM, which are fairly common nowadays.

Re: Nim 1.6

#167
post #12
post #8

Earlier quoted context omitted.

I really like the look of Nim but every time I dig into it I find a really strange syntax decision. For example: > The json module provides the %* operator which is used to create JSON objects I'm curious what the benefits are here of an operator over some more readable syntax. I have a dislike of languages where ascii noise seems to be favoured over readable english tokens.

This is interesting, especially for a language like Nim that favours familiarity with Python. Even Rust dropped most of its strange operators/sigils early on in the experimentation phase, because they confused people and Rust doesn't step back from confusing people lightly, haha.

Probably because Rust already has too many ascii symbols! ;) I still get brain mush remapping Rust's & from C's &.

But yah Nim's % is a bit strange at first, but becomes fairly handy in practice when dealing with lots a small bits of JSON. There's the % "to json" operator that mimics the $ "to string" operator for a single value. Then %* was added to handle multiple json items (I read it like apply % to all items). So it has a decent symmetry. Other than % and $ ascii operators are pretty rare in Nim code. Even bitops use or, and, shl, shr, etc over ascii operators.

Re: Nim 1.6

#168
post #135
post #111

Earlier quoted context omitted.

Instead of beautifulsoup you're honestly better off just running an instance of Firefox/Chrome and scraping data that way. You can do fairly easily these days and I have a library that allows you to do so in Nim: https://github.com/dom96/webdriver

I use it to parse crappy (non-standard) RSS feeds offline for an internal app I use. chrome-scraping would just be more of a pain (although I've done it before).

Have you tried htmlparser? Its fairly tolerant of "wild" html. It could use some tweaks to match the html5 spec that defines a lot more tags that don't require end tags. Also the library isnt to bad to grok and tweak yourself.

There's also Nimquery that looks nice, though I haven't used it yet. Still looks to replace a lot of beautifulsoup.

Re: Nim 1.6

#170

Earlier quoted context omitted.

Have you tried Nimler? It’s pretty nice! I haven’t used it for a year or so.

Well, I wanted to try Nimler (as an alternative to Rustler) but I couldn’t get it to compile on my Mac. Something about some missing symbols if I remember correctly. I’ll have to investigate deeper when I have the time, as it seems quite appealing to be able to rewrite the slower Elixir parts in Nim.

Odd, but hopefully fixed. The ability to add "noexceptions" annotation to ensure you handle any possible exceptions and avoid killing beam is awesome.
Post reply on HN