Of course that doesn't scale to larger types as even with a macro the compile speed will be horrible.
745 karma · joined November 1, 2021
Of course that doesn't scale to larger types as even with a macro the compile speed will be horrible.
I got curious and checked this in Rust, the generated assembly is the same!
I think Go lacks the features to make this ergonomic and flexible.
Before adding iterators the language should add tuples so that you won't need to special case 0,1 and 2 artity functions.
And shorter syntax for anonymous functions to make writing this less verbose, I believe this has been proposed before.
Also the special case for "0..N" ranges seems very unnecessary.
https://doc.rust-lang.org/1.71.1/src/core/slice/mod.rs.html#...
Because before anyhow/thiserror became popular there were 5 other popular crates for handling errors and if Rust added one of those to std we would be stuck with a subpar solution forever?
Because cargo is so easy to use that your preferred error handling solution is one `cargo add` command away?
Because for simple cases the tools the standard library offers are good enough?
a, err := f()
if err != nil {
return
}
a, err = f()
This will compile.In Go the type system doesn't force you to check for errors, the same way as languages with null pointers don't force you to check pointers before dereferencing them.
That's the real problem with errors and null in Go, not the verbosity (though that doesn't help)
Just because you can provide some niche examples where Go is used as a systems programming language doesn't mean it is a general purpose systems programming language.
Putting Go in the same category as C/C++/Rust/Zig is ridiculous.
[1]: https://www.redhat.com/en/topics/virtualization/what-is-KVM
> And turning warnings into errors just encourages people to write 'let _ = ...' to get rid of the error.
No? writing `let _ = make_future()` will clearly not await the future, why would you do it instead of just adding `.await` ?
Using `let _ = ...` is sometimes fine for Result if you really sure you don't care about the potential error you got but it's a no go with futures.
This means the compiler will emit a warning (can be upgraded to an error) if you forget to await a future even if it doesn't return anything.
[1]: https://doc.rust-lang.org/nightly/src/core/future/future.rs.... [2]: https://doc.rust-lang.org/nightly/src/core/result.rs.html#49...
Seems totally insane to me to use a pre-1.0 application written in a pre-1.0 language in production considering Node and Deno basically do the same thing.
A module’s go line must declare a version greater than or equal to the go version declared by each of the
modules listed in require statements. A workspace’s go line must declare a version greater than or equal
to the go version declared by each of the modules listed in use statements.
For example, if module M requires a dependency D with a go.mod that declares go 1.22.0, then M’s go.mod
cannot say go 1.21.3.
so the "go" directive is like "rust-version" in Cargo.toml and the "toolchain" directive is like the rust version in a rust-toolchain file.The rustup toolchain toml file is under your control, dependencies have no affect on it.
This Go feature is like the rust-version key in Cargo.toml where if a dependency specifies in it's own Cargo.toml file that it needs a rust version higher than you what you have you will get an error and your code won't compile (there is no option to auto upgrade the toolchain in rust).
No one is using a Vec<T> with indexes for long term storage if you know you will remove and replace items there, it's obvious regardless of programming language that it's a bad idea.
You use a dedicated data structure for this where the keys have a generation and that solves the ABA problem.
Rust has multiple crates that provide such data structures.
Not really...
var list = std.ArrayList(u21).init(std.testing.allocator);
try list.append('a');
Does creating the ArrayList allocate memory?
Is appending to the array list reallocates?
The only thing you know is that ArrayList will sometime use the allocator, you can't tell when.
And this gets worse once the abstraction level increases, if you have your own type which accepts an allocator and has 100 methods it's impossible to tell which methods allocate.In both languages you still need to know the specifics of the data structures you are working with, the only real problem that Zig solves is to actually allow you to use custom allocators with the std collections, which is something that is still unstable in Rust.
This is configurable, by default with optimizations on math overflow doesn't panic in rust, it wraps around.
Obviously the kernel won't enable panics here unless in debug mode.
Rust proponents mean exactly "memory safety" when they say rust is safe because that is the only safety rust guarantees.
Just because both of those things cause a crash doesn't mean they are the same.
Crashing due to an incorrect .unwrap() is a bug in the business logic of the application, the developer made a wrong assumption.
EXCEPTION_ACCESS_VIOLATION is a crash due to a memory issue that a memory safe language would have prevented.
> It's correctness that affects the user experience, not memory safety.
Memory safety is part of correctness, your program can't be correct if it crashes with EXCEPTION_ACCESS_VIOLATION.
This has nothing to do with DST but with type coercion.
The type of `b` is `&&str` but you requested the type to be `&str` which is fine as the compiler can coerce from `&&str` to `&str` in this case.
In the same way you can write
let b: &i32 = &&&&1;
and it will compile fineThere are dedicated data structures for this [1] that will not let you access another item by mistake.
I opened a bug about this on the rust repo. [1]
While in python you have list/dict/set/generator comprehension and that's it.