Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Workaday Wizard
Oct 23, 2009

by Pragmatica
I toyed with Rust when it was 0.6~ and I am looking forward to trying it again.

Is there a recommended autocompletion tool?

Adbot
ADBOT LOVES YOU

Workaday Wizard
Oct 23, 2009

by Pragmatica
Thanks whoever fixed the thread tag :)

Workaday Wizard
Oct 23, 2009

by Pragmatica
Rust's team is very open and welcoming to the point were they kicked a guy out for being too spicy. It's a shame they get blamed for what is an industry-wide problem.

Now that I think about it what language design team actually have a woman in it?

Workaday Wizard
Oct 23, 2009

by Pragmatica

Redmark posted:

I haven't followed Rust too closely, but didn't that guy have repeated and intense arguments with the core developers? Seemed like more a case of open personality conflict than being "too spicy".

His arguments were technical as far as I recall.

Workaday Wizard
Oct 23, 2009

by Pragmatica

xgalaxy posted:

What is everyone using for Rust dev in terms of IDE-like capabilities? I'd like to start looking at Rust more and I develop on both Windows and OSX machines. I see that there are Atom plugins, SublimeText plugins, VS Code plugins, and IntelliJ plugins. Which of these are the most mature and actively developed and supported? Is there any thing I'm missing? I use vim too but primarily on OSX.

Thanks.

The IntelliJ plugin is very good. Also Rust Language Server (https://internals.rust-lang.org/t/introducing-rust-language-server-source-release/4209) is promising.

Workaday Wizard
Oct 23, 2009

by Pragmatica

Asymmetrikon posted:

I think my least favorite thing about refactoring so far has been trying to isolate parts of a chain of iterators. The result of a .map().filter().whatever() has a gnarly result type.

Let the compiler help you! The following will give you a compiler error with what you need:

code:
let () = my.very(long).expression(blah, bleh, bloh);
e: This works by failing to destructure a pattern. If this actually compiles then your expression is returning `()`.

Workaday Wizard fucked around with this message at 21:02 on Jan 3, 2017

Workaday Wizard
Oct 23, 2009

by Pragmatica
intellij-rust is a much more straightforward ide that doesn't require anything extra. makes development real easy.

Workaday Wizard
Oct 23, 2009

by Pragmatica

General_Failure posted:

So IntelliJ rust is far enough along to be usable?

It's good enough for me, a terrible programmer.

The most important feature for me, quick navigation between files and definitions, works really well even with stuff in the standard library. I also find the code outline feature really helpful especially when reading third party code with many trait implementations.

You should try it anyway. It won't take much to set up (get intellij, install plugin, point plugin to rust toolkit, voila) and it works with regular old Cargo projects.

Workaday Wizard
Oct 23, 2009

by Pragmatica
IIRC the if let thing is because it's sugar for match.

Workaday Wizard
Oct 23, 2009

by Pragmatica

xtal posted:

You know what the tech community is really missing out on? Bureaucracy​

I don't see how having a documented change process is bad v:shobon:v

Or are you referring to something specific?

Workaday Wizard
Oct 23, 2009

by Pragmatica

Asymmetrikon posted:

Has anyone used the Rust IntelliJ plugin with rustup? If so, how do you get it to find the standard library sources? It comes up with an option to download them, and I click on it and it doesn't error out or anything, and I can check that the rust-src component is installed and the rust sources are downloaded, but no matter what I do the plugin doesn't seem able to find them. Even if I manually point it at any of the folders in the source path, it says those are invalid.

I didn't do anything special.

Try building your project.

Workaday Wizard
Oct 23, 2009

by Pragmatica

ssergE posted:

Is this if you do the "New Project" dialog in IDEA? If so, I had the same issue but found I could leave it blank and it sorted itself out automatically upon doing the initial indexing.

Here's a problem I've having at the moment with the plugin: How do I get IDEA to run the Visual Studio 2017 command prompt environment (vcvars64) to allow cargo to work properly (requires link.exe)?

EDIT: Apparently it's a known issue with VS2017 and rustup/cargo.
https://github.com/rust-lang/rust/issues/38584
https://github.com/rust-lang-nursery/rustup.rs/issues/1003

I ran "Developer Command Prompt for VS 2017", dumped the variables with "set > env_file", then added the variables to my running configuration (.idea/workspace.xml).
This way I was able to build and run directly from Intellij.

Workaday Wizard
Oct 23, 2009

by Pragmatica

Karate Bastard posted:

That doesn't sound much like Scientology at all!

But joking aside, is there such a thing nowadays similar to that go tutorial? That was super efficient in getting me into go, to understanding the key points that set it apart from other languages I knew from previous and how to think about it.

Rust didn't have that in the past (afaik?) so I'm still an ignoramus. Does it now?

The book is nice (check out the second edition first): https://doc.rust-lang.org/book/
There is also Rust by Example which is useful: https://rustbyexample.com/
Additionally you might find this guide useful later after you get the basics: https://github.com/kmcallister/rustic-symmetries

e:
The docs are quite useful and contain a lot of examples: https://doc.rust-lang.org/std/
PS: You can view the actual code from the documentation pages by clicking [src] at the top.

e2:
Don't forget to check out the super friendly user forum: https://users.rust-lang.org/ and IRC: #rust-beginners @ irc.mozilla.org

Workaday Wizard fucked around with this message at 15:25 on Jun 30, 2017

Workaday Wizard
Oct 23, 2009

by Pragmatica

xtal posted:

That's dumb as hell

Not really. It makes writing small programs easier and if you don't use it nothing changed for you anyway.

Workaday Wizard
Oct 23, 2009

by Pragmatica

xtal posted:

The cost of calling unwrap or expect once is not worth this oddity which is unique across all programming languages I've used.

How do Java, C#, Python, etc. report unhandled exceptions?

Workaday Wizard
Oct 23, 2009

by Pragmatica

Hell yeah. This will get rid of a ton of headache.

Workaday Wizard
Oct 23, 2009

by Pragmatica
That quiz kicked my rear end. Good thing I stick to basics.

Workaday Wizard
Oct 23, 2009

by Pragmatica

Mirconium posted:

I have a philosophical question for the thread:

Every day I program in any language besides Rust, since learning it, I wish more and more that every language was like Rust. The safety is amazing, the speed is amazing, but the thing I enjoy the most that I wanted to tear my face off about with Python, and bash, and to some degree C and all the other programming languages I've learned/tried to learn before is the total lack of ambiguity. In python even after years I have to think for a couple of minutes if I am about to pass by reference, pass by value, or do god knows what else. The silent fails on sorting nan-containing lists still haunt my nightmares.

But I'm really worried that the Rust team has no idea what the hell to do about their grabage library ecosystem.

There are like... 3 major libraries I'm totally sure I can trust outside of the stdlib, and tokio isn't even stabilized yet.

If you want to do linear algebra there are 2 major libraries, like 5 minor unsupported ones, and they all have overlapping features, yet each one is also missing important stuff. nalgebra has a bunch of types named poo poo like "Matrix2" "Matrix3" "Matrix4" etc, so I'm not particularly optimistic about the fundamental design choices. ndarray cannot invert a matrix without linking to BLAS or LAPAK.

Trying to get in on the development seems daunting since a) they're not even theoretically stabilized yet, b) they are pet projects by Some Guy, so I have no faith they will be worth developing for or even alive in another 6 months.

Anyone who's been around languages that lived through this maturation period? Do you figure that Rust will eventually have libraries worth a drat? Or is it doomed forever to be a neat language that dies in obscurity because crates.io is basically the pacific garbage patch with some tasty tuna in the middle?

Edit: I'm slightly optimistic since being able to compile down to web assembly is a very neat trick that should hopefully encourage more corporate usage, but the obstinate refusal to even attempt to curate crates is very very ominous to me.

I can't speak for others but in my experience the libraries are getting better and more ergonomic. The major example for me personally is actix-web.

I think the data science/math stuff is gonna take a longer time to improve since it's really hard to justify anything but Python for those tasks.

Workaday Wizard
Oct 23, 2009

by Pragmatica

street doc posted:

Both loadenv and dotenv are pulling up my system environment variables, but not the .env in the drat folder. Wtf

It might be a permissions issue. Check if the user running your application has access to .env file and that the file is in the current working directory.

This could happen if you accidentally create the .env file while root.

Workaday Wizard
Oct 23, 2009

by Pragmatica

Hed posted:

Sorry it took so long to reply. I decided to do some more research since I'm new to Rust and converting a program from Python. With a fresh set of eyes, I sat down and realized I hadn't namespaced the function. I popped in glob::glob() instead of glob() and everything immediately clicked!



Although, then it said the `use glob::glob` line was an unused import so I need to go read more about that stuff as well, since I would have thought `use glob::glob` would make it so that the glob() function I was using came from the glob crate. Thanks for your help, I'll need to remember the invalidate and restart cache thing in the future.

Just FYI you don't need `extern crate blah` for most cases anymore. You can just `use` whatever you want from the external crates directly.
More info: https://doc.rust-lang.org/nightly/edition-guide/rust-2018/module-system/path-clarity.html

Workaday Wizard
Oct 23, 2009

by Pragmatica
Testing...

Rust code:
// `elided_input` and `annotated_input` essentially have identical signatures
// because the lifetime of `elided_input` is inferred by the compiler:
fn elided_input(x: &i32) {
    println!("`elided_input`: {}", x);
}

fn annotated_input<'a>(x: &'a i32) {
    println!("`annotated_input`: {}", x);
}

// Similarly, `elided_pass` and `annotated_pass` have identical signatures
// because the lifetime is added implicitly to `elided_pass`:
fn elided_pass(x: &i32) -> &i32 { x }

fn annotated_pass<'a>(x: &'a i32) -> &'a i32 { x }

fn main() {
    let x = 3;

    elided_input(&x);
    annotated_input(&x);

    println!("`elided_pass`: {}", elided_pass(&x));
    println!("`annotated_pass`: {}", annotated_pass(&x));
}

Adbot
ADBOT LOVES YOU

Workaday Wizard
Oct 23, 2009

by Pragmatica
Neat! Good stuff admins.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply