Live data from Hacker News

Nim 1.0

nim-lang.org

241–250 of 308 posts

Re: Nim 1.0

#241
post #39

Earlier quoted context omitted.

Curious why you're adding Elixir in this list ? It operates is in a completely different space than nim / zig, as far as I know (Not statically checked, heavy but powerful runtime, much "higher level" abstractions, etc...) Not to prevent you from trying it, of course - to each and everyone their own...

I'd say Elixir is certainly a member of list of languages people are considering bailing out of Python for.

Yeah... I'm not bailing out Python for Elixir.

I use both Python and Elixir. Python for web scraping and Elixir for my side project website.

I can see if people want to move web dev from Python to Elixir but yeah not entirely bailing out for Elixir. BEAM VM in general is terrible for numerical stuff. Elixir is pretty niche, it solve one thing concurrency problems. Python is a much more general language.

Re: Nim 1.0

#242
post #234

Earlier quoted context omitted.

I think the biggest issue is that most equate GC with Java/Smalltalk style, instead of GC Modula-3/C# style.

Doesn't .NET (and C# with it) have stop-the-world GC, very similar to Java? Or do you mean something else?

CLR was designed for multiple languages execution models, including C++.

In what concerns C#, besides GC, you get access to off heap unamaged allocations, low level byte manipulations, value types, inlined vector allocations, stack allocation, struct aligments, spans.

All GCs have eventually to stop the world, but they aren't all made alike, and it is up to developers to actually take use of the language features for writing GC-free code.

Re: Nim 1.0

#243

> Type identifiers should be in PascalCase [1] I don't get why some languages adopt the 'PascalCase for types' approach (which is fine), but then a bunch of the built-in types such as 'string', 'set', 'int64', etc. are lowercase... it's annoyingly inconsistent. [1] https://nim-lang.org/docs/nep1.html#introduction-naming-conv...

I think it does set the built-in types apart for being built it. Also tradition?

That makes about as much sense as making builtin functions UPPERCASE. Also, what tradition?

Re: Nim 1.0

#244

Earlier quoted context omitted.

There are "concepts" which are like generics but still experimental. Are there any other generic programming facilities in nim? https://nim-lang.org/docs/manual_experimental.html#concepts

> Are there any other generic programming facilities in nim? https://nim-lang.org/docs/manual.html#generics

What I wanted to write was something like type restricted generics, apparently I ended my comment prematurely. Without concepts (interfaces), I find it hard to call this system "good generics" but there might be something I'm missing.

Re: Nim 1.0

#245

Earlier quoted context omitted.

> most importantly, if we all got in the same room, would I want to hang out with the people excited about this language? Interesting, I wouldn't even thought someone could consider it a criterium for a language choice. Now I wonder if most people care about it like you do.

Yes. A thousand times, yes. https://en.wikipedia.org/wiki/Yukihiro_Matsumoto (see the first paragraph) A huge part of the reason that people love Ruby even when there's so many Elixirs/Elms/Crystals/a hundred more around is simple: it's a community full of nice, smart, interesting people with varied interests that extend beyond coding.

> it's a community full of nice, smart, interesting people

Isn't everyone describing the community they belong as such? I have yet to meet someone advertising his programming language of choice with “the community is full of morons, join us!”…

Re: Nim 1.0

#246
post #30

Great! I love this language, so simple and powerful, so fast executables! I hope I don't spoil the party by asking: What's the status of GUI bindings?

I'm enjoying NiGui[0]. It uses Windows (Win32) API for Windows and GTK3 for Linux/Mac. It doesn't have every feature added yet, but it does have quite a few and is easy enough to add more. I've personally contributed a bit to this repo in hopes it grows in popularity, I found it to be one of the easier GUI's to work with (with Nim).

[0] https://github.com/trustable-code/NiGui

Re: Nim 1.0

#247

Congrats to the Nim team. One thing that is frustrating for anyone hearing about Nim for the first time is that it's really hard to look at what appears to be yet another slightly different take on Rust or Go and intuitively understand why it exists. There is absolutely a grid that can be populated: who started this, is it corporately affiliated, what languages is it similar to, what is the motivation of its creators…

> yet another slightly different take on Rust or Go From Wikipedia article of each language: Rust: First appeared July 7, 2010; 9 years ago Go: First appeared November 10, 2009; 9 years ago Nim: First appeared 2008; 11 years ago

It’s not actually important what came first, but rather whats currently being used/popular. Nim might have had the headstart, but its lost the race, so now it has to challenge its existence against the current popular set of languages people are looking at for transition

Re: Nim 1.0

#248
post #189
post #180

Earlier quoted context omitted.

> ... something unique I like about Nim, using `func` to declare pure functions (and `proc` for others) FORTRAN has this distinction since the beginning.

I think that's wrong. Isn't Fortran's procedure/function distinction between things that return a value and things that don't , rather than between things without side effects and things that might have side effects ? The latter is what Nim's func/proc distinction is about. (Modern Fortran does have a pure keyword meaning "no side effects", but that wasn't there "since the beginning".) [EDITED to add:] I checked in t…

You are right, thanks for the correction.

Re: Nim 1.0

#249
post #170

Earlier quoted context omitted.

> yet another slightly different take on Rust or Go From Wikipedia article of each language: Rust: First appeared July 7, 2010; 9 years ago Go: First appeared November 10, 2009; 9 years ago Nim: First appeared 2008; 11 years ago

The real question is what it offers over OCaml (1996). Nim people talk about GC being "optional" but have never been able to tell a clear story about what this does and doesn't mean (D has the same problem). Aside from that, even if the language puts everything together in a more polished package than its predecessors (and I've no idea whether Nim does or not), what's the unique selling point that would make it stand…

For me it's more: what does it offer over Crystal (apart from being freshly 1.0). Crystal seems a lot nicer and a bit more, hum, uniform. Nim seems to have a lot of features to be aware of, and doesn't have type-safe nil.

Re: Nim 1.0

#250
post #218
post #199

Earlier quoted context omitted.

Basically you only use GC if you declare something using a GC type. type # A `ref` type is GC and will use the heap. MyGCType = ref object fieldA: int # Otherwise ALL types are stack based. MyStackType = object fieldA: int Also GC is deferred, so if you use a GC type in a local scope that doesn't escape, you don't pay for reference counting. The only other type that use GC is `seq` (equivilent to C++ vectors) IIRC. T…

> Basically you only use GC if you declare something using a GC type. So similar to C# (2000)? A useful feature to be sure, but not a major innovation. > The standard library uses seqs in various places so if you fully turn the GC off using the compiler switch --gc:none you'll get warnings for things you use that will leak. There's no GC 'runtime' stuff that you need though. Running with the GC off (and accepting the…

I wouldn't say separating the GC at the type level is a major innovation, but as you say it's useful. I don't think Nim really sells itself on a groundbreaking GC implementation either. However it does give you a fast GC with enough flexibility should you need it. For example, the Boehm GC is not thread-local.

GC types are copied over channels with threads, or you can use the usual synchronisation primitives and pass pointers.

As you say, thread-locality avoids the hard problems and this is a good default - I would argue that most of the time you want your data being processed within a thread and the communication between them to be a special case.

Certainly, there's a lot of talk of adding some sugar to threading, and Nim does offer some interesting tastes, such as the parallel statement: https://nim-lang.org/docs/manual_experimental.html#parallel-...

The performance of the default GC is good to very good, the JVM is almost certainly better in most cases, however this is comparing apples to oranges; it's a different language.

Nim's GC pressure is much lower in most cases, not least because everything defaults to stack types which not only don't use GC but tend to be much better for cache coherence due to locality. Using ref types is not required unless you use inheritance, however the language does encourage composition over inheritance, despite providing full OO capabilities, so you find inheritance isn't as needed as in other languages.

Plus it's not really much different to using refs to drop down to pointer level and avoid the GC without disabling it:

  type
    DataObj = object
      foo: int
    Data = ptr DataObj

  proc newData: Data = cast[Data](alloc0(DataObj.sizeOf))
  proc free(data: Data) = data.deAlloc

  var someData = newData()
  someData.foo = 17
  echo someData.repr
  # the echo outputs eg: ptr 000000000018F048 --> [foo = 17]
  someData.free
All this means that you can 'not use the GC' whilst not disabling it. I am a performance tuning freak and I still use GC seqs all the time because the performance hit is actually using the heap instead of the stack, and worse, the actual allocation of heap memory - regardless of the language. The GC overhead is miniscule even with millions of seqs and would only even come into play when allocating memory inside loops. At that point, it's not the GC that's an issue, but the allocation pattern.

Again though, it's nice to be able to drop down to pointers easily when you do need every clock cycle.

Post reply on HN