News for hackers. Stuff that matters.
Re:Four Years of Rust by msvan on Wednesday May 15, 2019 @11:10AM (#19920141)
I wonder how many Rust users really want linear types and borrow checking, instead of the other stuff Rust brings to the table: modern language design, large and friendly community, nice type system, native compilation, good package ecosystem.

Personally I would prefer a well-designed GC'd language with a strong type system and native compilation over Rust, unless I was doing something with specific demands on parallelism or embedded software.

Re:Four Years of Rust by pornel on Wednesday May 15, 2019 @01:41PM (#19921849)
There are already several decent GC languages. If Rust was just another GC language, I don't think it would have attracted such a strong community required to develop all of these things and break out of obscurity. It'd be another Go with generics, or Elixir-native, or Swift with uglier syntax.

In the no-GC no-runtime niche for a very long time there was nothing viable besides C and C++. For programmers who want C-like level of control, performance and low-level compatibility there are very few alternatives, and if you want non-crash-prone parallelism on top of that, there's nothing but Rust.

Re:Four Years of Rust by dpc_pw on Wednesday May 15, 2019 @03:56PM (#19923108)
I don't really understand why people would want a GC over deterministic destruction like in Rust. GC is [neither necessary nor sufficient](https://ruudvanasseldonk.com/2015/10/06/neither-necessary-no...). Ownership model in practice is much more convenient precisely because objects can act like resources and implement their cleanup logic, and the business logic can rely on it. It's a great improvement in any imperative PL.

I have (re-)implemented couple of real-life projects, and each time Rust was much better higher-level language than eg. Java, Python or JS. Borrow checker fights are non-issue in practice: just avoid references, pass messages as copies and when you have to share data use `Arc` and copy on write (or just add `Mutex`).

There's a reason why Rust is most loved PL for 4 years in a row. Once you try it, and get past initial adjustments (mosty: what owns what relationship) everything clicks, and I guarantee that you won't miss GC at all.

Re:Four Years of Rust by pjmlp on Wednesday May 15, 2019 @04:24PM (#19923373)
Because having a GC doesn't mean throwing away deterministic destruction.

Many GC enabled system languages do offer both mechanisms.

It is a matter of enjoying productivity it offers, while having the tools to fine tune performance when it actually matters.

Re:Four Years of Rust by dpc_pw on Wednesday May 15, 2019 @05:47PM (#19924104)
> Many GC enabled system languages do offer both mechanisms.

?

Can you give me an example? Java's `finalize` is not deterministic destruction. D's scope guards (or Go's `defer`) are also not like destructors, because a calling code has to take care of them.

> It is a matter of enjoying productivity it offers,

There's hardly any productivity gain, and it is being offset by productivity gained by a reliable and hassle-free resource management.

Re:Four Years of Rust by manwe150 on Wednesday May 15, 2019 @11:00PM (#19925781)
Not exactly a systems language, but Python has deterministic destruction (due to the use of reference counting) of non-cyclic data structures.

Edit: Oh, and if you don’t think that’s enough, note that Rust doesn’t guarantee destruction to ever occur in that case (“considered safe”): https://doc.rust-lang.org/book/ch15-06-reference-cycles.html

Re:Four Years of Rust by kevinmgranger on Wednesday May 22, 2019 @11:57AM (#19982550)
> Python has deterministic destruction

Not quite.

https://docs.python.org/3/reference/datamodel.html#object.__...

> It is not guaranteed that __del__() methods are called for objects that still exist when the interpreter exits.

Re:Four Years of Rust by dpc_pw on Thursday May 16, 2019 @12:41AM (#19926175)
Oh, interesting. But from what I read it's only an implementation detail of CPython?

With `with`I can't eg. pass an open file to another function to eg. be closed there etc.

Example:

https://play.rust-lang.org/?version=stable&mode=debug&editio...

closing `File` will happen at the end of `foo` or `foo2`.

Re:Four Years of Rust by manwe150 on Thursday May 16, 2019 @12:21PM (#19930360)
That's probably a tricky question, since CPython is also essentially the spec. PyPy talks a bit about this: http://doc.pypy.org/en/latest/cpython_differences.html#diffe...

That's true, since Python has reflection it can't easily optimize that case, whereas that's a powerful benefit of having a linear type system for tracking ownership like Swift or Rust. But early freeing (which Rust has and Python does not) is slightly different from deterministic freeing (which both have) is slightly different from guaranteed freeing (which CPython has and Rust does not).

Re:Four Years of Rust by pjmlp on Thursday May 16, 2019 @12:31AM (#19926132)
D structs have destructors, for example.

Dealing with borrow checker on cases that are still being worked on (NLL 2, GUI callbacks), using unsafe for graphs or dealing with use-after-free array indexes for the alternative workaround, unsafe Drop implementations, doesn't look hassle free to me.

Re:Four Years of Rust by dpc_pw on Thursday May 16, 2019 @12:58AM (#19926255)
D's destructors are not deterministic, IIRC.

> using unsafe for graphs or dealing with use-after-free array indexes for the alternative workaround, unsafe Drop implementations, doesn't look hassle free to me.

Valid points, but these are rare problems in idiomatic Rust.

Specifically avoiding graphs by structuring code into a tree of ownership, has greatly improved architecture of my programs, to the point that I just do it like this in all programming languages I use.

Rust made me realize how many problems objects carelessly cross-referencing each other (especially in OOP) - "because there's a GC, so why not" create.

Similar with array of indexes - great improvement both in usability and reliability. At least all use after-free in that case is checked and fails deterministicly. It makes my data with graph-like, or relationship properties resemble relational database.

For problems with lifetimes in destruction all I needed so far is https://crates.io/crates/dangerous_option . I actually wish it was part of language (a nullable types, panicking at runtime).

Re:Four Years of Rust by pjmlp on Thursday May 16, 2019 @02:40AM (#19926710)
> D's destructors are not deterministic, IIRC.

Yes they are, they get called at the end of scope.

> Valid points, but these are rare problems in idiomatic Rust.

Being rare doesn't mean they aren't there, and anyone trying to write UI related code will deal with them on regular basis.

Re:Four Years of Rust by dpc_pw on Friday May 17, 2019 @05:47PM (#19943870)
https://forum.dlang.org/thread/[email protected]...

Can you clarify, what am I misunderstanding here? In couple of places online I've found that you can't depend on dtor being called.

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @05:03PM (#19923747)
As pjmlp said below, GC doesn't preclude deterministic destruction, so it isn't about resources in general; it is largely about memory. Also typical programs in any language have quite a bit of stack-allocatable data and C/C++/D/Go/Rust do support stack-allocatation, so the memory heap isn't involved everywhere.

Wherever the memory heap is involved, if the system isn't memory-starved, it can be argued that deterministic free-ing is a step too far; maybe you don't want time to be spent putting that long-ish list of heap-allocated values on the free list when exiting a function on the critical path. There is something to be said for lazy operations in such contexts, which the GC can provide (off the critical path - using GC.disable() in D) - a lot easier than a "region-based" memory management solution in C/C++/Rust. I don't know of a synthetic benchmark result to tilt the argument either way.

At a system level, it is slightly dismaying that the "back-pressure" required to trigger lazy operations is only present for memory, and only within a Unix process; when it comes to limits on open file handles or sockets or overall OS memory usage, there is no back-pressure to reclaim them - indeed no mechanism to lazily schedule files/sockets for closure.

Re:Four Years of Rust by dpc_pw on Wednesday May 15, 2019 @05:57PM (#19924192)
> indeed no mechanism to lazily schedule files/sockets for closure.

It's not only about file sockets. It's about your core abstractions. Thread-pools, channels, flushing streams, events and other stuff, unlocking Mutexes, auto-validating guards etc...

I have production or semi-production experience with code written in C, D, C++, Python, Go, Java, Node, Scala, Rust and others (please excuse argument from authority, but that's all I have right now) so I can tell the difference and I think ...

... people that haven't worked with Rust long enough greatly under-appreciate number of stuff that benefit from deterministic resource-like management - not only on system resource usage / performance side, but simply the day to day reliability and writing simple bug-free code with ease.

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @06:59PM (#19924621)
I wasn't talking about necessarily temporal operations like mutex ops; of course, they should be deterministically done - it is a beautiful implementation detail that it falls out of the principles of Rust, without explicit compiler support and/or "checked-delete" as is required in most other languages.

I meant lazy operations for avoiding unnecessarily making things like memory deallocation temporal. Unless you have a strict memory budget (and you might additionally need to have mitigation for memory fragmentation), freeing whenever GC deems it fit, or streams flushing whenever the OS/library deems it fit, can't be worse - but could potentially be better - for performance than being done only at points decided arbitrarily by the language and the program structure. It is simply easier to disable GC on critical paths.

But as you say, you are not (only) talking about performance. You are talking about determinism for predictability. I hope you are not implying predictability across various threads/processes that make up the system, only within 1 thread/process where that predictability leads to reliability.

Reliability across threads/processes needs strategy because failures are inevitable (yes, I have drunk the Erlang kool-aid too, among other ones). While I have no doubt that Rust's design principles would support developing such strategies, I do wonder as to what scale this would work up to ...

... as you say, I don't know the size of projects Rust has scaled to, I just know enough about Rust itself to balk at its complexity (and I am a C++ person!). Maybe we are just talking from different viewpoints. You, having done a variety of non-trivial production code in a plethora of languages, plump for Rust. But I honestly wonder about the size & longevity of your C/C++ semi-production code - semi, because it is C/C++ ;-) - I have worked on large C++ codebases for long-lived products, and I somehow can't see another complex language solving more problems net-net.

Re:Four Years of Rust by dpc_pw on Wednesday May 15, 2019 @08:25PM (#19925074)
> I meant lazy operations for avoiding unnecessarily making things like memory deallocation temporal.

Yes, I wasn't talking about real-time/performance consideration. The root post was along the lines of "Rust is nice, but I like productivity of a GC". I'm saying deterministic destruction is more productive for the developer and Rust makes a great high-level language.

Regarding stuff like non-blocking deallocation etc. You can still do it in Rust if so you desire. In the a destructor, enforced by the type, you can use nice abstractions, etc. and eg. defer deallocations, or draw memory from an arean. I think eventually Rust will just have more or less standardized type for GCs and graphs with explicit roots etc.

But sure, it is all still very new here, so if one is writing a real-time trading or OS, maybe they should stick to C/C++.

> But I honestly wonder about the size & longevity of your C/C++ semi-production code - semi, because it is C/C++

In C I worked on code powering embedded chips (mostly radio communication, kernel modeules) and eg. real-time hypervisor powering some high-end cars. In C++ eg. some high-perf data management stuff (data dedupilcation, encryption, etc.) in a SV unicorn. I actually would describe myself as C (as opposed to C++ person), but I know my around modern C++ quite well - i just really don't like working with it.

> I somehow can't see another complex language solving more problems net-net.

I don't think Rust is actually that complex. It is definitely bigger than C, but I think it's much smaller than C++. And it is sane. Thinks play well together in it, I think I could get a new dev productive with Rust in a week or up to a monthy, and as long as you avoid `unsafe` in Rust they will produce a decent code with ease. In C++ you're either an "expert" or you're debugging segfaults. ;)

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @08:53PM (#19925206)
I truly was curious about your C/C++ code - good for you that it was less C++ and more C! I don't know any masochists, so I don't know anybody who likes to work in C++ (even with just composition and generics), or even any reluctant "expert". I get away from segfaults because I am on server & can get away by more static copying of data (it pales in comparision to what alternatives offer).

I can see why you think Rust is tractable; you have worked on fairly complex stuff like automobile base software (AutoSAR, was it?). I am probably not as good at it as you are, so the cognitive load of designing at that scale with borrow-checking seems prohibitive. I hope there is a way to slice the problem which makes for less cognitive load.

Re:Four Years of Rust by dpc_pw on Wednesday May 15, 2019 @10:51PM (#19925746)
> AutoSAR, was it?

Just a real-time hypervisor for Tegra underlying Nvidia Automotive platform. MISRA C, ISO 26262. Bleh. :D

> so the cognitive load of designing at that scale with borrow-checking seems prohibitive

I have multiple 1k - 10k line Rust projects on github, and I hardly ever deal or think about lifetimes. I just randomly opened a project of mine on github, opening some major files and there's literally 0 explicit lifetime annotations anywhere.

People hang up on lifetimes because they are unfamiliar, but for someone that gets some understanding and accepts "ways of Rust" (mostly avoiding cyclical graphs, using IDs instead of pointers, etc.), there are not an issue. Only when designing some weird zero-cost abstractions in performance-critical APIs, trying to avoid any copying, one has to annotate some lifetimes in non-trivial ways. Usually you can just ask someone on IRC and they will give you an answer. :D

The mental overhead is actually way lower than in C (or most languages for that matter). After a while you get used to relying on compiler to check the mundane stuff and focus only on the higher level problems. It's quite relieving actually.

Re:Four Years of Rust by wyatwerp on Friday May 24, 2019 @03:10PM (#20004442)
MISRA C? Cool!

About the design model for programming in Rust, I guess only making the time to try writing something in Rust can answer the question. It is interesting how the steepness of the Rust learning curve could actually be a hook to get people to try it, which is all any well-designed language would need to gain adherents.

Back to critical systems programming, does MISRA C have a "certified" compiler like CompCert C or something? If so, Rust usage in such a niche must be a long way away - even if one could "certify" the Rust compiler code, how would one "certify" the million+ lines of C++ in LLVM!

Re:Four Years of Rust by njepa on Wednesday May 15, 2019 @04:17PM (#19923302)
I think mainly because mastering new concepts increases the barrier to entry, overhead and scope. Which in turn affects creativity. There are many brilliant programming languages, used by brilliant programmers, yet, most really useful software tends to be produced by whatever. It would be awesome if Rust could overcome that, but I don't really see how currently.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @04:34PM (#19923475)
In the no-GC no-runtime niche, you probably need brilliant programmers anyway. Most of them are banging their heads against the C++ wall right now; they would love to get back some of their lost creativity via mastering of new concepts (Rust borrow checker, or Pony's deny capabilities - https://pony-lang.io ).
Re:Four Years of Rust by njepa on Wednesday May 15, 2019 @05:45PM (#19924090)
In my experience C++ programmers aren't necessarily great programmers as such. Because low levels things usually requires domain knowledge and experience more so than programming brilliance.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @06:04PM (#19924245)
The topic was the no-GC no-runtime niche, which necessarily requires brilliant programmers, and they are stuck with C++. They would welcome tools to represent their resource control well, borrow checking or deny capabilities.

As a current C++ programmer who remembers what GCC 2.95's error messages looked like for even simple templates, I second you - it is less about the intellect, and more about experience and enough domain knowledge. But quite a few like me work on large C++ software that is not in the no-GC no-runtime niche; modules, good abstractions and native compilation would be enough to match or likely beat whatever we are putting together in C++, which doesn't even have modules yet - and the GC-based conveniences would be a big icing on the cake, so D, Nim, Pony all look interesting. (side note ... https://ponylang.io and not https://pony-lang.io as stated earlier)

Re:Four Years of Rust by njepa on Wednesday May 15, 2019 @08:11PM (#19925017)
I definitely think it is needed. I just don't think Rust has solved the paradox that the more you need something specialized the less you can afford the overhead.

Finding hundreds of web developers with some spare time who don't mind learning Rust, can port some of their tooling and use it in some part of their stack isn't going to be much of a problem. The same isn't true if you, say, need an embedded programmer who has worked with zigbee and needs to be in your lab for testing and verification.

Pretty much all major programming languages are where they are as a result of being some kind of "lowest common denominator" for their application. Something like Bash is pretty horrible as a programming language, but extremely accessible for sysadmins. Only now is it changing slightly were things like Python and Go is becoming more popular, but mostly because they are easier than the alternatives.

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @02:12PM (#19922128)
Taking nothing away from the Rust community that has managed such a complex language so well so long, I have to say that there never was anything viable in the no-GC no-runtime niche (that is why it is a niche - otherwise why would anybody be using GC'd languages). We were/are just gritting and bearing C++.

If it is a typical program, i.e. not a device driver or OS kernel running on low-memory hardware, having a GC + runtime doesn't preclude performance, for a long-running program. Of course, for short-running programs, just malloc, don't free, is the fastest.

Re:Four Years of Rust by jandrewrogers on Wednesday May 15, 2019 @04:12PM (#19923243)
The use case for non-GC languages go significantly beyond low-level OS kernel type code. Most of our backend infrastructure software and servers (e.g. database engines) are also poor fits for a GC languages, and this is what Rust is targeting. For this type of software, a GC has a large negative performance impact, so it isn't really an option. Operational cost efficiency is often a key factor in platform selection -- being able to reduce hardware requirements by an integer factor is compelling.

To me, Rust is a cleaner and stricter but also more narrow systems programming language than C++, and can be used as a sensible replacement for many C++ code bases, particularly as Rust adds features. Rust still has some challenges. For example, the DMA-driven, schedule-based memory safety models that have become fashionable in high-performance database kernels are not compatible with Rust's memory model. You'd have to make most of the code "unsafe" (in a Rust sense, it is actually an alternative memory safety model designed around a different set of assumptions).

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @05:48PM (#19924121)
Off-hand, Mirage OS comes to mind - it completely upends how you would "build" and "run" back-end services, and it is written solely in a GC'ed language - OCaml. And all GC'ed languages are not equal; see https://roscidus.com/blog about a Linux package manager ported from Python to OCaml for performance reasons (followed by an OCaml reimplementation of a component in a virtualized OS).

Some infrastructure, e.g. database engines, is ubiquitous, but all instances are of the same few software products written in C/C++/Java. Those ubiquitous instances have banged most bugs out of those codebases, so it is an uphill battle there to convince incumbents and upstarts alike, of the value of a new implementation. But Rust & Pony are marvelously positioned to march up that hill, especially if you throw in multi-threading.

My impression is that only a minority of widely-programmed back-end infrastructure that suits Rust is written in C/C++ (say, map-reduce kernels). The code-base size & the data flow complexity inside those components is pretty limited, and Rust should be tractable at that scale.

Most widely-programmed infrastructure software - in the back-end and on cell phone OS'es - have been merrily using Java/Python/Ruby/Erlang. OCaml is quoted as being used in the management component of VMware. These are much larger applications; is there any evidence or hint that Rust isn't onerous to develop larger systems in? Without that evidence, I feel (not think) that a disciplined GC'ed language (D? Pony?) has a better chance there.

Re:Four Years of Rust by pimeys on Wednesday May 15, 2019 @02:55PM (#19922544)
Having a GC also kind of makes it nasty to write libraries to other GC'd languages. In Rust all of this is very easy, and you can get the speed bump to your Ruby/Python/JavaScript libraries using a modern and safe language.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @03:31PM (#19922891)
Is the speed bump for other-language libraries or for other-language applications?

For speeding up other-language libraries, D has a -betterC mode, which prevents you from using the subset of the language and the libraries (standard & user-defined) that relies on GC. The remaining language is a very clean C that simply works on the other language's GC'd memory (using the other language's C interface), and can use stack allocation or any heap allocation strategy of your choice for its working set (reference counting ala C++ shared_ptr could be the obvious choice, but it is your party).

For other language applications, it is a valid option to speed up the entire application by writing it in D, as it has "all" the features of those other languages + all the convenience that is afforded by a GC + threads if you don't want a multi-process design. I quote "all" because I mean useful things like blocks/closures, generic data structures, etc. - of course, neither Rust nor D give you runtime devices like monkey-patching/meta-class hackery/prototype changes.

Re:Four Years of Rust by pimeys on Wednesday May 15, 2019 @04:09PM (#19923217)
We've been rewriting a big Scala code base to Rust now since January and the team is advancing in a nice pace.

Our plan was:

- Take one part of the system to rewrite over JNA

- Run a massive amount of Scala tests against the new code

- When green, take another part

- Meanwhile the other part of the team writes the user-facing code base, connecting it to the new Rust crates

- The test suit works also over an integration layer, so the other team can test their code and the backend with the same test suite

We're quite far already. Originally I was the only person with Rust experience. Now there's five of us.

Re:Four Years of Rust by hopscotch on Thursday May 16, 2019 @10:20AM (#19929285)
Why are you migrating from Scala?
Re:Four Years of Rust by pimeys on Thursday May 16, 2019 @05:03PM (#19933192)
The company wants much lower resource usage per node and easy integration with other languages.
Re:Four Years of Rust by buckminster on Wednesday May 15, 2019 @05:27PM (#19923944)
> Of course, for short-running programs, just malloc, don't free, is the fastest.

A custom malloc that knew free would never be called would be faster still. I wonder if any short-running utilities do this?

Re:Four Years of Rust by pornel on Wednesday May 15, 2019 @06:48PM (#19924550)
AFAIK the D compiler is basically this.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @07:05PM (#19924656)
And it is a short-running utility :-)
Re:Four Years of Rust by rudedogg on Wednesday May 15, 2019 @03:44PM (#19923003)
> It'd be another Go with generics, or Elixir-native, or Swift with uglier syntax.

I just want to point out that the Swift package management situation is currently bad. SPM (https://github.com/apple/swift-package-manager) can't be used within Xcode, and is basically not used for anything outside of server-side swift / Linux.

It also doesn't look like SPM will be integrated with Xcode this WWDC, so you're stuck with CocoaPods or Carthage.

I'm really jealous of cargo. And RLS (Swift LSP doesn't really work well because it doesn't know about your dependencies - back to the package manager issue).

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @11:37AM (#19920455)
Are you describing the D language? https://dlang.org C-like syntax and execution speed with high-level scripting-language-like conveniences, close to Lisp-level ability to generate code at compile time, an active user-base (https://forum.dlang.org) that continuously strives to get the language improved. Its (thread-local) memory heap is GC'd by default. They also have an LLVM back-end if that is pertinent. Recently, it even became another supported front-end in GCC, alongside Go, Ada, etc.
Re:Four Years of Rust by thrower123 on Wednesday May 15, 2019 @11:46AM (#19920547)
D is a weird one, because it has been lurking around for at least a decade and a half without really picking up the kind of steam and hype that later entrants have. I remember dabbling with D for game development way back in high school, as a friendlier alternative to C++.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @11:53AM (#19920625)
Well, Standard ML is a weird one too in that sense (lurking around for a couple of decades without picking up steam (outside academia?)). Languages having type inference and modules designed into them seems to have a good chance to live long.
Re:Four Years of Rust by pornel on Wednesday May 15, 2019 @01:54PM (#19921968)
D excluded itself from being C/C++ killer by having a GC. I know they've backtracked on that, and the -betterC subset of D looks interesting, but it's a bit late for that.
Re:Four Years of Rust by pjmlp on Wednesday May 15, 2019 @04:26PM (#19923390)
Only to the GC hating crowd.

Unreal and UWP/COM developers are perfectly fine with writing C++ code with a GC around.

Re:Four Years of Rust by pornel on Wednesday May 15, 2019 @05:31PM (#19923973)
If GC & runtime is on the table, then there are many nicer languages you can use (Go, D, Swift, Kotlin). I assume that the C and C++ users who haven't switched yet are largely the "GC-hating" crowd that can't.

COM and other refcounted ones get a pass. But I'm surprised that Unreal gets away with a mark-and-sweep GC. Perhaps because it's only required for UObjects, and the rest of the codebase can still easily avoid using the GC? You can even cause use-after-free bugs on UObjects, if you want to.

Re:Four Years of Rust by sanxiyn on Wednesday May 15, 2019 @11:56PM (#19926010)
Isn't Swift also refcounted?
Re:Four Years of Rust by pjmlp on Thursday May 16, 2019 @12:32AM (#19926137)
Reference counting is a GC algorithm, as per CS curriculum.
Re:Four Years of Rust by renox on Wednesday May 15, 2019 @06:11PM (#19924282)
Try to broaden your horizons.. I work in telecoms only one step away from a FPGA, a 1ms pause would be a critical bug report..
Re:Four Years of Rust by pjmlp on Thursday May 16, 2019 @12:25AM (#19926105)
My horizons are already broaden.

https://atlas.cern/discover/detector/trigger-daq

You can also try to broaden yours.

https://www.ptc.com/en/products/developer-tools/perc

Will this work for you? I guess most likely not, and you really cannot afford any kind of delay, where even a C++ virtual call would be considered a bug, given the 1ms delay.

The point being that only a very tiny population has such requirements, just like barely anyone writes applications 100% fully in Assembly.

Re:Four Years of Rust by renox on Sunday May 19, 2019 @01:19PM (#19954322)
I'll look at your links but to answer to your question: yes virtual functions are not accepted in the code.
Re:Four Years of Rust by adamnemecek on Wednesday May 15, 2019 @11:50AM (#19920602)
I think that part of the reason it didn't pick up is because it was made during an era when talking about the problems of C++ was brushed aside with "learn to program kiddo".
Re:Four Years of Rust by catach on Thursday May 16, 2019 @03:45AM (#19926969)
I suspect we are at least partially still in that era.
Re:Four Years of Rust by agumonkey on Wednesday May 15, 2019 @03:29PM (#19922868)
Success is often a matter of time. A good idea too early is the wrong idea kind of thinking.
Re:Four Years of Rust by amelius on Wednesday May 15, 2019 @12:15PM (#19920870)
What do you mean by:

> Its (thread-local) memory heap is GC'd by default.

What happens to objects that are allocated in one thread, and then have their reference passed to another thread?

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @01:43PM (#19921862)
Do you mean "thread local passed to another thread by mistake"? There is an option to make data global instead. Unless it is a Unix pipeline kind of design, independent threads can populate their working set (from file/socket/whatever) into thread-local memory.

It depends on whether shared-memory is a design requirement or an implementation artifact (Erlang does just fine with a largely shared-nothing model).

It also depends on whether a program runs for a short time, or for a long time. If you are running for a short time, why not just avoid the GC entirely; "manage" memory manually by malloc-ing and never free-ing (free-ing too takes time, and doesn't make memory available to other processes anyway).

Re:Four Years of Rust by bitwalker on Wednesday May 15, 2019 @01:03PM (#19921448)
The typical approach here as far as I'm aware is to use a deallocation queue - frees of an object that was allocated on another thread are freed by putting that object in the original thread's deallocation queue. When that thread gets an opportunity, it frees everything in its deallocation queue to reclaim that memory.
Re:Four Years of Rust by pcwalton on Wednesday May 15, 2019 @01:16PM (#19921597)
Manually, or automatically?
Re:Four Years of Rust by p0nce on Wednesday May 15, 2019 @05:16PM (#19923852)
In D the GC heap is shared across registered threads, so it supports values allocated in one thread and passed to another. This particular passage from one thread to the other is guarded by a "shared" type constructor, so as to have a type system guarantee.
Re:Four Years of Rust by weberc2 on Wednesday May 15, 2019 @11:19AM (#19920259)
I'm definitely in this category. I think I want "Go with generics and enums and Cargo" (and no, OCaml folks, I am not describing OCaml). I want to write more Rust, but I rarely can afford to trade off on Go's productivity for Rust's performance and safety.
Re:Four Years of Rust by lmm on Wednesday May 15, 2019 @11:23AM (#19920319)
What is it you don't like about OCaml, or similar ML-family languages (e.g. F#)? Most of "modern language design" seems to amount to the ML featureset.
Re:Four Years of Rust by Hermitian909 on Wednesday May 15, 2019 @11:48AM (#19920568)
As someone who really enjoys OCAML, it has a variety of issues that prevent it from becoming popular (though I'm hopeful for reasonML).

No multicore

Standard library has... issues

No community consensus on a common base setup, questions about which library to use for a task often get answers like "well, do you want to use functors or monads? because that will change the library we recommend" which is really not what you want to hear when you're just trying to set up your first server.

Documentation is, in general, bad. Most packages just give a list of function signatures.

The community is small, academic, and often French.

Re:Four Years of Rust by xvilka on Wednesday May 15, 2019 @01:00PM (#19921409)
Modern OCaml (4.06+) is not that bad, but yeah, lack of proper parallelism and bad Windows support (without hacks like MinGW or Cygwin) is what still hurts. Standard library these days is only one - Base, one buildsystem - Dune, Camlp4 is dead, and compiler improved a lot recently (including speed if you enable flambda).
Re:Four Years of Rust by p0nce on Wednesday May 15, 2019 @04:54PM (#19923675)
You guys are welcome to D, you may enjoy unboxed floats, guaranteed monomorphization and native threads. Also, 3 backends.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @08:24PM (#19925072)
The reference compiler is as free-standing as OCaml's because it too has its own back-end. Its front-end is shared with the other 2 back-ends: feeds the ubiquitous LLVM in LDC, and is included as a supported front-end in GCC since version 9.1.

Anyway, there is no way you'd give up ML-tradition pattern-matching; D doesn't have it.

Re:Four Years of Rust by p0nce on Thursday May 16, 2019 @06:08AM (#19927615)
Well engineering decision are tradeoffs, using D i've never missed pattern-matching and I have used ocaml before.
Re:Four Years of Rust by renox on Wednesday May 15, 2019 @06:18PM (#19924331)
Honest question: what is so bad about having to create one process per core? If you have lots of data you can use shared memory, so the performance should be similar no?
Re:Four Years of Rust by Hermitian909 on Thursday May 16, 2019 @12:21PM (#19930363)
For shops that really care about highly performant parallel tasks, the difference matters. For people who just want more performance for free it's too much work versus what other languages provide.

If OCAML were already popular I don't think the lack of parallelism would be huge issue, but it's niche, which is a huge downside to any language in a business context. The upsides the language provides in terms of performance, ergonomics, and maintainability need to overcome that downside. All the issues I listed mean that OCAML can't generally pass that bar.

Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @08:16PM (#19925033)
I don't know. Maybe because it is GC-only? It doesn't have custom allocators, so there may be no easy way to map an object to some location in shared memory.
Re:Four Years of Rust by yawn on Wednesday May 15, 2019 @11:40AM (#19920488)
Not the grandparent, but...

OCaml: multicore, standard library situation (which one?) is a mess, adoption. F#: Have to deal with null and lack of ADTs when you interact with .NET (or JS for Fable) standard lib. The tooling situation in F# has been a mess since .NET Core, especially in Linux. Treated as a 2nd class citizen by MS.

Re:Four Years of Rust by msvan on Wednesday May 15, 2019 @11:45AM (#19920535)
Multicore OCaml is actually making promising progress, but I agree that the standard library situation is a little bit unfortunate.
Re:Four Years of Rust by ynnn on Wednesday May 15, 2019 @02:10PM (#19922120)
Sadly, that's what I've been hearing for at least 5 years.
Re:Four Years of Rust by akra on Wednesday May 15, 2019 @10:18PM (#19925605)
I'm using F# tooling in Linux and both VS Code and Jetbrains Rider's IDE's outclass most functional language IDE's at present IMO. It's greatly improved within the last year or so. If you use code most of your app in F# the null factor doesn't really bite you all too often and its not too hard to handle when it does.
Re:Four Years of Rust by wtetzner on Wednesday May 15, 2019 @01:55PM (#19921977)
I love OCaml, but my biggest pain point is not having something like Cargo. I haven't spent a lot of time with opam since 2.0 came out, so maybe it's better now, but when I used it it felt very much designed around installing packages globally, instead of defining dependencies per-project.

The other issue with the package ecosystem is cross-platform support. While OCaml itself works on windows, opam doesn't (or at least didn't) without a lot of extra work, and it seemed like most packages were designed only for unixish OS's.

There are projects where I've used Rust instead of OCaml, even though I'd have preferred to use OCaml, simply because the infrastructure is so much better and easier to use for Rust.

Re:Four Years of Rust by msvan on Wednesday May 15, 2019 @02:31PM (#19922323)
Esy (https://esy.sh/) has completely solved the first problem, fwiw.
Re:Four Years of Rust by weberc2 on Wednesday May 15, 2019 @04:48PM (#19923616)
This is a huge step in making OCaml more approachable. I get the feeling that there are quite a few of these modernizations around, but you have to know about them up front in order to hit the happy path. Would be great if there was some sort of "OCaml Happy Path" repo that laid out all of the right tools to use to be successful right off the bat. Sort of on the subject, Reason would be great but last I checked it utterly neglected its native compilation story--it advertised native compilation but every time I ran into an issue the Reason community would tell me that OCaml support was broken and I should use Node. Excited for the improvements to be sure!
Re:Four Years of Rust by wtetzner on Wednesday May 15, 2019 @03:39PM (#19922967)
Thank you! I'll try it out.
Re:Four Years of Rust by wyatwerp on Wednesday May 15, 2019 @11:39AM (#19920470)
Indeed! For example, it is amazing how small Poly/ML is for a type-inferred multi-threaded language.
Re:Four Years of Rust by e12e on Wednesday May 15, 2019 @12:15PM (#19920872)
> "Go with generics and enums and Cargo"

Isn't that d-lang?

Re:Four Years of Rust by eikenberry on Wednesday May 15, 2019 @02:02PM (#19922045)
From the looks of things you'll probably get the Go you want first. The only thing missing from the roadmap are enums and there are a few Go2 proposals for them.
Re:Four Years of Rust by weberc2 on Wednesday May 15, 2019 @04:52PM (#19923659)
Maybe, albeit I'm concerned that the Go team might ship some broken version of generics or enums that we'll be stuck with for years and years. I think that would be strictly worse than no generics or enums. I hope they think holistically about the problem.
Re:Four Years of Rust by the_mitsuhiko on Wednesday May 15, 2019 @12:28PM (#19921029)
> I wonder how many Rust users really want linear types and borrow checking, instead of the other stuff Rust brings to the table: modern language design, large and friendly community, nice type system, native compilation, good package ecosystem.

I think there are probably more users that would love this but they are not users of the language to begin with. The community that actually forms around Rust is the type of community that does not want GCs, wants the borrow checker and the constraints that form the language.

Re:Four Years of Rust by logicprog on Wednesday May 15, 2019 @12:13PM (#19920853)
In that case, would ReasonML[1] suit you? ReasonML is based on OCaml, just with a more C-like syntax and nicer tooling, etc. OCaml's semantics are very similar in a lot of ways to Rust, perhaps even better in certain ways. Although it's pitched as a compile-to-JS solution for web development, it's perfectly usable as a natively compiled PL too, using `jbuilder` (dune).

[1]: https://reasonml.github.io/

Re:Four Years of Rust by leshow on Wednesday May 15, 2019 @12:27PM (#19921017)
That's what I love about Rust, you get all of those things without having to sacrifice performance. i.e. I get a modern language, get to write code at a relatively high level, and still don't even have to use a GC. You learn to love the borrow checker, it's an amazing tool to work with.
Re:Four Years of Rust by p0nce on Wednesday May 15, 2019 @04:56PM (#19923685)
Having a GC doesn't "sacrifice performance" in itself
Re:Four Years of Rust by lhorie on Wednesday May 15, 2019 @12:27PM (#19921015)
Personally I started looking at Rust precisely because borrow checking is a massive improvement over the C/ASM wild west.

If you like GC, I feel like there are plenty of other good options, like D, Ocaml, CLR languages (C#/F#).

Re:Four Years of Rust by yawn on Wednesday May 15, 2019 @11:33AM (#19920419)
This is exactly how I feel. I'd be all about Rust if it was GC'd. Go is close enough that it's what I reach for for personal projects, but not having ADTs and pattern matching is super frustrating for modeling data.
Re:Four Years of Rust by UnpossibleJim on Wednesday May 15, 2019 @12:16PM (#19920889)
Not to be the nay sayer here, but garbage collection kind of goes against the premise of Rust, as stated by the mission statement. I'm a fan of Rust, but I also like Python, but they are different tools for different problems. Go seems like the tool for your specific problems. I'm not trying to be offensive towards you, or anything, but Rusts mission statement was written pretty clearly and the reasons against a garbage collection were laid out reasonably. It's a systems language, meant to be along the lines of C or C++. Used for close to the metal projects, like operating systems, or drivers (ostensibly), where a garbage collector is going to have a debilitating effect as cycles and efficiency are very necessary. The compiler is the checker, taking the place of the garbage collector (sort of).
Re:Four Years of Rust by ummonk on Wednesday May 15, 2019 @01:06PM (#19921482)
You're missing the point. Go is not the tool for their specific problems because it's a crappy language that lacks generics, algebraic data types, etc.

In contrast, a language very much like Rust, but with GC, would be the right tool for their problems.

Re:Four Years of Rust by lostmsu on Wednesday May 15, 2019 @01:49PM (#19921923)
How about Scala?
Re:Four Years of Rust by amelius on Wednesday May 15, 2019 @01:27PM (#19921711)
If this is true then Rust is the wrong tool for many projects in which it is currently used. Most of those projects are not an OS or driver and are far from the metal.

Even the compiler itself would not fit your description.

Re:Four Years of Rust by UnpossibleJim on Wednesday May 15, 2019 @02:34PM (#19922351)
It doesn't HAVE to be used for bare metal, but that's what it's best at, but it is bad for quick prototyping, that's for sure. So if you had a project that needed a project that needed quick turn around and rapid prototyping and someone wanted to use Rust because it's the "new hotness" or whatever, then absolutely not. It's the wrong tool for the job. The same as C, or C++ would be the wrong tool. Python is great for something like that.

Just like if you wanted heavy number crunching and data manipulation, I'd push someone towards R and Scala as they have the libraries to handle it (and, I'd also say Python, but I'm starting to show my biases here). Go is great for back end systems, as that's what it was designed for, and it's now getting libraries built out for it for other things to fill in gaps for other things, just as Rust is filling in other spaces, but there's only so far it can go from its original design doc. The GC makes it, inherently, not a systems language. That doesn't mean it isn't great at other things. Rust is great as a systems language, that doesn't mean it isn't great at other things, but it's terrible as a rapid prototyping language. It lacks that capability. It wasn't designed for that =/

Re:Four Years of Rust by estebank on Wednesday May 15, 2019 @11:38AM (#19920465)
What would stop you from using Rc/Arc/RefCell to have reference counting and internal mutability where you need it?
Re:Four Years of Rust by steveklabnik on Wednesday May 15, 2019 @11:39AM (#19920472)
It's really, really awkward to use them everywhere.
Re:Four Years of Rust by estebank on Wednesday May 15, 2019 @11:56AM (#19920664)
They are, and it is one of the places where I'd see us working towards improving their ergonomics in the next couple of years. In the meantime I'm convinced that most code falls either on "small enough that they can be Copy" or big balls of state that also need internal mutability. For people just arriving to the language I always recommend "don't be afraid of .clone(), .clone() until you understand the rest of the language, then jump deeper into borrowing/lifetimes". I would love to have some affordances to avoid having to give that advice.
Re:Four Years of Rust by thenewwazoo on Wednesday May 15, 2019 @12:05PM (#19920747)
It's funny, I give almost the exact opposite advice when I'm helping Rust newbies. My diktat is "clone is banned unless you can explain why you must have it", and then I teach people about what a move is and how to think about lifetimes.

w.r.t. Arc/Rc, I'd say that it might feel verbose at first, but it makes explicit what a GC does implicitly, and you can get all the benefits of Rust's ownership model at the same time. I can pick and choose when to rely on the GC and when to explicitly manage lifetimes myself. That's really cool! I maybe a bit weird in this, but I like complexity to get surfaced so I can't pretend it's not there.

Re:Four Years of Rust by estebank on Wednesday May 15, 2019 @12:21PM (#19920945)
> My diktat is "clone is banned unless you can explain why you must have it", and then I teach people about what a move is and how to think about lifetimes.

That is good advice for people that are getting familiar with the borrow checker, making them think about allocations and ownership, but making newcomers that are getting familiar with the entire language, in some cases coming from very different paradigms, can be very demoralizing and the reason they stop or become convinced that "Rust is too hard for them" when what is happening is that they are trying to learn too many concepts at the same time.

The way I see it, the learning curve for most of Rust is a fairly mild slope, with a climbing wall around lifetimes. The further you progress learning the rest of the language, the shorter the wall will feel.

That being said this is born of my experience helping a few people learning Rust, but I could be completely off-base for the general case.

> w.r.t. Arc/Rc, I'd say that it might feel verbose at first, but it makes explicit what a GC does implicitly, and you can get all the benefits of Rust's ownership model at the same time.

But it is verbose. I think this is part of the problem with Rust learnability, because Rust makes inefficient code evident (think unsafe, clone and Rc), and that makes experienced programmers want to remove the inefficiency before they are proficient with the language enough to do so, so they encounter the hardest edges of the language early.

I appreciate that these markers make it better for me when reading the code and I wouldn't want them to disappear, but it does make it for a more verbose experience where the compiler sometimes feels pedantic. I think that better refactoring tools could make these kind of pains (and related ones, like adding lifetimes to a struct) go away almost entirely.

> I can pick and choose when to rely on the GC and when to explicitly manage lifetimes myself. That's really cool! I maybe a bit weird in this, but I like complexity to get surfaced so I can't pretend it's not there.

I'm in the same boat. I just wish it was easier for rustc to detect early when you're trying to apply a pattern from a language that doesn't have memory ownership or thread safety or relies on internal mutability and provide appropriate advice beyond "you can't do that".

Re:Four Years of Rust by thenewwazoo on Wednesday May 15, 2019 @01:01PM (#19921417)
> But it is verbose. I think this is part of the problem with Rust learnability, because Rust makes inefficient code evident (think unsafe, clone and Rc), and that makes experienced programmers want to remove the inefficiency before they are proficient with the language enough to do so, so they encounter the hardest edges of the language early.

That's a really, really insightful way to frame it. I don't think I agree that it's a problem, though. Indeed, it's probably the very thing I like most. There's a fine line between syntactic sugar and obfuscating the underlying principles (e.g., I think async syntax is toeing that line). I feel (and I've read others saying the same) that one of the reasons Rust has made me a better programmer is because it makes thinking about this complexity second-nature, and now I do it even when other languages permit (or encourage!) me to forget it.

I'm big on pedagogical rigor and I think there's a particular way to come at learning Rust that results in things like Arc/Rc/RefCell et al feeling good and natural (also, dealing with Result::Err, for similar reasons). I think both of our experiences are equally valid and probably entirely situational. I'll have to think a bit more about it. I have an opportunity to teach Rust to a large-ish group within my company, so it's top of mind for me right now.

Re:Four Years of Rust by burntsushi on Wednesday May 15, 2019 @01:08PM (#19921516)
> I have an opportunity to teach Rust to a large-ish group within my company, so it's top of mind for me right now.

If you could share an experience report when you're done, that would be most helpful. :-)

Re:Four Years of Rust by Outpox on Wednesday May 15, 2019 @12:59PM (#19921397)
Have you written about this (your diktat about clone()) somewhere? I'd be interested to read more.
Re:Four Years of Rust by thenewwazoo on Thursday May 23, 2019 @10:28PM (#19997967)
Re:Four Years of Rust by thenewwazoo on Wednesday May 15, 2019 @01:02PM (#19921428)
I haven't, but maybe I will today.
Re:Four Years of Rust by thelastbender12 on Wednesday May 15, 2019 @11:55AM (#19920656)
curious, does Swift potentially fill this gap for you?
Re:Four Years of Rust by yawn on Wednesday May 15, 2019 @12:02PM (#19920716)
Yes, Swift is very close. I know I'm moving the goal posts here, but...

My personal itches are usually web projects. Once Swift gets async/await and Vapor|Kitura switch to it, I'll probably jump to Swift. I really dislike dealing with futures/promises. The Swift web frameworks also don't generate standalone binaries like Go/Rust do...the tend to push you to cloud/docker solutions. Swift is still pretty Apple platform centric, but that feels like it's changing even now.

Re:Four Years of Rust by rubber_duck on Wednesday May 15, 2019 @08:37PM (#19925136)
You can AOT C#/F#/.NET

It has value types, Span, PInvoke etc. that make low level interop simple, GC and higher level semantics and better ecosystem/tooling than most alternatives.

Runtime size and GC limit some use cases

Re:Four Years of Rust by lenkite on Thursday May 16, 2019 @06:47AM (#19927762)
AFAIK, F# has still got some wrinkles for AOT support. https://github.com/dotnet/corert/issues/6055
Re:Four Years of Rust by eridius on Wednesday May 15, 2019 @05:21PM (#19923886)
If you don't want the borrow checker, why are you even using Rust? The borrow checker is the foundation of the zero-cost safety guarantees that make Rust such an incredible language to work with.
Re:Four Years of Rust by mlevental on Wednesday May 15, 2019 @12:20PM (#19920929)
swift is the language you're looking for. unfortunately it's pretty much only useful for ios dev.