Live data from Hacker News

Mastering Nim – now available on Amazon

nim-lang.org

51–60 of 106 posts

Re: Mastering Nim – now available on Amazon

#51
post #44

Earlier quoted context omitted.

That’s how I feel about Elixir. Everything else just feels wrong now. I’d be curious to get your Nim highlights.

My experience after a couple of weeks: Pros: Extremely good C and C++ interop Significant indentation Very good performance Quick compilation Terse, but readable Easy cross platform Powerful macros and close to trivial DSL construction Very little code to do a lot of stuff Incoming future features look very promising Cons: Hard to predict and control program performance, LTO does a lot of heavy lifting Immature ecosy…

Nim has several GCs available. For predictable performance you may want to use ARC. See: https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...

For my contribution to the ecosystem see Nexus mentioned in another comment. If you see bugs please report them. Sometimes libraries are deprecated/abandoned because of new ideas, this happens in every ecosystem.

I personally use camelCase/PascalCase, but Nim is style insensitive, meaning you can call procs written in camelCase using snake case. However this is controversial and under discussion, my personal opinion is to make style sensitivity optional, with insensitivity the default.

Ambiguous variable names I hate, you won't see that in Nexus, if anyone does they should file an issue. That's really developer dependent.

For my part Nexus has some docs and a basic tutorial. But if people want more they need to ask for it. Why write docs nobody wants or will read? Anyway, this book (Mastering Nim) is one more definite step forward for learning Nim.

I think compiling to C is what mostly happens, C++ is probably an outlier. Even then, a C++ compiler isn't difficult to install if needed.

Re: Mastering Nim – now available on Amazon

#52

Earlier quoted context omitted.

That’s how I feel about Elixir. Everything else just feels wrong now. I’d be curious to get your Nim highlights.

thats exactly how I feel when it comes to web frameworks. nothing else has anything good enough to give up all the nice toys elixir gives me. haskell's types are cool vuetify makes me consider nuxt but only elixir has otp, immutable data structures, intercluseter message passing, channels, good performance, ease of use and descent ecosystem out of the box. rust is the only other new language Im looking at but for thi…

Elixir is indeed the most loved web framework according to the latest StackOverflow survey. I'll be looking to Elixir for ideas for Nexus (web framework).

Re: Mastering Nim – now available on Amazon

#53
post #26

If you want more adoption of the language, probably best to leave a copy on the website for free. I think I saw some statistics that it doesn’t really reduce sale of the hard copies that much.

Curious on this, would you happen to have a citation?

Re: Mastering Nim – now available on Amazon

#54

I absolutely hate Nim for spoiling pretty much all other programming languages for me. I wish it gained more traction. Congratulations on your book and keep up the great work, Araq. You did an outstanding job with Nim and I wish you all the best!

Care to give a brief overview of what you find appealing? I've never looked into the language before.

Other comments already gave great examples but for me personally: - Concise syntax - Elegant language constructs (e.g. method call syntax) - Great macro system - You have control over what GC you use - Great performance - Everything is simple, it's easy to read other people's code

Re: Mastering Nim – now available on Amazon

#55

I absolutely hate Nim for spoiling pretty much all other programming languages for me. I wish it gained more traction. Congratulations on your book and keep up the great work, Araq. You did an outstanding job with Nim and I wish you all the best!

Care to give a brief overview of what you find appealing? I've never looked into the language before.

I particularly like, from the syntax side:

- Python-style syntax with significant indentation

- Uniform Function Call Syntax: a.len() == a.len == len(a)

- Fully unqualified imports by default: which might seem scary to Python programmers, but works great in practice because of static typing

- All of the above makes code readable and succinct

And from a language features side:

- Compiles to C with all the architectural targets that come with it

- Compilation to C also allows for easy C interop: wrap function signatures and types and you're done

- This, in turn, means that Nim libraries can bootstrap off of the massive C ecosystem, while adding nicer APIs on top

- Extremely performant GC by default: optional Rust-style annotations can further improve performance, and you can remove all overhead and manually manage memory with C-style pointers if you'd like

- Useful compile-time templates and macros that can directly change the AST

The community is also active and helpful on IRC/Matrix/Discord/Gitter (bridged together)

Re: Mastering Nim – now available on Amazon

#56
post #43

I absolutely hate Nim for spoiling pretty much all other programming languages for me. I wish it gained more traction. Congratulations on your book and keep up the great work, Araq. You did an outstanding job with Nim and I wish you all the best!

I totally agree, Nim is great but it really needs more traction. I'm developing a web framework for Nim with batteries included (an ORM, for one), Nexus: https://github.com/jfilby/nexus

jasfi, I am actually following your project and wanted to take this moment to ask a couple of questions. How are you planning to solve for Postgres drivers/clients with async and pipelining support?

I had added nim std lib to the Techempower benchmarks, and while Nim shines in the plain text and other non db related requests, it comes at the very bottom as far as tests like Fortune go. When I did the work, there were no maintained/active Postgres drivers with async and pipelining support. And IMO, that wa the biggest reason why Nim hasn't had great benchmarking scores.

Re: Mastering Nim – now available on Amazon

#57

Earlier quoted context omitted.

You have a few different issues with the assumptions in your comment. First, yes, one can ask for a source without a sincere request for it, known as sealioning. However, that was not what I was doing, because: > While statistical data is much better then common sense reasoning, it's still possible to make claim via deduction and even anecdotal evidence. Oftentimes, intuition is not correct. Think for example to the…

>Oftentimes, intuition is not correct. However oftentimes statistical data is not AVAILABLE. Thus you must make a claim with available evidence. >Similarly, simply because you believe that ebook sales reduce print book sales intuitively does not mean that this be so. No but given the logic of how humans prefer to get free things then pay for things, and given the fact that I myself prefer this you can make a best pos…

The real problem here is that you're extrapolating way past a reasonable intuition. Not only are you intuiting that pirating would impact sales, you're extrapolating that:

1. An ebook is the only way a pirated version gets circulated (many physical-only books are scanned and uploaded)

2. The displacement caused by piracy from introducing an ebook version will outweigh the combined revenue of physical and ebook sales, such that physical-only revenue > physical book revenue + ebook revenue - piracy displacement, which depends on assumption 1.

3. Piracy displacement is comparable across media types and topic. For example, does your "intuition" tell you that a programmer is just as likely to pirate a programming book given the amount of free learning material on the internet as a movie watcher is to pirate a movie or a video game player to pirate a game?

I think your intuition is more flawed than science. Science at least suggests only what the results show and doesn't build upon unsubstantiated assumption after unsubstantiated assumption.

To address some other points:

> However oftentimes statistical data is not AVAILABLE. Thus you must make a claim with available evidence.

In that case, you should make a hypothesis and not a claim, even if you don't have the means to test it. If you make a claim, you have the burden of proof, but by your own admission, you have none.

> 1 person is 1 data point which is better than zero. Anecdotal data matters.

It might be better than zero, but not my much. In many cases, it's worse because it's misleading. Anecdotal data only matters in aggregate such that the sample size is reasonable. Using a derivative of your car accident example: just because one pedestrian survives getting hit by a car doesn't mean that getting by a car isn't fatal.

Finally, your link is not a counter to the parent's link as all their link says is that ebooks sell more than physical books while also acknowledging that ebook piracy has also grown.

Re: Mastering Nim – now available on Amazon

#58
post #57

Earlier quoted context omitted.

>Oftentimes, intuition is not correct. However oftentimes statistical data is not AVAILABLE. Thus you must make a claim with available evidence. >Similarly, simply because you believe that ebook sales reduce print book sales intuitively does not mean that this be so. No but given the logic of how humans prefer to get free things then pay for things, and given the fact that I myself prefer this you can make a best pos…

The real problem here is that you're extrapolating way past a reasonable intuition. Not only are you intuiting that pirating would impact sales, you're extrapolating that: 1. An ebook is the only way a pirated version gets circulated (many physical-only books are scanned and uploaded) 2. The displacement caused by piracy from introducing an ebook version will outweigh the combined revenue of physical and ebook sales,…

--edit, i thought the original author was countering me. Turns out it's another person so I'm editing the comment to appropriately respond.

>The real problem here is that you're extrapolating way past a reasonable intuition. Not only are you intuiting that pirating would impact sales, you're extrapolating that:

No I'm not. I make a best claim based off of the best possible evidence.

>1. An ebook is the only way a pirated version gets circulated (many physical-only books are scanned and uploaded)

No you extrapolated that I was thinking this. Your intuition is the one way beyond reason. First off I am aware of scans and scanlations. There's an entire scene of asian comics where not only are the pages scanned, but they are translated into english. Additionally famous books like JK Rowlings final Harry Potter was famously not released as an ebook but was scanned within a couple days of it's release.

Not having an ebook makes pirating HARDER. Such that books such as computer programming books may never get copied because they're more obscure. It would be stupid of me to extrapolate unreasonably that you're unaware of this, but unlike you, I don't make unreasonable extrapolations. You're aware of everything I just said, but now you're also aware that you yourself is quite unreasonable.

>2. The displacement caused by piracy from introducing an ebook version will outweigh the combined revenue of physical and ebook sales, such that physical-only revenue > physical book revenue + ebook revenue - piracy displacement, which depends on assumption 1.

This is a reasonable assumption. Given my own anecdotal evidence. Unless you have evidence to prove otherwise?

>3. Piracy displacement is comparable across media types and topic. For example, does your "intuition" tell you that a programmer is just as likely to pirate a programming book given the amount of free learning material on the internet as a movie watcher is to pirate a movie or a video game player to pirate a game?

It is comparable. This is a highly reasonable assumption. Everybody likes free things, this extends past media types and topic. I am a programmer and I am just as likely to pirate from all genres and media types. I also pirate software.

>I think your intuition is more flawed than science. Science at least suggests only what the results show and doesn't build upon unsubstantiated assumption after unsubstantiated assumption.

Well I would say you'd be wrong. It's not so clear especially given the whole fiasco in psychology. https://en.wikipedia.org/wiki/Replication_crisis It's actually not so clear cut what to trust.

Science is better then intuition in principle. But in practice it is highly flawed. So flawed that there are measurable cases where intuition beats it.

>In that case, you should make a hypothesis and not a claim,

There's no difference between these two things. A hypothesis is a claim. They are one in the same. You don't truly understand science. You're imagining that a claim is hypothesis proven, but there's actually no such thing as proof in science. All there is in science is just claims and supporting evidence. But there is never enough evidence for proof. The entire endeavor of science is an attempt at falsification.

From a statistical perspective, Fuzzy connections can be drawn through correlations. Correlations are also again not proof as correlation does not equal causation.

Causation on the other hand is a much harder type of experiment to setup. Much more expensive and the conclusions it produces are also still not proof. Just a fuzzy causative connection that may or may not be actual.

>It might be better than zero, but not my much. In many cases, it's worse because it's misleading. Anecdotal data only matters in aggregate such that the sample size is reasonable. Using a derivative of your car accident example: just because one pedestrian survives getting hit by a car doesn't mean that getting by a car isn't fatal.

There is a time when I worshipped science like you thinking that dispassionate logic was the way to truth. It is the truth path, and I followed it so much that I understand the philosophy of science and everything about it. But once you get to a certain point of understanding it comes full circle. You realize the limits of science and you realize that it's so limited that it's flawed.

Here's the thing. People often mistake science as a form of logic. As if science was a way to logically analyze the world. This is wrong. Science and logic are different. Logic is often inapplicable to the real world, but science is no replacement for logic.

Intuition is flawed. But in many cases not more flawed then science. There are tons of studies with bogus results out there. And those bogus results can be often invalidated by intuition alone.

Another thing with intuition is raw speed. If I punch a person in the face he will be in pain. Intuition tells me this in seconds. A scientific study will take a lot of time and money to create a fuzzy causative connection at best. But most people don't even run the causative experiment as that experiment is more complicated and harder, so they just do the correlative experiment that proves absolutely nothing then they call it a day.

Also you have to note anecdotal data is much more then one data point. Intuition can be described as a machine learning model trying to upscale a picture. It is often flawed but you have to realize the model is also OFTEN right despite not being a purely logical automaton. When given anecdotal data, people often describe with vivid descriptions and reasoning such that we can run our intuitions on it and form a somewhat accurate conclusion.

>Finally, your link is not a counter to the parent's link as all their link says is that ebooks sell more than physical books while also acknowledging that ebook piracy has also grown.

Then his link doesn't support his point. Then his evidence was invalid to begin with. Thus my claim completely demolishes his claim.

Re: Mastering Nim – now available on Amazon

#59

first time I've heard of nim! anyone using nim in prod care to share their experience?

Disclaimer: I have not written a single line of C/C++ in my life, nim was the first language that exposed me to lower level concepts essentially.

I have a webpage-backend life in it, re-coded a very CRUD-heavy and medium-sized Django project in nim for funsies. You do notice that the ecosystem is not mature. You may have read another comment on here earlier that libs often are not fully featured or have clunky APIs. ORMs in particular are an area where you'll find a lot of teething issues. I found myself contributing to said libs in order to fix some of that, adding another lib to deal with connection pooling for me while I was at it.

Overall though, the coding experience has been intensely enjoyable and fun for me, which is why I kept going. Pushing logic to compile time is trivial, you don't even really need the macro system to do that since there's a pragma for that, and voila, suddenly you are able to have compile-time evaluation on whether you're trying to query a Many-To-Many relationship in your database correctly, guaranteeing you that you won't face those issues ever at runtime. I love this.

And all of this was without me having done any kind of deep dive into the macro system, I was mostly using generics, templates and compile-time-procedures (which are normal procedures, but annotated with the compile-time-pragma). And said macro-system from what I've seen opens up a whole new world of possibilities.

Another fun tidbit is that python interop is effortless, in both ways, thanks to numpy. As in, it is effortless to use python libraries, as it is effortless to make python use a library written and compiled in nim.

Edit: Deployment with docker needed some figuring out first, but wasn't hard by any means. Could use more documentation though, which I'll likely add.

Re: Mastering Nim – now available on Amazon

#60

There's 3 languages in the same class. Julia, Nim and Crystal. I'm specifically curious about Crystal vs. Nim. Benchmarks show that crystal is pretty much faster, but I'd also like to know the advantages of why someone would choose Nim over Crystal I'm looking for reasoning that is deeper then just superficial language syntax differences. Has anyone extensively used both? I would like an unbiased view from someone wh…

Gonna copy paste an old comment of mine:

-----

Syntax wise: Nim is to python what Crystal is to Ruby

Capability wise: both are incredibly powerful general purpose languages. Crystal is fully OOP, while Nim has a more functional/procedural bent. Nim is better for DSLs and has a fascinating macro system.

For system language use, Nim is a better choice as you can use it with its Arc GC or no GC at all.

Perf wise, Crystal seems to be marginably faster in most benchmarks. Though at that level the difference isn't much.

crossplat wise, Crystal has no "official" windows support (and you cannot do webdev on it) while Nim has.

Ecosystem wide: Both are young languages and the ecosystems are tiny. Crystal has more and better options for webdev. Nim, IMO, is better for games, console apps etc.

Tooling wise; crystal IDE tools are far behind that of Nim. But both are terrible when you consider any decent language out there.

Ecosyt

Personally I like Crystal a lot due to its type system and syntax but you can't go wrong with either language.

Post reply on HN