The hello world code example reinforces my opinion that Rust is verbose and ugly.
Please don't post shallow dismissals or instigate generic tangents on HN. The guidelines make it clear we're trying for something much better here. https://news.ycombinator.com/newsguidelines.html
Ugly is a matter of taste. But I agree Rust isn't the best language to describe UI: it makes you focus on ownership and lifetimes and explicit memory allocation, instead of the layout. That's in Slint, we uses a DSL for the UI description and keeps the logic in Rust. I blogged about the subject here: https://slint.dev/blog/domain-specific-language-vs-imperativ...
I think this is more of a function of the GPUI library being very powerful. If you just write "hello world" in rust that is a lot shorter.
loading story #50624531
loading story #50622850
Rust is not to blame for that example. Here's the same example rewritten with iced:
use iced::widget::{column, *};
use iced::{Center, Color, Fill, Theme, border, color};
fn main() -> iced::Result {
iced::application(|| (), update, view)
.window_size((500, 500))
.run()
}
fn update(_: &mut (), _: ()) {}
fn view(_: &()) -> impl Widget<()> {
let swatch = |c: Color| {
container("")
.width(32)
.height(32)
.style(move |_| container::background(c))
};
let colors = [
color!(0xff0000),
color!(0x00ff00),
color!(0x0000ff),
color!(0xffff00),
Color::BLACK,
Color::WHITE,
];
container(
column![
text("Hello, World!").size(20).color(Color::WHITE),
row(colors.map(swatch)).spacing(8),
]
.spacing(12)
.align_x(Center),
)
.center(Fill)
.style(panel)
}
fn panel(_: &Theme) -> container::Style {
container::background(color!(0x505050)).border(border::color(color!(0x0000ff)).width(1))
}
Also this is a pretty shit example because it's mostly showing styling... and in any sane app, you have a predefined themeThe typical GUI example is a counter
Syntax is rarely a reason to choose a language
If Rust feels "ugly" to you, may I suggest you consider how that comes from lack of familiarity, rather than an intrinsic shortcoming of the language?
loading story #50623273
loading story #50624291
loading story #50623773
loading story #50624257
loading story #50624100
Or, there is a lot going on there and the library/Rust doesn't hide it from you. Your mileage will vary depending on which format you prefer and that's why I pick Rust.
Idiomatic Rust seemed to always use a ton of method chaining much more than any other language, even TypeScript, so a lot of Rust code just reads like "names.iter().cloned().map(|name|name.trim().to_string()).filter(|name| name.is_empty()).map(|name| name.to_lowercase()).filter_map(...)" all the time.
loading story #50624077
loading story #50622981
loading story #50622985
Rust is ugly as a beginner, beautiful as an intermediate, and sorta ugly again as an expert.
well, luckily we don't have to write the code ourselves anymore
It comes with the multi/cross-platform territory because at the end of the day (at varying degrees from one such lib/tool/paradigm to others) it's just one piece of clothing trying to dress every body type, size, shape, and colour.
I agree. There are some languages that looked at all the possible symbols on a keyboard and decided that every single one must be used as part of hello world. Then on the opposite end there are those who stopped at open and close parentheses.
This is common in most lower level languages in a large part because they are more powerful.
The funny thing is the replies insulting you for a fairly tame and rather accurate opinion. Almost like rust has this weird subset of users who cannot handle anything negative about their favorite tool.
I'm not sure what you mean... It's a beautiful dialect of Klingon.
Who cares. You might as well be saying assembly is verbose and ugly. That is just the output of "create a hello world gpui app" prompt.