4 ms·
From what I've seen so far, I really like the clean syntax of Zig. I want to like Rust, but it looks so verbose and loaded with special characters.
by wycy 8y ago
From what I've seen so far, I really like the clean syntax of Zig. I want to like Rust, but it looks so verbose and loaded with special characters.
- steveklabnik 8y agoWhich special characters bother you the most? Before 1.0 we largely removed most of them.
- wycy 8y ago::, & (pass by ref?), ! (macros), {:?}, _ => (), whatever is happening in this example with <T> and [T]: fn largest<T>(list: &[T]) -> T { To be fair, some of these are in Zig too, such as &.
- gnud 8y agoI'm a rust newbie, but I have to disagree. Your "horror example" is actually very readable for most programmers familiar with either Java, C# or c++, I think. In java or C# it would be something like T largest<T>(T[] list) The major difference being the reference syntax in rust, but that's the price of explicit ownership/no GC. I love the fact that it's obvious where macros are being used. _, => and () are originally from ML, so I know it from my university days, but these days you also find some or all of them in C#, Java, Kotlin, ES6. So a lot of programmers have already been exposed to them.
- steveklabnik 8y agoYeah, I guess * :: is the same as in many other languages * & too * ! is unique, I guess * The format string stuff is based on ... C#/Python stuff? I forget exactly. * _ => () is composing three other bits of syntax that aren't unusual on their own * <> is genrics, like in many languages * [T] is slices, which are not entirely unique but are also similar to array stuff which uses []s Thanks for elaborating, it's helpful to understand the perspective.
- Cyph0n 8y ago:: probably looks unfamiliar to anyone who hasn’t worked in C++, PHP, or Perl.
- ternaryoperator 8y ago:: is used in Java too, ever since Java 8.
- oblio 8y agoSo 50% of Java devs :)
- kungtotte 8y agoIt might be hard for someone who writes Rust every day to see it, but it has a lot of special characters compared to many languages. It also has less or equal amounts compared to other languages, of course, but I dislike that aspect of those languages too :) Compare these two listings: http://rosettacode.org/wiki/Stack#Simple_implementation http://rosettacode.org/wiki/Stack#Simple_implementation http://rosettacode.org/wiki/Stack#Nim http://rosettacode.org/wiki/Stack#Nim You can see directly that Rust has a lot more there. Obviously Nim skips out on braces so that's a gimme, but I don't really count block braces when I'm talking about special characters. It's more stuff like Option<&'a Frame<T>> or &'a mut T or ->
- steveklabnik 8y ago> It also has less or equal amounts compared to other languages, of course, but I dislike that aspect of those languages too :) Yeah, thanks, I think this is at the root of a lot of it. > It's more stuff like Option<&'a Frame<T>> or &'a mut T or -> Yeah; some of the stuff isn't needed anymore; you can drop the : 'a s, for example. And we have been talking about allowing some more elision, so pub struct Iter<'a, T: 'a> { next: Option<&'a Frame<T>>, } could be pub struct Iter<'_, T> { next: Option<&Frame<T>>, } when all is said and done. The '_ in the signature is important so that you know it's parameterized by a lifetime, so we don't plan on ever getting more concise than that.
- mohammedbin 8y agoSteve I wish some of the reg deref stuff used pattern matching for cleanliness instead of &. I want to say I like you how you guys develop in the open and how you in particular are out and about in the discussions here. Also, can you make a post someday about your experience with WSL?
- steveklabnik 8y ago> used pattern matching for cleanliness instead of &. Could you expand on this, I don't quite know what you mean, but I'm interested! > I want to say I like... Thanks! > your experience with WSL? My experience was, "This is pretty cool!" but, in the end, I don't use WSL anymore and just use regular old Windows. I can elaborate more if you'd like, but it boils down to "basically everything has windows native versions anyway and it works a bit better that way."
- edflsafoiewq 8y agoa::b::c::<T>()? // Rust try a.b.c(T) // Zig
- steveklabnik 8y agoThat’s not what Rust looks like normally, though; usually you’d use “use” and the T is inferred. The :: and <> are also not particularly unusual syntax for their respective features either.
- edflsafoiewq 8y agoa::b::c is ugly compared to a.b.c whether you put it in an expression or in a use statement and ::<T>()? is not that rare (ex. rdr.read_u16::<BigEndian>()?). You asked what bothered us, not what was unusual :)
- steveklabnik 8y agoOh totally! I mean it as a way of sorting out why. Like, it would bother me more if I had to write it more, so maybe it’s that styles are different or some libraries require it more often? byteorder is one of those crates, it’s true, and I don’t use it super often. So this is helpful!
- mikekchar 8y agoI'm curious. What do you (or other people) dislike about special characters. For me, they are more readable than text (maybe I should start writing APL ;-) ). Granted, I'm dyslexic and apparently dyslexia only affects characters which are phonetic. This has also been my experience and I love Chinese characters in Japanese text because it's much more comfortable for me to read. So that's why I might prefer symbols. I'm wondering, though, why people dislike symbols (and I know it's a very common thing). It's just like any other letter, except that it has a meaning. I wonder, it is because it's hard to read phonetically (just the opposite of my problem)? Whenever I've asked people they say "Symbols are ugly", which is kind of an unhelpful response. It's like saying, "I don't like it because it is unlikable". I hope someone has a slightly deeper insight into the reasons.
- oscargrouch 8y agoThe most something follows the most intuitive way of making one thing, less arbitrarity and change for change itself, it might also be only noise, so the author can claim its a original work just because it uses a different sort of symbols. Byproduct of individuality and ego. Most people can detect noise and arbitrarity. But if you are making something really original, giving you are being a pioneer into something, in that case you can define the direction of something, where that direction should serve as a guide to things that will follow. I dont know about others, but my brain tend to be anti-noise (and i fell this pattern in a lot of other people too), because theres too much information for us to consume, that having to handle some people "cheating" to give a apparent originality, can make anyone who feel its the "noisy arbritrary sort of change" that is being presented, to dislike the "noise" almost immediatly. Technology should be aiming toward zen-budism, less ego and therefore, less disonesty and less noise.
- webmaven 8y agoThe more symbols used, the less it looks like a human-consumable language (note: "looks like", not "is"). The more symbols, the harder it is to unpack the code into (and restate in a) human language. Even in your head. IOW, if you're mostly monoligual, and you think about code in English (or whatever your preferred language is), more symbols can actually make it harder to think about the code. Trivial example: a = a+b is slightly easier to say (and think) in English than a += b