News for hackers. Stuff that matters.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adeon on Thursday June 02, 2022 @07:29PM (#31601953)
I wish there was a Rust-like programming language that was just a little bit higher level than Rust. I like Rust's wide ecosystem with high quality packages, the nice type system, traits, the idea that my code generally runs pretty fast even if I'm being lazy about writing good code, and my code usually working correctly if it compiles.

I care about speed and correctness but Rust makes me also care about ownership and lifetimes even when I don't really want to care about that stuff. I've written Rust for years now and this still occasionally can really slow me down. Rust is still a very nice language so I just deal with it :) no pain no gain.

I would love a Rust-with-GC or something in that spirit that is similar to Rust but automatically figures out lifetimes as much as possible and GCs whatever it cannot figure out automatically. I've looked at languages like Nim and read about research languages like Koka so I'm optimistic something will emerge from this space I really like.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by aphexairlines on Thursday June 02, 2022 @07:40PM (#31602050)
I think that's ocaml. Higher level, with GC, nice type system, no traits but signatures and higher order modules might be enough for you, and a compiler that produces fast native binaries.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adastra22 on Friday June 03, 2022 @02:26AM (#31604921)
There are plenty of languages to choose from if you allow a GC. I think Rust's niche is systems-level programming where a garbage collector is an impossibility. I wish there was an easier to use language with Rust's features which occupied this niche. I find myself reaching for modern C++ instead of Rust when I want to be productive :(
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adev_ on Friday June 03, 2022 @04:03AM (#31605512)
> I find myself reaching for modern C++ instead of Rust when I want to be productive :(

You are not the only one, this is also my experience.

And if you think about it: This is fine. There is a reason why we are not using TLA+ or format proofs framework when we want to do quick prototyping: Safety has a cost like everything else.

It can be a run-time cost (in case of ARC or GC languages) or a mental effort / productivity cost but it is still a cost.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by pjmlp on Friday June 03, 2022 @08:54AM (#31607558)
Same here, I like Rust a lot, however in one side I already have JVM and .NET languages for 99% of the stuff I do, and for the remaining 1%, having C++ burned on my brain since 1994, with the 40 years of tooling, I rather spend the time using it.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adeon on Thursday June 02, 2022 @07:52PM (#31602163)
I think you are pretty spot on here. I write Rust and Haskell most of the time, where the choice depends on the kind of project I'm working on. Also I've written Rust professionally but Haskell has been confined to random hobby projects.

I love Haskell but it has its own flavor of problems. I've meant to brush up a bit on OCaml; I've heard it has interesting features in its module system that Haskell does not have (maybe what you call "higher order modules").

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ChadNauseam on Thursday June 02, 2022 @08:11PM (#31602350)
Yup. Professional OCaml dev here, higher order modules are pretty cool. But OCaml shows its age and without typeclasses I don't find it very pleasant to program in. Most days I'd rather use Rust to be honest.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by oxff on Friday June 03, 2022 @04:47AM (#31605808)
Ocaml is just a mess. Has like two standard libs. You'll just fighting everything but your application logic instead.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by octachron on Friday June 03, 2022 @05:34AM (#31606130)
There is only one OCaml build system (dune) which is used by people that don't write their own build system. But yes, you have the freedom of using alternative to the OCaml standard library if you wish so.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by oxff on Friday June 03, 2022 @06:24AM (#31606489)
I might terminally dumb
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by pjmlp on Friday June 03, 2022 @08:55AM (#31607571)
Having an npm like ecosystem is hardly better.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by jnash on Friday June 03, 2022 @12:47AM (#31604400)
Yep ocaml seems to be a perfect balance of all the best of other languages.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Amasuriel on Friday June 03, 2022 @06:32PM (#31614505)
Or F# if you want a wider ecosystem, it’s based on Ocaml and has many nice functional features, but you can utilize any .net code you want
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by yeputons on Thursday June 02, 2022 @07:37PM (#31602021)
> I care about speed and correctness but Rust makes me also care about ownership and lifetimes even when I don't really want to care about that stuff.

I don't think one can care about speed and correctness without caring about lifetimes and ownership. Even if you do not care about memory ownership and use garbage collection, there are plethora of other things that you take care of. For example, if you've juts sent an RPC/HTTP request, and a user closed a particular window, should you abort the request or not? What if the user have closed all windows except one? Can they actually close window X without doing something in window Y first? What should happen if you forgot to abort the request and now the callback is called, but the original caller is gone?

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by valenterry on Friday June 03, 2022 @05:08AM (#31605926)
I think after the (correct) first sentence you are a bit mistaken here. The example you describe can be solved correctly and also with good performance in garbage collected languages such as Haskell or Scala. I would even say that those languages make a correct solution easier than in Rust, but they trade in a bit of performance for it (e.g. by using immutable datastructures instead of an ownership model). But for async stuff, I think this is actually simpler.

However, when performance is key, then Rust is by far the easiest solution to get it performant and still correct.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by shultays on Friday June 03, 2022 @06:00AM (#31606327)
"good performance" is a relative term. You may consider Haskell or Scala having "good performance" but for others having garbage collection itself is a big no. So you are either left with Rust's approach where you limit the programmer, or C++'s approach where you leave memory management mostly to the programmer
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by valenterry on Friday June 03, 2022 @12:01PM (#31610154)
I think you missed the point here.

My response was focussed on the part of the challenges of async logic. And what OP essentially said is that Rust does not only help performance because of the ownership model (vs. garbage collection), but also because it makes it easy to come up with correct and performant solution to async-related problems.

My point was that, when ignoring the performance benefits of ownership model vs. garbage collection, a language like Haskell or Scala makes a performant and correct solution for async problems easier than Rust does - at least at the current point in time.

I hope it's more clear now.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by NoGravitas on Friday June 03, 2022 @12:14PM (#31610345)
You can get great performance from garbage collected languages, to be honest. I guess what you can't get is perfectly predictable latency — but that only matters for a pretty narrow class of applications.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Hirrolot on Friday June 03, 2022 @12:35PM (#31610568)
How then people write high-performance servers in JVM?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by taneq on Thursday June 02, 2022 @09:45PM (#31603226)
I feel this fact is grossly underappreciated. Caring about speed and correctness but not ownership and lifetimes (and thread safety and race conditions and...) is like caring about road safety but not caring about headlights. You're not avoiding ownership and lifetime problems, you're just avoiding looking at them.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by preseinger on Sunday June 05, 2022 @02:40PM (#31633679)
Thread safety, and memory model safety, and all this important stuff, is important! But ownership and lifetimes are models of reality that Rust asserts as part of its domain language, which, like all models, are approximations of reality, not reality itself. They're useful to the extent that they help to solve a given problem. And not all problems fit into the assumptions that they assert.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by birdfood on Thursday June 02, 2022 @08:10PM (#31602345)
I've bounced around a few languages this year, looking for a language to use in my spare time for fun / enjoyment / skills growth (I have a similar set of criteria to you). I've looked at rust, swift, haxe, zig, and now nim, and I think I'll be sticking with nim. I like that it's seemingly simple, and takes care of memory management for you, but you still have access to pointers if you want them and can extend the language with its macros. It seems like a language that I'll be able to grow with / pick up complexity as I want it, but by default I'll have concise readable code. What was your take on nim?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by jnash on Friday June 03, 2022 @12:48AM (#31604413)
Try ocaml or F#. I did the same as you and was surprised how well balanced ocaml/F# are compared with everything else.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adeon on Thursday June 02, 2022 @09:58PM (#31603325)
There were many things I liked about Nim:

* The compiled programs run pretty fast.

* Compiling is pretty fast too (compared to Rust or Haskell).

* It's easy for me to bind to whatever C library I have even if nobody made nice Nim packages for it. This one was important for the project I was working on.

* There is a GC, but if you choose the proper GC it will be based on reference counting (or if you are compiling to JavaScript, it'll use JavaScript's GC). It means I don't have to care about cleaning up resources. My memory may be wrong but I think Nim also tries to remove reference counting checks when it can. I haven't ever checked in the compiled code does it do a good job at this.

* The language rarely complains that something in my code is wrong; there's no borrow checker complaining. Even with little experience I was able to write some quite complicated code. It's like Nim wants to do its best to compile and run my crappy code.

* It's easy to read. Maybe because it looks so much like Python and I have lots of Python experience. Nim does not want to complain about your code unless it has to. Despite being statically typed, you don't have to write type definitions that much.

There are things I don't like as much:

* The story for running threads in Nim is not great. You can run OS-level threads but it's a bit janky (you'll have to now care what data can be shared). It wouldn't stop me from writing multi-threaded software though if I really needed threads.

* The documentation could be a bit better. I think Nim project should take this giant page: https://nim-lang.org/docs/manual.html and reorganize it and make sure the language is easy to read and find stuff. I often have trouble finding documentation on some language feature. I think the project is acknowledging this right in the first paragraph "This document is a draft! Several of Nim's features may need more precise wording. This manual is constantly evolving into a proper specification."

This one is harder to pinpoint into specific examples but the language feels a bit immature. I feel like there's bunch of half-baked features that were thrown in on a whim idea. And obviously the package ecosystem isn't as wide as in more established programming languages. I looked it up and Nim has apparently existed since 2008; I'm sure it used to be way more immature ;)

Despite the negatives, I think Nim is an amazing tinkerer's language. I can very quickly write programs that will be speedy and easy to read. I'm not sure I'd start a very complicated large project in Nim though. I am bullish that Nim will mature and its userbase will grow, fixing some of the warts.

In a few months I plan to take a long vacation and work on a video game with my friend. There is a high chance that I'm going to use Nim for this project; to make something that runs both in browser and also natively.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by birdfood on Thursday June 02, 2022 @10:29PM (#31603539)
Good summary, I haven't touched threads but I'd agree with everything else. I'd also add that since the language feels dynamic, I feel like my code is less structured, but I think this might just be because all the boilerplate you have to write in other languages isn't there. So maybe my code is just as unstructured and with nim I can't be fooled by boilerplate into thinking it is.

I've been following the nature of code and making a little 2d platformer at the same time using nim + raylib. Compiling to wasm I found to be even simpler than when doing the same thing with C++. It's really nice being able to compile to native or wasm with a single compiler flag.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by teleforce on Thursday June 02, 2022 @07:57PM (#31602212)
Try D it has most features that you just described. It feels Phytonic and it's GC by default[1].

There is an ongoing work for borrow checker for D language, and pardon the pun but I believe D is borrowing just the right amount features from Cyclon and Rust for safer compiled software without overly complex programming syntax.

[1]Origins of the D programming language:

https://dl.acm.org/doi/abs/10.1145/3386323

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by nicoburns on Thursday June 02, 2022 @07:45PM (#31602112)
Swift is by far the closest from a language point of view, but alas the ecosystem is all-but-nonexistent outside of the Apple systems.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by josephg on Thursday June 02, 2022 @10:24PM (#31603506)
This is a shame.

Swift could be a lovely general purpose language. I like the balance swift strikes between ease of use, expressiveness and performance. Like, swift has an equivalent of Option - but there’s syntax sugar for it. Rust has String / &str / Etc. To get a SSO string you need to pull in an external crate. Swift just has a built in, good, general purpose SSO string as part of the language.

But adding random half baked features to swift seems to be on the promotion path at Apple. Nothing is well documented. The language doesn’t feel stable and there isn’t much of a broad community like there is with rust, javascript and python. It’s a pity!

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by efnx on Friday June 03, 2022 @04:21PM (#31613166)
I would argue that swift is pretty distant compared to the ML family of languages - specifically Haskell. Besides garbage collection, the biggest difference between Haskell and Rust is that Haskell already has higher kinded types.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by sprkv5 on Thursday June 02, 2022 @08:30PM (#31602496)
OCaml[1] is what you are looking for. You also might want to look at Roc[2], even though that's not released yet.

1. https://ocaml.org/ 2. https://www.roc-lang.org/

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dagmx on Thursday June 02, 2022 @10:21PM (#31603485)
Sounds like you're describing Swift. I'm trivializing it, but Swift is basically a higher level Rust with everything wrapped in an Arc.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by therockhead on Friday June 03, 2022 @04:05AM (#31605545)
As someone who does Swift 9-5 and dabbles with Rust, this statement rings true to me.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @06:27AM (#31606505)
Scala might just be that. It has a very strong type system which is quite similar to Rust's, lifetimes are managed by the JVM's state-of-the art GC, and all in all it is a very expressive language. Think of python-level expressivity, but all statically typed with type inference. It also has a similar stance on the functional-imperative question as Rust has - it prefers functional concepts but lets you write imperative code when you want to hand-optimize something.

Oh and I almost forget to point out that it can just use basically one of the largest ecosystems, and can also compile to js or native (for the latter there is scala native as well as graal)

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by EugeneOZ on Friday June 03, 2022 @06:45AM (#31606621)
Does it have a borrow checker and mutability control?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @07:19AM (#31606841)
It is a GCd language, a borrow checker is very seldom needed outside of that (and frankly, one should just use try-with and similar constructs for other kinds of resources), so why would it need one? As for mutability, it is not enforced on a language level (only shallowly), but the standard library, the language primitives and basically everything makes control over mutability very good. In practice it won't be much different than Rust with the interior mutability pattern.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by EugeneOZ on Friday June 03, 2022 @07:40AM (#31606978)
“Side-effect” of borrow-checking - there is always only one who can write to a variable. It's much more important than GC.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @07:45AM (#31607018)
Oh I see. No it does not have it enforced at the language level, but it relies heavily on immutable data structures, and the type system is strong enough to express a complete actor-based concurrency library.

But since it is interoperable with Java and that exposes low-level primitives of concurrency, it can’t really be made guaranteed data-race free.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by EugeneOZ on Friday June 03, 2022 @07:50AM (#31607053)
Your responses were quite informative, thank you. Even for me, Scala looks more interesting now. I have some Java adepts, I’ll try to convince them to climb a few steps.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by inChargeOfIT on Thursday June 02, 2022 @08:28PM (#31602474)
I really like the idea of something like vlang (https://vlang.io), as I've tried multiple times to find the motivation to learn Rust, but always end up going back to golang for the simplicity.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Tozen on Thursday June 09, 2022 @01:27PM (#31684149)
Unless there is some very compelling reason to need Rust, a lot of people would be better off with Golang or Vlang, because it would make their lives easier in terms of more general usage and ease of use.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by throwamon on Thursday June 02, 2022 @07:38PM (#31602032)
Sounds like OCaml is exactly what you want. Many of Rust's features are even inspired by it.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ssokolow on Tuesday June 07, 2022 @09:36PM (#31662249)
As well as syntactic constructs.

For example, Rust's unusual 'a syntax for lifetime parameters is Ocaml's syntax for generics because lifetimes are a special class of generics.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by crabbygrabby on Thursday June 02, 2022 @08:03PM (#31602277)
Without diving into completely obscure programming languages, you can look at Scala, F#(doesn't scale super great ime), or I guess golang.

That said, they all don't give you what rust gives you and have their own troubles.

The truth is, either you care about life times and ownership, or you really don't care much about speed and correctness. Not saying that targeted at you as a person, but the royal "you". Even in c/c++ I have to think about that stuff, there's just no tools for it .

Fwiw you can import crates to have a gc in rust. To me it defeats the purpose. Wishing you the best on your search

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by mbrodersen on Saturday June 04, 2022 @08:42PM (#31626741)
What makes you think that F# doesn’t scale? Anything you can do in (say) C# you can do in F#?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by 0des on Thursday June 02, 2022 @07:48PM (#31602132)
Go and Hare are rust-adjacent with just a touch of crayon involved. I highly recommend both especially Go since you mention rust with GC
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by rfiat on Thursday June 02, 2022 @09:58PM (#31603329)
It's interesting that you find Go to be Rust-adjacent. Setting aside the USPs of each language (goroutines and borrow checker respectively) and just speaking about the general experience of writing code, I find Go painful for all the reasons that I find Rust pleasant.

The best summary I can give of Rust is that it was designed by people who learned from the mistakes of the programming languages that came before it.

The best summary I can give of Go is to quote Rob Pike's response [0] to a request for syntax highlighting in the Go playground:

> Syntax highlighting is juvenile. When I was a child, I was taught arithmetic using colored rods (http://en.wikipedia.org/wiki/Cuisenaire_rods). I grew up and today I use monochromatic numerals.

[0] https://groups.google.com/g/golang-nuts/c/hJHCAaiL0so/m/kG3B...

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by 0des on Thursday June 02, 2022 @10:48PM (#31603680)
It's like my favorite John Quincy Adams quote, "It is what it is, and it ain't what it ain't" Different strokes for different folks you know? At the end of the day if folks code at all, and it makes them happy, that's a good thing.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adastra22 on Friday June 03, 2022 @02:30AM (#31604941)
If your primary criticism of golang is that its creator doesn't like syntax highlighting, then it must be doing pretty good.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dgunay on Friday June 03, 2022 @05:39AM (#31606166)
It is mostly an example of the mindset that I think GP is trying to illustrate.

Go has nil where Rust has Option.

Go has weird not-quite-tuple returns & if err != nil where Rust has Result.

Go has no real enum concept, where rust has its powerful enums and matching constructs.

Go has generics, but only after a decade of pressure from users (and even then, they are much much less useful than Rust's type system).

I like Go and I feel very productive in it, but its commitment to simplicity is dogmatic in many ways and it very much is missing milestone advancements in PLs from the past several decades. It could easily have been made in the 90s.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by christophilus on Friday June 03, 2022 @07:58AM (#31607116)
I would love a language that combined the best aspects of Go and F#: expressive, great type system, fast compilation, native binaries, opinionated formatter, excellent concurrency, comprehensive standard library, consistent documentation, etc.

Throw in great compile to JS capabilities with small bundle sizes and the ability to map Typescript typings into the language so you can seamlessly consume well typed libraries, and man. Killer language, right there.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dgunay on Friday June 03, 2022 @06:53PM (#31614734)
Me too! Go's tooling and runtime are great, I just want a more useful type system.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by curun1r on Friday June 03, 2022 @01:27PM (#31611193)
I feel like Go was built with primary design considerations that are often not considered publicly and often at odds with what programmers want out of a language. I saw one of the first public talks from the creators at Google I/O and they stressed two things: compilation speed and new developers coming up to speed quickly. From what they said, Google had a few C++ projects with multi-hour compilation times that, when profiled, showed about 90% of the time was spent reading header files. So a core Go philosophy was single-pass compilation to cut down compile times as much as possible. Similarly they stressed that the focus on simplicity meant there wasn’t as much variation in style of Go code and new programmers—even those unfamiliar with Go—could quickly come up to speed and contribute to a project.

Viewed through this lens, the resistance on the part of the creators to changes that compromise these values even a little bit makes sense. Generics take time to get used to and any code base that makes extensive use of them will take longer to get up to speed in, even if it enables you to move faster later on.

That talk has really shaped how I look at Go. I think it solves problems that Google has (really large projects built by teams that have a ton of turnover) really well. But as with a lot of things that emerge from Google, it’s a solution to a problem that not too many other companies face. The ones that do will get an awesome tool that’s proven to work. But the ones for whom it’s 90% of what they need are going to get a lot of pushback getting that last 10% accepted because it already does almost exactly what Google needs it to do and any departure from that will be, in their minds, counterproductive.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dgunay on Friday June 03, 2022 @07:04PM (#31614845)
I agree, I've mostly made peace with what Go is and I still enjoy using it.

It just tantalizes me because of how close it is to my ideal general-purpose programming language. There is a large middle ground between the minutes-long compile times of Rust and the seconds-long compile times of Go.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ncmncm on Saturday June 04, 2022 @08:53PM (#31626817)
If such a compromised process produced something close to your ideal, that should worry you deeply.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by justinsaccount on Friday June 03, 2022 @02:11PM (#31611753)
As someone that writes a bunch of go but has never really gotten off the ground with rust:

  * Option? I don't mind if err != nil, but sure, it would simplify some things.
  * Result and real tuples? awesome.
  * real enums? sign me up.
If that was all added to go I wouldn't mind at all. But what does any of that have to do with

  impl<'a, H, Fut, Tail> Execute<'a> for Dispatcher<H, Tail>
  where
    H: Fn(&'a Update) -> Fut + Send + Sync + 'a,
    Fut: Future<Output = ()> + Send + 'a,
    Tail: Execute<'a> + Send + Sync + 'a,
  {
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dgunay on Friday June 03, 2022 @06:58PM (#31614786)
It doesn't, primarily the way I saw the discussion heading was (warning: strawmen ahead):

> "Go is a good alternative to Rust because it is easy to write performant, concurrent code"

> "Go is not very comparable to Rust. I won't describe why, here's a quote by Rob Pike and I'll strongly imply it's because its creators deliberately avoided complexity, even where useful."

> "You did not explicitly criticize anything about Go, therefore it must not have flaws"

Then I came in and described exactly where I feel Go ignores the state of the art in PLs.

> But what does any of that have to do with (Rust-shaped vomit)

Go doesn't need all those type system gymnastics because it does not have the problem of the borrow checker to deal with and doesn't promise to avoid segfaults for you.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by int_19h on Monday June 06, 2022 @06:26AM (#31638785)
It is a serialization of relative lifetimes, basically. Whenever you write code in any language that doesn't have a GC, you either have to maintain a mental map like this to avoid bugs, or you make the language do it for you like Rust does.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by 0des on Friday June 03, 2022 @03:00PM (#31612298)
Shit like this makes my brain hurt
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ngrilly on Friday June 03, 2022 @02:59PM (#31612277)
3 issues you listed with Go are actually about the same thing (the lack of sum types):

- Go has nil where Rust has Option.

- Go has weird not-quite-tuple returns & if err != nil where Rust has Result.

- Go has no real enum concept, where rust has its powerful enums and matching constructs.

And the point on generics coming late is unfair. All programming languages got major features introduced late (for example async/await in Rust).

But I admit I'd love sum types, a less verbose error handling (but to be honest I'm not sure exactly how), and that I missed generics.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dgunay on Friday June 03, 2022 @06:49PM (#31614683)
Yeah I don't mean to criticize Go's generics for being less featureful given how late they were introduced, but they do currently prevent me from building any kind of mapping/filtering/pipeline style code because of their limitations (no generic type parameters on methods). A Go implementation of Result or Option could paper over the lack of sum types if we only had that.

The more I think about it, what I really want is something with the ML feeling of Rust, but in the space that Go occupies (good performance GC languages). Go frustrates me because it nails the runtime and tooling side of things but falls far short of it in the other ways I mentioned.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by int_19h on Monday June 06, 2022 @06:30AM (#31638801)
There's no shortage of good-perf languages with a GC: F# would be one prominent example that sounds very similar to what you describe.

The usual objection is that it requires a .NET runtime, whereas Go produces a single self-contained executable. But .NET can produce self-contained executables these days.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ngrilly on Monday June 06, 2022 @11:16AM (#31641567)
Yes, .NET can produce binary executables, but is it a common practice? I’m asking because I think the ecosystem matters a lot. If it’s a common practice, then it’s more tested and more stable and you get more tools and documentation.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by int_19h on Monday June 06, 2022 @09:20PM (#31648715)
It's a relatively recent feature, at least the "pure" implementation (what they had before was, essentially, a self-extracting binary), so it's still gaining popularity. But seems to be fairly common with containers.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ngrilly on Saturday June 04, 2022 @05:10AM (#31618404)
I absolutely agree with everything you just wrote and would use a language like that.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by rfiat on Friday June 03, 2022 @08:59AM (#31607621)
As the sibling commentor said, syntax highlighting is only one example meant to illustrate Go's sometimes unnecessarily frustrating design. In case it wasn't clear, the example wasn't that Rob Pike doesn't like syntax highlighting. The example was that Go's playground doesn't have syntax highlighting (even as an option) for a reason as arbitrary as "because I said so".

That is why I find Rust and Go to be dissimilar. Rust is a language full of good ideas, almost all of which didn't originate in Rust. Go feels like it was designed with a very specific brief - "we want C but with GC and easy concurrency" - but whose designers otherwise had an NIH syndrome-like aversion to good ideas and common sense.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by throwaway17_17 on Friday June 03, 2022 @12:59PM (#31610837)
I don't agree with your framing. You are stating a 'moral' proposition, i.e. Rust == Good Ideas AND Go == Bad Ideas, and then applying the 'moral' position to the language as a whole. So you end up saying, in brief (and acknowledging that I do not think you are actually making a moral claim about the qualities of these languages) you are saying Rust is Good, Go is Bad and therefore they are dissimilar. I don't think the reasoning your putting forward actually says anything about the language and there similarity/dissimilarity.

I am not saying that Go and Rust are similar or not. I don't really agree with GP's comment where Go should be in the running for a Rust-with-GC/slightly-higher-level-Rust, but the frankly dismissive Rust Good therefore not similar to Go Bad is not justified. Although the conclusion regarding similarity is probably correct.

Also, this is a little off topic, but I have seen multiple people say that Go 'was designed with a very specific brief - "we want C but with GC and easy concurrency"' and then go on to complain about the lack of things like generics, destructuring match syntax, functional concepts, etc. But, all of those discussion, including your comment, start out with what seems to be an acknowledgement that Go's design had a very specific target. I agree that Go is basically the fulfillment of the brief you gave, i.e. C with GC and easy concurrency. So, when the target is C with two unique things, why does everyone then seem confused that Go doesn't have all of these extra 'good ideas and common sense'.

I'm not trying to turn this into a thread on Go's merits or lack thereof. I just don't understand why so many people seem to think that Go somehow didn't do exactly what it set out to do. You don't have to think what they decided to design was a worthwhile language, but to expect a lion to be a shark, or an apple be a steak, is just illogical.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by rfiat on Friday June 03, 2022 @06:44PM (#31614616)
I appreciate your comment. My intention wasn't "Go is dissimilar because it's bad and Rust is good" but I can see why you'd think that. I'll attempt to clarify.

The reason I like and recommend Rust is the number of decisions it gets right which are completely orthogonal to the borrow checker. It's clear that a lot of thought was put into the unexciting parts of the language. That's why I like using it even though I don't particularly need the borrow checker and I'd be happy with GC. Some examples off the top of my head:

  - Expression-oriented nature makes code easy to write and nice to read
  - Compilation errors are as clear and helpful as possible
  - Comprehensive yet skimmable API documentation
In short, Rust is a nice language outside of the borrow checker.

A lot of the things which strike me as nice about Rust can't be said about Go. For that reason I think Go is a surprising suggestion for someone who likes Rust but doesn't care about ownership and lifetimes.

There are a number of minor but valid frustrations I encounter when writing Go which are completely orthogonal to the brief of "C but with GC and easy concurrency". I'd understand if these problems were a result of the language's goals but often they seem to exist for no particular reason. In that regard I think Go is quite dissimilar to Rust.

I hope that explains my viewpoint more clearly :)

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by throwaway17_17 on Friday June 03, 2022 @07:48PM (#31615256)
You’re comment make your point very well. Honestly, so did the first comment. Sometimes I find myself so tired of just lurking and reading HN that I just text dump some comment onto a totally valid parent comment.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by adeon on Thursday June 02, 2022 @08:05PM (#31602290)
I like Go a lot. At my previous employer a lot of the systems we wrote for log processing were written in Golang. And I thought it was really nice; I can compile my code really quickly and code in general will run pretty fast. I've only used in the space of big data file processing though.

My only real issue with Go is that I feel the language part itself is simplistic and doesn't have the kind of type/trait/typeclass/similarthing like Rust or Haskell has. In Haskell I especially like doing DSLs using monads, e.g. I did a integer-problem-to-SAT-problem DSL and another DSL for NetHack playing AI. In Go making these DSLs is more pain. Although I think that would be true for Rust as well, just not as much.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by c-cube on Friday June 03, 2022 @12:57AM (#31604464)
Hare is not rust adjacent, sorry. It can't even represent the (small) stdlib of rust since it lacks generics, RAII... Not to mention the memory safety. It belongs in a different class of languages.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ncmncm on Friday June 03, 2022 @05:10AM (#31605937)
"Toys"
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by 0des on Friday June 03, 2022 @03:03PM (#31612331)
You are not correct but I'll accept your opinion as your understanding of it.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @06:31AM (#31606532)
Go's lack of expressivity and weak as hell type system is hardly close to Rust, like I can barely see a similarity other than both being a PL. Hell, probably Java is closer to Rust than Go, at least it is also nominally typed.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by mftb on Thursday June 02, 2022 @09:58PM (#31603328)
Just wacky I had to scroll this far to see Go mentioned. In certain contexts Rust is very impressive, in others Go is a much better choice. I'm really starting to hope that we'll see some of the important advancements in Rust packaged up in a better language.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ncmncm on Saturday June 04, 2022 @08:56PM (#31626823)
Go is very deliberately designed for when you depend on a team with sharply limited skills.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by mftb on Sunday June 05, 2022 @12:37AM (#31628057)
These one-liners aren't super-constructive, my own comment was hardly in-depth, so whatever...

On any team or in a community your most likely to have a range of skill levels across members. A language can be many things, a powerful tool or a strong barrier.

When I first heard about Rust I thought we were on the verge of getting some real advancements across a much larger community of developers and scope of projects. Instead I think we're headed further down a path of at least 3 major groups of PL (scripting, memory-managed, precise semantics). Who knows, maybe it's for the best. If so we better get busy improving the inter-op.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by goodpoint on Thursday June 02, 2022 @08:49PM (#31602708)
> I've looked at languages like Nim and read about research languages like Koka

Nim is indeed going in the right direction with ORC/ARC

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by DeathArrow on Friday June 03, 2022 @02:00AM (#31604773)
>I wish there was a Rust-like programming language that was just a little bit higher level than Rust.

I think F# might fit this role.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by syntheweave on Thursday June 02, 2022 @10:08PM (#31603390)
In addition to the Ocaml recommendations I suggest Haxe, which is basically "Ocaml concepts transposed into a compiler targeting various GC runtimes". (Compiler is also written in Ocaml - it's not kidding around) Easy to pick up if you already know JS syntax, and basically covers the "best-of" of static inferred type systems, but you can easily break out of it if you need dynamic or low-level behavior.

Downside is that it's not convenient if you just want one standard library and runtime because it targets all of them. You have to justify the trade-offs involved in that, but it's a good secret weapon.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kitd on Friday June 03, 2022 @04:57AM (#31605868)
D lang is incorporating a borrow-checking system. I'm not certain how far along they are with it. Walter Bright posts here often and will know. D has a wide range of GC and non-GC techniques that may meet your needs.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by p0nce on Friday June 03, 2022 @06:01AM (#31606343)
And no D programmer says "it was really hard but worth it in the end". It's worth it right from the start.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by sideeffffect on Friday June 03, 2022 @08:53AM (#31607541)
> Rust-like programming language that was just a little bit higher level

I think the best answer is Scala. It has an awesome community/libraries/ecosystem. See this for example https://news.ycombinator.com/item?id=31601040#31604573

There are other great answers, like F#, Haskell or OCaml, but these are not as mainstream and that comes with its challenges.

With Scala you get and awesome IDE, surprisingly wide variety of libraries and the whole Java world as a backup.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by benibela on Friday June 03, 2022 @01:17PM (#31611067)
Pascal was almost there

It puts the reference counting in the type system. Like the default string type and arrays (=vectors) are reference counted. And for speed you could use manual memory management

Any string literal is like an arc<string>. E.g. in Delphi you can now write string concatenation like:

   var a = 'bcd';
   var b = 'xyz';
   var c = a + b;
which corresponds to Rust like

   let a = Arc::new(String::from("bcd"));
   let b = Arc::new(String::from("xyz"));
   let c = format!("{}{}", a,b)
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by ssokolow on Tuesday June 07, 2022 @10:11PM (#31662412)
I think the big thing that hurt Pascal initially was the poor start it got off to. By the time things like Borland Pascal came around and fixed the weaknesses from explicitly starting as a teaching language, the damage had already let C pull ahead.

As for nowadays, I'd say there are three things that help people to bounce:

1. The big name (Delphi) is proprietary and Free Pascal's documentation feels like it hasn't caught up with various lessons that were learned about how to document a toolchain and standard library since the early 2000s.

(And that's before you discover that, apparently, the API documentation is manual enough that the official stance on the Free Vision TUI component's documentation is "go find a copy of the Turbo Vision book from the Borland Pascal manuals", and that the Free Pascal Wiki either neglected to mention one or two classes when they were saying what is yet to be reimplemented or neglected to mention additional restrictions present in the DPMI port.)

2. Similar to with Ada, the ecosystem people are normalized into as they learn programming is leaning more and more strongly on the C-descended syntaxes, making Wirth-style syntaxes feel more alien.

I have to admit, compared to something like Rust, there's a certain off-puttingness to having so much verbosity and ceremony in the structure of the block constructs. To exaggerate a bit to get the point across, it's sort of like Pascal expects me to remember all the layouts and lines for what an empty tax form looks like well enough to draw it from memory before filling it out... and that sense of discomfort doesn't go away if I delegate it to my code snippets tool.

It lends an ambient sense that there's an iceberg of structure I don't understand and Pascal expects me to remember how many separate peaks it should have poking out of the water and where they should be, without me understanding the topography of the submerged portion.

(And yet I still recommend it as the Java/C# equivalent for DOS retro-hobby computing, since it's safer than C and has a much richer library of bundled functionality and comparable performance.)

3. The Free Pascal APIs are aggressively 90s and don't have enough examples to break you from your 2010s-and-beyond expectations. (I was almost tearing my hair out over how to get status updates from their zip extraction code before I realized that I was fixated on the Qt/GTK/DOM/etc. idea of using some kind of signal.connect(my_callback) function rather than using subclassing to set an event handler.)

Just, in general, it's an experience that's alien to current language trends and growing more so, the documentation available before you're committed enough to pay for it is wanting, and if you're willing to pay hobbyist prices, you need to do your own research on what exists to pay for.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by TheCipster on Friday June 03, 2022 @04:11AM (#31605586)
I have high hopes for Jakt: https://github.com/SerenityOS/jakt
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Wodann on Friday June 03, 2022 @07:38PM (#31615181)
Have you heard of https://mun-lang.org/ ?

It's an embeddable scripting language with the goal of being a Rust-like language that supports hot reloading of functions AND data. To achieve the latter, it uses GC'ed memory such that memory can easily be mapped when the memory's type changes.

It's still in early development but maybe one day will serve your needs :)

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Ar-Curunir on Thursday June 02, 2022 @07:52PM (#31602169)
I think some aspects of ownership are useful, e.g. move semantics and mutable/immutable references. withoutboats had a good post about a Rust-with-ownership-and-GC language a while back: https://without.boats/blog/revisiting-a-smaller-rust/
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by renonce on Friday June 03, 2022 @04:44AM (#31605792)
Would it be possible to do something like Rust+Go where you integrate Go code natively into Rust? So Go pointers become `GoPtr<T>` where `GoPtr<T>: Copy + GC` etc. Then all Go structs implement `GoStruct` which would have a static method called `reflect` that returns all the information required for type reflection. One thing I love about Rust is its genericity that at least makes imagining such things possible, though I do expect a lot of engineering effort.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by labrador on Thursday June 02, 2022 @10:44PM (#31603643)
People don't like to mention C# since like PHP, it has a bad rep from early days, but C# 10 and .NET 6 hit all the sweet spots people are mentioning. C# and .NET now run on Linux and Mac and compile to a single executable like Go with tree shaking so the binary is much reduced. I don't really care, but it's a shame people don't take another look at C#. When I learned Rust I was surprised how similar it felt to C#, but much more ergonomic.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by orthoxerox on Friday June 03, 2022 @07:58AM (#31607112)
Static interfaces are still in preview, DUs aren't being actively worked on, that's what I miss from Rust when I'm writing C#.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by NoGravitas on Friday June 03, 2022 @12:19PM (#31610411)
Have you used the OneOf library? It's not DUs, but it's kind of an 80% solution in that space.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by snthpy on Saturday June 04, 2022 @03:31AM (#31617932)
Have a look at nim through the lens of this talk:

https://youtu.be/j0fUqdYC71k

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by teucris on Thursday June 02, 2022 @07:47PM (#31602129)
What about a transpiler that added a ^ operator that made a variable actually an Arc and inserted unwraps, clones, etc as necessary?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by efnx on Friday June 03, 2022 @04:19PM (#31613143)
You should try Haskell. It has everything Rust has (and much more) and it also has a garbage collector. I prefer it to ocaml.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Aardappel on Tuesday June 07, 2022 @09:18PM (#31662132)
Lobster's automatic compile time reference counting has exactly this purpose: https://aardappel.github.io/lobster/memory_management.html
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by NoGravitas on Friday June 03, 2022 @12:18PM (#31610396)
Koka and Vale both seem to be decent (experimental) approaches to languages that learn from Rust, both what it got right, and what it got wrong.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Hirrolot on Friday June 03, 2022 @12:40PM (#31610622)
I think Rust will eventually repeat the story of C++. 1) There will emerge more ergonomic languages that solve real-world problems that Rust attempted to solve. 2) Rust's issues with type system and async will be largely resolved, so it could be used in areas where it is absolutely required.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by tucnak on Friday June 03, 2022 @06:19AM (#31606449)
Elixir?
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by eggy on Friday June 03, 2022 @06:52AM (#31606663)
Not for system-level programming.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by dymk on Friday June 03, 2022 @08:59AM (#31607615)
Well they want something GCd so it won’t be for systems programming anyways
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by bin_bash on Thursday June 02, 2022 @08:12PM (#31602358)
I know some folks are working on this but I just want cargo for JS