| |
| ▲ | Mond_ 4 days ago | parent | next [-] | | This point has been litigated to death. Read this here: https://matklad.github.io/2023/01/26/rusts-ugly-syntax.html Almost everything that people think is ugly about Rust's syntax exists for very specific reasons. Most of the time, imo Rust made a good decision, and is just making something explicit. Some things take time to get used to (e.g. if let), but for most people that's less an issue of syntax, and more an issue of not understanding a powerful feature (e.g. pattern matching deconstructions). | | |
| ▲ | johnisgood 4 days ago | parent | next [-] | | The reasons do not matter here. It is still ugly / noisy / overly-complicated and probably could have been done better. I understand pattern matching deconstructions, I have seen it in other languages. Funnily enough they were nowhere as ugly / noisy / complicated as Rust's is. Rust seems to have bolted on a lot of fancy shit that may be appealing to a lot of people and that is it. In your link, the first one is fugly, the last one is fine. Maybe Rust just encourages ugly (i.e. complicated) code a bit too much. | | |
| ▲ | embedding-shape 4 days ago | parent | next [-] | | As someone who mostly writes Clojure code professionally during the day, I agree, Rust's syntax is complicated for no good reason, ugly and overly-verbose. But then I think that about most Algol-like language too, not just Rust. And despite that I do use Rust when I want something simple to deploy/deliver, as handing over a binary that just runs is such a nice experience, and it's real easy to make fast. As long as I don't have to maintain in long-term, Rust is fine for what it is. | |
| ▲ | LtdJorge 4 days ago | parent | prev | next [-] | | I like Rust’s syntax and dislike Elixir/Ruby’s. I also prefer Erlang’s to Elixir, lol. | |
| ▲ | Mond_ 4 days ago | parent | prev [-] | | > It is still ugly / noisy / overly-complicated and probably could have been done better. I don't know, it feels like you're just saying that you don't like it, missed the point of the post, and are not giving us anything concrete. Can you list a very clear example of how you'd improve the syntax? Again, see the post: You can remove things, but you're losing explicitness or other things. If you want a language that's more implicit, this is fine. I don't. | | |
| ▲ | johnisgood 4 days ago | parent [-] | | > Can you list a very clear example of how you'd improve the syntax? The demand that I must design a better language to have valid criticism is absurd - I don't need to be a chef to know food tastes bad, do I? I'm a user of languages, not a language designer. My job is to evaluate whether Rust's syntax serves my needs, not to solve the PL design problems that led to it. The syntax is noisy. That's not "missing the point" - that's the direct consequence of the design choices you're defending. If your argument is "the complexity is necessary for memory safety" fine, but don't pretend the cost doesn't exist or that pointing it out is invalid. You're conflating "can identify a problem" with "must solve the problem". Those are different skills. I'm evaluating Rust as a user, not auditioning as a language designer. | | |
| ▲ | Mond_ 3 days ago | parent [-] | | No, I just don't think you have identified a problem in the first place. You've complained a lot, but you've not even been specific enough to point at a single concrete thing! You've been so lacking in specifics I don't even know if you'd prefer Ocaml, Go, or Python-style syntax over Rust! Like, I can't tell since all you've said is that you don't like it, without even telling me how you don't like it or what you prefer! You say "over-complicated". I disagree, my impression is that is mostly about as complicated as it needs to be to solve the problems it is trying to solve. | | |
| ▲ | johnisgood 3 days ago | parent [-] | | Symbol soup and layers of hell that is abstractions. A language in which it is valid syntax to have 6 symbols next to each other is a bad idea. You do not have to know what programming language I prefer either[1]. Why would you? [1] If you are curious, I have talked quite a lot about it, along with why I dislike Rust. |
|
|
|
| |
| ▲ | mihaic 4 days ago | parent | prev | next [-] | | I'm actually fine with almost all the decisions that Rust made in terms of logic and concepts, but specifically don't like the synthax itself: the symbols, keywords like the consonant-only "fn" instead of "func" for instance, the fact that || {} starts a lambda instead of || -> void {}, the fact that you can return things by simply having them in an if branch. It's the main reason I don't use the language. | | |
| ▲ | DrNefario 4 days ago | parent | next [-] | | Most of those are a matter of preference, implicit return is just plain better, and it would be absolutely insane if closures required the return type to be specified. I do agree that the toilet bowl `|_|()` syntax is ugly, though. | | |
| ▲ | mihaic 4 days ago | parent | next [-] | | Again, I think JS/Typescript has a better syntax, since the implicit syntax is better when unbranched, like x => expression, but it's harder to read the more branches there are, since it's hard to visually scan where results can be located. | |
| ▲ | magicalhippo 4 days ago | parent | prev [-] | | > implicit return is just plain better I really dislike them. Makes me wonder if you just got distracted and forgot to finish the function. Be explicit, don't make me have to spend time figuring it out. |
| |
| ▲ | Mond_ 4 days ago | parent | prev [-] | | Meh, if these are the main reasons you don't use the language, I don't know what to tell you. I get having preferences, but whether the keyword is `fn` or `func` is such a banal, trivial thing that doesn't matter at all. | | |
| ▲ | mihaic 4 days ago | parent [-] | | Each taken individually is something I can ignore. But there are so many of them that it's no longer trivial to ignore. |
|
| |
| ▲ | Asooka 4 days ago | parent | prev | next [-] | | They could have at least put the types on the left. Types on the right are a good fit for mathematics, where everything is single-letter symbols, so your eyes do not have to go across the line to see the entire definition, but in programming function definitions often span an entire line on screen, so the most important information should be the first thing shown! Also most programmers do not have formal education in mathematics, so the whole "function : domain -> image" syntax is foreign to them. We really should strive to democratise programming for everyone, rather than make it isolated to a small clique of "properly" educated white men who all went to the same university. The type of a variable and the return type of a function are the most important pieces of information regarding those, so they ought to be on the left. It also fits the data flow going right to left (i.e. how the '=' operator works). C's type declarations can get pretty gnarly, so there is definitely room for improvement there. I would say Java (and C#) got it as close to perfect as possible. If you want to replace C/C++ you should make your language look as inviting as possible to users of the old one. I truly think this strange fetish for putting types on the right is what gives C programmers the ick when they see Rust for the first time and is hampering its adoption. | | |
| ▲ | kelnos 4 days ago | parent [-] | | After using C and Java for years and years I absolutely loved types on the right when I started using Scala. On the right just makes so much more sense to me, and I'm not a math guy. Each to their own, I guess. |
| |
| ▲ | bernds74 4 days ago | parent | prev | next [-] | | "if let" just breaks my brain, it feels backwards to me and takes me a minute each time to work out what's going on. In 40 years of programming I've never seen a syntactic construct that I found less intuitive. And it would probably be easily fixable, if it was more along the lines of "if x matches Some(let z)". | | |
| ▲ | ai_ 4 days ago | parent [-] | | if let makes a lot more sense when you learn that a normal let expression also takes a pattern[1]. let Coordinates(x, y) = get_coords();
But this is intended for "exhaustive patterns". If you can't express an exhaustive pattern, like with an Option, then you can use let ... else let Some((x, y)) = get_coords() else { return };
if let is just an extension of this "let pattern" system.Once you internalize how patterns work (and they really work everywhere) it all starts to really make sense and feels a lot cleaner. [1]: https://doc.rust-lang.org/reference/patterns.html |
| |
| ▲ | 4 days ago | parent | prev [-] | | [deleted] |
| |
| ▲ | ikkun 5 days ago | parent | prev | next [-] | | as a beginner rust programmer, I agree. it takes me way longer to parse someone else's rust code than it does for me to read C or C++, even though I have about the same amount of experience with them.
in that example, I had to look up what "if let Err() =" does, because it's not intuitive to me. it seems like every time I read rust code, I have to learn about some strange feature that's probably convenient when you know it, but there's a billion of them and they add up to hard to read code until you've spent tons and tons of time with rust. it's just so much to memorize compared to other languages. | | |
| ▲ | ben-schaaf 4 days ago | parent | next [-] | | I have the opposite experience: C++ is what I have the most experience with by a very wide margin, but I find reading other people's rust code way easier than other people's C++ code. There's way more weird features, language extensions and other crazy stuff in C++ land. | | |
| ▲ | johnisgood 4 days ago | parent | next [-] | | I think both Rust and C++ are behemoths. I do not even know what "proper" "modern" C++ is. | |
| ▲ | ikkun 4 days ago | parent | prev [-] | | I believe you, I haven't contributed a lot of C++ code and it's quite possible the projects I have contributed to (e.g. godot engine) just happen to be written very legibly. |
| |
| ▲ | piva00 4 days ago | parent | prev [-] | | It reminds me the experience I had when working with Scala, I really tried to like it but the mind-boggling amount of features created similar issues. It took me about 2 years to feel somewhat comfortable but I'd still run into code where someone decided to use their own set of unconventional favourite features, requiring me to learn yet-another-way to do the same thing I had seen done in other ways. I just got tired of it, didn't feel more productive nor enlightened... | | |
| ▲ | tormeh 4 days ago | parent [-] | | Don't understand this complaint about Rust, but I'll give you Scala. Never seen a language so finely tuned to empower architecture astronauts to make terrible decisions. And boy do they make terrible decisions. |
|
| |
| ▲ | Sharlin 5 days ago | parent | prev | next [-] | | It takes at most a week to get used to just about any syntax. It should absolutely never be a reason not to try a new language. That said, it would be lovely if Rust had a more ML-like, rather than C-like, syntax (being originally inspired by O’Caml), but that would likely not help attract devs in the intended target audience! The insert function, for what it’s worth, has nonstandard formatting; the de facto standard rustfmt tool would use more newlines, making it clearer and less dense. The function also uses a couple of syntactic features like `if let`, which may seem unfamiliar at first but become second nature in a few days at most. | | |
| ▲ | alt187 5 days ago | parent | next [-] | | It probably takes a week to get used to ugly pants too. OP's point is a matter of aesthetic judgement. I don't mind it either, but = |&I: can| -> Agree { Rust::Syntax }; is.a(Bit(&mut chaotic); | | |
| ▲ | Sharlin 4 days ago | parent [-] | | I should probably have used something less ambivalent than "getting used to". There's certainly more elegance in Rust's semantics than syntax, but the latter doesn't really differ much from C, except for much better for loops, a sane declaration syntax (this is a BIG deal), and of course all the features that C just doesn't have, like closures^* Some of the syntax noise just has to be there in some way, to support the real deal which is the semantics. ^* I don't particularly enjoy the Ruby-borrowed || either, particularly because Alt-7 is a terrible key combination to type, but oh well. | | |
| ▲ | bombela 4 days ago | parent [-] | | Out of curiosity, what language specific keyboard requires alt-7 to enter the pipe symbol? On the QWERTY keyboard, the pipe is near the enter key and easily typed. |
|
| |
| ▲ | mikkupikku 4 days ago | parent | prev | next [-] | | Every time a language developer chooses to give their new language a novel, let alone chaotic, syntax, they sin against the very premise of software development being an engineering profession. Can you imagine the madness if mechanical engineers had the same laissez-faire mentality towards the conventions and learned best practices of their field? Randomly chosen bolts to use left hand threads just because it suits their arbitrary whim, every thread has a unique pitch never seen before just to make the machine stand out from the crowd. Parts of the machine use hot rivets, not because the design demands it but because it scratches a retro aesthetic itch the designer had that day. Every time a new machine is designed it has a whole class of new never before seen quirky ways of being put together and any mechanic who pleads for standardization on common sense ways of putting a thing together are just told to git gud because the creative expression of the 'engineers' is paramount. (This is how we end up with German cars, isn't it?) | | |
| ▲ | dzaima 4 days ago | parent | next [-] | | It's of course a matter of perspective, goals, and assumed knowledge. Is it choosing to not follow best practices, or leaving outdated practices with unfixable downsides behind? Is it inventing new things or instead actually just taking already-existing things that you just happened to not know about? Is it making arbitrary changes, or necessary ones for a useful goal? Is an extra bit of temporary pain for existing engineers worth making things better for all future engineers? (not to say that Rust has necessarily made all the right decisions; but alas basically nothing is perfect, and things certainly won't get better if noone tries) | |
| ▲ | wtetzner 4 days ago | parent | prev [-] | | > Every time a language developer chooses to give their new language a novel, let alone chaotic, syntax, they sin against the very premise of software development being an engineering profession. Exactly which syntax should every language be using then? Everyone will give you a different answer. > Randomly chosen bolts to use left hand threads just because it suits their arbitrary whim Claiming the syntax was chosen randomly on a whim is very much not true: https://matklad.github.io/2023/01/26/rusts-ugly-syntax.html And there are times when it does make sense to use left-hand threads. Just because someone looks at new syntax and doesn't immediately understand it doesn't mean that syntax doesn't exist for good reason. Also, if your language's constructs and semantics don't exactly match those in other languages, then giving them the same syntax would be actively misleading, and therefore a design flaw. Syntax is also only an issue for people who haven't taken the time to learn the language. If you haven't learned the language, then familiar syntax isn't going to help you anyway. You'll just think you understand something you don't. | | |
| ▲ | mikkupikku 4 days ago | parent [-] | | It's like asking if the world should standardize on left handed or right handed screws as a default. There comes a point where the choice matters less than picking one at all. | | |
| ▲ | dzaima 4 days ago | parent | next [-] | | Screw handedness is something that's basically always fine either way if planned for, and with largely no benefit for either option, so standardizing that is easy enough. But, like, even then, there's screw drive (JIS vs phillips vs pozidriv vs a ton more) to worry about with screws. (never mind the obvious aspects of diameter & length; and whatnot else I happen to not know about) The significant thing I think is that such trivial impactless questions just do not exist for programming languages. Even like comment starting characters is a messy question - "//" nicely aligns with "/* */" using the slash char, but "#" is a char shorter and interpreted languages need to handle "#!" as a comment for shebangs anyways. And things only get more complicated from there. And, unlike with physical things, it's trivial to work with non-standardized things in software. Not like you're gonna copy-paste arbitrary code from one language into another and just expect it's gonna work anyway (else we wouldn't have more than one language). | |
| ▲ | wtetzner 4 days ago | parent | prev [-] | | Bit that is more like standardizing on a language, not a syntax across languages. I also don't think syntax is even a problem worth worrying about. It takes very little time to become accustomed to a new syntax. It's the semantics that are hard to learn. Difficulty syntax can often be helpful when learning a new language, as it serves as a reminder that the semantics are different. |
|
|
| |
| ▲ | dman 5 days ago | parent | prev [-] | | Laughs in lisp | | |
| ▲ | Sharlin 4 days ago | parent [-] | | I've written Clojure professionally. It's exactly the language I had in mind when I said that it takes a week to get accustomed to. I find it a very clean and elegant language. Shame that it's dynamically typed. | | |
| ▲ | tmtvl 4 days ago | parent [-] | | Check out Common Lisp, it's gradually typed, so if you want you can just write your code like this: (defun fib (n)
(declare (type (Integer 0 100) n))
(the (Integer 0 *)
(if (< n 2)
n
(+ (fib (- n 1))
(fib (- n 2).)
|
|
|
| |
| ▲ | figassis 5 days ago | parent | prev | next [-] | | It’s promises make me interested, but the syntax is my main turnoff. I am a Go person, and I think what brings people to go is the opposite of what brings people to Rust. I am willing to sacrifice some memory safety (because I maybe naively think I can manage to write software without many memory bugs) for the simplicity and dev experience that Go offers. | |
| ▲ | Levitating 4 days ago | parent | prev | next [-] | | The first statement defines a closure. The second is an if-let statement. It's not chaotic, you're just unfamiliar with the syntax. I actually find the Rust syntax very natural, more than C in some areas. | | |
| ▲ | johnisgood 4 days ago | parent [-] | | More than C? Highly doubt that. | | |
| ▲ | Levitating 4 days ago | parent [-] | | Arrays are initialized with curly braces but the type notation uses brackets. typedef takes the identifier at the end of the statement. The asterisk is used to de-reference but used to denote a reference in types. While loops may take the condition after the block. |
|
| |
| ▲ | 6r17 4 days ago | parent | prev | next [-] | | tbh it's bit boring to get stuck on aesthetic of writing up something. It's a bit nauseous to see how this place is hostile to rust for no reason other than "it's not pretty". It's a joke at this point we could make caricature of HN viewpoint on rust. We get it, you don't like it. | | |
| ▲ | christophilus 4 days ago | parent | next [-] | | HN is not some monolithic single perspective. There are plenty of Rust fans here, and they show up just as frequently as the complainers. In fact, there is overlap between the two groups. You can be a fan of a tech and still complain about its warts. | |
| ▲ | johnisgood 4 days ago | parent | prev [-] | | Oh come on, how many times have we seen "blazingly fast in Rust", "rewritten in Rust" etc.? Many times. We get it. You like Rust. This "rewrite in Rust" bullshit is just as nauseous and I am sick of seeing it, too. So what? In fact, it is quite a meme now. Please, every time you see someone praise Rust (every other day), tell them the same as you have told me, just the opposite way around. |
| |
| ▲ | mpalmer 5 days ago | parent | prev | next [-] | | It really reads quite simply once you're familiar with the language. You only see chaos because there are none of the semantic hooks you'd get from experience | | |
| ▲ | johnisgood 4 days ago | parent [-] | | Everyone who tells me this, I would love them to write an useful project in Forth. ;) Guess what? They would blame Forth, Common Lisp, etc., yet I could tell them the same things I am being told about Rust. | | |
| ▲ | mpalmer 4 days ago | parent [-] | | Forth and Common Lisp are demanding, but they demand different things of the novice programmer than Rust. The latter's baroque syntax is not provably good or necessary, but I'd call it the other end of a compromise for safety and expressiveness. And once you learn it, you've learned much of the language by default. Not so with with the first two! The mental models involved in reasoning about a piece of code require much more cognition on the part of the programmer. | | |
| ▲ | johnisgood 4 days ago | parent [-] | | Sounds like you are heavily biased in favor of Rust. What you said about Forth and Common Lisp applies to Rust, too, no matter how much you are trying to deny the reality of it. Just admit that you love Rust, and quite biased in favor of it. | | |
| ▲ | mpalmer 3 days ago | parent [-] | | I do like Rust quite a bit. I don't know Forth or Common Lisp as well, but I don't dislike them. I admit, I have learned very little about them from you so far. You strike me as someone who isn't really prepared to have an actual debate on technical matters, because all you have done is: - manufacture some fictional strawman who is complaining about languages you like - tell me I'm wrong without even bothering to get into why - claim that I'm biased, when all I've done is explain my opinion that all three languages are challenging in different ways | | |
| ▲ | johnisgood 3 days ago | parent [-] | | You claimed much more than that. See your statement: "Not so with with the first two! The mental models involved in reasoning about a piece of code require much more cognition on the part of the programmer.". Your whole comment is about favoring Rust over those two because Rust is your beloved language. Additionally, it is not up to me to teach you Forth nor Common Lisp. Finally, you should read your own comment where you replace Rust with Common Lisp, for example, and Forth and Common Lisp with Rust. You may see what I was referring to. In fact, let me do it for you: > Rust is demanding, but they demand different things of the novice programmer than Common Lisp.
The latter's baroque syntax is not provably good or necessary, but I'd call it the other end of a compromise for safety and expressiveness. And once you learn it, you've learned much of the language by default. > Not so much with Rust! The mental models involved in reasoning about a piece of code require much more cognition on the part of the programmer. See it yet? |
|
|
|
|
| |
| ▲ | neonz80 4 days ago | parent | prev | next [-] | | I find the short type names for integers and float hard to read. Somehow the size of the type is more important than if it is a signed integer, unsigned integer or a floating point number. Using Vec for arrays is also annoying, repeating the mistake from C++. | | |
| ▲ | Denvercoder9 4 days ago | parent | next [-] | | > Using Vec for arrays is also annoying, repeating the mistake from C++. Neither Rust nor C++ uses vectors as array, they're distinct things. An array is a fixed-size object, which never allocates and its elements thus always retain their memory address. In Rust they're `[T; N]`, in C++ `T[N]` or more recently `std::array<T, N>`. A vector on the other hand is dynamically sized object, that may (re)allocate to accomodate new elements, and the address of their elements can change. In Rust they're `Vec<T>`; in C++ `std::vector<T>`. | | |
| ▲ | neonz80 4 days ago | parent [-] | | I'm aware of how they are used, but fundamentally there is nothing with the words "array" and "vector" that says that one has a fixed size and the other has a dynamic size. If anything, it should be the other way around. Using the name vector for dynamic arrays is annoying when doing any kind of math coding. Even the designer of STL says the name was a mistake. |
| |
| ▲ | bigstrat2003 4 days ago | parent | prev [-] | | I genuinely don't understand how you can find the type names for numbers hard to read, nor how you can say the size is treated as more important. The first thing in the type is what kind of number it is! |
| |
| ▲ | ozgrakkurt 4 days ago | parent | prev | next [-] | | For me it is the usage of macros and traits everywhere. Good luck if you want to get into the code of a library to understand what a function does. You have to go through 3 macros and 5 traits across 5 files. When it could have been just a couple function calls. People don’t stop and think if they really need that trait or macro for five seconds, they just have to use it every time | | |
| ▲ | LtdJorge 4 days ago | parent [-] | | I dislike macros for that reason when reading code on GitHub or Docs.rs, but Rust was kind of made to be used with an IDE (or LSP). | | |
| ▲ | bigstrat2003 4 days ago | parent [-] | | That is poor practice IMO. The simple reality of the world is that not everyone uses such tools. Designing a language with the expectation they will is deliberately ignoring the needs of some users. | | |
| ▲ | pjmlp 3 days ago | parent [-] | | IDEs were invented by a mix of XEROX PARC, Symbolics, TI efforts into graphical workstations development, we have moved beyond the point of refusal to adopt modern tooling. |
|
|
| |
| ▲ | cannonpalms 4 days ago | parent | prev | next [-] | | The insert function is very unidiomatic. Instead of defining a cmp closure, you would typically implement Ord and friends. | |
| ▲ | 5 days ago | parent | prev [-] | | [deleted] |
|