Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc.

I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc.

Scheduled Pinned Locked Moved Uncategorized
120 Posts 48 Posters 160 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

    I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

    (*one per reply, multiple replies per household are allowed)

    ids1024@mathstodon.xyzI This user is from outside of this forum
    ids1024@mathstodon.xyzI This user is from outside of this forum
    ids1024@mathstodon.xyz
    wrote last edited by
    #79

    @fasterthanlime Linear types (I believe that term is correct; the term is sometimes used for Rust's existing model, but that's more properly "affine").

    So you could define a type that instead of having a destructor, is required to be passed to a function consuming it instead of allowing it to fall out of scope.

    1 Reply Last reply
    0
    • zwol@masto.hackers.townZ zwol@masto.hackers.town

      @soc @fasterthanlime

      Here's a few more things on my list but not yours:

      The dereference operator (unary *) should be postfix. C got this wrong in 1970 and we've been paying for it ever since.

      && and || should have equal precedence and be non-associative wrt each other — this mandates what everyone actually does in practice, writing explicit parens whenever they are mixed.

      #[path = "boo.rs"] mod foo; should be spelt mod foo = "boo.rs"; and it should be required for all out-of-line modules.

      soc@chaos.socialS This user is from outside of this forum
      soc@chaos.socialS This user is from outside of this forum
      soc@chaos.social
      wrote last edited by
      #80

      @zwol @fasterthanlime I'm fine with the idea of requiring explicit parentheses, though I prefer a more conservative approach of

      - fixing broken precedences inherited from C, and
      - having fewer binary operators in general, and
      - subsequently having fewer precedence levels

      Applying all that, one ends up with ~5 precedence levels and <10 operators (not including comparison operators):

      Language Design: Binary Operators are Overused

      TL;DR: Use methods.

      favicon

      (soc.me)

      That kinda solves all my concerns I have with binary operators.

      1 Reply Last reply
      0
      • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

        I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

        (*one per reply, multiple replies per household are allowed)

        soc@chaos.socialS This user is from outside of this forum
        soc@chaos.socialS This user is from outside of this forum
        soc@chaos.social
        wrote last edited by
        #81

        @fasterthanlime Probably throw out the whole rather useless `PartialOrd`/`Ord` and `PartialEq`/`Eq` hierarchies, then pick better names, then implement all replacement traits for floats.

        1 Reply Last reply
        0
        • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

          I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

          (*one per reply, multiple replies per household are allowed)

          simonomi@mstdn.socialS This user is from outside of this forum
          simonomi@mstdn.socialS This user is from outside of this forum
          simonomi@mstdn.social
          wrote last edited by
          #82

          @fasterthanlime Swift-style argument labels! IMO the most underrated feature that literally every programming language would be better off with (clearer APIs with no downside!!)

          soc@chaos.socialS 1 Reply Last reply
          0
          • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

            I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

            (*one per reply, multiple replies per household are allowed)

            nanobot248@mtd.sysblog.atN This user is from outside of this forum
            nanobot248@mtd.sysblog.atN This user is from outside of this forum
            nanobot248@mtd.sysblog.at
            wrote last edited by
            #83

            @fasterthanlime i would add a compiler-supported `declaration_of!(some-struct-or-trait-name)` macro that is replaced with the trait declaration (aka the trait def without code blocks) or the struct declaration (struct field definitions and a list of all implemented traits).
            that way it would be possible to auto-generate struct proxies, e.g. when composing multiple types or for newtypes.

            1 Reply Last reply
            0
            • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

              I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

              (*one per reply, multiple replies per household are allowed)

              vbfox@hachyderm.ioV This user is from outside of this forum
              vbfox@hachyderm.ioV This user is from outside of this forum
              vbfox@hachyderm.io
              wrote last edited by
              #84

              @fasterthanlime the orphan rule.

              fasterthanlime@hachyderm.ioF 1 Reply Last reply
              0
              • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

                (*one per reply, multiple replies per household are allowed)

                michalfita@mastodon.socialM This user is from outside of this forum
                michalfita@mastodon.socialM This user is from outside of this forum
                michalfita@mastodon.social
                wrote last edited by
                #85

                @fasterthanlime Just stuff I remember now, there was more:

                1. `Arc<>::clone()` gives me goosebumps

                1 Reply Last reply
                0
                • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                  I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

                  (*one per reply, multiple replies per household are allowed)

                  michalfita@mastodon.socialM This user is from outside of this forum
                  michalfita@mastodon.socialM This user is from outside of this forum
                  michalfita@mastodon.social
                  wrote last edited by
                  #86

                  @fasterthanlime Just stuff I remember now, there was more:

                  2. lack of declaration distinction between dyn safe and dyn non-safe traits, so compiler cannot restrict us before use

                  1 Reply Last reply
                  0
                  • cyberia@tilde.zoneC cyberia@tilde.zone

                    @fasterthanlime I think I'd allow anonymous structs/enums. Often I find myself reaching to create an enum field inside a struct and it's annoying having to make a whole separate named declaration for it.

                    O This user is from outside of this forum
                    O This user is from outside of this forum
                    octorine@fosstodon.org
                    wrote last edited by
                    #87

                    @cyberia @fasterthanlime My toy language has tuples, which are like in rust, and variants, which are anonymous enums where the constructors are numbered rather than named.

                    I also defined my enums as just enums, not enums of structs.

                    1 Reply Last reply
                    0
                    • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                      I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

                      (*one per reply, multiple replies per household are allowed)

                      O This user is from outside of this forum
                      O This user is from outside of this forum
                      octorine@fosstodon.org
                      wrote last edited by
                      #88

                      @fasterthanlime Hottest take here. I would get rid of multi argument functions. We already have tuples. Every function should take one argument and return one value.

                      1 Reply Last reply
                      0
                      • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                        I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

                        (*one per reply, multiple replies per household are allowed)

                        boxdot@chaos.socialB This user is from outside of this forum
                        boxdot@chaos.socialB This user is from outside of this forum
                        boxdot@chaos.social
                        wrote last edited by
                        #89

                        @fasterthanlime Replace Pin<T> by &pin T.

                        1 Reply Last reply
                        0
                        • tribaal@hachyderm.ioT tribaal@hachyderm.io

                          @fasterthanlime I think I’d just make tokio part of the standard and avoid the async function colouring problem. Then spend time on the compiler to be smart about the actually necessary async inclusion vs compiling to sync

                          soc@chaos.socialS This user is from outside of this forum
                          soc@chaos.socialS This user is from outside of this forum
                          soc@chaos.social
                          wrote last edited by
                          #90

                          @tribaal @fasterthanlime I think other languages promised that, and they could not deliver on these promises.

                          tribaal@hachyderm.ioT 1 Reply Last reply
                          0
                          • simonomi@mstdn.socialS simonomi@mstdn.social

                            @fasterthanlime Swift-style argument labels! IMO the most underrated feature that literally every programming language would be better off with (clearer APIs with no downside!!)

                            soc@chaos.socialS This user is from outside of this forum
                            soc@chaos.socialS This user is from outside of this forum
                            soc@chaos.social
                            wrote last edited by
                            #91

                            @simonomi @fasterthanlime I don't feel they add much benefit on top of named arguments ... is there a good argument to not spend that language complexity elsewhere?

                            simonomi@mstdn.socialS 1 Reply Last reply
                            0
                            • vbfox@hachyderm.ioV vbfox@hachyderm.io

                              @fasterthanlime the orphan rule.

                              fasterthanlime@hachyderm.ioF This user is from outside of this forum
                              fasterthanlime@hachyderm.ioF This user is from outside of this forum
                              fasterthanlime@hachyderm.io
                              wrote last edited by
                              #92

                              @vbfox what's the alternative?

                              josh@social.joshtriplett.orgJ vbfox@hachyderm.ioV 2 Replies Last reply
                              0
                              • soc@chaos.socialS soc@chaos.social

                                @simonomi @fasterthanlime I don't feel they add much benefit on top of named arguments ... is there a good argument to not spend that language complexity elsewhere?

                                simonomi@mstdn.socialS This user is from outside of this forum
                                simonomi@mstdn.socialS This user is from outside of this forum
                                simonomi@mstdn.social
                                wrote last edited by
                                #93

                                @soc @fasterthanlime by "named arguments" do you mean something akin to python-style kwargs? or maybe LSP inlay of argument names at callsites?

                                a lot of the value of argument labels comes from them being manditory and chosen by the callee. i really value Swift's API design tenet of "clarity at the point of use", and even the simple aesthetic change of going from `sayHi(person)` to `sayHi(to: person)` can make a big difference IMO

                                simonomi@mstdn.socialS soc@chaos.socialS 2 Replies Last reply
                                0
                                • simonomi@mstdn.socialS simonomi@mstdn.social

                                  @soc @fasterthanlime by "named arguments" do you mean something akin to python-style kwargs? or maybe LSP inlay of argument names at callsites?

                                  a lot of the value of argument labels comes from them being manditory and chosen by the callee. i really value Swift's API design tenet of "clarity at the point of use", and even the simple aesthetic change of going from `sayHi(person)` to `sayHi(to: person)` can make a big difference IMO

                                  simonomi@mstdn.socialS This user is from outside of this forum
                                  simonomi@mstdn.socialS This user is from outside of this forum
                                  simonomi@mstdn.social
                                  wrote last edited by
                                  #94

                                  @soc @fasterthanlime aside from clarity, being able to 'overload' on argument labels is really really nice, and Rust deals with a lot of same-method-but-with-try/mut-instead already

                                  1 Reply Last reply
                                  0
                                  • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                                    I am NOT making a Rust replacement, but — if you could fix one* thing about Rust syntax/semantics/etc. what would you fix?

                                    (*one per reply, multiple replies per household are allowed)

                                    simonomi@mstdn.socialS This user is from outside of this forum
                                    simonomi@mstdn.socialS This user is from outside of this forum
                                    simonomi@mstdn.social
                                    wrote last edited by
                                    #95

                                    @fasterthanlime this one is a bit tongue-in-cheek, but i think nearly every programmer/language designer has something to learn from the Swift API design guidelines. if Rust could just steal that in its entirety (and probably improve upon it!) that'd be perfect 😛

                                    Link Preview Image
                                    Swift.org

                                    Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

                                    favicon

                                    Swift.org (swift.org)

                                    1 Reply Last reply
                                    0
                                    • soc@chaos.socialS soc@chaos.social

                                      @tribaal @fasterthanlime I think other languages promised that, and they could not deliver on these promises.

                                      tribaal@hachyderm.ioT This user is from outside of this forum
                                      tribaal@hachyderm.ioT This user is from outside of this forum
                                      tribaal@hachyderm.io
                                      wrote last edited by
                                      #96

                                      @soc @fasterthanlime which language tried to abscond the “runtime machinery” if possible at compile time? Genuine question. I know at least one language without function colouring problem for async, but to my knowledge it always includes a runtime (golang)

                                      soc@chaos.socialS 1 Reply Last reply
                                      0
                                      • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                                        Unfortunately the ecosystem is split between colored functions and coloured functions

                                        niq@fosstodon.orgN This user is from outside of this forum
                                        niq@fosstodon.orgN This user is from outside of this forum
                                        niq@fosstodon.org
                                        wrote last edited by
                                        #97

                                        @fasterthanlime maybe we can try to get the ecosystem united by compromising and spelling it coulored from now on?

                                        1 Reply Last reply
                                        0
                                        • fasterthanlime@hachyderm.ioF fasterthanlime@hachyderm.io

                                          @vbfox what's the alternative?

                                          josh@social.joshtriplett.orgJ This user is from outside of this forum
                                          josh@social.joshtriplett.orgJ This user is from outside of this forum
                                          josh@social.joshtriplett.org
                                          wrote last edited by
                                          #98
                                          There are various ways we could relax it a little. Allow top-level crates to implement arbitrary traits for arbitrary types. Allow libraries to opt-in to having new impls for their traits/types. In general, I'd love to see it become possible to integrate crate A with crate B using crate AB, rather than A or B; that would remove a major scaling issue and source of lock-in in the ecosystem.
                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups