Announcement

Collapse
No announcement yet.

Rust 1.21 Released With Minor Updates

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #11
    Originally posted by mmstick View Post

    Every syntax choice has been made based on how well it can explicitly express the intent of the action being performed though. As a systems language, there's really no other syntax that would suitably convey all the information that Rust's syntax is currently conveying. After all, we spend more time reading code than writing it, so the less ambiguity in syntax, the better. About all you could change are which characters to convey what information.

    Although I don't see how it looks like Ruby. Ruby's syntax looks more like Python than Rust, which looks kind of like a functional, modern day C++.
    I don't really have a problem with Rust's syntax but that's overstating the case by far. There really isn't a reason that for example
    Code:
    fn foo(bar:i32) -> i32 {
        //stuff
    }
    is intrinsically any better than
    Code:
    i32 foo(i32 bar) {
        //stuff
    }
    at conveying the important information, it arguably looks prettier but there isn't some objective advantage to this. Similarly anywhere else it breaks from C-Style syntax where features are equivalent. Obviously Rust enums, match expression, the way the impl/type system stuff works, and other rust specific features require their own special syntax, but it's just a bit much to declare Rust syntax the only way to go.
    Last edited by Luke_Wolf; 10-13-2017, 03:51 AM.

    Comment


    • #12
      I really think rust is an awful language because it has some big design flaws. First and foremost: The whole cargo nonsense. You really see it was developed by people coming from the JavaScript world. Instead of building interoperable system libraries, you have to write your own library for everything, even for shared libraries that you already have on your system. So just the basic system of rust + cargo already compiles a large amount of different libraries, each with it's own versioning. Together with the fact that they again reinvented the wheel of a package system (it is only the 3rd? 4th? package management I have to use?). Instead of writing one useful library, which covers a whole area of functions, you again have a library for each tiny piece of code. It is exactly a copy of the npm stupidity, just to "system development" now.

      Aside from that, why can't they use the system's LLVM libraries, when they are already installed. No, you have to recompile all of LLVM, even for processor architectures you never use.

      So Rust clearly looks like a hype-language by people trying to reinvent the wheel, because web is so modern and they refuse to learn from past mistakes.....

      Comment


      • #13
        Originally posted by Luke_Wolf View Post

        I don't really have a problem with Rust's syntax but that's overstating the case by far. There really isn't a reason that for example
        Code:
        fn foo(bar:i32) -> i32 {
        //stuff
        }
        is intrinsically any better than
        Code:
        i32 foo(i32 bar) {
        //stuff
        }
        at conveying the important information, it arguably looks prettier but there isn't some objective advantage to this..
        Try to express (i32 -> i32) -> (i32 -> i32) in C.

        Comment


        • #14
          Originally posted by veeableful View Post

          Impl is implement. A lot of things are abbreviated in other languages. int, bool, var, etc, func, ifdef, etc.. I think it's more consistent (like why in Java you say boolean for boolean but int for integer int or in js, why variable is var but function is function). Just my thoughts.
          Good point.
          I could guess "Impl" was short for Implement, but I still don't know what it does or what it means.
          Like is it a class, a interface or a trait or something else?

          I wish Rust was more like C, C++, C#, Java, and PHP and that it was less like Ruby.

          Comment


          • #15
            Originally posted by uid313 View Post
            I could guess "Impl" was short for Implement, but I still don't know what it does or what it means.
            Like is it a class, a interface or a trait or something else?
            It is a keyword used to add "methods", including associated (i.e. static) to a type.
            impl MyType {...} - adds methods to a type "MyType".

            impl SomeTrait for SomeType {...} - adds implementation of SomeTrait (i.e. interface) to SomeType. Unlike other languages, where you can only implement interfaces for your type, Rust allows you to add implementation of interfaces from your module to any type, including foreign. So, you can create trait Foo, implement it for i32 (builtin type for 32-bit int), then cast pointer to i32 to pointer to Foo and then use that pointer OOP like way, as if Foo is a base class for i32.

            Comment


            • #16
              Originally posted by uid313 View Post

              Good point.
              I could guess "Impl" was short for Implement, but I still don't know what it does or what it means.
              Like is it a class, a interface or a trait or something else?

              I wish Rust was more like C, C++, C#, Java, and PHP and that it was less like Ruby.
              Can you please stop comparing it to Ruby or, at the very least, try to explain why exactly you think it looks like that?
              I (and, from the looks of it, quite a few others) just can't see it. The syntax has far more in common with Haskell and similar, functional languages.

              Comment


              • #17
                Originally posted by Khrundel View Post
                It is a keyword used to add "methods", including associated (i.e. static) to a type.
                impl MyType {...} - adds methods to a type "MyType".

                impl SomeTrait for SomeType {...} - adds implementation of SomeTrait (i.e. interface) to SomeType. Unlike other languages, where you can only implement interfaces for your type, Rust allows you to add implementation of interfaces from your module to any type, including foreign. So, you can create trait Foo, implement it for i32 (builtin type for 32-bit int), then cast pointer to i32 to pointer to Foo and then use that pointer OOP like way, as if Foo is a base class for i32.
                I don't know if that is any useful or good, but that is very confusing for me who are mostly used to the languages of C, C++, C#, Java and PHP.

                Comment


                • #18
                  Originally posted by caligula View Post

                  Try to express (i32 -> i32) -> (i32 -> i32) in C.
                  in C
                  Code:
                  typedef int (*return_func)(int);
                  return_func function(int (*input_function)(int)) {
                      //stuff
                  }
                  or in C++
                  Code:
                  std::function<int (int)> function (std::function<int (int)> input){
                      //stuff
                  }

                  Comment


                  • #19
                    Originally posted by uid313 View Post

                    I don't know if that is any useful or good, but that is very confusing for me who are mostly used to the languages of C, C++, C#, Java and PHP.
                    Or... you could just read The Book as opposed to trying to just wade into code... https://doc.rust-lang.org/book/second-edition/

                    just wading into code may work okay when you're shifting from one C Family language to another, but Rust is not a C Family language, and even within C family languages it benefits you greatly to at least read some of the docs before you dive in. Impl isn't confusing at all if you use even a minimum of due diligence in learning the language

                    Comment


                    • #20
                      Originally posted by Luke_Wolf View Post
                      in C
                      Code:
                      typedef int (*return_func)(int);
                      return_func function(int (*input_function)(int)) {
                      //stuff
                      }
                      Now do the same without the typedef. It's cheating. The problem here is, C's syntax is totally backwards. For documenting the type, you're better off writing the comments in Rust. Maybe you can handle it, but there are lots of programmers totally lost with this syntax, yet they are fully able to implement monads in Haskell.
                      Last edited by caligula; 10-13-2017, 04:51 PM.

                      Comment

                      Working...
                      X