276 points · by tosh · 7y ago · 222 comments
Shameless plug - I made a proposal[2] to create Business Applications Working Group to help promote Rust in enterprise software, quant and "normal" finances, taxes, and governance, the areas now completely dominated by COBOL and Java. Rust is a perfect fit for such applications, offering more safety and security, speed and higher levels of abstraction. Hopefully, formal verification will arrive soon as well.
[1] https://github.com/rust-lang/rust/pull/61946
[2] https://internals.rust-lang.org/t/proposal-business-applicat...
I think it's great that you wanted to push Rust to the area where Java flourished (by Java I'm guessing Enterprise?). I respect your passion.
Personally, I never like a language that has esoteric syntax utilizing various non-alphabetical characters. Perhaps this particular aspect is what drew me to languages like Java/JavaScript. I don't mind writing "public static void" because writing code is like 10-20% (the rest is code-review, meeting stakeholders/Product Owner/PM, come up with plans, write documentations, etc) of my activity throughout a decade of my career as a Dev.
There are some caveats (or rather ... personal dislike) with Java and JavaScript for example: I don't like the Closure syntax in Java and I don't like the fact that JavaScript lacks cohesiveness => People who write ES5 code do have to implement patterns specific to JS in order to re-create some of the OOP constructs. ES6 with Class/constructor/static syntax help but then they added generator via '*' (asterisk, but why? why don't use the keyword 'gen' or 'generator' just like async/await keywords?).
The other thing I realized lately is that I prefer GC platform/ecosystem so that I can focus less on the platform itself.
1. Long ago, Rust had some interesting built in syntax for different kinds of pointers, and so people checked out Rust then, and didn't realize we got rid of it. This objection has happened less and less since that was ~5 years ago (wow time flies), but sometimes it still comes up.
2. The lifetime syntax uses a single apostrophe, like 'a. We took this syntax from OCaml (though slightly re-purposed), but if you haven't used OCaml, and many have not, it can feel very weird.
3. Not everyone prefers the "curly braces and semicolons" style of systems languages, and so they feel the <>s and ::s and {}s and ;s are noisy. We kept this style to be familiar to systems programmers.
In general, Rust doesn't have a lot of unique syntax, but it does draw from two generally disparate areas: functional languages and systems languages. If you haven't used both before, some of it can feel strange. It happens.
pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
vec![]
}Check out COBOL. You'll love it. :-)
You are not going to find people that knows about avx or red-black trees in a Javashop in my experience.
That said, I’d hire them just don’t want to be them.
> avx or red-black trees in a Javashop in my experience.
You meant AVL right?
As much as I dislike Leetcode and whiteboarding interview culture, there's an army of people who know these stuff (data structure) working for
Google (largely Java shop), Amazon (boy, this one is a HUGE Java shop) LinkedIN (o yea, o yeaa...) Square, Twitter, etc.
I can go on but let's just stop there.
Try LeetCode and see how many submissions are in Java :). I'd say it's probably the most-used programming languages doing whiteboard data-structure styled interview.
Save money over what? It's usually a lot easier to optimize memory use than to rewrite code. Going by the 80/20 rule, 80% of the memory pressure on the GC will be created by 20% of the code. So amortize the price of the rewrite over the expected lifespan of the app. Then compare this to, let's say, the cost of optimizing 10% of the app to eliminate 40% of the memory pressure. Then, also factor in the likely rate of bugs introduced in a rewrite compared to the optimizing GC and the cost of incurring, finding, and fixing those bugs.
Going by this analysis, I would suspect that in some environments where rapid iteration is key, progress is fast, and apps have short lifespans, it might be better to optimize GC instead of rewrite to eliminate it. I'd also expect that in other cases, it is better to rewrite to eliminate GC.
Because you want better battery life? Reduce power and cooling costs? Reduce cloud service bill?
1 - https://nim-lang.org/docs/manual_experimental.html#guards-an...
The type system knowing about ownership and borrowing also allows the elimination of race conditions (outside of `unsafe`, of course...). I don't know of a GC language that also does that, though obviously that doesn't mean there isn't one... ;)
Rust doesn't get rid of race conditions. It lets you write memory safe concurrent code. These are two separate things. You still have to be cognizant that code may not run in the order you expect.
This is still a great language feature.
An example in the standard library is MutexGuard - you get one when you lock a mutex, and when you drop it, that releases the mutex. You can't forget to release the mutex, and you also can't release it too early, because then you lose access to the data protected by the mutex. There are ways to defeat this, of course, but you have to go out of your way to do it.
I've used a library which uses a similar pattern for writing to a ring-buffered message queue: when you grab a slot in the queue to write to, you get a SlotGuard, and when you drop it, you lose access to the slot, but that commits the slot and lets other threads read it.
NOTE: maybe the parent edited his comment between my reply and yours?
Rust can guarantee the elimination of race conditions in low-level multi-threaded code, but aside from that there's nothing really safer about its type system compared to say Java. And one would anyways use a higher-level concurrency library in Java, or perhaps the concurrency annotations, making the formerly mentioned advantage barely relevant.
Memory safety is certainly not the only kind of safety, but it is alas the only kind of safety supported by Rust (and every other language except C and C++).
So Java really is the new COBOL?
Android will keep Java relevant for a long time, even after the introduction of Kotlin.
But being realistic, i dont think any non-GC´ed language has a chance to become the next corporate darling as Java is now.
In that sense, Go, Swift, C#, etc are much more fit to become the next kings in this area, and even them will do it very, very slowly.
The script family of languages also dont make a good fit, giving they tend to be bad at creating big, performant and constantly evolving kind of programs (Javascript, Python, etc).
I guess the languages which are AOT compiled, GC´ed and mostly objected oriented with some mix of FP will probably be more of a fit the take the crown jewels of the king Java.
The problem Rust will face in this scenario, is that it requires people with a level of brain power that contrary to 'high tech' is not that much available in the corporate level, (and the ones that have dont want to spend all of their lives behind a computer screen).
And also is a "productivity hog", when we compare to sophisticated languages like C# or Swift, as productivity in Rust is on par with C++, which is not good enough when compared even with the verbose and over-enginered Java codebase.
It´s basically the same reasons why, C++ is not the prefered language there. And i dont think just using the magic word 'safe' will have any charm for this kind of crowd. Giving while Rust can use this trick against C and C++, it doesnt work for productivity minded languages like Go, Kotlin, Swift and C#.
Mind you that modern GC´ed languages are pretty safe, and also pretty fast. So it will be very hard to convince the corporate layer to use a language where there will be scarcity of labor, and that means they will have to pay more and be able to have less employees.
The smartphone revolution gave performant and resource aware languages a renaissance and Rust is surfing in this wave. Rust has a lot of chance in smartphone, embedded, libraries and utilities and even in specific scenarios on the server.
But even for the "rewrite all in Rust" mantra for C++ (a language Rust is competitive with) it will stop going forward, giving the Unix, C and C++ codebases are pretty much very influential and with a lot of sophisticated and complex stuff already out there.
Anyway, i dont understand this urge to use just one language for everything. I think this is unrealistic and illusory, and i think its a better approach to elect two or three languages with fitness in some fields and just use them.
The "one language to rule them all" was already the Java approach since the nineties, and while it make it a very popular language, it was in a time where the competition were not that great and even then, it proved to not work really well in all scenarios (and i think thats a good thing because it means we are free from a computer language monopoly, which would slow down the evolution in the field).
Today we are using static or dynamic code checker (which are not cheap) but it would be so much better if we could simply not create some kind of issues in the first place.
I know that Rust is not a silver bullet either but having some Rust support in Vxworks makes so much sense. This is basically my secret wish of the last few years coming true. If anyone at Windriver is reading this, thank you!
It does not mean we are going to rewrite everything tomorrow, but at least we can seriously consider that for new features we could introduce some Rust services in a few years likely.
C++ makes things look simpler than they are and eventually you end up in one nightmare scenario after another, because of all the hidden complexity.
Rust just shoves all that complexity to the forefront, right in your face, so that you are forced to deal with it and don't end up in nightmare land later.
Java is a great glue language. But if the problem you are solving can't be fixed by glue, say performance, computationally heavy algorithms or something of that kind, then look elsewhere.
What are the chances it's a placeholder for malicious/trojan code intended to steal Libra coins? (c.f. the event-stream backdoor[2])
Should really be:
https://crates.io/crates/someorg/libra
https://crates.io/crates/facebook/libra
People like unqualified names because it's slightly cute, though.A) Packages can change owners without changing names (and breaking downstreamers)
B) It encourages creative names, rather can calling something myusername/http, you have to give the package a real name like hyper, express, curl, etc.
Who wants this?
Crates.io has all sorts of other problems where it assumes good faith.
I am not personally interested in cryptocurrency, but it's always great to see more big companies using Rust!
This is the second time this has happened to me today, you'd think I would have learned. Sigh.
If you wonder what is meant by that, I think I know of an example. They have done this (quite unusual) choice to not include a Cargo.lock into their project because it gives a bad developer experience on merge conflicts [1]. They'd love to have a merge tool for the purpose, see more in [2].
My ideal would be "cargo test --coverage=report/".
The most popular Ethereum implementation (Geth) is written in Go. The second most popular Ethereum implementation (Parity) is written in Rust.
Now, Libra is written in Rust.
So I guess the moral of the story is, if you want to write a greenfield high performance application, Go or Rust should be your choice compared to C++.
Some types of software require memory safety models that Rust was not designed to express e.g. safety models when mutability of references and ownership of objects are not observable at compile-time. High-performance database engines tend to have this challenge due to pervasive DMA-ed I/O and opaque page-structured memory. The OS hides this from most applications that aren't high-performance systems code. In C++ (which also looks askance at these memory models) this is addressed by designing an execution scheduler to dynamically guarantee safety; the scheduler understands the memory model and never schedules or executes a sequence of concurrent operations across a set of mutable references that would violate the safety model -- the operations are oblivious. In modern designs this requires no locks and negligible state.
Rust can deal with these types of memory models too while minimizing the amount of unsafe code with enough layers of indirection, it just has a high performance cost.
I don't see how this generalization follows from the three examples you've cited?
Rust in production use tends to be found in circumstances where there is no need for mature tooling, and no expectation of a need to hire experienced coders. Of course there are exceptions.
The tooling does need to be more mature but for many projects the pioneer tax paid to improve the tooling may be worth it. Besides, it's not as if C++ dependency management is very mature either — most people build custom tooling for that anyway.
Go is not in the same performance category as Rust and C++. It has more limited use cases where it works well, due to mandatory runtime. Rust and C++ are more general purpose.
Backend and infrastructure sees more Rust though. Eg the Mercurial server implementation.
There will of course be explanations why the holes are really not Rust's fault, and that bugs and security failings are possible in any language, but it will force a more realistic assessment of Rust's strengths.
For example, the real fix for their vulnerable code example is using automatic bounds checking, just as Rust does. Replacing [] with at, eliminates the vulnerability. Most C++ programmers are allergic to at, so Mozilla could have created some container wrappers that do this by default. GCC and I think also clang have a macro which adds automatic bounds-checking to the STL containers.
C++ is coded quite differently today than when Gecko was written -- at least, in places where the official Coding Standard does not forbid it. Mozilla and Google's do.
After the more-realistic assessment, claims about Rust's inherent safety will need to be walked back some. It will still be an enormous improvement on C.
Is there an easy way to map all links of form www.reddit.com/* to old.reddit.com/* on all my devices? (I assume /etc/hosts would work for linux?)
https://chrome.google.com/webstore/detail/old-reddit-redirec...
In order to redirect it on all your devices, install Firefox. It can install extensions on Android, too. Should solve it for everything except smart TVs (Firefox for Amazon TV can't install extensions) and iOS.
No, because both www.reddit.com and old.reddit.com (in fact, *.reddit.com) already map to the same IP address. They are distinguished through the Host HTTP header. The only way to do that mapping would be within the browser (or with a MITM proxy, which I wouldn't recommend).
I think that's how an ad-blocker worked on iOS before they enabled the functionality.