25 ms·
Was Rust Worth It?
- anotherevan 3y agoI thought the likening of the strictness of the language and compiler errors and warnings to an emotionally abusive relationship was quite offensive. I programmed in C and C++ for years, to compiler messages don't make me feel like I should be taking them personally. Sure beats having a runtime error any day. I wonder if those with that attitude have come from a background where they used dynamically typed languages or non-compiled languages more, or it is something even people with a wider experience find particularly onerous with Rust?
- chungy 3y agoPerhaps my biggest critique is that crates.io has no namespacing. Anyone can just claim a global and generic package name and we mostly have to deal with it (unless you avoid using the crates.io repository, but then you'll probably have more problems...). Some of these globally-claimed generic packages are not really the best package to use. Maybe it was a reaction against the Java-style reverse DNS notation, which is verbose and annoying, but a more GitHub-style user/group namespace prefixing package names would have been the nice middle ground.
- rochak 3y agoGo made a great decision to namespace packages via this Github style.
- treyd 3y agoAnd the horrible decision to not make library-level ("module") and code-unit-level ("package") namespacing orthogonal. The former was an afterthought tacked on since the package system was designed to be used only within Google's monorepo and little care was paid to how it would work when it was released to the public and used more generally.
- starttoaster 3y agoI want to understand what you just said, but I fear watering your language down a bit might be a tall ask with some people. Would you be willing to eli5 what you believe Go did that was a horrible decision with regards to module/package namespacing?
- cdelsolar 3y agoI think he wants them to be treated differently for some reason.
- ezrast 3y agoI think what they mean is: if you see a line like `import git.example.com/foo/bar/baz`, that could be package `baz` inside module `git.example.com/foo/bar`, or it could be package `bar/baz` inside module `git.example.com/foo`. Also, even if you know it's the latter, package namespacing isn't strictly related to directory structure, so `bar/baz` has no specific meaning outside of the context of a go import. They could have used any other separator for package components - `git.example.com/foo:bar:baz` - but instead they chose the slash, making the scheme both technically ambiguous and easy to confuse for an HTTP URL.
- starttoaster 3y agoAh that makes sense. I think Go did somewhat stumble a bit in the early days due to this, especially with repositories in GitLab, where GitLab allows essentially a directory tree where your repository can be nested indefinitely in directories like `https://gitlab.com/mygroup/subgroup1/subgroup2/repository https://gitlab.com/mygroup/subgroup1/subgroup2/repository`. I still don't think this is a huge issue, to be honest. Not one big enough for me to complain about, for sure. But it's definitely not ideal.
- baby 3y agoHow is this a good decision? You have to alias packages when names collide
- tapirl 3y agoWhat is the better decision to avoid name colliding?
- pjmlp 3y agoGo packages is yet another design item that I dislike on the language, exposing SCM URLs directly on the source code, and no story for binary caching.
- yencabulator 3y ago> exposing SCM URLs directly on the source code Incorrect. You're able to use any URL you control, regardless of where your SCM is located.
- pjmlp 3y agoThanks for pointing out you didn't got what the whole point of the wrong design is about.
- yencabulator 3y agoThanks for confirming you'd rather be a hater than someone with justified opinions.
- pjmlp 3y agoI am quite open about my opinion regarding most of Go's design decisions.
- jrockway 3y agoURLs for packages makes a lot of sense. It works well in the land of Go. It also conveniently eliminates the need for the language to have a global packages database. Upload your package to example.com/your-thing and it's released! (You can, of course, still offer a cache and search engine if you want to.)
- alpaca128 3y agoCargo does support URLs to git repos for dependencies. But crates.io is the official platform and almost every search I do on it returns at least one generically named entry with an empty repository that someone snatched away and never used.
- swatcoder 3y agoNo, URL's don't make sense because your application shouldn't care where on the internet your dependency happened to be hosted when you integrated it. It's location has nothing to do with what it is. By the time you're going to production, your vetted and locked dependency should be living in your own cache/mirror/vendored-repo/whatever so that you know exactly what code you built your project around and know exactly what the availability will be when you build/instantiate your project. Your project shouldn't need to care whether GitHub fell out of fashion and the project moved to GitLab, and definitely shouldn't be relying on GitHub being available when you need to build, test, deploy, or scale. That's a completely unnecessary failure point for you to introduce. Systems that use URL-identified packages can work around some of this, but just reinforce terrible habits.
- dhosek 3y agoAgreed. The other thing I don’t really like is that you can’t split up things in the rust namespace hierarchy between crates (something that’s natural with jars in JVM). I would have liked to have defined things so that I could have the unicode handlers for finl live in finl::unicode, the parser in finl::parser, etc. but because they’re in separate crates rust gets upset about finl being defined twice and there’s no workaround for it. There are likely pitfalls I don’t see in what I want, so I live with it.
- ramranch 3y agoWould re-exporting partially solve your problem?
- dhosek 3y agoAs I recall, I could do something where I could have a common root crate that would import and re-export the other crates with the namespaces modified on the exports and then control which crates are exported through feature gates, but it just seemed more hassle than it was worth.
- epage 3y agoWe have an RFC for this that has fairly broad support that I just need to bug some people some more so we can approve it. https://github.com/rust-lang/rfcs/pull/3243 https://github.com/rust-lang/rfcs/pull/3243
- lolinder 3y ago> Maybe it was a reaction against the Java-style reverse DNS notation I suspect it was less a reaction against anything and more just following the norms established by most other package managers. NPM, PyPI, RubyGems, Elixir's Hex, Haskell's Cabal... I'm having a hard time thinking of a non-Java package manager that was around at the time Rust came out that didn't have a single, global namespace. Some have tried to fix that since then, but it was just the way package managers worked in 2014/2015.
- jiggawatts 3y agoYes, and all of those have had major security issues caused by their lack of foresight. "We're pretending security is not an issue." has been the feedback every time this is raised with the Cargo team. To be honest, it's turned me off Rust a little bit. The attitude of "Rust is memory-safe, so we don't need any other form of security." is not a good one.
- muldvarp 3y ago> "We're pretending security is not an issue." has been the feedback every time this is raised with the Cargo team. Do you have a specific link where I can read this response, because this is not at all the responses I have read.
- jiggawatts 3y agoJust some random Cargo security-related issues I noticed: - No strong link between the repo and the published code. - Many crates were spammed that were just a wrapper around a popular C/C++ library. There's no indication of this, so... "surprise!"... your compiled app is now more unsafe C/C++ code than Rust. - Extensive name squatting, to the point that virtual no library uses the obvious name, because someone else got to it first. The aformentioned C/C++ libraries were easy to spit out, so they often grabbed the name before a Rust rewrite could be completed and published. So you now go to Cargo to find a Rust library for 'X' and you instead have to use 'X-rs' because... ha-ha, it's actually a C/C++ package manager with some Rust crates in there also. - Transitive dependencies aren't shown in the web page. - No enforcement or indication of safe/unsafe libs, nostd, etc... - No requirement for MFA, which was a successful attack vector on multiple package managers in the past. DISCLAIMER: Some of the above may have been resolved since I last looked. Other package managers also do these things (but that's not a good thing). In my opinion, any package manager that just lets any random person upload "whatever" is outright dangerous and useless to the larger ecosystem of developers in a hurry who don't have the time to vet every single transitive dependency every month. Package managers need to grow up and start requiring a direct reference to a specific Git commit -- that they store themselves -- and compile from scratch with an instrumented compiler that spits out metadata such as "connects to the Internet, did you know?" or "is actually 99% C++ code, by the way".
- yarg 3y agoThis needs to be resolved by every damned language. Just make signed dependencies a universal default, point to an https page for the package vendor and use the signing key from there. Neither node nor maven ever bothered to solve this, so we end up wandering the Wild West wondering when it will be that HR, or legal, or architecture comes knocking on the door to ask what we were thinking having a dependency on a dynamic version of Left Pad. I'd kinda like to see what Cloudflare and Let's Encrypt could come up with if they worked together on at very least a white paper and an MVP POC.
- lesuorac 3y agoI don't think that's the real solution. Pay somebody either internally or externally to maintain a repo of all your dependencies and point your code at that. You won't get a left-pad incident. You won't get a malicious .so incident (unless you mirror binaries instead of source code). Like if you ran out of screws to make your product with do you walk around the street and scrounge up some? No, you go to a trusted vendor and buy the screws.
- yarg 3y agoI'm not suggesting scrounging. I'm suggesting that the guys who've repeatedly proven themselves technically competent around security at scale might have a couple of useful ideas regarding how the industry might go about crawling its way out of this little security clusterfuck. And perhaps even stop treating something as simple as a BOM as an enterprise feature, given that the overhead on such things is damned near zilch and the security implications are staggering. https://www.cisa.gov/sbom https://www.cisa.gov/sbom
- cmrdporcupine 3y agoThere's reasons why Google projects don't go out on the internet to get their 3rd party deps. They're all checked into Google3 (or chromium, etc.). One version only. With internal maintainers responsible for bringing it in and multiple people vetting it, and clear ownership over its management. E.g. you don't just get to willy nilly depend on a new version -- if you want to upgrade what's there, you gotta put a ring on it. If you upgrade it, you're likely going to be upgrading it for everyone, and the build system will run through the dependent tests for them all, etc. And the consequence is more responsible use of third party deps and less sprawling dependency trees and less complexity. And additional less security concerns as the code is checked in, its license vetted, and build systems are hunting around on the Internet for artifacts.
- cetra3 3y agoI think most people are in support of namespacing but it's a big change and will take a while to see through.
- Jalad 3y agoThis is a common critique, and although I don't have insight into why the original decision to not have namespaces was made, the current outlook is that until issues related to continuity are resolved, it's a no go: https://samsieber.tech/posts/2020/09/registry-structure-influence/ https://samsieber.tech/posts/2020/09/registry-structure-infl...
- sigwinch28 3y agoThat article starts with the premise that “it’s a feature, not a bug” then goes on to describe a whole bunch of things I consider to be anti-features of a packaging system that has a flat namespace. The first section says it discourages forking. I consider this to be bad. Nobody’s code should be more important purely because it squatted a better name. The Identity section actually makes the case that flat registries make naming harder. The section on Continuity is “we’ve tried nothing and we’re all out of ideas”. Make up an org name and grandfather all packages in the flat namespace into that special org. Also this is already a problem because packages in the flat namespace do get abandoned, then forked, and then we have the associated issues. The section on Stability seems to take it as a given that crates.io should be the only registry. I don’t. It also seems to conflate cargo with rustc for the benefit of the argument. The squatting section describes only anti-features and I don’t consider the author’s legitimate use cases to be legitimate reasons to squat. I think the only legitimate problems that need addressing are the ergonomics of accessing namespaced packages throughout transient dependencies and backwards compatibility with non-namespaced code. But the fact that these are real problems does not, to me, make a flat namespace a “feature”. It’s just easier to implement. It’s okay for it to be a mistake that takes effort and time to fix.
- kevincox 3y agoAnother option would be to grandfather all packages into their own org. So serde becomes serde/serde. This way you don't need to manage permission rules in the legacy "all" namespace. You get some oddities such as serde-derive/serde-derive but the package owners can choose if they want to move to serde/derive or leave it in a separate namespace.
- fawadasaurus 3y agoI did some analysis on crates.io to find the top name squatters. Then I did some calculations and found that the top name squatter created their crates at a rate of about one ever 30 seconds for a period of a week straight. I send the analysis to the crates.io team and pointed that they have a no-automation policy. They told me that it was not sufficient proof that someone was squatting those names. That's my problem with crates.io is that they have a clear policy and they don't enforce it so all the short/easy to remember names for crates are already taken and there is nothing you can do to get it.
- echelon 3y agoThere's a secret effort in the Rust community to supplant Crates.io and create an entirely new package ecosystem with proper namespacing, security, and much better community. Not naming names, but I know several people working to put Crates.io out to pasture. There's a level of playing nice with them for the time being (eg. build reproducibility), but it's only KTLO. Crates.io needs to die for Rust to thrive. They're a bungled, mismanaged liability. New code, new leadership.
- solardev 3y agoWhy does something like that need to be secret...? Isn't it in the community's best interest?
- TylerE 3y agoDrama avoidance and avoiding bikeshedding seem obvious. Much easier to present a working system than a design that will get nitpicked into irrelevancy.
- solardev 3y agoYeah, that makes sense.
- sapling-ginger 3y agoThat quite funny. Just like when some people formed a violent militant group to take down a violent tyranical dictatorship. Of course they would promise that they would absolutely de-arm right after the dictatorship has been overthrown, and immediately establish a peaceful democratic government with fair election. They absolutely would, would they? They would never turn into what they were formed to replace, would they?
- SCLeo 3y agoIf you have a namespace, can't people just globally-claim namespaces instead? like serde/serde or something similar. I feel if you really don't want people claim whatever they want, you have to do the Java package style where namespaces are tied to domain names.
- WatchDog 3y agoMaven and Java really don’t get enough credit for how well it’s dependency management works. So many inferior dependency management systems for other languages have come along later, and learned nothing from those that came before it.
- baby 3y agoIs this a joke?
- theendisney2 3y agoI think the correct approach is to do full-real-name_good-package-name it might not be practical but it would be legendary.
- bsder 3y agoNot even remotely a joke. The inverse-style domain name thing does a really good job of removing the whole issue of squatting from the ecosystem. You have to demonstrate some level of commitment and identity through control of a domain name in order to publish. I would also say that this puts just enough friction so that people don't publish dogshit. crates.io demonstrates quite clearly that you either have to go all the way and take responsibility for curation or you have to get completely out of the way. There is no inbetween.
- speed_spread 3y agoHaving tried Java and other languages, no, it's not a joke. Other than XML Maven got a lot of things right.
- chii 3y agoand i dont particularly think that using xml is that bad. The schema is well defined, and gives you good autocompletion in any competent IDE (such as intellij). It took some iterations before maven 3 became "good", so people forget that it wasn't as nice before now! Unfortunately, it seems that the lessons learned there is never really disseminated to other ecosystems - perhaps due to prejudice against "enterprisey" java. Yet, these package managers are now facing the sorts of problems solved in java.
- baby 3y agoI love this lack of namespacing personally, because it means that whatever crate you see in a project is going to be the same as the crate your see in another one. Never need to alias crate names. It happens in Golang all the time and I really think namespacing packages was a mistake there.
- lolinder 3y agoGolang's problems aren't due to using namespaces, they're due to delaying too many decisions until too late. Go has namespacing mostly because for a long time it didn't have a package manager at all, so people just used a bunch of ad hoc URL-based solutions mostly revolving around GitHub, which happens to have namespaces and also happened to lend itself to aliasing (because a whole GitHub URL is too long). If you want to look at an actual example of namespacing done well, Maven/Java is the place to look. There is no aliasing—the same imports always work across projects.
- Grimburger 3y agoYet to see any proof that namespacing has made things better in other ecosystems, are go style links or other types of namespaced imports any less prone to supply chain risks? It's definitely a good thing that people choose new unique names for crates rather than dijan/base64 vs dljan/base64 Do understand the desire of having a crate for audio manipulation called "audio" but at the same time how often do we end up with "audio2" anyway? It's an imperfect solution for an imperfect world and I personally think the crates team got it right on this one.
- chungy 3y ago> Yet to see any proof that namespacing has made things better in other ecosystems It's really as simple as this: many libraries are generic enough implementing something that already exists. Let's say you want a library to manage the SMTP protocol. On crates.io, of course someone has already taken the "smtp" crate (ironically, this one is abandoned, but has the highest download counts, because it's the most obvious name). Let's say you disagree with the direction this smtp crate has gone, and you make your own. What do you call it? Namespaces solve this problem. You'd instead of have user1/smtp and user2/smtp competing in feature sets. You can even be user3/smtp if you don't like the first two. This is precisely what Java enables too. The standard library is in com.java.*; if you don't like how the standard library does something, you can make com.grimburger.smtp and do it yourself. If you choose to publish to the world, all the more power to you. It doesn't conflict with the standard library's smtp implementation.
- corytheboyd 3y agoI don’t work with rust on the regular, but this is so annoying with package repositories in general. No don’t use http-server, it’s bad, instead you have to use MuffinTop, it’s better. And then you just have to know that. The concept of sanctioned package names would be interesting, but probably chaotic in practice as the underlying code behind this sort of alias changes over time. This will remain a part of being a domain expert in any given ecosystem forever I think, hooray!
- Conscat 3y agoI think if you get three to five developers who are enthusiastic about X language, their collective knowledge will select good packages.
- ReactiveJelly 3y ago(You probably agree with me but I'm going to just write one big comment instead of replying to every slightly incorrect comment in the thread) Naming things really is one of the hardest problems. This crates thing is a special case of Zooko's Triangle: https://en.wikipedia.org/wiki/Zooko%27s_triangle https://en.wikipedia.org/wiki/Zooko%27s_triangle Crates.io names are human-meaningful and everyone sees the same names, but it's vulnerable to squatting, spamming, and Sybil attacks. You could tie a name to a public key, like onion addresses do, but it's unwieldy for humans. (NB, nothing stops you from doing this inside of crates.io if you really wanted) You could use pet names where "http-server" and "http-client" locally map to "hyper" and "reqwest", but nobody likes those, because they don't solve the bootstrap problem. It's a problem with all repos because when you say "http-server should simply be the best server that everyone likes right now", you have to decide who is the authority of "best", and "everyone", and "now". Don't forget how much useless crap is left in the Python stdlib marked as "don't use this as of 2018, use the 3rd-party lib that does it way better." So yeah... probably will be a problem forever. As a bit of fun here are some un-intuitive names, and my proposed improvements: - Rename Apache to "http-server" - Rename Nginx to "http-server-2" - Rename Caddy to "http-server-2-golang" - Rename libcurl to "http-client" - Rename GTK+ to "linux-gui" - Rename Qt to "linux-gui-2" - Rename xfce4 to "linux-desktop-3" Then you only need to remember which numbers are good and which numbers are bad! Like how IPv4 is the best, IPv6 is okay, but IPV5 isn't real, and HTTP 1.1 and 3 are great but 2 kinda sucked. Very simple. If a company as big as Apple can have simple names like "WebKit", "CoreGraphics", and "CoreAudio" then surely a million hackers competing in a free marketplace can do the same thing.
- thayne 3y ago> Some of these globally-claimed generic packages are not really the best package to use. Or it is just a placeholder from a squatter.
- throwawaaarrgh 3y agoCPAN has the best model IMHO. Hierarchy that starts with categories. You build on top of the base stuff and extend it, rather than reinvent/fork something with a random name. Result is a lot more improvement and reuse, and more functionality with less duplication. Plus it's easy to find stuff. Perl's whole ecosystem is amazing compared to other languages. It's a shame nobody knows it.
- lifthrasiir 3y agoI don't think a lack of namespace is that much problem. Sure, it is often annoying, but people are creative enough to create a short enough and still available crate name for most cases. Namespacing only makes sense for a large group of related crates---and it wouldn't give much benefit over a flat namespace. As other mentioned though, a typosquatting is a much bigger problem and namespacing offers only a partial solution. (You can still create a lookalike organization name, both in npm and in Github.)
- rat87 3y agoId argue typesquatting a namespace is arguably easier then type squatting a package name since you will often ignore the namespace name
- rat87 3y agoI don't see the problem. Even with namespaces you'll have brandonq/xml vs parsers/xml with no clue if one is better then another. Also possibly with some confusion over whether things with the same name are forks or not. May make it a little more difficult to Google. Why not just have brandon_xml vs xml-parser and have a community list of best and most popular libraries? I guess the only issue is that some generic/obvious package names are bad packages. That can have been avoided if they banned/self-squated most of the names. I suppose if you use dns namespaces and actually tie it to ownership of the domain name it might make sense but that would also cause issues(what if you forgot to renew the domain?).
- pdimitar 3y ago> brandonq/xml vs parsers/xml with no clue if one is better then another. You will have this problem only once. After an initial research you settle on one and move on with life. I don't get how having to vet a dependency is going to be more difficult than before. The process is 99% the same, you still have to do the research work initially in both cases.
- xtremegoose 3y agoThe advantage is one of trust. If the `abc` developers build well known library `abc.pqr` are well trusted then I know I can use `abc.xyz` and everything else under the same namespace without (much) vetting. We could even have `rust.xyz` for crates that are decoupled from `std` but still maintained by rust core devs such as `regex`.
- pjmlp 3y agoWhile Java made that notation famous, it was already used in NeXTSTEP and Objective-C, hence why you will see this all over the place in macOS and derived platforms, on configuration files and services.
- satvikpendem 3y agoI like that there are no namespaces, it forces people to come up with unique names rather than naming their calendar crate to be `calendar`.
- littlestymaar 3y ago> Perhaps my biggest critique is that crates.io has no namespacing. Anyone can just claim a global and generic package name and we mostly have to deal with it (unless you avoid using the crates.io repository, but then you'll probably have more problems...). Some of these globally-claimed generic packages are not really the best package to use. This is true that with no namespace anyone can end up squatting a cool name, but with namespace you end up in an even worse place: no-one end up with the cool names, and it makes discoverability miserable, because instead of having people come up with unique names like serde, everybody just name their json serialization/parsing library json and user now needs to remember if they should use "dtolnay/json" or "google/json" (and remember not to use "json/json" because indeed namespace squatting is now a thing), and of course this makes it completely ungoogleable. We've had the namespace discussion for hundreds of time in the various Rust town squares, and the main reason why we still don't have namespace is because it doesn't actually answer the problem it's supposed to address and if you dig a little bit you realize that it even makes them worse. Having a centralized public and permissionless repository opens tons of tricky questions, but namespaces are a solution to none of them.
- pdimitar 3y ago> everybody just name their json serialization/parsing library json and user now needs to remember if they should use "dtolnay/json" or "google/json" What's the problem with that? You will have to explicitly state intention which is always a good thing. > and of course this makes it completely ungoogleable You are aware that just pasting username/projectname gives you exactly what you are looking for in the several top search engines, correct? > We've had the namespace discussion for hundreds of time in the various Rust town squares, and the main reason why we still don't have namespace is because it doesn't actually answer the problem it's supposed to address and if you dig a little bit you realize that it even makes them worse. OK, if you say so. Is this worse state of things documented somewhere?
- yencabulator 3y ago> and of course this makes it completely ungoogleable Do you really think nobody has ever been able to google a Go import path? Some of these arguments are ridiculous.
- anon776 3y ago"Rust has its warts". Interesting terminology.
- bojo 3y agoThis is a fairly common idiom, "X has its warts." Or do you mean something else?
- avgcorrection 3y agoCan’t really accuse programmers of being creative with words and phrases. Most of them will be rehashes of blogs and memes from the last couple of decades. But maybe I’m bikeshedding by saying that.
- nu11ptr 3y agoThis is written by someone who has obviously written a lot of Rust code. I like its balance. It feels fair and not fanboyish like these write ups often do.
- elcritch 3y agoYah, it's nice reading some balanced takes.
- throwaway914 3y agoI feel like Rust finally broke the idea that programmers should be in complete control and completely conscious of everything the compiler is doing. It hasn't been that way in decades, compilers are freaking magic. But Rust undid a lot of that with borrowing. People became comfortable with the compiler knowing better than them. I just wish we could relax further: We should never be explicitly iterating forward over a collection unless we need this behavior for the algorithm. Things should be implicitly parallel. Etc. Give me rusty bash.
- jjn2009 3y agoArguably memory managed languages are the same or are you speaking to some specific slice of the available programming languages?
- alpaca128 3y ago> We should never be explicitly iterating forward over a collection unless we need this behavior for the algorithm. Things should be implicitly parallel There is already a crate providing parallel iterators. You just rename the iter() call and that's it. I don't agree it should be implicit though.
- ModernMech 3y agoIt’s called Rayon for anyone who wants to know.
- oconnor663 3y agoI think "not in control of what the compiler is doing" is overstating things a little bit. In some ways, Rust gives the programmer more control than C does. For example, Rust has standardized support for inline assembly, but inline assembly in C relies on vendor-specific extensions. But to your point, the convenient defaults are very different. Unsafe typecasts require a lot of ceremony and careful thought in Rust, and they have to follow more rules than in C. In particular, references are all effectively "restrict" in Rust, and it's really easy to screw that up when you do unsafe cast from raw pointers to safe references, which is a big incentive not to write code like that if you have a choice.
- 1vuio0pswjnm7 3y agoHow do people prefer to compile rust programs offline.
- miloignis 3y agoIn what way? Rust (cargo technically) might have the best support for offline compilation of any language I use. `cargo vendor` does pretty much everything I want it to.
- lesuorac 3y agoAlso you can download documentation for offline using `cargo doc` so you can easily lookup stuff during a flight. Although you do need to figure out all your dependencies ahead of time so that you download their documentation before you leave.
- herbstein 3y agoJust FYI, `cargo doc` doesn't download the documentation. It re-generates the documentation from source. You only need the source code to generate documentation.
- raggi 3y agoLearning when to invest in type constraints and when not to is an important lesson. It’s not unique to rust, though it might express a little differently. I’ve dealt with excessively typed c++ and excessively abstracted and typed Java and they have the same class of refactoring problems. I’ve also dealt with plenty of undertyped and under documented go, where there are specific values all over the place which turn into runtime footguns - and these can be truly dire to refactor as well, you get an earlier sense of progress but you ship bugs to users most of the time. There’s no magic answer to this set of trade offs. Rust gives you tools to mostly pick your place, on this specific axis it provides an unusually broad choice.
- ayakang31415 3y agoI never programmed in Rust, but I had enough experience in C programming to know that segmentation faults are annoying to debug. I heard Rust prevents memory management problems at compilation level, so it forces you to create safer program. Given this, I want to ask Rust programmers here: For people who have no experience in managing memory at coding stage (basically programmer who have no experience in C-like language), can such people appreciate what Rust aims to deliver?
- kag0 3y agodisclaimer: I'm not a big rust programmer, but I appreciate it. I think it's a matter of perspective/background. Depending what language you're coming from you might appreciate a lot of the more modern language features, or binary size, or performance. On the other hand, you might already be working with a pretty cutting edge language with a garbage collector or other and decide that Rust has some cool benefits but not worth the switch.
- love2read 3y agoI heavily appreciate the simplification of the memory model. I was able to go from comfortable with typescript/js to comfortable with rust with essentially zero knowledge of manual memory allocation in just a few months.
- jiggawatts 3y agoIn that scenario Rust can be attractive because of its high performance compared to languages with a garbage collector. No matter what Java fans will tell you, any runtime with a GC will have worse overall performance for most large codebases than a compiled language with no GC. Sure, microbenchmarks might not look too bad, but complex software is a different matter. Rust is great for services such as API endpoints, where low latency and high throughput at a low cost are more important that hot reload during development.
- evrimoztamur 3y agoI think so, I wrote an entire video game from scratch in Rust and my experience has been absolutely delightful. I have to manage nulls via Options, cast things explicitly, cannot do dumb stuff like modifying an array while iterating it, etcetera. It’s guiding my code in ways that I wasn’t able to myself, and eventually leading to essentially what is a bug-free game. Imagine! The experience has been far more than just borrow checking, it’s opened up my mind to a lot of concepts that my previous trials with Java, JavaScript, and Python fully obscured in arcane ways. Rust’s compiler is wonderful, and once you get past the ergonomic struggles (which I did by just going through Advent of Code), you’re set.
- gfodor 3y agoDoesn't seem to answer my main question about Rust vs everything else which is what is the more joyful to work in?
- quickthrower2 3y agoProbably something in the set {everything else}.
- love2read 3y agoIt really depends on what your previous programming experience is, if you can state which languages you know now, someone can give a better response to this.
- tantalor 3y ago> I started writing tests in Rust as I would in any other language but found that I was writing tests couldn’t fail. This is a common refrain in C++ testing: if it compiles then it's probably correct. > Rust has accounted for so many errors that many common test cases become irrelevant In practice, if you think this way I think it's a sign that you aren't testing the right things in those other languages. You should be testing business logic, not language stuff. If you look at your test code and think "I would test this in JavaScript, but I don't need to do that in Rust" then just delete the test.
- adastra22 3y ago> This is a common refrain in C++ testing: if it compiles then it's probably correct. I’ve heard this in Haskell and in Rust. I’ve never heard it applied to C++…
- ModernMech 3y agoI think they meant Rust? Rust definitely has that property to an extent; C++ is so far from it it’s not even funny.
- jeremyjh 3y agoI’ve definitely experienced it in Haskell and Rust. I can believe some C++ could be that way, but I’ve never experienced it, but then again those projects didn’t have useful tests either. I think with C++ a lot of this depends on domain and the quality of the code and libraries.
- xhainingx 3y agoIt's truer in C++ than java or similar languages ime since java relies more on exceptions, but it's certainly not as true as Haskell or rust
- Skunkleton 3y agoIs it true enough in c++ to be useful though?
- clumsysmurf 3y agoAs an outsider, I often hear about async Rust being less than ideal. Perhaps I don't understand, because I haven't dipped my toes in the water yet... but I do most of my work in Kotlin with Coroutines, and concurrency is everywhere in the UI. I can't imagine working in a language having a major deficit in this space. Are there any efforts to overhaul or completely rethink this?
- adastra22 3y agoIt’s pretty much the same issue all languages have, that async functions are colored. I don’t think it is unique to rust. Algebraic effects would solve this, but I don’t know any language other than OCaml that is working on that approach.
- adamgordonbell 3y agoCan't scala, haskell, (kotlin?) you just lift functions into Async? You can convert colors simply but only one way, and practically that works, functional core imperative shell, etc.
- subarctic 3y agoI mean... that's not really the pain that people are referring to when they are struggling with async Rust, especially when you compare it other languages like JavaScript that also have a difference between async and regular functions.
- vlovich123 3y agoIt’s not just that. There’s a few big problems with Rust async aside from the normal coloring problem that is inherent to async and not worth talking about. * The async runtime and async functions are decomposed but tightly coupled. That means while you could swap out runtimes, a crate built against one runtime can’t generally be used with another unless explicitly designed to support multiple. I believe C++ has a similar problem but no other major language I’m aware of has this problem - that’s typically because there’s only a single runtime and it’s embedded in the language. Things like timers and I/O are not interoperable because the API you use has to be for the runtime you’re running under. I believe there’s work ongoing to try to remedy this although in practice I think that’s difficult (eg what if you’re using a crate relying on epoll-based APIs but the runtime is io_uring). * async in traits. I believe that’s coming this year although the extra boxing it forces to make that work makes that not something 0-cost you can adopt in a super hot path. * async requires pinned types which makes things very complex to manage and is a uniquely Rust concept (in fact I read a conceptually better alternative proposal for how to have solved the pin/unpin problem on HN not too long ago, but that ship has long sailed I fear). * The borrow checker doesn’t know if your async function is running on a work stealing runtime or not which means there’s a lot more hoop jumping via unsafe if you want optimal performance. * async functions are lazy and require polling before they do anything. That can be a bit surprising and require weird patterns. Don’t get me wrong. The effing-mad crate is a fantastic demonstration of the power of algebraic effects to comprehensively solve coloring issues (async, failability, etc). But I think there’s stuff with runtime interop that’s also important. I don’t think anyone is yet seriously tackling improving the borrow checker for thread per core async.
- jjn2009 3y ago> I code better in other languages now I feel this one, something about spending too much time in JS makes me not want to write clean software..
- Sytten 3y agoSide comment but I looked at the documentation, github repo and even code for wick and I still have zero idea what it does. And I am rust developper full time...
- Zagitta 3y ago"Programming in Rust is like being in an emotionally abusive relationship. Rust screams at you all day, every day, often about things that you would have considered perfectly normal in another life. Eventually, you get used to the tantrums. They become routine. You learn to walk the tightrope to avoid triggering the compiler’s temper. And just like in real life, those behavior changes stick with you forever." This is a pretty negative and unfortunate take on rust that I cannot recognize after having spent the past 2 years professionally writing backend rust. I did write c++ before that so it's likely that it takes some experience with the pain of an unhelpful (and in some cases downright hostile) to fully understand and appreciate the so called "yelling" rust does. From my perspective every lifetime complaint the compiler has is a deeply appreciated hint that not only saves you countless hours of debugging down the line but also makes me feel confident/safe in the code which you never could achieve in a c++ codebase without making defensive copies everywhere. Being able to lend/borrow data without fear truely is rust's greatest strength and something people coming from GC languages have a hard time appreciating.
- Analemma_ 3y agoIt's a bit of an oversimplification, but a little quip I've used when talking about developing in Rust vs. other languages is, it's a question of where/when do you want the pain. In Rust, it's at development time (and hiring and ramp-up time); in C++ it's at runtime; and with GC languages it's at billing time when you have to pay for that extra compute and RAM. There's no way to get rid of the pain entirely.
- ModernMech 3y agoYes but there’s a difference in who feels the pain. Compile time pain is felt by devs, who have the constitution and ability to fix such issues. Runtime pain is felt by users and can result in data loss and security issues in the wild, and is harder to debug. One kind of pain has a bigger blast radius than the other. I prefer compile time pain to runtime pain.
- willsmith72 3y agoif it were that simple, I'd take the "billing time" payment every time. Engineers' time is the greatest cost for just about any tech business
- strangescript 3y agoI love Rust but saying your aren't sure if its worth it after three years is a red flag.
- bogwog 3y agoDo you need memory safety? Then why use Rust when you could use Java, JS, Python, etc? You can't "disable" memory safety in those languages. Do you need bare metal performance? Then why use Rust when you could use C or C++, which have much larger ecosystems, platform support, more mature tooling, etc. Do you need BOTH memory safety and baremetal performance at the same time? Then there really aren't many other options besides Rust. But what I've started wondering lately is: are there really that many situations where you actually need both of those things at the same time? C++ tends to get misused a lot, but I feel like the same thing is happening with Rust.
- Kenji 3y ago[dead]
- jackpeterfletch 3y ago> Do you need memory safety? I think that’s an unusual way frame that requirement. All programs need to handle memory _correctly_. Very few seg fault as part of expected operation.
- bogwog 3y ago> Do you need memory safety guarantees? Is that better?
- jrpelkonen 3y agoSegfaults are not actually even the worst outcome, corrupting the program state yet still trucking along can lead to far worse consequences.
- AlotOfReading 3y agoIf you're remotely sane, you'll always want memory safety. That's not really an optional property, because even in C/C++ compromising memory safety throws you straight into the land of nasal demons. The question is whether you want the compiler to ensure memory safety, or to do it completely on your own without language support. Personally, I've never met anyone who can ensure memory safety in their C/C++ without onerous restrictions even more severe than those rust imposes, but maybe you're superhuman.
- RagnarD 3y agoI continue to be delighted by indications that real high level languages compiling to Webassembly are supplanting the godforsaken nightmare of JavaScript. I think anyone focusing solely on JS is overdue for looking at those languages and getting up to speed on the huge differences before they wake up to find that the market for making and fixing kerosene lamps has been replaced by fusion reactors.
- forrestthewoods 3y ago> I also now get irrationally upset when I experience a runtime error. No. This is an exceedingly rational anger.
- subarctic 3y agoIt's only mentioned off hand in one sentence at the end, but have people found that Rust is hard to hire for? In my experience it's relatively easy to filter for good candidates when you're hiring for Rust, whereas, just as a point of contrast, I've noticed it's more difficult to find frontend developers who are good at TypeScript (since a lot of frontend developers just use plain JavaScript).
- jandrewrogers 3y agoI don't think it is unusually difficult to find Rust programmers. The challenge is finding Rust programmers who also have expertise in systems software development. Rust was designed to be a systems language but ironically it primarily seems to attract developers that do not have expertise in systems software. This isn't necessarily a problem. C++ and Rust can coexist pretty well in practice, and Rust is a good entry point for learning how to write systems software.
- cmrdporcupine 3y agoSadly I have found the flip side, too: as someone with a systems software interest/background (I wouldn't say expert), the # of jobs in the Rust ecosystem that are not glorified webdev/microservicing (or worse, crypto) is actually quite small. So I guess I wouldn't be surprised that the applications are trending that way, too, as that is where growth is happening right now it seems.
- subarctic 3y agoThat's the flip side of the same coin as your parent comment, I guess - because Rust is more accessible than C or C++, a lot of people have started using it for stuff that's not hardcore systems software, and as a result it's not as good a filter for that stuff as C and C++ are. On the other hand, we use Rust on the backend of our web based saas product, and it serves as a great filter for quality developers for us.
- oldbbsnickname 3y agoMostly yes and good. One thing I don't appreciate is nonorthogonality of certain uses and control structures that cannot be refactored into a function despite structural equivalence without introducing a multiple borrow conflict.
- Yodel0914 3y agoI've always assumed this was because of my inexperience with the language, but I find this frustrating, too.
- throwawaaarrgh 3y ago"Rust screams at you all day, every day, often about things that you would have considered perfectly normal in another life." A good C compiler does this when you turn on all the flags. I like languages/compilers that let you selectively disable the screaming and let you write bad code on purpose. Bad code that works but can be written fast is often better than perfect code that takes forever to write. Once you have a bad but working POC, you can make it less bad. "It’s got no problem attracting new users, but it’s not resulting in dramatically improved libraries or tools. It’s resulting in one-off forks that handle specific use cases." Age has nothing to do with that. Attracting core devs is hard, and putting lots of effort into making it attractive is necessary. On top of that, cultural conventions are set by the early adopters, and a lack of convention is often just as sinful as a bad existing convention. Take Python for example. They took a lackadaisical approach to development and runtime environments, and as a result there's 50 competing ways to develop or run a Python program. Their most-used package repository, PyPI, has been a mess for years. Nobody builds on top of existing packages, names make as much sense as a random word generator, the ecosystem is rife with malware, you can't even search for a package on the command line, etc etc. None of that is the language's fault, it's the community and core team's fault for sitting on the sidelines rather than leading. Culture matters more than the tech it's centered around. (I'm not trying to pick on them, I just know their problems better. C has been around for a half century and its community never really put together half the solutions more modern languages did)
- Someone1234 3y ago> A good C compiler does this when you turn on all the flags. I like languages/compilers that let you selectively disable the screaming and let you write bad code on purpose. Bad code that works but can be written fast is often better than perfect code that takes forever to write. Once you have a bad but working POC, you can make it less bad. Rust supports that. Just mark everything unsafe.
- stouset 3y agoThat doesn’t turn off the overwhelming majority of Rust’s soundness checks. `unsafe` isn’t a magic “let anything fly” switch.
- veber-alex 3y ago> It also looks like (soon) you’ll finally be able to configure global lints for a project. Until now, you had to hack your solution to keep lints consistent for projects. > I questioned my sanity every time I circled back around to the Clippy issue above. Surely, I was wrong. There must be a configuration I missed. I couldn’t believe it. I still can’t. Surely there must be a way to configure lints globally. I quadruple-checked when I wrote this to make sure I wasn’t delusional. You create a .cargo/config.toml in the workspace root so it covers all your crates. inside the file: [build] rustflags = ["-Wclippy::lint_name_to_warn", "-Dclippy::lint_name_to_deny"] The only limitation is that rustflags are not additive, so if you have other sources of rustflags like the RUSTFLAGS environment variable it will overwrite this setting.
- mplanchard 3y agoWe just have a script that adds the lints to any lib.rs or main.rs files that runs on commit. ezpz
- sunshowers 3y agoProgramming in Rust is really not like being in an abusive relationship. The compiler is trying to help out as much as possible, especially since rustc has the best error messages in the world.
- fawadasaurus 3y ago[flagged]
- sunshowers 3y agoThis really is an inappropriate comparison. Can we be serious for a bit? A professional-grade tool providing professional-grade feedback is not remotely like an abusive or even turbulent relationship.
- civilitty 3y agoBesides, it's mostly the programmers doing the abusing. People do sick things with lifetimes and generic associated types. Sick, sick things.
- estebank 3y agoAs one of the main people working on Rust compiler diagnostics, I find this comparison beyond distasteful. The tooling is not capricious in its restrictions and we go out of our way to make it communicate to people with as much empathy and support as possible.
- latency-guy2 3y agoThere's a clear distinction between someone who writes the code and everyone else in the world who works with the outputs of your code. Doesn't feel that way to me.
- maxbond 3y agoI'm sorry you're having a bad experience. I've found changing a couple habits developed in other languages helped me to have a good experience with Rust's diagnostics. 1. Reading the error messages. I was used to error messages verbosely printing a lot of details which were mostly irrelevant and letting the programmer sort it out, and I developed a habit of skimming them. I had a better time with Rust when I realized it was giving me information that was mostly relevant, and that I should actually read them. 2. Interpreting error messages as feedback rather than failure. I was used to error messages meaning I had done something wrong, and getting them all the time was frustrating. Watching Jon Gjengset's coding videos, I was struck that he wrote code to trigger errors deliberately in order to get feedback from the compiler. I now try to work through Rust error messages the same way I would failing unit tests; I make some small changes, I knock out the errors, and then move on to the next subtask. This keeps the number of errors small and manageable, and gets me into a tight feedback loop with the compiler. Relatedly, I encountered the idea (in a blog post I no longer remember) that the Rust compiler is more like an automated pair programming partner than other compilers. This change in mindset really helped for me; thinking of it as a friendly helper rather than a loud complainer made the work lighter. (That's why I personally don't like the 'abusive partner' metaphor, for me that mindset makes it toilsome and miserable. Also because I've had an abusive partner, and it's nothing like that, and I could do without the reminder.) 3. Setting up my IDE to show me inline type annotations and error messages. This made the feedback loop tighter, I only have to drop into a terminal for complex or unfamiliar error messages. With practice I can fix most errors using a one-line summary. 4. With practice, I've internalized Rust's semantics, and I've stopped painting myself into corners with unnecessarily cyclic data structures and such. I also read a blog article or maybe a tweet (which I've also forgotten) about giving yourself permission to use Box or clone and not sweating every copy or allocation. It pointed out that if you were writing Python, everything would be an Arc<T>, and you'd think nothing of it; in Rust the performance cost is explicit, so you agonize over it, but a lot of the time it's not a big deal to copy some data or to perform an allocation.
- dilippkumar 3y ago> After two decades of JavaScript and decent experience with Go, this is the most significant source of frustration and friction with Rust. It’s not an insurmountable problem, but you must always be ready to deal with the async monster when it rears its head. In other languages, async is almost invisible. I am a former C and C++ programmer who lived calling into pthread almost every week for a decade. I use async rust everywhere now. I don’t get the hate that async gets. In my opinion, everyone should be using async for everything. Including stuff that’s seemingly single threaded “simple” stuff.
- ilaksh 3y agoThe problem that I am running into at the moment is that a few things like the rhai Engine aren't Send and I am trying to use them in an async closure. What GPT-4 suggested was creating a tokio Runtime inside the thread and then block_on(). I will try it tomorrow. (This is the first significant Rust project for me.)
- codys 3y agoThe answer here is almost certainly one of these: 1. Fix rhai::Engine so it is Send (if !Send is unintentional) 2. Use tokio::spawn_blocking or normal threads to run the rhai::Engine bits 3. Don't hold the rhai::Engine across an await point. Which one depends on rhai Engine details and what you want to accomplish. Doing a block on inside a new thread seems unlikely to do anything useful (unless there's some undisclosed detail that makes it reasonable). I encourage you to ask about this in the rhai repo in a discussion or issue.
- ilaksh 3y ago1. Not applicable unless it is absolutely required, and not something I will consider until I have exhausted other options, since there is a reason they have not made it Send already. It will likely be quite complex and enlarge the scope. 2. I am using a normal thread but when I make it async the compiler wants Send. 3. The await point is in code that uses the engine. I am not sure there is another good option, since I need to use an API that has several libraries all of which are async. The block_on is to allow the tokio Runtime created in that thread to execute/poll it So, thank you for your input, I will test out the suggestion that I mentioned above, and then maybe look into spawn_blocking if that doesn't work.
- antoineMoPa 3y agoJavascript to Rust is a big step for sure. It's probably a less painful journey if you already have a background in Typescript/C++. This article has good feedback though and I hope the language evolves to address some of it in the future.
- JohnFen 3y agoI'm learning Rust because it seems clear that it's going to be important professionally. I wish I loved it, I really do. I see the benefits. But, at least so far, it's one of the most unpleasant languages I've used. I keep hoping that as I gain proficiency, I'll stop disliking it, but as I climb higher on the learning curve, I'm not really warming to it. It's fine. It won't be the only language I'll be proficient in while being averse to it at the same time. But I heard so many people proclaiming their love for it that I expected to enjoy it, too.
- peterashford 3y agoI've tried several times to get into Rust and keep bouncing off it. It just feels so non-ergonomic.
- fawadasaurus 3y agoThe beatings will continue until morale improves.
- HKH2 3y agoWell, what do you dislike about it?
- JohnFen 3y agoGood question! There's no single thing, I think, and the things I dislike about it aren't even really technical criticism or the like. They're more... aesthetic? I find the syntax unpleasant, for instance. It's extremely opinionated and a few of those opinions are ones I disagree with. Also, just generally, it tends to make even simple things pretty complex. I understand why and am not really objecting to that, but it does make using it a bit like running with lead shoes. I expect that the latter part may get better as I use it more (but perhaps not -- there are other languages I'm fully competent in but dislike for similar reasons).
- GuestHNUser 3y agoI share your sentiment about Rust. Fine language for sure, I just don't enjoy programming in it. Simply put, I don't like using the abstractions that the language encourages. For what it is worth, I found pursuing Zig to be a breath of fresh air. It's a promising alternative in the same space as C (and also Cpp and Rust). Checkout Andrew Kelley's introduction to the language.
- andrewstuart 3y agoA key factor in selecting language is ChatGPT. I need to use ChatGPT as a programming sidekick/pair programmer/mentor. Yes, I am not afraid to admit - I need an AI assistant and won't program without it - AI is far too valuable. If ChatGPT struggles with a programming language that is a big problem. I have had a great experience with ChatGPT with TypeScript, SQL, Python, golang, C++. I tried ChatGPT with Rust and it essentially failed - it does not understand the language. AI has become an essential tool for me in programming if the language doesn't do AI or doesn't do it well then that's a huge mark against it.
- forrestthewoods 3y agoChatGPT 4 has worked great for Rust for me.
- andrewstuart 3y agoWhen I tried it a while back it had no grasp of the hard parts of Rust - of which there are many. Not knowing the hard parts is not a workable outcome.
- forrestthewoods 3y agoDid you try ChatGPT 3.5 or 4? There’s a world of difference. Whats an example of a question it failed? I understand Rust pretty well. I can totally see ChatGPT not being able to help with complex lifetime issues. I’ve never asked it such things.
- abdullahkhalids 3y agoI tried for a long time for chatgpt to help me write a simple function that generated a random array and then summed along the columns. Could not do it. Pasting in an error message, made chatgpt spit out another version of the code with some other error.
- andrewstuart 3y ago
- RantyDave 3y agoRe: async, rust is a down to the metal language. IE library yes, runtime no. Async implementations are all either runtimes (Javascript), or libraries that implement a runtime (Python). Under the circumstances I think it's fair that rust has less than ideal async. I still like threads, but the I'm old and uncool.
- rstuart4133 3y ago> I still like threads, but the I'm old and uncool. Hey, I resemble that remark. But I disagree with it. Green threads give you all the advantages of async, but with less of the hairs. In particular no special syntax or change of programming style is required. Yet underneath green threads and async just different styles of event driven I/O, so both run at similar speeds and excel at the same tasks. (Actually green threads should run faster, as storing state on a stack is generally faster than malloc.) I have no idea why Rust abandoned green threads in favour of async. Actually, that's a partial lie - there have been far too many words wasted on explaining why. The problem is the reasons they give look to be an caused by design decisions they made in their implementation. The primary objection seems to be speed. The current async is indeed faster than their old green thread implementation. But that was caused by their choosing to avoid coloured code in their green threads (maybe they were copying Go?). Other objections were similarly to do with the implementation they threw away, not green threads themselves.
- kprotty 3y ago> Green threads give you all the advantages of async They require more memory over stackless coroutines as it stores the callstack instead of changing a single state. They also allow for recursion, but its undelimited meaning you either 1) overrun the guard page and potentially write to another Green thread's stack by just declaring a large local variable 2) enable some form of stack-probing to address that (?) or 3) Support growable stacks which requires a GC to fixup pointes (isn't available in a systems lang). > green threads should run faster, as storing state on a stack is generally faster than malloc. Stackless coroutines explicit don't malloc on each call. You only allocate the intial state machine (stack in GreenThread terms). > The primary objection seems to be speed It's compatibility. No way to properly set the stack-size at compile time for various platforms. No way to setup guard pages in a construct that's language-level so should support being used without an OS (i.e. embedded, wasm, kernel). The current async using stackless coroutines 1) knows the size upfront due to being a compiler-generated StateMachine 2) disallows recursion (as that's a recursive StateMachine type, so users must dynamically allocate those however appropriate) which works for all targets.
- c-smile 3y agoWhy each article about project completion in Rust is read as ex-husband words about his ex-wife: - I loved here. I am still is. But we needed a divorce.
- notamy 3y ago<misread the code, please ignore>
- maxbond 3y agoTo clarify, they aren't disabling the lints in the section you've highlighted. `deny` makes a lint a failure instead of a warning. This is similar to `-Werror` in C. `allow` is the directive to disable a lint. Eg, I often start new or disposable projects with `#![allow(unused, dead_code)]` just to keep my IDE clean while the code is in an unpolished state.
- notamy 3y agoYou are correct! I misread it entirely, that's on me. I misread #![deny] as #![allow].
- synergy20 3y agoUse Rust like ADA, or use it for OS yes. For typical applications I am learning nim, which has python syntax, c speed and size, and could be memory safe too. I really feel nim deserves more love, for that you can balance coding-speed(write like python script), size , performance and security, and cal leverage c and c++ libraries without FFI, no other languages can have those at the same time.
- wg0 3y agoOr crystal which looks more like ruby than Nim looks like python.
- alphanullmeric 3y agoUse C++ if you want control, use Rust if you want safety. And it seems to an extent that carbon will offer most of both.
- afdbcreid 3y agoRust offers you great control when you need it (to the same level of C++, basically. This is what it was designed for). And even the Carbon docs say that if you start from scratch prefer languages like Rust.
- alphanullmeric 3y agoNo it doesn’t. The vast majority of what is taught in a college C++ course would be either impossible or extremely difficult to do in rust. You couldn’t implement std::tuple or std::variant for instance. The carbon docs never recommend rust, they just urge you to use something already available.
- topspin 3y ago"Want to use an async library? There’s a chance you can’t use it outside of a specific async runtime." I complained about this here[1]. I'm told "Tokio won, it's not a problem anymore." Wrong. It's still a problem and it's a killer. [1] https://news.ycombinator.com/item?id=37892655 https://news.ycombinator.com/item?id=37892655
- cmrdporcupine 3y agoYeah those are terrible responses. Tokio monoculture is a serious problem.
- topspin 3y agoOn the supposed "monoculture": First, I have to wonder whether any of this can be legitimately elevated to the level of a "culture." Right now, according to GitHub "insights," tokio-rs has approximately 2.0 regular, every day contributors. And that's the most widely used Rust async runtime. Everything else is likely even more thin. Second, Tokio has a lot of share because it was early and aggressive in actually delivering usable async documentation and code. I recall, years ago, reading Tokio documentation on how futures worked and grasping these concepts all the way from file descriptors one might epoll() in C, up to the Rust abstractions, and thinking "hell, I could write an executor from first principles based on this." Tokio earned the advocates it has, as oblivious to the real state of things as some of them might be. I think the real problem is that async Rust is incomplete. As I said elsewhere, async Rust syntax is fine. The implications of async Rust exposed some papercuts in the language that have had to be dealt with since, but the core syntax is fine. I believe that can be attributed to the serious minded attention that the syntax received from people way, waaay up the cognition curve. The part that didn't get enough thought was async runtimes. In an ideal world, one would develop a Rust library that utilizes and/or implements asynchronous calls and transparently, flawlessly run on any correctly implemented runtime alongside any other number of libraries also utilizing and/or implementing async calls. That is not the case, and the damage that's doing is severe. For every one person, such as myself, that will dare attempt to articulate this pain and, in the process, certainly revealing clear evidence of blatant ignorance, a thousand others just silently gave up.
- bjourne 3y ago> I am a massive proponent of test-driven development. I got used to testing in languages like Java and JavaScript. I started writing tests in Rust as I would in any other language but found that I was writing tests couldn’t fail. Once you get to the point where your tests can run – that is, where your Rust code compiles – Rust has accounted for so many errors that many common test cases become irrelevant. I wonder what kind of tests the author was writing? The test cases I write for my code is for weird edge cases I detect during testing, like parameter over or underflows, correctness of parsing functions, etc. Things that do fail. I don't get why you'd write tests for trivial things that can't fail.
- stavros 3y agoUnfortunately, those are usually the kinds of tests people write. Rust just makes the uselessness more obvious.
- anarazel 3y agoWhen writing in loosely typed languages, some folks aim for 100% line coverage, to make it more feasible to refactor down the line. Which then of course ends up being a lot of tests for fairly basic stuff that the type system could help you with...
- tubthumper8 3y agoline coverage but also branch coverage. Every safe navigation operator used in "defensive" coding, ex. `foo?.bar` is actually another branch that needs to be covered if that's the metric people are using. All of those tests are unnecessary in a language where the type is known at compile-time.
- anarazel 3y agoMy experience with folks proudly proclaiming "100% coverage" is that it's typically "just" line coverage, even if you're obviously right.
- bjourne 3y ago
- epage 3y ago> It also looks like (soon) you’ll finally be able to configure global lints for a project. Until now, you had to hack your solution to keep lints consistent for projects. In Wick, we use a script to automatically update inline lint configurations for a few dozen crates. It took years for the Rust community to land on a solution for this, which brings us to… Wow, as the author of that feature, I'm surprised to see someone was so passionate about it. I've found that many times I've been having to tell people why they should care about it. > I don’t know why. Maybe the pressure to maintain stable APIs, along with Rust’s granular type system, makes it difficult for library owners to iterate. It’s hard to accept a minor change if it would result in a major version bump. There is a tension between people wanting features and people not wanting to deal with version bumps. I've seen this a lot in maintaining clap, especially when it went from unmaintained for years to having active releases. As for cargo, the compatibility guarantees are tough. Take the lints table. We can't throw in a first try, knowing we can fix in in a cargo 2.0. We are tied into the rust project itself which means we have the same compatibility guarantees. This is one reason we generally encourage trying ideas out in third-party plugins before we integrate them in directly since they can break compatibility. > You can’t even publish a crate that has local dev dependencies You can; cargo automatically strips them. However, if you tell cargo that there is a version of it in the registry (by setting the version), then it must be published. This is why when I redesigned `cargo add` for being merged into cargo, I made it so `cargo add --path ../foo --dev` will not add the `version` field. We do need to find ways to clarify that the purpose of the version field is for looking it up in the registry. Allowing the dev dependencies to be stripped also helps with issues of circular dev-dependencies. > However, many developers break large projects down into smaller modules naturally, and you can’t publish a parent crate that has sub-crates that only exist within itself. We do have an RFC for this: https://github.com/rust-lang/rfcs/pull/3452 https://github.com/rust-lang/rfcs/pull/3452 The most complex part is the Index, figuring out how to represent it in the metadata tables we maintain so we avoid having to download every `.crate` file. I also worry there might be tech debt around assumptions of there being a single version of a package when nested packages will easily break that. > You can see the problem manifest in the sheer number of utility crates designed to simplify publishing workspaces. Each works with a subset of configurations, and the “one true way” of setting workspaces up still eludes me. When I publish Wick, it’s frequently an hour+ of effort combining manual, repetitive tasks with tools that only partially work. I'm a bit confused on this point. While there are things to improve around publishing workspaces, I'm not sure how this relates to setting workspaces up or what problems they've had with that. I'd also be curious what problems they had with releasing packages. I don't think I've seen issues from them in cargo-release's Issues.
- kuon 3y agoI wrote a lot of rust, but after some years it still feels unproductive. I do a lot of zig now and I am like 10 times more productive with it. I can just concentrate on what I want to code and I never have to wonder what tool or what library to use. I know rust gives memory safety and how important that is, but the ergonomic is really bad. Every time I write some rust I feel limited. I always have to search libraries and how to do things. I cannot just "type the code". Also the type system can get out of control, it can be very hard to actually know what method you can call on a struct. I still think rust is a great tool, and that it solves tons of problem. But I do not think it is a good general purpose language.
- synergy20 3y agonim could be another option which defaults to c backend with python syntax
- goku12 3y ago> but the ergonomic is really bad. Every time I write some rust I feel limited. > But I do not think it is a good general purpose language. Remember that this is not a sentiment that's shared by everyone. I use Rust for tasks that need anything more complicated than a shell script. Even my window manager is controlled from a Rust program. I say this as someone who has been programming in Python for nearly two decades now. At this point, I'm about as fast in Rust as I am in Python.
- lumost 3y agoI tried to get into rust for many years, I'm now in a C/CPP job (after Java/Python/Ruby and other gigs). What I've come to understand is that Rust's lifetime model is very difficult to work with whenever you have a cyclic reference. In C/CPP the same holds, but you deal with it through clever coding - or ignoring the problem and cleaning up memory later. Java, and other GC'd languages just work for these structures. While the Rust devs believe such cyclic references are rare - I think this speaks mostly to the problem domain they are focused on. Relational models are everywhere in Apps, they are often common in complex systems software like databases, and they are fairly rare in firmware/drivers/system code code. There are a few patterns for dealing with cyclic references, but they all end up requiring either unsafe or a main "owner" object which you clean up occassionally (effectively arena allocation). Having now worked in C/CPP - the idea of having unsafe blocks sprinkled around the code doesn't bother me, and many C/CPP components have some form of arena allocation built-in. I just wish Rust learning resources would be more upfront about this.
- virtuous_sloth 3y agoUnison language has a very elegant solution to the naming problem.
- osigurdson 3y ago>> I started writing tests in Rust as I would in any other language but found that I was writing tests that couldn’t fail. I'm curious if this is other's experience as well. I've only dabbled in Rust but it isn't clear to me how it would ensure that the code is correct.
- skavi 3y agoIt does nothing special compared to the rest of the field of strongly typed MLish languages.
- yellowviking 3y agoAs much as I love rust. Its just shocking to learn these newer languages like go didn't take any learnings from jvm and dotnet world for something simple as dep/package management
- kmiller96 3y agoI think Rust is one of those excellent tools where it does well to interface into a high-level language like python. Need performance, security, and reliability? Build that part in Rust, and have the rest be executed and orchestrated in python. It also forces great design patterns in the form of encapsulation and a strong API. I think the idea of being monolingual in codebases is a silly limitation and lots of development teams would be a lot more productive if they embraced the idea of polylingual codebases.
- brundolf 3y agoThe clippy bit is a little confusing: > It also looks like (soon) you’ll finally be able to configure global lints for a project. Until now, you had to hack your solution to keep lints consistent for projects. In Wick, we use a script to automatically update inline lint configurations for a few dozen crates. It's trivial to configure global lints per crate. The author's problem comes down to having multiple crates per project. Which is something people do sometimes, and should be supported, but there's a big difference between the two interpretations. I would go so far as to say most Rust projects are only one crate (and so support "global" linter configuration)
- xvedejas 3y agoI believe procedural macros always need to be defined in a separate crate, so at least all projects that use procedural macros will have multiple crates
- brundolf 3y agoStill, that's two global configurations to manage, where the original wording was easy to misunderstand as "you have to override linter warnings at every single line where they occur"
- blackoil 3y agoIs Rust a replacement for only C/C++ or also Java/Python/C#/TS? In the latter, I already get some memory safety which I believe is one of the biggest selling points of Rust. Are other benefits of language strong enough that we look into it to develop projects traditionally built in Java or Node?
- 1vuio0pswjnm7 3y ago"The Rust standard library is enormous." Years ago I tried compiling a rust sample program. The binary size was one thing that put me off. Today, I see the issue of large binary size has been addressed. The binary I get is sufficiently small. If this issue of ~500M standard library is fixed, e.g., if some of it is made optional not mandatory, I will give rust another try.
- afdbcreid 3y agoRust binaries are by default nowhere close to 500MB. If they are not small enough for you, you can try https://github.com/johnthagen/min-sized-rust https://github.com/johnthagen/min-sized-rust. By avoiding the formatting machinery and using `panic_immediate_abort` you can get about the size of C binaries.
- 1vuio0pswjnm7 3y agoComment is based on the rust-std package I'm currently seeing in VoidLinux. It is over 500MB. 3 packages will be downloaded: 3 packages will be installed: libexecinfo-1.1_3 libexecinfo-devel-1.1_3 rust-std-1.73.0_1 Size to download: 136MB Size required on disk: 509MB Space available on disk: never enough! Cheacking Debian and NetBSD it seems like the Rust standard library is smaller, much less than 500MB. The simple question is how much space is required for an installation of the Rust compiler. On VoidLinux, it's significantly more space than for a GCC installation. 509MB is just too much for my tastes.
- Animats 3y agoSome days I have misgivings, but not about the language. About the crate situation. Too many important low-level crates stuck at 0.x. I've previously written about problems with the high-performance 3D graphics libraries, but only game devs care about those. At the language level, the big problem is back references. Sometimes you do need them, and the only safe way to do them at present involves reference counts in the forward direction and weak references in the back direction. Then you have to call .borrow() and .upgrade() too much. I'd love to see a static analysis solution to that. (Rough outline of such a solution: Owning object belongs to Owner trait. Owned object belongs to Owned trait. Owned object has .owner() and .owner_mut() functions which retrieve references to the owner. Owners probably have to be pinned, so they can't move while a back-reference exists. If an Owner changes a reference to an Owned object, the back reference is automatically updated. That's the easy part. Now figure out how to prove by static analysis that a specific use of this does not violate Rust's no-aliasing rules (N read-only, or 1 mutable). This looks do-able for the non-mutable case, because having a non-mutable reference to both owned and owner is OK. Mutability, though, is tough. Anybody thinking about this?)
- cratermoon 3y ago> Too many important low-level crates stuck at 0.x. Is it fair to say that Rust failed to supply a robust set of standard libraries comparable to other modern languages? Or was the language aimed at level geared towards implementing rather than providing libraries? If it's truly a systems language, then what library features are essential, and what are 'nice to have'?
- nindalf 3y agoThere was a conscious decision to avoid providing a vast standard library because those inevitably become outdated with time. Building a standard library is relatively easy, maintaining for decades is hard. But it’s a trade off because there are concrete upsides to a large standard library. I wrote about this more - Rust has a small standard library (and that’s ok) - https://blog.nindalf.com/posts/rust-stdlib/ https://blog.nindalf.com/posts/rust-stdlib/
- dingi 3y agoBiggest turn off for me was Rust's horrendous syntax. Dangling apostrophes, wrapping the hell out of things, etc. Just look at this Result<Arc<T, A>, Arc<dyn Any + Sync + Send, A>>. Absolutely horrendous.
- pornel 3y agoThat’s a shallow problem that goes away as you start using the language. Lifetimes need something to stand out as an identifier. 'a is weird, but works. Whether it could use a different ASCII sigil is a bikeshed problem. Types borrowed <> from C++ to look less weird to C++ programmers. But this again is just a surface level issue. Semantically, the wrapper types are incredibly useful. Having all nested types spelled out is convenient when reading code – you know what you're getting and what are the standard properties of it.
- Kiro 3y ago> Refactoring can be a slog This made me not want to try Rust. I was coding vanilla JavaScript for a very long time before trying TypeScript but when I did I was amazed at how much easier refactoring became. That alone made me very excited about type systems and I instantly started looking at Rust, thinking it would be even better. Apparently not. Maybe the sweet spot (for me) is TypeScript.
- muixoozie 3y agoFor what it's worth, I find refactoring in Rust a joy.
- p0nce 3y agoI tried Rust briefly and it had that "Ocaml" feel of solving a puzzle.
- q8840 3y agoI'm glad to see there's a wide range of opinions here. I'm not too concerned with performance or safety (since my code hasn't been seen very often). I use rust just because it has a lot of "libraries that help me develop". While other language libraries have a poor search experience and ranking system, Rust has a great library search system. I use it because I don't have to read blog posts like C/C++ or java to find libraries that help me develop, or wade through unnecessary libraries like C# or go, I can use the rankings, and it has a good documentation system.
- nlnn 3y agoThis has mostly been my experience too. I like using Rust because it reduces the cognitive load I have to deal with for many things (performance/safety are nice, but not a priority). As you've said, finding great libraries is easy, and so is adding/building them. I find this a nice change from e.g. Python (where there are so many way of different competing ways dealing with packaging/dependencies). Also thanks to the error handling, sum types and the like, I don't have to worry so much that I've deal with all errors, handled all enum variants, etc., the compiler takes care of that.
- bowsamic 3y agoI definitely agree with the first negative point. Rust libraries often feel weirdly restrictive and unfinished, even after having a lot of time to mature. Somehow they just don't end up feeling that much better. I just don't understand why though, is there something about Rust that makes this a problem?
- skdotdan 3y agoRust is great, but one thing I’d like to see is an interpreted, dynamic, less strict version of it that could be used for prototyping and gradually typed into compiling Rust code. In other words, a new programming language doing to Rust the reverse of what Mojo is trying to do to Python.
- andai 3y ago>I also now get irrationally upset when I experience a runtime error. Had this experience in my first Rust program. It turned out Rust had silently changed the types of some variables based on some code hundreds of lines later, which caused an overflow at runtime. Spooky action at a distance!
- rizky05 3y ago[dead]
- karg_kult 3y agoI've tried it a few times and it has great features on paper but to use it gets in your way too much. I can spin up a C# dotnet project write and test the code 10 times faster than in Rust. It might not perform as fast but the hot code can be written in a small C library using code/runtime analysis tools to catch any memory safety issues.
- neonsunset 3y agoA note on putting the hot path into C component: Writing performance-sensitive code in C/C++ and calling it via interop used to be the way to go during .NET Framework days but since then has become a performance trap. Especially for small methods, calling them through interop is a deoptimization because they cannot be inlined, and involve GC frame transition (which you can suppress) as well as an indirect jump and maybe interop stub unless you are statically linking the dependency into your AOT deployment. In case the arguments are not blittable to C - marshalling too. Of course, this is much, much faster than anything Java or Go can offer, but still a cost nonetheless. It is also complicates the publishing process because you have to build both .NET and C parts and then package them together, considering the matrix of [win, linux, macos] x [x64, arm64], it turns into quite an unpleasant experience. Instead, the recommended approach is just continuing to write C# code, except with pointer and/or ref based code. This is what CoreLib itself does for the most performance-sensitive bits[0]. Naturally, it intentionally looks ugly like in Rust, but you can easily fix it with a few extension methods[1]. [0]: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs#L1561 https://github.com/dotnet/runtime/blob/main/src/libraries/Sy... [1]: https://github.com/U8String/U8String/blob/main/Sources/Comparison/U8AsciiIgnoreCaseComparer.cs#L53-L75 https://github.com/U8String/U8String/blob/main/Sources/Compa...
- karg_kult 3y agoThanks, I haven't had to do dropping to C for a while as the improvement in performance of dotnet along with features like AOT, Span<t> etc close the gap enough for the domain I work in. Good to know you can remain within the framework and get decent performance though with the unsafe pointers/refs. Would be interesting to see a good benchmark using only C# with latest features and Rust, although I cognisant of the fact there is more to it than pure performance (binary size, dependencies, GC etc).