6 ms·
For anyone that hasn't played around with rust yet, this is why I'm excited about rust: https://github.com/Azdle/hello-gtk.rs/blob/master/src/main.rs https://gi
by azdle 11y ago
For anyone that hasn't played around with rust yet, this is why I'm excited about rust: https://github.com/Azdle/hello-gtk.rs/blob/master/src/main.rs https://github.com/Azdle/hello-gtk.rs/blob/master/src/main.r...
That is a GTK GUI application that makes HTTP requests in under 40 lines of code.
Don't get me wrong I love all the safety gaurentes and what not, but just being able to write quick simple apps that would usually be a pain to write in C is a game changer for me. A lot of this is down to Cargo (the Rust package manager, very npm-like imo) and all the great rust libraries that already exist. I'm super excited to see where this goes now that it's 1.0, people can stop worrying about breaking changes in the language and just get down to writing libraries to do everything.
- sho_hn 11y agoI agree this is a very good thing by itself, but let's be clear that the extremly poor programmer ergonomics of the GTK-via-C stack have been superseded by nicer kit long ago (even within the GTK community).
- GarryManson 11y agoSeems like theres no good reason for rust to do this when vala can -- and better, it just compiles to the same C
- madez 11y agoVala has reference counted garbed collection, while Rust doesn't need that. Also, Rust verifies, among other things, the absence of data races.
- GarryManson 11y agoThat's not much good when you're just talking to ahitty GObject APIs that - guess what! - use reference counted GC and have lots of race conditions. You gain nothing
- pcwalton 11y agoYes, you do. Your internal logic doesn't need the overhead of reference counting and can be race-free. This is how Mac apps tend to be fast: the high-level application logic is reference-counted and uses relatively slow Objective-C dynamic method calls, but things that are performance critical (CoreGraphics, VideoToolbox/AudioCodec, OpenGL, sqlite, the Mach kernel) are written in C and C++.
- sho_hn 11y agoThis is also a general pattern in Rust, cf. unsafe blocks: You wrap code that doesn't adhere to Rust's strict rules (e.g. because it interacts with C) in unsafe { }, disabling various compiler checks and requiring you to check it for correctness manually. Unsafe-ness doesn't bubble up, though, i.e. having an unsafe block within doesn't taint, say, a function - allowing you to silo nasty things away and enforce strict checks around it.
- pekk 11y agoI haven't noticed that Mac apps tend to be faster than apps on other platforms. Can you provide a citation for this?
- pcwalton 11y agoI didn't mean "faster than other platforms", just "not slow". Really it's a testament to the fact that front-end glue logic can often be written in whatever language you want without compromising interactive performance (as long as the implementations of those languages don't require long pauses or something like that), which is something we've known for a long time.
- SamReidHughes 11y agoHeck, when doing Objective-C I'd drop down to C++ as quickly as possible just because the language is nicer. I'd be even more inclined to drop down to Rust.
- ossreality 11y ago
- luuio 11y agoNot that it's not amazing, but can't i'm pretty sure most languages can do that same thing.
- moonchrome 11y agoDoes this build with something simple like "cargo build" ? It should but I can't test right now on this PC. If it does than I would disagree - not many other native languages can do that - having a native language with a sane build system, package management and proper modules would be a huge deal on it's own.
- azdle 11y agoYes it does. I just do a `cargo run` and it figures out the dependencies, builds, and runs.
- e12e 11y agoJust tried, and it's both a little frighting and a delight to see cargo pull down and build the dependencies. For the information of those that can't test at home, the stripped release build weighs in at 722K, and worked on first try on my Debian Jessie system. Woho! You might want to add a CC0 license to the project (or something else, but that's usually what I see recommended for "sample code"). [ed: and: ldd ./target/release/hello_gtk |wc -l 59 ]
- lmm 11y agoWhy is that exciting? You've been able to do that almost line-for-line in Python for at least 8 years, if you're not bothered about the "safety guarantees and what not".
- azdle 11y agoAdmittedly, I've never tried using GTK from python and that seems like it does take care of a lot of the "easy" that I'm liking here. However, it's really the combination of everything that rust offers while still letting you make short programs like this. I really don't mean the downplay all the safety stuff, that is the main reason that I'm interested in rust. I just don't feel like the fact that you can do things so easily in rust gets enough attention. My biggest "Oh my god, that was awesome!" moment was when I first built the project and Cargo just took care of the whole dependency tree and I never even had to think about it. I've never had that in a low level language before. I've actually been stepping out of a lot of the C that I've been doing into doing more with JS just because NPM makes it so damn easy to whip something up. I'm hopeful that rust will let me come back to a much lower level where a 10MB binary is really large.
- copsarebastards 11y agoWhy are you not bothered about the "safety guarantees and what not"? Note that "what not" includes a lot of performance and portability which Python will likely never have, but Rust might.
- ossreality 11y ago""safety guarantees and what not"" are you god damn kidding me
- pornel 11y agoRust is not a replacement for Python, but a replacement for C. It's exciting that you can have power, portability and speed competitive with C, but with syntax and safety so good that you're comparing them to Python :)
- dragonwriter 11y ago
- imaginenore 11y agoEven PHP can do that http://en.wikipedia.org/wiki/PHP-GTK#Example http://en.wikipedia.org/wiki/PHP-GTK#Example