It is actually hard to objectively define how a programming language is ugly. Let the argument be countered. No need to get hurt (w.r.t. policies or rust)
...it also has a lot of really nice APIs, and traits allowing you to bolt on extra functionality "for free" is a big part of it.
I am relatively new to Rust but I do find shopping for API features harder than with other languages.
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?
use dioxus::native::{Config, LogicalSize, WindowAttributes};
use dioxus::prelude::*;
fn main() {
let window = WindowAttributes::default().with_surface_size(LogicalSize::new(500.0, 500.0));
let config = Config::new().with_window_attributes(window);
dioxus::native::launch_cfg(app, vec![], vec![Box::new(config)]);
}
fn app() -> Element {
rsx! {
Stylesheet { href: asset!("/assets/tailwind.css") }
HelloWorld { text: "World" }
}
}
#[component]
fn HelloWorld(text: String) -> Element {
rsx! {
div { class: "flex flex-col gap-3 bg-[#505050] size-[500px] justify-center items-center shadow-lg border border-[#0000ff] text-xl text-white",
"Hello, {text}!"
div { class: "flex gap-2",
div { class: "size-8 bg-[red]" }
div { class: "size-8 bg-[lime]" }
div { class: "size-8 bg-[blue]" }
div { class: "size-8 bg-[yellow]" }
div { class: "size-8 bg-black" }
div { class: "size-8 bg-white" }
}
}
}
}
You can also use standard CSS if you prefer it over tailwind. And if you wanted to deduplicate, the 6 divs can be written in a loop like so: for color in ["red", "lime", "blue", "yellow", "black", "white"] {
div { width: "32px", height: "32px", background_color: color }
}> move |_| container::background(c)
There's no way anyone can see this and thinks it is legible
New languages always feel a bit inapproachable. It’s like learning Russian (for a westerner). Super impenetrable at first, but at some point (early on!) the alphabet just clicks and then the rest is “just” regular language learning. Same with PL syntax. Overwhelming at first, until it clicks and then you can’t remember what you found overwhelming about it.
I see this and think it is very legible. It is hard to imagine why anyone can have issues with this.
I really like :()), it looks like a monkey with two chins!
fn view(_: &()) -> impl Widget<()> {
and think "nailed it"Pretty straightforward to my mind.
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.