Live data from Hacker News

Ray Tracing in Nim

nim-lang.org

61–68 of 68 posts

Re: Ray Tracing in Nim

#61
post #8

I keep seeing Nim and it looks really productive and very interesting! Does anyone know how it compares to Zig?

Zig supports zero-effort C binding by reusing existing C headers instead of wrapping them^. The only other language known to me having such feature while not actually being a superset of C is Terra†. I feel like we are still several light years away from the Holy Grail of programming languages, which would retain full compatibility while also being extremely productive. Walter Bright (the creator of DLang) once state…

Not sure the age of the original author is very relevant. GvR was 35 when he started work on Python. Chris Lattner was 31 with Swift, Brendan Eich was 33 with JS. These are some of the most used languages today. I’d say it’s more a matter of being in the right place at the right time to serve a particular use case.

Re: Ray Tracing in Nim

#62
post #56

Has anyone had any luck reproducing the benchmark figures given for the smallpt program? When I try, gcc handily beats nim in the multi-threaded scenario and they are neck and neck in the single-threaded one. For 10 samples per pixel: g++ multi-threaded : 33.52 nim multi-threaded : 36.90 g++ single-threaded: 75.78 nim single-threaded: 75.95 nim 1.2.0, g++ 10.1.0. I used the flags -O3 -march=native -mtune=native -Wall…

Here is the code if anyone is interested: https://github.com/bjourne/c-examples/blob/master/programs/s... With a few tweaks, g++ beats nim both in the multi-threaded and single-threaded setups.

Re: Ray Tracing in Nim

#63
post #38

With all due respect, Nim is a great language performance wise however I fail to see how is it different from D. Many advertised features have been present in D for a long time. Syntax wise Nim it is a step back. It's hard to read and understand while any C/C++ dev will have next to no effort reading through D code. And of course while D is C ABI compliant it interoperates with C++ well too. I seriously doubt that Ni…

> Syntax wise Nim it is a step back. It's hard to read and understand while any C/C++ dev will have next to no effort reading through D code. And of course while D is C ABI compliant it interoperates with C++ well too. On the other hand, people coming from Python, Ruby, Pascal, Ada will appreciate the minimal amount of sigils. > I seriously doubt that Nim or any other language in this regard has better metaprogrammin…

I suspect d's metaprogramming is not as good as nim's (haven't used the latter), though it's better than metaprogramming of every language I've used without macros.

That said, it can do all of the metaprogramming-related tasks you mention.

Re: Ray Tracing in Nim

#64
Since Nim transpiles itself down to C code, and then compiles it to assembly, and machine code. Then, how does Nim avoid the occasional security issues, buffer overflows, and other undefined behavior problems that always arises from C written programs?

Is this not a concern? Or is Nim fully vetted, that it doesn’t use defective C libraries?

Re: Ray Tracing in Nim

#65
post #38

Earlier quoted context omitted.

> Syntax wise Nim it is a step back. It's hard to read and understand while any C/C++ dev will have next to no effort reading through D code. And of course while D is C ABI compliant it interoperates with C++ well too. On the other hand, people coming from Python, Ruby, Pascal, Ada will appreciate the minimal amount of sigils. > I seriously doubt that Nim or any other language in this regard has better metaprogrammin…

I suspect d's metaprogramming is not as good as nim's (haven't used the latter), though it's better than metaprogramming of every language I've used without macros. That said, it can do all of the metaprogramming-related tasks you mention.

Are you aware of D libraries in that vein? I'm especially interested in the first 2, since those are something I'm actively working on at the moment.

Re: Ray Tracing in Nim

#66
post #65

Earlier quoted context omitted.

I suspect d's metaprogramming is not as good as nim's (haven't used the latter), though it's better than metaprogramming of every language I've used without macros. That said, it can do all of the metaprogramming-related tasks you mention.

Are you aware of D libraries in that vein? I'm especially interested in the first 2, since those are something I'm actively working on at the moment.

I don't know of any DSLs, but the stdlib arbitrary precision integer library works just fine at compile time:

  enum x = BigInt("0xffffffffffffffffffffffffffffffff") % 2;
  writeln(x);
('enum' means 'make this value a compile-time constant; error if you can't')

Re: Ray Tracing in Nim

#67
post #49

Earlier quoted context omitted.

If they’re data centric, would you not be better off with vanilla python? If you have numpy do the heavy lifting, it’ll be as fast plus all the syntactic/ecosystem benefits

Numpy is nice but pure-Nim applications appear to outperform it easily: https://narimiran.github.io/2018/05/10/python-numpy-nim.html https://github.com/mratsim/Arraymancer

Interesting but given the low total execution time, the majority of time in the numpy implementation is going to be spent initializing CPython.

I think if this were on the order of minutes/hours you would see numpy outperform.

Re: Ray Tracing in Nim

#68

Anyone have thoughts on nim vs rust for data centric (Scala like) applications

That depends on why you use Scala? Do you use Scala as a better Java? If so, Nim may be what you want. Do you use Scala for its incredible type system? Rust may be what you want. Do you use Scala for its functional tendencies? Rust may be what you want. As an aside, I've found that once you get over the Rust learning curve, writing 'correct' programs is easier in Rust than any other language I've used. And for data c…

What about scalable data? Like spark applications? I am familiar with weld but seems like more mature distributed computing is still on the horizon
Post reply on HN