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

    @cyberia @simon @yosh @poliorcetics Right, I don't mean that as like an insult saying you're incapable of imagining things outside of the tools you're currently allowed to use. I'm just saying that I've caught myself coming up with excuses for the limitations of the language I use because I know those limitations are not going to be lifted... and therefore, it's easier to imagine that they make sense than to imagine that I'm suffering for no good reason is the long version of what I was trying to say.

    cyberia@tilde.zoneC This user is from outside of this forum
    cyberia@tilde.zoneC This user is from outside of this forum
    cyberia@tilde.zone
    wrote last edited by
    #60

    @fasterthanlime @simon @yosh @poliorcetics Sure - but this is a pattern I use in TypeScript as well which allows anonymous structs as function returns. In this case the restriction in Rust made me a better TS engineer, so it goes both ways. I would definitely agree with you in other contexts (like passing structs as parameters in C being messy meaning that people think it's an undesirable thing in general)

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

      I think I may have accidentally come up with a drinking game

      If someone mentions function coloring, you have to finish your glass

      sdowney@mastodon.socialS This user is from outside of this forum
      sdowney@mastodon.socialS This user is from outside of this forum
      sdowney@mastodon.social
      wrote last edited by
      #61

      @fasterthanlime
      Do I have to finish sync or async?

      1 Reply Last reply
      0
      • chosunone@pleroma.chosunone.ioC chosunone@pleroma.chosunone.io
        @fasterthanlime When I borrow `self` mutably, it ends up locking down the entire self from immutable borrows, but really I just want certain fields to be locked down. Some fields will never be mutably borrowed and so I should allow immutable borrows to self that only access those fields. Basically in the direction of field projection.
        ianthetechie@fosstodon.orgI This user is from outside of this forum
        ianthetechie@fosstodon.orgI This user is from outside of this forum
        ianthetechie@fosstodon.org
        wrote last edited by
        #62

        @chosunone @fasterthanlime I think this just comes down to making the borrow checker (static analysis) more intelligent so that you can have more granular *borrows*, right?

        Actually marking the fields as mutable or immutable doesn’t make much sense to me either, so I guess you’re suggesting either new syntax when borrowing or else a smarter borrow checker?

        (It’s a tension point to be sure but I don’t hit it very often)

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

          Unfortunately the ecosystem is split between colored functions and coloured functions

          ianthetechie@fosstodon.orgI This user is from outside of this forum
          ianthetechie@fosstodon.orgI This user is from outside of this forum
          ianthetechie@fosstodon.org
          wrote last edited by
          #63

          @fasterthanlime I frequently write both and TBH this isn’t even in my top 10 complaints 🤷

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

            @yanns they use `_` for that? huh! been a while since my EPFL days

            yanns@mstdn.socialY This user is from outside of this forum
            yanns@mstdn.socialY This user is from outside of this forum
            yanns@mstdn.social
            wrote last edited by
            #64

            @fasterthanlime they used '_' for a lot of things, too much actually, bringing confusion. In Scala 3, they tried to reduce this, for example by using '*' for imports.

            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)

              waridley@mastodon.gamedev.placeW This user is from outside of this forum
              waridley@mastodon.gamedev.placeW This user is from outside of this forum
              waridley@mastodon.gamedev.place
              wrote last edited by
              #65

              @fasterthanlime The `Index` trait would be able to returned owned smart pointers.

              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)

                ianthetechie@fosstodon.orgI This user is from outside of this forum
                ianthetechie@fosstodon.orgI This user is from outside of this forum
                ianthetechie@fosstodon.org
                wrote last edited by
                #66

                @fasterthanlime well my number one was fixed literally in my birthday in 1.88 with if let chaining. And that was a complaint from the first day I started writing Rust about 8 years ago 😂

                These days my biggest complaints are probably

                1. The relatively clunky syntax for nested lookups in deeply optional trees like JSON structures.
                2. The lack of a Swift style defer block. This can be emulated with scope/drop guards but a proper keyword would be so much nicer.

                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)

                  piecritic@hachyderm.ioP This user is from outside of this forum
                  piecritic@hachyderm.ioP This user is from outside of this forum
                  piecritic@hachyderm.io
                  wrote last edited by
                  #67

                  @fasterthanlime List<T>, Collection<T>, Map<K, V> (https://github.com/bbqsrc/collections) -- and also that concrete methods override trait methods, not the other way around (related to the above, was a shitshow implementing this.)

                  1 Reply Last reply
                  0
                  • latenightowl@social.linux.pizzaL latenightowl@social.linux.pizza

                    @fasterthanlime The syntax for traits: in my head, "I am writing a struct implementing this trait", not "this trait is also implemented by my struct".

                    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
                    #68

                    @latenightowl @fasterthanlime Agreed.

                    Though even if one stayed with the existing approach

                    > trait SomeTrait for Type

                    would be better than the

                    > impl SomeTrait for Type

                    Rust today uses.

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

                      Unfortunately the ecosystem is split between colored functions and coloured functions

                      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
                      #69

                      This would honestly make a decent Twitch stream

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

                        @arichtman @pndc yeah exactly the fix is unsoundness so..

                        piecritic@hachyderm.ioP This user is from outside of this forum
                        piecritic@hachyderm.ioP This user is from outside of this forum
                        piecritic@hachyderm.io
                        wrote last edited by
                        #70

                        @fasterthanlime @arichtman @pndc invent a concept of restricted or external traits and go insane at the consequences

                        1 Reply Last reply
                        0
                        • samir@mastodon.functional.computerS samir@mastodon.functional.computer

                          @lutzky @fasterthanlime I would very much like a garbage-collected language that shares the Rust standard library and has first-class interop with Rust libraries.

                          I have no idea if it’s possible though.

                          piecritic@hachyderm.ioP This user is from outside of this forum
                          piecritic@hachyderm.ioP This user is from outside of this forum
                          piecritic@hachyderm.io
                          wrote last edited by
                          #71

                          @samir @lutzky @fasterthanlime I have done experimental crimes in the past on this, and to a large extent this is possible.

                          The problem is of course the infinite number of edge cases and the fact that, in practice, you'd need to use the C ABI to have nice things. And the C ABI is the antithesis of nice things.

                          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)

                            gronkulus@app.wafrn.netG This user is from outside of this forum
                            gronkulus@app.wafrn.netG This user is from outside of this forum
                            gronkulus@app.wafrn.net
                            wrote last edited by
                            #72

                            The ability to be generic over const/mut references - I very often find myself writing get and get_mut methods for the same things. You can hack together a version of this with GATs but it really deserves dedicated syntax, or better yet a single system to abstract over mut-ness, async-ness and const-ness.

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

                              @zwol @fasterthanlime That one is also on my list!

                              Do you have your list somewhere?
                              My list (syntax-only) is https://soc.me/languages/design-mistakes-in-rust.

                              zwol@masto.hackers.townZ This user is from outside of this forum
                              zwol@masto.hackers.townZ This user is from outside of this forum
                              zwol@masto.hackers.town
                              wrote last edited by
                              #73

                              @soc @fasterthanlime I've never written the whole thing down, no.

                              Looking at your list, I would also have proposed [] instead of <> for generics, and smushing :: into . by whatever means necessary. I'm indifferent to = instead of : for key/value pair literals. Many of the other things feel uncomfortable as a knee jerk reaction but maybe I could get used to them. I think you're wrong about what macros get used for.

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

                                @soc @fasterthanlime I've never written the whole thing down, no.

                                Looking at your list, I would also have proposed [] instead of <> for generics, and smushing :: into . by whatever means necessary. I'm indifferent to = instead of : for key/value pair literals. Many of the other things feel uncomfortable as a knee jerk reaction but maybe I could get used to them. I think you're wrong about what macros get used for.

                                zwol@masto.hackers.townZ This user is from outside of this forum
                                zwol@masto.hackers.townZ This user is from outside of this forum
                                zwol@masto.hackers.town
                                wrote last edited by
                                #74

                                @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 2 Replies Last reply
                                0
                                • lutzky@ohai.socialL lutzky@ohai.social

                                  @fasterthanlime support a "slow but correct" mode. Rust's tradeoff is "fight the compiler hard, but resulting code is fast and correct". I'd like an option for "less compiler fighting, slower is OK, less correct is not OK". Something like "implicitly wrap all my shit with garbage collection". I'd like Go-level performance with rust-level correctness.

                                  lutzky@ohai.socialL This user is from outside of this forum
                                  lutzky@ohai.socialL This user is from outside of this forum
                                  lutzky@ohai.social
                                  wrote last edited by
                                  #75

                                  @fasterthanlime bonus points if it's reversible. That is, I'd like to stick #[!author_is_lazy_just_gc_everything] on the top, and:

                                  1. Write new code like the lazy bastard I am
                                  2. Be able to go "oh shit, ot does need to be fast" later, remove it, receive the justice of compiler errors
                                  3. Decide "this fast code needs maintenance but I am lazy" - stick the #[!thing] on top on preexisting, correct rust code, and only then add stuff.

                                  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
                                    #76

                                    @zwol @fasterthanlime Oh, I agree on that!

                                    I have put that in a non-Rust-specific article here:
                                    https://soc.me/languages/unary-operators-are-unnecessary

                                    zwol@masto.hackers.townZ 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)

                                      cuchaz@gladtech.socialC This user is from outside of this forum
                                      cuchaz@gladtech.socialC This user is from outside of this forum
                                      cuchaz@gladtech.social
                                      wrote last edited by
                                      #77

                                      @fasterthanlime I'd fix whatever language/compiler defects cause async streams to be SO BAD to create.

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

                                        @zwol @fasterthanlime Oh, I agree on that!

                                        I have put that in a non-Rust-specific article here:
                                        https://soc.me/languages/unary-operators-are-unnecessary

                                        zwol@masto.hackers.townZ This user is from outside of this forum
                                        zwol@masto.hackers.townZ This user is from outside of this forum
                                        zwol@masto.hackers.town
                                        wrote last edited by
                                        #78

                                        @soc @fasterthanlime I cannot agree with dropping prefix unary negation operators. Too much of a divergence from math notation.

                                        And I think dereference does need an operator, not a method, I just think it belongs on the right. I'm not sure about enreference (unary &); it feels natural to put it on the left but maybe that's 40 years of C talking.

                                        Rust has a thing where sometimes you have to write &*(expr) or *&(expr) and all of *those* cases should be intrinsic methods, yeah.

                                        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)

                                          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
                                          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