Rust vs Go new thread

the first thread was in

Attached: 1*ktpi_k09hWB5RaSRK1a-9A.png (1600x694, 1.62M)

Other urls found in this thread:

benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-go.html
techempower.com/benchmarks/#section=test&runid=019d5c9b-823f-4890-8ed9-28c0a2718bdd&hw=ph&test=json&l=yykewt-f
rust-lang.org/production/users
youtube.com/watch?v=0IMe7C5y3PU
twitter.com/SFWRedditVideos

Reminder that node.js bootcamp babies can fuck off

I agree, the same for goshit low IQ retards like you

only low IQ here is you, webshit baby

both are gay languages, learn a real language you nancy

not true, I design floating-point units for a living, unlike you, 5$/hour upwork retard

...

Having worked with Rust for quite some time, trait objects are quite literally useless. At least in go you can object.(Interface) or object.(Type) to 'get it back out'.
In Rust, once you have a Box it's stuck there. You're limited to only the functions of Trait, you cannot specify additional traits ala Box, and you cannot get it back out back to its original type unless you use Box, which elides ALL type information, meaning you cannot perform operations on it - and you can only get back the original, concrete type (if you know it in the first place, which largely limits its use again).

Is it possible to make your trait inherit Any? But yes, you're right. Rust trait objects are pretty terrible. Type assertions for trait objects should be pretty easy to figure out even without Any.

>Is it possible to make your trait inherit Any?
Any is implicitly implemented for everything. What one needs is specifically an Any trait object, not any trait object that implements Any.
In order to downcast you need specifically Box, &Any, or &mut Any.

This is quite normal for any statically typed language.

However it's also a design flaw on your part.

right, and let's just all go back to type punning and void *p while we're at it?

Saaid the guy who probably doesnt even have a job

What I was proposing was this.
use core::any::Any;

struct Foo {

}

trait Bar : Any {

}

impl Bar for Foo {

}

fn main() {
let foo = Foo{};
let obj : &dyn Bar = &foo;
let foo2 = obj.downcast_ref::().unwrap();
}
But it seems not to work.

You are trying to branch your code based on the type of an object. That Is almost always a bad idea. Go use C# if you wanna do that shit

I'm lead dev for a distributed system that does scheduling optimizations. My system tells other companies how to tell their wageslaves how to work. Performance is important for my work, so whenever someone says node.js is good I just have to laugh in their face.

This. Both rust and go are pretty bad languages.

Rust is objectively great

this, only the community sucks

sure, if you're gay

right, because downcast_ref() is only implemented on dyn Any, it's not actually a part of the Any trait.
the only method actually in the Any trait is type_id(). all of its other methods are implemented on dyn Any.

you're getting at something though, and this is the pattern I usually end up using in my Rust projects, though tedious:
use std::any::Any;

trait AnyTrait: Any {
fn as_any(&self) -> &Any;
}

trait Bar: AnyTrait {}

struct Foo;
impl Foo {
fn print(&self) {
println!("Only Foo can do this");
}
}
impl AnyTrait for Foo {
fn as_any(&self) -> &Any {
self
}
}
impl Bar for Foo {}


fn main() {
let b: &dyn Bar = &Foo{};
let f: &Foo = b.as_any().downcast_ref::().unwrap();
f.print();
}


the extra trait with as_any is required because, and feel free to laugh, Box also itself implements Any and thus the compiler cannot distinguish whether or not you'd be downcasting to a Box or the type itself.

traits allows you to write linear logic

normal functions: messy, you have to read right to left to understand it
f(x(item))


trait implementations: linear and and easy to read
item
.x()
.f()

wow that's fucking hideous

Go > Rust
You don't need multiple threads with several hundreds posts

that's just ufcs, D lets you do this without traits

said nobody with IQ > 120 ever

IQ 140 reporting in
Go > Rust

this is as 'general' as I've ever gotten downcasting to work. It ain't pretty but I guess it's something...
Maybe I'll write a procedural macro so I can just #[derive(Downcast)].
use std::any::Any;

trait Upcast: Any {
fn as_any(&self) -> &Any;
}
impl Upcast for T where T: Any {
fn as_any(&self) -> &Any {
self
}
}

macro_rules! impl_downcast {
($trait_name:ident) => (
impl dyn $trait_name {
fn downcast_ref

daily reminder Rust has fastest HTTP stack
daily reminder Rust beats go in computational benchmarks also, and it btfos everything except C

daily reminder Rust is the future for anything including webdev, unless you need 99.99999999% performance then use C or ASM

benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-go.html

techempower.com/benchmarks/#section=test&runid=019d5c9b-823f-4890-8ed9-28c0a2718bdd&hw=ph&test=json&l=yykewt-f

Attached: lood_thong.jpg (720x1000, 124K)

also, yes I use Rust, and pic related is my cute trap waifu.

who is this thot?

he is a cute boy stop calling him a thot

Attached: 1553424130449.png (591x716, 325K)

Fuck Go, and fuck Gophers, and fuck Rob Pike.

What a fucking shitty language.

Attached: 1477161635445.jpg (236x236, 8K)

I made the first thread to just talk about which one would you think will become more popular in the future but the fuck did that thread turn into and why is there a second one

Attached: 131342535.jpg (1106x1012, 70K)

Rust is the comfies language I've ever dealt with especiallty when it comes to data serialization and eserialization, I use comfy serde and just add the elements I need in the struct and get it deserialized automatically from comfy reqwest, I've never seen this degree of comfiness in any other language

Why are these thread named Rust vs Go. These languages are completely different and can be used together.

I'm a rust developer and I'd still use node for webservices. It's much easier to stick some apis together and sprinkle some react front end on top of it than use Rust. If you deal with some heavy computation, just make native library and bind it using gyp or something.
However I must admit that Rust has the comfiest json support out of all strongly typed languages.(serde)

>Rust
Polymorphism. You can discard concrete type information and reduce bunch of values to one base type and store them together, as a so-called trait object. Eg you are making a game and want to store all objects on map in one collection, so you use Vec where entity can be either Player or Mob or Collectible.
Check out std::net::ToSocketAddrs for really nice use of traits to allow specifying network address using many different methods.

For that snipped of code, you should use trait bounds, to require that T is a type that implements methods you are looking for.

>Why are these thread named Rust vs Go
Cause both are the most popular new languages, and people wonder which one will become more influential

Go because Google has better shills than Mozilla.

Attached: 1454278176197674710.png (1000x665, 67K)

Google literally doesnt give a single fuck about Go anymore

the amount of time google mentioned go in their developer conference in 2019 is around

0

Attached: 1537352365762.jpg (414x415, 114K)

they never did, go exists to keep rob pike from wandering off

>cocks in your ass vs cocks in your mouth new thread

Of you want to get it back use enum or Any.
However I personally believe there is no use case for Any in Rust at all. Also enum and any is the only way to have zero cost abstraction so it's all fine.
I think you might have some problems in the architecture of your program. You shouldn't need to cast trait object to a concrete type.

Just add fn to_any(&self) -> &Any method to your trait.
IIRC better solution for downcasting is on the way.
Also just use the goddamn tagged unions.

It's more comfy than I believed is possible with strongly typed language. Serde is truly amazing.

>Serde is truly amazing
it is thanks to the features of Rust itself, this library can never be implemented to become that comfy in any other language

>most popular new languages
swift and dart are popular new languages. rust and go are meme languages nobody uses

swift is so shit people use a JS framework to build mobile applications, i dont even know what Dart is

Rust is used by Dropbox, Cloudflare, Amazon, Chef, Deliveroo, and so many other big companies

rust-lang.org/production/users

Go is the brainlet version of OCaml.

Why not C#, it's more modern and way faster!

>Runs in a VM

M E H

>Why are these thread named Rust vs Go. These languages are completely different and can be used together.
We aren't ready yet for Perl vs. COBOL

>rustards will defend this

Attached: rustarded.png (861x359, 51K)

the absolute STATE of Rust

>language does not let me to shoot myself in a foot therefore it's bad
If you want to write code like this you might as use unsafe/C. Have fun debugging these runtime errors!

>language so bad it won't even let you assign values to array elements
Why the hell does it even have arrays then?

There's nothing unsafe about this, different array elements are being referenced.

> what is .split_at_mut()

those kids with their foot guns

Rust: Generics, no runtime, best performance, best in class type safety
Go(oogle): No generics, massive runtime with garbage collection, better performance than shit like Java but forever doomed to be worse than C++, C and Rust due to its runtime, type-what? As soon as you deal with containers, everything becomes interface, aka void*.

let ref_a = &mut array[1];
*ref a = 9;
let ref b=&mut array[2];
*ref_b = 9;

seriously what kind of real world shortcoming is this? I am not really sure why this is not allowed but this is really a very retarded use case to bash Rust

boilerplate

>best in class type safety
doesn't even have hkt

Sure, this code is valid but Rust's compiler's job is to guarantee your code is safe, not to prove it.
This code might safe. But imagine adding all kinds of edge cases to compiler, eg if two indexes are constant expressions and they value is different then it's safe etc. But what's the point? Imagine someone will change one of the indexes into runtime variable and boom... It's unsafe now and you have to rewrite your code and change the way you think about borrowing. It would also increase compile time even further. Rust is not a behemoth of all possible paradigms like C++. Learn to write probably correct code and use the Rust way. You can accomplish this using different methods with no runtime overhead.

C also doesn't allow you to do safe things that are not recommended. Eg strongly typing prevents you from assigning two structures of different types with same layout. Of you can follow strong typing, you should be able to learn borrows and lifetimes.

>probably
provably*

>Rust vs Go
They don't even compete for the same segment you massive fucking mongoloid dickhead.

Attached: ligma2.png (783x419, 307K)

Go can't compete with Rust in all use cases, Rust on the other hand can, you massive fucking mongoloid dickhead.

Today I will remind them
youtube.com/watch?v=0IMe7C5y3PU

>imagine being this much of a faggot

He is a faggot about it but he is right you gotard

I'm retarded, I've read his post backwards.
Of course Rust is better than Go in every way.

you're better of using java instead of go for all possible use cases

Rust can be as low level as C and as high and FP-like as Ruby, Rust can be used for both embedded systems on retarded ARM processors as well as distributed systems and microservices in huge servers. Golang is cancer for anything beyond a 5-endpoint REST API

>rust can be FP-like

Attached: 1539545167312.png (2512x1018, 421K)

Rust has many FP features

Go can be used where Go is useful
Rust can't be used anywhere at all

I wrote in both and Rust is more productive as long as it's not a small REST/gRPC API

Rust is incredibly productive if all you're writing is blog posts about how great it is

not that dude, but unironically rust skullfucks every single other language. seeth more gotard

How can it do anything to other languages when it can't even be compiled?

??????

retard

I think user is saying he's too dumb to understand a borrow checker with like 2 or 3 rules.

maybe you were just born with a low IQ

They don't even have similar goals, why does this thread exist?

Attached: TheyShallFeelMySuffering.jpg (692x960, 207K)

Let's first note that traits are poor man's typeclasses. Type classes have I think around 3 uses:
1) capturing functions that have similar meaning and it's simply mundane to make up a new name every time, like Display trait which is for converting to a string
2) allowing you to use sane notation for different yet still similar things, like 1+1 which could be either an integer or a floating point number or actually pretty much any kind of number that you can make from an integer
3) some generic type-level magic (because you can essentially program in type classes and you can automatically generate functions that will change their behaviour drastically depending on the type in question or perhaps will let you make use of more expressive types)

When using typeclasses or interfaces you should actually state what things implementing it should do. If you check Haskell type classes, you'll see they always have some laws in the description. Nobody will enforce you to actually implement what is supposed to be implemented there because it would:
1) require much more expressive type system and actually some sub-language with termination guarantee so you could prove things inside it
2) prove for every instance/implementation that you make that it actually fulfills the specification. You don't want to do it.

how nice are type classes in languages with dependent typing? the idea of e.g. statically proving monad laws is appealing

Why the fuck would anyone compare Go to Rust? Go should be compared to Java or .NET

Actually I have to correct myself. Go does not even have generics. It's a useless piece of shit language.

I was reading about those in Coq just recently. Indeed you can define whole Functor-Applicative-Monad hierarchy along with appropriate laws. Bad news is that it's really mundane work when you need to prove every law. When I searched for some information on it, I discovered people don't really use these classes with laws but I found very little examples overall so I'm not sure about it. I'm surely no Coq expert and actually I'm pretty new to this theorem proving thing but nevertheless I found it difficult to define a simple Applicative instance for lists.

Another cool thing in Coq type classes is that they are first-class objects. When you define any instance you give it a name and you can refer to it. And you might need to refer to those names because overlapping in presence of dependent types turns out to be a difficult problem so Coq doesn't check for it at all (the best you can do is to ask Coq to give error when he infers multiple instances but that's only when you're using the methods and not when defining instances). You can manage the database of available instances to help yourself with these issues.

Also, Coq can actually enter endless loop when looking for an instance. Overall pretty cool.

didn't need another thread for language warring shit

rust originally had channels and green threads written into the syntax just like go. that was its big selling point at the time: it was concurrency-oriented language like limbo and alef. that is why they are compared.

muhnerics

you'll find something else to whine about when go2 is out

fucking cunt

>muh it will be available in Go2
Yea how the fuck is that helping me now you bitchass hipster?

Attached: EVc3Nm0.png (770x478, 427K)

fuck golang, the most retarded language ever written, a 14 yo girl would design a better language

he^5

shit, this might be the truth.

>better performance than shit like Java
Only when a lot of concurrency is involved.

The Java version would require a separate keyboard, though.

Should honestly have its own keyword at this point for how often you need to repeat this trash.

in haskell this is just >>=

not even in that case apart from lightweight memory usage

Go does NOT have better performance than Java, please educate yourselves better. Java scales so well that Netflix, Amazon, Alibaba and Google all rely heavily on it for their core systems