/frg/ - Friendly Rust General

Previous thread: Talk about anything related to the rust programming language

Attached: rust.png (2000x2000, 101K)

Other urls found in this thread:

github.com/rust-lang/rust/issues/28008
docs.rs/smallvec/0.6.3/smallvec/
matthias-endler.de/2018/fastcat/
reddit.com/r/rust/comments/6zbl57/do_the_rust_developers_support_and_advocate/
github.com/pingcap/tidb
github.com/pingcap/tikv
twitter.com/AnonBabble

What is currently the best way to implement two dimensional vectors in Rust?

it's kind of crappy

Attached: smug.jpg (242x208, 9K)

spbp

growing or statically sized? [[0u8; 4]; 4] for static and vector of vectors for growing
I remember the Box::new([[0; a]; b]) used to have (oh, still has) a bug where on debug runtime, it was fist placed on stack, then dynamic memory was allocated and it was copied; which would block your stack on big arrays but was optimized out on release optimization.

ok now it's even better, it blows the stack on release as well :^)

but you can use this 3 years old experimental feature with is only allowed on nightly
github.com/rust-lang/rust/issues/28008

Or you can just unsafe it.

rust everyone

Attached: e58.jpg (500x370, 26K)

I read somewhere that vectors of vectors was bad and that you're supposed to use a single dimensional vector that uses a mapping function

could be because of alignment in memory reduces cache misses
really depends on your demands on growing

>can't do something, just unsafe it like any other language
rust in a nutshell, everyone
and they wonder why their pretentious shit isn't taking over the world

or allocate vector with known capacity, initialize it manually and cast it to boxed slice

Just use the smallvec crate:
docs.rs/smallvec/0.6.3/smallvec/

rust confirmed 3x faster than C matthias-endler.de/2018/fastcat/

>they're still delusional

Attached: laughing.jpg (400x386, 34K)

C BTFO

>portable standard syscall slower than optimized OS-specific non-standard syscall
ftfy

Ruby is also faster than C in that usecase. It's just calling an external library function, ffs.

It's over, rusties.

Attached: theLogo.png (400x400, 15K)

ATS is a research language. Rust is turning into a relatively mainstream one.

It's harder to make a language mainstream than to make it good.

>stupid shit question
>20 replies in this thread
>nobody has an acceptable answer
>mfw

Kek

>Rust is turning into a relatively mainstream one.
get back on your meds

can rust get me a job?

It objectively is on that trajectory by any objective measure, though. Don't blame him for your stupidity.

it really isn't

Yes it is.

you're on Jow Forums, stop pretending you're ever going to get a job

I have a job and i love posting on Jow Forums

Last thread people was talking about using rust for gamedev but the biggest issue is that directx and opengl are coded in c/++ and with that layer of obstraction an engine running on rust won't have any advantages.

Attached: 1532062319724.jpg (720x480, 46K)

What does a FIFO linked list look like in rust?

A lot of data structures have to be implemented unsafely. This isn't exclusive to Rust. Rust just gives you the option to make those features unavailable if you're not using them, kind of like const in C.

The "unsafe" keyword is so retarded. Why is it called unsafe? It implies the code inside that segment is unsafe, even though it probably is safe.

Would you prefer "trusted," since it delineates the trusted codebase?

>If you want to make dynamically allocated arrray in Rust, you first put it on the stack, allocate space on the heap, then copy it over
Am I getting this right? That is absolutely ridicolous if true

That the rendering part is done with C doesn't prevent you from making the rest of a game in Rust

Reminder that if you
- Always use rule of 5
- Always use smart pointers
- Never use new, other than in classes in combination with smart pointers
- Use const as much as possible
-Never use raw pointers

in C++ you will have the same memory safety guarantees that rust has but will atually have a useful language with a big ecosystem of libraries.

>- Use const as much as possible
but then you have fucking stupid type names like cost long long * const instead of rational ones like Box

rust is still more pleasant to program in

How am I supposed to be part of the community when it is this retarded?

Attached: imagine_being_this_cucked.png (771x578, 81K)

>1.28 is out today
Still waiting on
Waiting for
> Fields in traits
>Higher Kinded Types
>Procedural macros
>Const generics/pi types.

Attached: jBvIort.jpg.gif (500x691, 1.27M)

why the fuck would you have const type * const anything?

For the same reason in rust you'd write mut twice.
A const is for the pointer and the other is for the pointed data.

yeah but what's the point

it is a constant kind of point

>What is currently the best way to implement two dimensional vectors in Rust?
Delete rust and install mingw

If it's dynamically sized, then sadly I think you have to use something like ndarray or implement it yourself over a 1d vector.

What's the best way of writing a doubly linked list in Rust without using unsafe codes/prepackaged libraries?

RefCell? Don't know why you would honestly need to roll your own doubly linked list though.

reddit.com/r/rust/comments/6zbl57/do_the_rust_developers_support_and_advocate/

Attached: rustcuck.jpg (703x707, 96K)

Don't ever disagree with Rust team
You've been warned

Attached: rustcuck.png (865x229, 21K)

it's literally a language for masochists what would you expect

DELETE THIS

Attached: rustcucks.png (231x218, 7K)

That won't work for all the operations I need. I want to write a LISP like data structure.

Guess I'll stick to C++...

It's funny how they say that his personal opinions shouldn't affect his contribution to the project, yet time and time again leftists always oust someone from conferences and businesses because they don't have a leftists ideology. Case in point, Moldbug, specifically Steve Klabnik complained that he shouldn't be allowed to speak because of his alt-right views.

They have two sets of standards, remember how they ousted the CEO of Mozilla.

Rust is developed by academics with no industry experience whatsoever and a target audience of webshits who never touched the actual bare metal

The academics have a great idea, the problem is, as usual, they have a problem implementing it.

Academic ideas work well in theory, but never work at all in practice

DOUBLY LINKED LIST
O
U
B
L
Y

L
I
N
K
E
D

L
I
S
T

So far, that seems to not be the case with Rust.
The mistake they made was releasing 1.0 so early.

Attached: 0a6a36c982de0770f069c50b9fa14928.png (1113x1200, 801K)

Rust won't ever be used in production, though

Unless something better comes along, it will, eventually.
Give it a bit to get to a real "1.0", I know it's a meme at this point, but it really only needs a year or two at the rate it's going.
Unless Mozilla abandons it, the SJWs start making retarded decisions other than policy crap like slave/master, or some other weird event, it will probably be used in production after that.
There are some big projects using Rust now, too.

>There are some big projects using Rust now, too.
explain these projects, besides it being used inside Mozilla.

Kek

I've convinced my work to do our next big project in Rust rather than SEEPLES

>Fields in traits
This sounds like a mistake.

>Rust is turning into a relatively mainstream one
You mean it's transitioning into one you shitlord

>can rust get me a job?
Yes, as a janitor.

There are two good ways. Vec of Vec is stupid unless you are doing row/column manipulation.

Compile time sized multi-dimensional arrays are just arrays of arrays. [[0u8; x]; y]

Runtime sized multi-dimensional arrays are Vec + a wrapper type which indexes into the vector, ie (y*s_x + x). This is ultimately what they are in any language, if you don't want to dereference multiple pointers.

If you are doing lots of linear algebra / need something more complicated, then the answer is "use a library". In Rust that's nalgebra.

I hate this meme, and I hate that so much of the Rust community doesn't understand that /you are supposed to be able to use unsafe and raw pointers in library code/. The point of Rust is that you can put strict boundaries on where you use unsafe memory accesses.

But the vast majority of code I write day to day can be easily checked by the Rust compiler without any burden on me as a programmer.

Which industries is Rust used in? And why should I learn it over sage c#?

>Which industries is Rust used in?
None.
And why should I learn it over sage c#?
You don't.

What are the decent open source projects one without ton of experience can participate?

There is practically zero usage overlap between C# and Rust, the latter being targeted at C++ and to a lesser extent C.

>Which industries is Rust used in?
Potentially everywhere C++ is used, at the moment though, the only project with some impact I know of is Mozilla's 'servo' browser engine used in Firefox.

I don't know. C++ is already used a lot and people have the expertise for it already. Plus C++ is way more powerful than Rust and you have a lot more flexibility in the abstractions you can make.

TiDB, a scalable MySQL alternative is made by rust. And I happened to know some companies actually use TiDB in production.

I dislike Rust because its community is infiltrated by cultural marxists and actively using it would imply that I support their actions.

github.com/pingcap/tidb
I don't see any Rust.

github.com/pingcap/tikv
TiKV, the underlying data store, is written in Rust.

Go engine on top of Rust core is not a bad way to structure a project like this, IMO.

Yeah, I just noticed that.

We should carve out our own Rust community without the SJW faggotry.

As a matter of fact, it can, if you're actually good.

Email your resume/github to [email protected] if interested.

Yeah, it's absolutely retarded, they never managed to decide on an emplacement design that people were okay with, so they don't do it.

That kind of thing tends to get optimized out in release builds tho.

And lower performance because everything gets moved to runtime rather than compile time, pls.

Also shallow constness is retarded, stop spreading lies.

What about specialization? We'll wait forever my friend, they're too busy with the ergonomics initiative and CLI bullshit for babbys.

It's being used in production right now.

Looks like 1C logo

>because everything gets moved to runtime rather than compile time
RAII is compile-time, smart pointers are RAII. I don't see how this adds dynamic dispatch into anything

Besides assembly, is there a version of Rust that has a nicer syntax?
Statements like
_ => println!("....") or ->
are ugly af.

[=](i: i32) { } takes environment 'by value': equivalent to move |i: i32| { }

[&](i: i32) { } takes environment 'by reference'

[&mut](i: i32) { } takes the evironment 'by mut ref'

[](i: i32) { } has no closure, type equivalent to a plain free function


Coming from C++ it's not making much sense.

>We should carve out our own Rust community without the SJW faggotry.
Good luck with that, the whole organisation is a SJW hive.

Basically, if you don't think that white people, particularly men, are preying on minorities and have achieved their skill purely through white priviledge, then you should not write code in Rust.

there are a dozen other reasons you shouldn't consider rust.

This, seriously, it's like they looked at C++ templates and said, 'we can do worse than this, much worse'.

It even mixes CamelCase and under_score as idiomatic Rust code, it's a fucking mess.

The code for RAII gets ran during runtime, references and ownership in Rust doesn't.

std::shared_ptr is reference counted so runtime and is equivalent to Rc/Arc in Rrust, std::unique_ptr usually comes with a small runtime cost as well depending on move constructors and it's equivalent to just passing a value in Rust.

I want to make a real-time application that a exe interacts with by sending packets to/from the server, is rust a good language for this or should I consider something else?

Program*

That's quite untrue, I know a lot of people, some even working for Mozilla who disagree with the notion.

But fighting them is just a waste of resources and time, so why would you do that? Just go with the flow. You don't have to be friends with them and you can still disagree on technical merit.

Because in a community like that of Rust, I am very likely to come across people holding these views on white males such as myself, and should I enter a technical disagreement with someone who is not a white male, it will be used against me.

I mean seriously, the Rust Community Team LEAD is Ashley Williams, the same feminist LGBTQ advocate who tweeted 'kill all men' among other things.

No thanks, I won't knowingly put myself in such a shitty position.

From my experience going to Rust related events, that is not the case.

I met Ashley Williams and Steve Klabnik and I heavily dislike them, it's fairly easy to avoid them as they stay in their own hugbox anyway.

If you avoid an actually good piece of technology for the people around it you're as bad as them, and if you had the power to do what they do to people they disagree with you'd do the same.

There's other good technology out there, without the SJW baggage, if it was Rust or nothing I would buy your reasoning.