Rust Language

Has anyone here been doing anything interesting with Rust?
C used to be my primary language, but recently Rust has taken it's place. It has allowed me to do really great stuff, really quickly, and without compromising.
Some people tell me that maybe from C it's a leap, but not so much from C++. I could never get into C++, however, as it feels like such a hack.
What do you guys think about it?

Other urls found in this thread:

redox-os.org/news/gsoc-self-hosting-final/
nim-lang.org/
ponylang.org/
twitter.com/SFWRedditVideos

Everything about Rust is cool but the compile time

And the politics.

The game studio Chucklefish made a custom Rust game engine that's now running on three major consoles.

I've used Rust, I quite liked it.
But C++ is still better, and Rust is still lacking in features.

No kidding? What's it called?

What kind of programs do you fags even write? I can't ever think of anything to try and do

The game? Spellbound, I guess
It's about witches or something

It's nice, I like it so far. Avoiding bounds checks can be an issue when trying to squeeze out performance, but shouldn't be an issue for 99% of Sup Forums.

this

I don't get this meme. Rust has modules; how can it possibly be worse than C++ here? Is it LTO?

That looks cool, but I was talking about the name of the engine.

Right now I'm writing a program to process csv files from my bank to track and analyze my spending and another program that will help me log my time, so I can know exactly when and how much time I spend wasting my life away. I'm also thinking about throwing machine learning into the mix with Google's new Tensorflow thing, somehow, but that might have to be something different entirely. Ideally I'll spawn The Singularity, but I'm thinking instead of trying to make something like AlphaGo Zero but for a game called The Game of Y. I have a handful of other ideas, but I don't have the time for all of them.

>Replace C with Rust!
>C is dangerous!!

$ldd hello_rust
...
libc.so


sheep

I'm used to going over my code rather than running it recklessly, so I don't really recompile that often. rustc compliments this nicely by doing a LOT of checks for you that you would have to do otherwise or during run-time, that would take you longer to do, and that you wouldn't do as well or as exhaustively. These checks are really fast, too. The long waiting time is after the code has been checked through and through such that errors are due to your solution, not minute details regarding resource management. Also, the time the compiler takes is indicative of the time you didn't take writing stuff out without really nice zero-cost abstractions. Well, that is in a perfect compiler. For big project and small changes I'll concede testing can be quite time consuming as of now; that is why the team is currently working on incremental compilation I believe. Also, not everyone's workflow and application is the same as mine, so obviously faster compile times are always a good thing, but I think, for the most part, they should not be a deterrent for most people trying out the language or even building a serious application of system's program.

I believe that's mostly there to allow Rust code linked with C code to share the same heap. Does away with that "whose free is it anyway" game you have to play with CRT on Windows.

It should be possible to do without libc dependency but as with all things Rust, if Mozilla doesn't need it it probably doesn't work so good.

mumble mumble, something excuses

the digits have spoken

lmao
The kernel is written C, so it's pretty much a requirement, or at least for the sake of not re-inventing too many wheels, to just link with libc. You can make safe wrappers of most libc functions.

>y-you can make s-safe wrappers around unsafe code user

hahahaha

satan owned your thread
it's finished
give up

It's been pretty difficult learning it. Referencing vs borrowing and strings vs slices etc

>libc.so
>part of the OS
>the only way to call sys functions
>every programming language is forced to use it
>C luddites only weapon for saving their dying langauge

>mumble mumble, something excuses

kek; bretty much.

Don't get me wrong; not actually following through on support for this kind of thing while parroting the "C is deprecated" meme is one of my biggest complaints about the language. That, and the complexity trend that's turning it into Nu-C++.

>Rust
>"systems programming"
>literally incapable of sys calls without C
>admits it

Go doesn't need libc
Really makes you think

daaaaaamn
those digits are on fire

Borrowing is taking a immutable or mutable reference of something. `String` is pretty much a byte vector. `str` it the type used when you write `&str` which is a slice of a string in the traditional immutable sense. A slice is a reference to a section of a data structure. It's very general which is why you can have &str from a String or a Vec. It's pretty much a special wrapper for &[u8] because it's a fundamental datatype.

Who is saying C is deprecated? It will always have a use because its power is pretty much limitless. Rust imposes sane limits for writing sane programs, but obviously a limit is a limit, and C is going to fill that niche.

>Who is saying C is deprecated?

Mostly just shitposters on Sup Forums and clueless web devs on Hacker Jews.

Making syscalls is always a hack and a pain in the ass. Even in C you either have to write the part in asm or use a compiler extension that is not part of the language because C is a universal and simple language. This is why libc, unistd.h, etc. exist, which are themselves "safe" wrappers of asm directives over the Linux kernel api. Rust forwent, for now, the writing of those functions because C already did it, because C is just as "incapable" of doing syscalls.

on NT, unless you compile with MS C/C++, (almost) everything else compiles against private system libc msvcrt.dll, unfortunately

i.e. I use mingw-w64, so there's usually _only_ one malloc()/free() pair present at any given time

But if you want to use DLLs built against mscvrt in a mingw program or vice versa, you're screwed. In that case you must keep track of which lib owns the memory and always pass it back to the same lib to free it. If you free stuff allocated by msvcrt malloc with mingw free, it explodes.

On Loonix nobody bothers with this. Everyone just links against the same libc and lives in harmony.

>zero-cost abstractions

What does this even mean?

What features are you wishing for?

Take other languages.
I want to make a class so I can make multiple objects easily.
I want to inherit some features and override some shit.

I could do this all without classes but classes are much easier. Classes are an abstraction. The further you abstract, the more costly it is since it needs to be tracked etc during run time.

Zero cost abstractions don't have that run time cost.

>Who is saying C is deprecated? It will always have a use because its power is pretty much limitless.
typical bullshit C memes, not even funny anymore, I wonder if all the kids in mom's basement pretending to be grey bearded hackers really expect anyone on this thread to take them seriously

there's cargo check for when you just want to see if it compiles

you don't have to link to libc but you'll lose std

I'm not confused about my gender identity so I have no interest in Rust.

It's better than it was before, but far from ideal.
The modules is a meme at the current stage. Modules are just being combined in one file during compilation if I am not mistaken. You don't have to recompile everything if you put things into different crates (libraries), though. That was the only way to speed up compilation for a long time. They were promising to make the process faster and they did some things that improved performance. There are several layers of abstraction (IR) between the language (Rust) used by a developer and the language used by LLVM and these layers multiply. Currently there are 5 (or even more) such layers (picrelated)

>Modules are just being combined in one file during compilation if I am not mistaken.

So, basically yes, it's LTO (or more properly, cross module optimization) that's the issue then. I'd think it should be possible to disable some of the cross module passes, or (if the concept of a module doesn't survive long enough to be useful) divide up the IR in some other way and parallelize.

I sure hope the default model is to do all passes serially for the whole program at once. That'd indeed be insanely slow.

>I sure hope the default model is to do all passes serially for the whole program at once.

Obviously I meant that I hope it *isn't*. Whoops.

It's not LTO. LTO is not enabled by default.

The engine doesn't have a name, but they think about publishing the sources when the game is close to release.
The chief developer did a AMA on leddit about the details

Okay, guess we have some confusion of terms here. I'm coming from a C background, where any optimization or code generation involving multiple source files means LTO. Maybe the mechanics are a bit different in Rust but fundamentally I think we can agree the key issue is with the work unit of the compiler being too large, or a lack of practical incremental compilation. Yes?

Well, what I've done is to compile a window manager written in Rust (I forgot its name) and it took about 30 mins on my i5 4th gen laptop, wasn't it too long?

By compile time, I meant the time to build a source code unit into an object file, module is just a way to reduce build time for a big project in long-term and there are some build systems for C++ do use it
Zapcc also uses it

30 minutes for a window manager is a bit crazy IMO. A clean build of the entire Linux kernel for a typical modern PC takes around that long, and it uses recursive make (rather inefficient).

Compile time computations.
Much finer borrow checking. (Currently being worked on, but taking fucking ages. See non lexical lifetimes)
Better architecture support. Rust is currently unable to compile to mips1.
Non type template parameters.
I'm sure there's more but those are the ones that immediately come to mind.

That's pretty long, but I couldn't tell you if it was *too* long because I don't have enough information.

>Has anyone here been doing anything interesting with Rust?
Yeah, I switched from C++ to Rust for my personal projects ~2 years ago, it's really good. I've played with some primitive game programming, networking and even contributed a little to RedoxOS.

Redox is a complete joke.
Haiku is better.

>Spending 16 years to reimplement a dead OS
I mean, BeOS was probably innovative back in 1996.

Does Rust itself run under Redox?

You can use asm directly

Yes, more or less, there was GSoC project this year: redox-os.org/news/gsoc-self-hosting-final/ .

Rust is for faggots who are too stupid for C

You really swallowed the entire koolaid didn't you?

Mostly applied to abstractions which have a compile-time cost in lieu of a runtime cost.

Nothing wrong with that.

ok. to make it simple, is this Rust good for me to learn as a complete beginner?

i want to create small simple native applications.

>is this Rust good for me to learn as a complete beginner?
No, learn C first.

Don't optimizing compilers for most languages do this already for abstractions that can be optimized away at compile time? How is Rust's compiler different from others in this respect?

Rust people, is it common to use a lot of enums? Is that considered a 'Rust' way of doing things?

it was a different person who answered you. But yes, I am with you. Lack of incremental compilation and decent parallel working are key problems here.

There is something wrong with thinking Rust is a legitimate tool for everyday programming instead of a fleeting curiosity that nobody will remember in another five years.
At least Scheme is still around and has a book about it.

Not 'Rust' way, but functional way. It's called "Algebraic data type", though.

Sum types are very useful, I use them a lot and miss them when they're not in other languages. It's not a particularly Rust thing.

Actually that is great. For now Redox was dependent to another system so it could only be considered as a toy. If this gets finished Redox actually becomes relevant.

Languages made for a particular purpose usually survive. As it isn't a language someone made for fun (e.g. Nim and others) and it backs up an entire project (Servo), it certainly is legitimate.

If only they were similar. Compare instead to C++ and D. C++ is shit. D from various source I've read seems better.

Bitch, our company uses Nim in production.

is it you, mention nim at every occasion guy?

The compiler that generates LLVM bytecode is not optimized for compile time performance yet.

Making syscalls is dirt simple and requires like 5 lines of assembly at most. Better yet, just write a generic "syscall" wrapper and you only need to write assembly in one place.

Tell me about Nim. It looks awesome, but I haven't had the time to learn it.

>you either have to write asm or use a compiler extension

>you just have to write asm, or maybe even have a compiler extension!

gee thx user

Yup. Got IP banned for a a few days during my ad campaign. They deleted all my posts too lol

nim-lang.org/

Also, guys check out Pony: ponylang.org/