News for hackers. Stuff that matters.
Re:Choosing Nim out of a crowded market for systems programm... by 127 on Friday November 25, 2022 @06:31PM (#33748122)
I have done non-trivial things both in Rust and Nim. For big projects Rust seems a little more robust, but for medium and small projects Nim is an order of magnitude faster to develop for. There are still many rough edges, but it's exactly the tradeoffs I would personally pick for my one person small business making tools for artists. So far I have been using Rust and it's alright, but looking very much into Nim to see if I can replace Rust because of the high cognitive load to keep all of the Rust stuff in my head, as I don't really need safety.

Shout out to https://github.com/StefanSalewski/gintro which was super simple to build a simple GUI tool. With Rust I have no idea what to use after trying 5 different libraries.

The downside of Nim seems to be highly unpredictable performance in my experience. With Rust it's much easier to control. This might be a deal-breaker unless I can find some solution to it. Maybe it's just using it more than two weeks and learning the ropes.

Re:Choosing Nim out of a crowded market for systems programm... by encryptluks2 on Friday November 25, 2022 @07:39PM (#33748614)
If I recall Nim doesn't even allow tabs. Programming languages should not be overly opinionated in formatting, especially when it requires extra bytes to use spaces.
Re:Choosing Nim out of a crowded market for systems programm... by thunky on Friday November 25, 2022 @07:54PM (#33748709)
> Programming languages should not be overly opinionated in formatting

I think gofmt, python black, etc have demonstrated that it's usually better to have a single standard then it is to fight endlessly about these details.

Re:Choosing Nim out of a crowded market for systems programm... by pigsinzen on Friday November 25, 2022 @08:36PM (#33748963)
They have demonstrated that some people have interest in controlling formatting.

It would be a stretch to say they demonstrated that it’s better to enforce a standard.

Black, itself, changed rules many times within a 1-year period to the point our own CI would fail on existing code that previously passed.

Re:Choosing Nim out of a crowded market for systems programm... by __turbobrew__ on Friday November 25, 2022 @08:55PM (#33749057)
> CI would fail on existing code that previously passed.

You problem isn’t that black changed formatting rules, your problem is that you didn’t pin CI dependencies. This isn’t a unique problem to black, any other tool used in CI pipelines can cause things to break if you don’t pin them.

Re:Choosing Nim out of a crowded market for systems programm... by danuker on Friday November 25, 2022 @09:27PM (#33749254)
Indeed. Something wihout security impact will use pointless resources when you update. Do it rarely (or never if possible).
Re:Choosing Nim out of a crowded market for systems programm... by booleandilemma on Friday November 25, 2022 @08:35PM (#33748959)
It's funny you say that, because Go and Python are two of my least favorite languages, partially for reasons of formatting.
Re:Choosing Nim out of a crowded market for systems programm... by mikebenfield on Friday November 25, 2022 @08:09PM (#33748800)
I disagree entirely. Ideally there should be one valid way to format your code, and robust tools to make that formatting happen automatically.

Allowing alternatives yields zero benefit and causes pointless debates and diffs.

Re:Choosing Nim out of a crowded market for systems programm... by bobbylarrybobby on Friday November 25, 2022 @08:30PM (#33748924)
The benefit is, what if I don't like four spaces as indentation? What if I like two? Why do other get to force their aesthetic preferences on me when there already exists the tab character, whose apparent width is configurable?
Re:Choosing Nim out of a crowded market for systems programm... by lamontcg on Friday November 25, 2022 @09:01PM (#33749087)
> causes pointless debates

yes, having languages establish an immutable standard for tabs vs spaces has clearly ended all debate over them.

Re:Choosing Nim out of a crowded market for systems programm... by mikebenfield on Saturday November 26, 2022 @04:10PM (#33756762)
But it actually kind of has ended this nonsense in the go community, and to a lesser extent in the rust community.
Re:Choosing Nim out of a crowded market for systems programm... by chrisseaton on Friday November 25, 2022 @08:19PM (#33748862)
Do the extra bytes matter?
Re:Choosing Nim out of a crowded market for systems programm... by bobbylarrybobby on Friday November 25, 2022 @08:26PM (#33748900)
Programming languages shouldn't even consider whitespace (except perhaps new lines) syntactically important at all, so the whole discussion is silly. Once you've decided whitespace is important you might as well make emoji part of the syntax.
Re:Choosing Nim out of a crowded market for systems programm... by throw827474737 on Friday November 25, 2022 @08:49PM (#33749033)
Why not? Making identation part of the syntax allows more for less?
Re:Choosing Nim out of a crowded market for systems programm... by ghoward on Friday November 25, 2022 @09:19PM (#33749210)
Because indentation-based languages have very limited formatting they can do. They can't do any indentation formatting.
Re:Choosing Nim out of a crowded market for systems programm... by bobbylarrybobby on Friday November 25, 2022 @10:29PM (#33749605)
You cannot cut and paste freely when indentation matter
Re:Choosing Nim out of a crowded market for systems programm... by throw827474737 on Sunday November 27, 2022 @03:21AM (#33761376)
Yes ok, but this is not very limiting and doesn't make this approach a ridiculous and failed one to start with, as the OP originally suggested and those languages which do it disprove already?
Re:Choosing Nim out of a crowded market for systems programm... by tmtvl on Friday November 25, 2022 @09:13PM (#33749166)
I disagree: if we make languages have NWS (Non-optional WhiteSpace) then we can easily disambiguate between:

  let traversed-distance := yard-length;
And:

  let traversed-distance := yard - length;
Which is valuable as kebab-case is best case.
Re:Choosing Nim out of a crowded market for systems programm... by jimbob45 on Friday November 25, 2022 @08:39PM (#33748975)
If it helps, you can configure your text editor of choice to auto-swap tabs for spaces. However, I share your displeasure for the gesture.
Re:Choosing Nim out of a crowded market for systems programm... by throwup on Friday November 25, 2022 @08:39PM (#33748979)
It looks like gintro is a GTK binding - the Rust equivalent would be gtk-rs. https://www.gtk.org/docs/language-bindings/rust/

I'm curious whether you tried gtk-rs and if so what problems did you have?

Re:Choosing Nim out of a crowded market for systems programm... by pitaj on Friday November 25, 2022 @08:51PM (#33749041)
> looking very much into Nim to see if I can replace Rust because of the high cognitive load to keep all of the Rust stuff in my head, as I don't really need safety.

Personally I find that Rust has less cognitive load, because so much of what you'd generally worry about in other languages is covered by language features in Rust: static typing, algebraic data types, etc

Re:Choosing Nim out of a crowded market for systems programm... by dilawar on Friday November 25, 2022 @09:46PM (#33749377)
I agree but I tool functional programming course in college. It was hard! Someone who may not have invested enough in leaning basics of FP, I can totally see why Rust feels like a hard language. During the prototyping phase, I also avoid lifetimes and other esoteric features and often use unhealthy amount of Arc and Rc.

Nothing beats Cargo and company and loves compiler messages. Have used NIM as python replacement, and while language is great and nim batteries are decent, the ecosystem is not there. But who would use nim as python replacement!?

Re:Choosing Nim out of a crowded market for systems programm... by sph on Saturday November 26, 2022 @03:58AM (#33751142)
How would functional programming help with Rust? I am fluent in both, and having map and reduce in the Iterator trait does not make Rust anything like a functional language.
Re:Choosing Nim out of a crowded market for systems programm... by Gene_Parmesan on Saturday November 26, 2022 @05:38AM (#33751571)
IMO Rust is what you'd get if you took a functional lang designer and forced them at gunpoint to create a procedural systems lang. It's not functional, but you can tell it was largely inspired by ideas from the paradigm -- immutable by default, expression-centric to an extent, features like Option<T> and Result<T> available, etc.

It's certainly a language that encourages programming in a functional flavor, even if the lang itself isn't functional.

Re:Choosing Nim out of a crowded market for systems programm... by efnx on Saturday November 26, 2022 @01:52PM (#33755443)
The things that make rust “functional” are features like a type system that supports sum and product types and functions as typed values that can be passed around. It really is a functional language (in the original ML sense of the word) but with another orthogonal type system bolted on (borrow checker).

It’s missing some features like higher kinded types but it’s functional nonetheless.

I’m interested to hear what your definition of functional is - it’s always interesting because it’s such a vague term, really.

Re:Choosing Nim out of a crowded market for systems programm... by efnx on Sunday November 27, 2022 @01:17PM (#33765145)
Jeez downvoters - just look at the definition of “functional language”

https://en.m.wikipedia.org/wiki/Functional_programming

And then tell me Rust is _not_ those things.

Re:Choosing Nim out of a crowded market for systems programm... by moldavi on Saturday November 26, 2022 @12:49AM (#33750337)
I'm sometimes a bit confused when people say that Rust has less cognitive load. I assume that's compared to something like C or C++, right?

I've used Rust and (imperative-style) Scala a lot, and I have to say, Scala is way easier since it doesn't have to deal with the borrow checker, but it still has an amazing type system.

Nim is statically typed and has algebraic data types, so I imagine it's also as easy as Scala, easier than Rust.

Re:Choosing Nim out of a crowded market for systems programm... by mumblemumble on Saturday November 26, 2022 @12:59PM (#33754981)
I think that it has to be?

I like Rust well enough, but thinking about memory management is a reasonably large effort that I generally don't have to make in most languages. Rust, in not having a GC, strictly adds to that load compared to most languages out there. The exceptions are languages like C, C++, and assembler, and there I agree that Rust seems to make things a fair bit easier.

(Though, disclaimer, I never got around to learning modern C++, which I gather is a huge improvement over the style of C++ I do know.)

I'd be willing to accept, though, that Rust's lack of full-blown OO features, and its strict controls on mutation, often makes things easier in large shared codebases. Perhaps not letting people do some particularly wild things that I'm used to seeing in Java and C# at my day job. I'm not in a position to have a worthwhile opinion on that claim, though.

Re:Choosing Nim out of a crowded market for systems programm... by insanitybit on Sunday November 27, 2022 @01:00AM (#33760783)
Imagine if someone said "I've used Python and Scala and Python is way easier since I don't have to deal with a type system". That's where people are coming from.

The borrow checker isn't a hindrance, it's an aid. Rust gives me syntax to describe lifetimes and a tool to check that syntax.

Re:Choosing Nim out of a crowded market for systems programm... by eru on Tuesday November 29, 2022 @04:18AM (#33785365)
Yes, but if you have immutability and a garbage collector (and can afford to use some extra memory overhead), the borrow checker and lifetimes aren't really all that necessary to bother with.
Re:Choosing Nim out of a crowded market for systems programm... by raverbashing on Saturday November 26, 2022 @01:47AM (#33750537)
Well, one thing that makes Rust harder is tooling. I don't seem to get around its code completion, at least in VSCode, and the docs, while mostly good, are hard to understand sometimes

I personally don't like that "structures with methods" way of doing things in Rust/Go but maybe that's just about getting accustomed

Re:Choosing Nim out of a crowded market for systems programm... by etra0 on Friday November 25, 2022 @10:24PM (#33749586)
I recently tried Nim for the first time, and although is simpler, the model with values vs refs was a little more complicated than needed imo, and the 'easy C interactivity' wasn't as simple as with, let's say, Zig, where you'd simply do `@cImport`.

It's still fun though, and I appreciate the minimal visual noise while writing it.

Re:Choosing Nim out of a crowded market for systems programm... by culi on Saturday November 26, 2022 @02:32AM (#33750681)
> With Rust I have no idea what to use after trying 5 different libraries.

Seems like GTK is the pretty clear frontrunner?

https://www.areweguiyet.com/

Re:Choosing Nim out of a crowded market for systems programm... by aew4ytasghe5 on Saturday November 26, 2022 @03:53AM (#33751116)
While GTK is a gui library, it is not a rust gui library. The GTK you link to is simply rust bindings for the GTK library.

The most popular rust gui library at the time of writing seems to be egui with 489k downloads.