|
Generalising the return type of main just got merged: https://github.com/rust-lang/rfcs/blob/master/text/1937-ques-in-main.md
|
![]() |
|
![]()
|
# ? Jun 13, 2024 15:47 |
|
That's dumb as hell
|
![]() |
|
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.
|
![]() |
|
xtal posted:That's dumb as hell Do you have any reasoning behind that hot take?
|
![]() |
|
taqueso posted:Do you have any reasoning behind that hot take? The cost of calling unwrap or expect once is not worth this oddity which is unique across all programming languages I've used.
|
![]() |
|
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?
|
![]() |
|
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. If you keep defining main() { then nothing will change.
|
![]() |
gonadic io posted:Generalising the return type of main just got merged: https://github.com/rust-lang/rfcs/blob/master/text/1937-ques-in-main.md Awesome! This will make writing a lot of small programs and example code much cleaner.
|
|
![]() |
|
xtal posted:That's dumb as hell The only thing I saw about it that seemed odd was this line: quote:Therefore I am proposing that all the standard impls' report functions should use 0 for success and 2 for failure. I'm not sure I'm convinced by their explanation on why EXIT_FAILURE shouldn't just be 1.
|
![]() |
|
I'm playing with Rocket and Diesel -- they're the first real frameworks I've tried in rust (tokio is probably the largest library I've dealt with). CodeGen and Macros are going to ruin this language. http://docs.diesel.rs/diesel/macro.infer_table_from_schema.html I'm flabbergasted that the compiler even makes this possible. I'm doubly flabbergasted that Diesel presents this in their tutorial as the way to generate their schema.
|
![]() |
Is there a good physical book about rust? I learn best just by reading paper.
|
|
![]() |
|
MALE SHOEGAZE posted:I'm playing with Rocket and Diesel -- they're the first real frameworks I've tried in rust (tokio is probably the largest library I've dealt with).
|
![]() |
|
I think this is a pretty bad idea too but, to be fair, languages like Java do a ton of this stuff at compile time too, e.g. Jooq. What I dislike most about macro based DSLs is that inevitably they will end up like C++-style template monstrosities that are poorly documented and where there is no hope of sane autocompletion.
|
![]() |
|
Sagacity posted:I think this is a pretty bad idea too but, to be fair, languages like Java do a ton of this stuff at compile time too, e.g. Jooq. What I dislike most about macro based DSLs is that inevitably they will end up like C++-style template monstrosities that are poorly documented and where there is no hope of sane autocompletion. What concerns me is that rust made this incredibly easy. Yes, I was importing a crate called `_codegen`, which should have tipped me off, but beyond that it's just a macro. If this were enabled as part of a plugin, it would be a different story. Macros should not be able to do this, and now I'm going to have to be incredibly suspicious of every single macro I encounter because it could be doing network insanity at compile time. (I could be mistaken about some of this, I haven't actually figured out how this macro works yet). DONT THREAD ON ME fucked around with this message at 19:59 on Aug 12, 2017 |
![]() |
|
MALE SHOEGAZE posted:What concerns me is that rust made this incredibly easy. Yes, I was importing a crate called `_codegen`, which should have tipped me off, but beyond that it's just a macro. If this were enabled as part of a plugin, it would be a different story. Macros should not be able to do this, and now I'm going to have to be incredibly suspicious of every single macro I encounter because it could be doing network insanity at compile time. (I could be mistaken about some of this, I haven't actually figured out how this macro works yet).
|
![]() |
|
Ralith posted:"just a macro" can't do this. At a guess, the macro expands to a custom derive, which IIRC can run arbitrary code. Understanding what the macros you're using do is good practice regardless, of course. Yeah, if you look at the source you get this: code:
|
![]() |
|
Weird, it never occurred to me that you could use custom derive like that. I assume procedural macros will allow similar behavior? If so I really hope they gate them somehow because I really don't want things like this to be standard macro behavior. But to Ralith's point, it's not like I ever really use a macro without understanding what it does, so maybe it's okay.
|
![]() |
|
Procedural macros should generally be the exception, at least once declarative macros 2.0 lands. Hell, any kind of macros at all should be the rare exception, much less complicated ones. It's good to have escape hatches in a language, even if some people will always be tempted to treat the escape hatch more like a revolving door.
|
![]() |
|
Ralith posted:Procedural macros should generally be the exception, at least once declarative macros 2.0 lands. Hell, any kind of macros at all should be the rare exception, much less complicated ones. It's good to have escape hatches in a language, even if some people will always be tempted to treat the escape hatch more like a revolving door. I think I've misunderstood the state of macros. My understanding was the procedurals macros were macros 2.0, but it sounds like you're saying that's not the case. Guess I have some reading to do.
|
![]() |
|
I think the need for macros will go down a bit once const_fn is stable. Certainly that's what I mostly use them for myself.
|
![]() |
|
gonadic io posted:I think the need for macros will go down a bit once const_fn is stable. Certainly that's what I mostly use them for myself. And impl Trait, one of the areas I used macros the most is where I basically wanted to just treat heterogeneous objects as a uniform trait and a trait object was insufficient. (Such as selecting between and initializing different implementations of the same interface based on user input, and then doing the same thing to it regardless). E: Like code:
Linear Zoetrope fucked around with this message at 14:48 on Aug 14, 2017 |
![]() |
|
Does anyone know how to test libloading plugins? I have the following sort of thing: [Generic language] -> Plugin Loader/Context manager/etc (extern C no mangle cdylib Rust crate that uses libloading) -> Rust plugins (no mangle dylib Rust crate) I'd basically like to test the Plugin loader, but to do that I need a compiled plugin. I've screwed around with making a dylib plugin_test crate and putting it in dependencies and dev-dependencies, but I've crawled all around the target directory and it looks like if it's written in Rust it's automatically linked statically as a .rlib and there's no .dll/.so/.dylib in sight. Additionally, Cargo doesn't (yet) support test-specific build scripts. It's not the end of the world to write some scripts to run on Travis/Appveyor that manually build a test crate and set some test environment variables, but I was hoping for something a bit more Cargo-friendly.
|
![]() |
|
Did a bunch of tutorials and am mostly through the official Rust book. Really liking the convenience of "cargo build" and the .toml file as opposed to cmake, which has been my White Whale for many years because I am dumb and bad. It feels like a compromise between Javascript's npm stuff and C/C++'s make files.
|
![]() |
|
Cargo is easily Rust's best feature. Every time I have to dive back into C++ or Python land (and I'm a PhD student doing research work, so a lot of these aren't exactly... iron clad libraries) I end up with weird messes of dependency management. ESPECIALLY around the fuzzy OS-level boundaries where something works on one OS but suddenly the nice pip or setup.py or apt-get dependencies or whatever become a giant nightmare on OS X or Windows or not-Windows or Cent OS (but not Ubuntu) and so on. Rust doesn't prevent this, I've seen a few niche libraries that require some sys-type crates that they could only get working on one or two OS's or require installations of a language that are a pain to properly setup on Windows or something, but the mix of Cargo and Rust's general platform agnostic-ness makes it a hell of a lot less likely, and IME crate maintainers in Rust-land are much more likely to document these idiosyncrasies. Rust isn't a perfect language, but once you learn how to cope with how long you spend before getting a large engineering effort to compile and how to deal with the corner cases where the borrow checker gets really stupid it's one of the most pleasant environments to work in. (Also, I have to at least give a shoutout to Rust having very firm community guidelines wrt kindness, inclusiveness and recent initiatives to get women, transpeople, POC, etc into the core community with things like impl Future. It's really nice to know they're at least trying and it makes getting help with Rust way less draining.)
|
![]() |
|
Just wanted to mention that Firefox beta channel now has Quantum, which includes Servo, which means that in a couple of weeks hundreds of millions of people are going to be running Rust code on their desktops all day, for better performance.
|
![]() |
|
Firefox has been shipping a Rust MP4 container parser for a while now.
|
![]() |
|
Oh, I forgot about that!
|
![]() |
|
What do you guys recommend for GUI crates? I've heard good things about using GTK bindings for Rust but since I'm using Windows and MSVC it looks like I'd have to go out of my way to do everything in a separate IDE or whatever. Tried Googling it but I don't see any simple solution, but maybe I'm just bad and dumb. I learned about the Rocket crate recently and think it might be a good exercise to try to do for a web project.
|
![]() |
|
GTK bindings don't care what IDE you use, but GTK on windows is pretty terrible. Rust doesn't really have any mature GUI stuff yet; you could try a web UI instead.
|
![]() |
|
Non-lexical borrow scopes are finally under review
|
![]() |
|
Did anyone itt ever post about ideas for projects to make or whatever? Because I'm looking through the popular crates on crates.io and trying to come up with simple stuff to make for my Github portfolio. Sorry if this is a dumb question.
Love Stole the Day fucked around with this message at 07:07 on Oct 26, 2017 |
![]() |
|
Hell yeah. This will get rid of a ton of headache.
|
![]() |
|
Love Stole the Day posted:What do you guys recommend for GUI crates? You can still use a binding to QML perhaps (or even to IMGUI if you don't have too many requirements)
|
![]() |
|
Kyren (developer on Starbound) did a cool AMA about making a 2d game in rust: https://www.reddit.com/r/rust/comments/78bowa/hey_this_is_kyren_from_chucklefish_we_make_and
|
![]() |
|
Has anyone installed rust rls successfully in visual studio code and have the project auto compile and run in any debugger (on windows) ? What Rtfm page did I miss?
|
![]() |
|
Rust just got some really sweet enum memory layout optimizations. Highlights:
|
![]() |
Ralith posted:Rust just got some really sweet enum memory layout optimizations. Highlights: This is extremely cool!
|
|
![]() |
|
limaCAT posted:Has anyone installed rust rls successfully in visual studio code and have the project auto compile and run in any debugger (on windows) ? What Rtfm page did I miss? This is sort of iffy. I feel like everytime I don't use Rust for a couple months and come back to it with VS Code, I have to completely re-set it up from scratch. That and the fact the RLS keeps breaking with nightly's is really frustrating - I'm currently using the JetBrains Rust plug-in to at least more success now.
|
![]() |
|
Yeah the intellij plugin is much better right now. RLS will likely be the superior choice eventually but it’s not there yet.
|
![]() |
|
![]()
|
# ? Jun 13, 2024 15:47 |
|
MALE SHOEGAZE posted:Yeah the intellij plugin is much better right now. RLS will likely be the superior choice eventually but it’s not there yet. Even that just randomly decides to stop working for even syntax highlighting for me, though. I think I'll go back to Sublime which at least doesn't try for now. ![]()
|
![]() |