1.  

    At this rate, C# 10 will be indistinguishable from F#! Although it’s weird that (per the top comment reply) records are only officially supported in .NET 5, when they don’t appear to be anything special compared to F# records (which evidently work fine currently). I hope that means F# records will have first-class runtime support in .NET 5, rather than there being two different-yet-identical record implementations.

    1.  

      I think you are too optimistic. Maybe in .NET 7 :)

    1. 1

      F# lets you define a module with the same name as a different module (or class) in a different namespace, bring them both in scope, and use all definitions as if from a single module. There’s also type String with ... which I believe C# has a version of as well.

      1. 25

        0x5. I like when the publication date is easy to find.

        Oh my gods yes this. SO many blogs, and even actual news sites, omit the publication date. Information goes stale quickly people, especially technical judgements and opinions. Please.

        1. 4

          Some pages even deliberately change the publication date so it always looks fresh and up-to-date for SEO.

          1. 2

            I’ve heard about that trick too. Does anyone know if it really works…?

            1. 2

              As far as I know, search engine tech has long since outsmarted simple content-based tricks like this (and e.g. keyword stuffing) to the point where “SEO” is an obsolete strategy compared to simply writing good content.

              1. 2

                The quality (or lack thereof) of Google’s results lately does make me question that assessment.

                1. 3

                  Ha, well, yes, there is that, but at least this was the general aura of advice while I was adjacent to the field a couple of years ago. The odd time I have used Google recently it feels like it’s gone the other way, where the poor quality results are because it’s trying to be too clever and completely missing the mark.

                  1. 2

                    I’ve had, recently, searches where all the results, besides the one in the top, were malicious sites.

                    1. 4

                      I’m not surprised! Google is a high-profile target, and you can game any algorithm if you can figure it out. I guess I’m saying any SEO advice aimed at legitimate websites is likely outdated at best and snake oil at worst.

                      1. 1

                        I suspect Google just doesn’t care about their search engine anymore, as they’re getting as much money as they want elsewhere than search.

        1. 3

          If I may be frank, I am unconvinced that this matters at all. Humans are used to inconsistencies in language. We can look at a code fragment containing the words String and username in any order and interpret it correctly.

          1. 2
            • It stops being easy with bigger types, e.g. if the type is a callback function type.

            • It still makes a difference for parsers. If the language supports more complex syntax like argument destructuring, or C-like definition-mirrors-usage, then the grammar for Type ident can get messy, while ident: Type starts with the simpler part and has a convenient separator.

            1. 1
              • You can put the type on its own line, Haskell-style. If it’s so large as to require multiple lines, ident: Type ends up hanging off awkwardly to the right.
              • This one certainly is cleaner, but you have the same “when does this phrase end” problem elsewhere, in e.g. expressions. You may already be using tools such as precedence, mandatory casing, and parentheses in other areas of the language to disambiguate types, patterns, and identifiers, so you can just re-use them here.

              I am not arguing that Type ident is better[1], but it seems every argument in favor of one style can be given an equally particular counterargument in favor of the other. It’s like the eternal tabs/spaces bikeshed, except it doesn’t actually seem to affect most programmers enough for them to have a strong opinion.

              [1] I am a little fond of the idea of being able to treat types as values or patterns, with the value Type having the type Type -> Type, obviating the need for type annotations as a separate construct. Obviously, this only makes sense with prefix notation in the first place.

          1. 4

            I was half expecting a 40-character line length limit.

            1. 2

              Why?

              1. 6

                50% off

            1. 2

              The recent drastic shortening of my daily commute has given me more free time, so I’m dusting off my pet language, hopefully in time to release something cool for its 13 month anniversary.

              I’m adding a language on top which should help ease the difficulty I’ve been having in creating a language while also trying to learn it.

              1. 4

                Suggested (2017), and I don’t have much time to rehash this, but: functional <> pure.

                1. 2

                  I propose a new metric unit of length, the perimetre, defined to be the circumference of a circle with a diameter of one metre. Now pi is one, which is eminently more sensible than 3-and-a-bit or six-and-a-bit, and all I need is a collection of blog posts.

                  1. 3

                    That is not how it works. In your proposal pi is one perimetre, while in reality pi is a dimensionless unit.

                    1. 4

                      Then we shall redefine one to be 1/π. That way we’ve just scaled everything up a bit. If my calculations are correct, everything should work out the same.

                      1. 1

                        1=1/π=(1/π)/π=1/π²=… ad infinitum

                      2. 1

                        Pi is one perimetre per metre, which is length/length ergo dimensionless.

                        1. 1

                          Then pi isn’t one, or it doesn’t make sense. How do you add 1 perimetre + 1 metre?

                    1. 3

                      This was a pleasant read!

                      I have thought a while about this, and will (eventually) implement this scheme for equality, mostly inspired by Scheme:

                      • identical? for reference equality (and possibly also primitives),
                      • equal? for structural equality (for types that support it),
                      • equivalent? as a more general trait which also requires a context within which you are comparing, like hashing or floats within a given epsilon. (The above two are special cases of this.)

                      Hopefully it will be intuitive and obvious, with no gotchas.

                      (Minor note: F# will let you use mutable as an adjective for Offspring and jane in case you didn’t want to switch to C# for that example).

                      1. 1

                        This reminds me of Ruby & Objective-C cocktail.

                      1. 15

                        I find it funny that most of these big tech companies claim they’re all in on going environmentally friendly, but yet you’re forced to throw a perfectly good piece of hardware into the trash after a few years. E-wasting doesn’t count because I feel most people don’t do this and e-wasting is arguably a joke. Most of your e-wasted stuff ends up on a boat to a developing nation where its ripped apart by hand and the toxic chemicals get into the local water supply.

                        1. 3

                          Consider a plausible alternative:

                          Assume that a big vendor builds its hardware thick/strong enough to last for ten years physically. Say a phone with thicker, stronger glass in front, a battery design sized for longevity, a strong case made of thick metal, and a stock of spare parts large enough that even the average customer uses the device for ten years, the demand for repairs is 95% likely to be met. Assume it sells millions, like the real devices in the real world. Assume further that most buyers replace it after two or three years anyway, perhaps because some new apps ask for newer, faster CPUs or more RAM/storage. How much glass, metal, chemicals did the vendor waste on building longevity?

                          It’s not obvious to me that catering to the people who want longevity is a net win over today’s state.

                          1. 4

                            What you are describing for a substantial part of this post is a rugged device, which is an entirely different class. You don’t need a strong metal case and a thick glass to keep a device safe that sits on the couch for most of the time.

                            No one disagrees that when someone sits on it, it’s a tradeoff to make whether it breaks or not.

                            The post is talking about software longevity, which is much easier to create.

                            1. 2

                              Actually, what I had in mind was a phone rugged enough to survive in a pocket for years without being bent out of shape or destroyed by a keyring, and with a battery designed to be charged n thousand times over many years instead of being designed for quick charging and maximum initial capacity.

                              Are phones carried around in pockets a parficularly rugged class of device? I think not.

                              EDIT: Wait, are you suggesting that manufacturers should provide software updates well after the end of a device’s expected physical lifetime?

                              1. 4

                                No, I’m suggesting that manufacturers should not block people from providing their own software updates.

                                1. 1

                                  I think you mean “should not bootlock their devices”, right?

                                  As I understand it (from idling in the LineageOS irc channel) the big problem of devices like the one in the blog post is that the hardware is buggy and there’s no documentation, not even a sensible git commit log for the kernel source. MediaTek in particular has a rotten reputation among LineageOS contributors. Some/many devices are also bootlocked and that could be a big problem, but in a way it isn’t. The comparable devices that aren’t bootlocked, or for which security bugs are well known, don’t have a lot of LineageOS ports, see?

                                  Whether you’re killed by two bullets or three doesn’t make much difference, you’re just as dead.

                                  You could of course demand documentation, sensible driver code and an open booter. That at least makes it simple to spot unsuitable vendors.

                                2. 1

                                  My old dumbphone (a Sony Ericsson w710i) is still alive and kicking after almost 15 years. I’ve dropped it countless times, I carry it in the same pocket as my keys. Battery life is still pretty good (I charge it once a week or so). I would definitely consider it “rugged”.

                                  1. 1

                                    Phone hardware tech took a giant step back in reliability with the advent of glass fronted touchscreens (don’t @ me). Older Nokias and Ericsson phones were really durable.

                              2. 3

                                Assume further that most buyers replace it after two or three years anyway, perhaps because some new apps ask for newer, faster CPUs or more RAM/storage.

                                I don’t think that’s a given. Games consoles come to mind - developers are able to wring more and more out of the same hardware over its lifespan. There’s lots of room for creativity given that kind of constraint, and I’d love to see it happen in mobile development.

                                1. 3

                                  No doubt a global recession will facilitate this…

                                  Consoles aren’t really analogous. The console makers often make decent amount of money from each game sold - the hardware is a loss leader - so it makes sense to provide games for as long as possible for each console generation.

                                  Phone/tablet hardware makers (apart from Apple) don’t make much money after the initial sale.

                                  1. 4

                                    Consoles aren’t really analogous. The console makers often make decent amount of money from each game sold - the hardware is a loss leader - so it makes sense to provide games for as long as possible for each console generation.

                                    They are - kind of. And they are a good example how long term stability yields improvements through giving people the possibility to gain experience.

                                    The price of the platform[1] is roughly stable and the sturdiness of the platform is a major part of marketing and success. They just selected their item margin to be negative. Still, they are constantly being changed internally.

                                    Apple is a good example on the high end: their margins after sale aren’t that high and they struggle to sell monthly services. They are actively moving to improve that. Google has also made the model work for them: they get fees from vendors for certification and have vendors build the hardware platform from them.

                                    One could say that consoles are a prime example of someone looking at the problem an making their business work early!

                                    [1]: For those interested, there’s a good interview on the background of the XBox 360 with their German marketing manager, sadly in German: https://www.stayforever.de/2019/12/xbox-360/. Just as an example: he makes the interesting point that consoles built out of standard components can’t drop in price over their lifespan as components need to be constantly changed - they will just not be fabricated anymore. That’s also the reason why HD sizes get bigger over the lifecycles: the vendors just don’t sell smaller ones anymore.

                                    1. 1

                                      Thanks a lot of expanding on this. Very interesting.

                                      FWIW I’m a satisfied Xbox user and I really appreciate how easy it is to acquire older games at good prices without having to hunt around for used items[1]

                                      [1] and yes I know this is probably bad for resale and for people owning physical media but it’s so damn convenient!

                                  2. 2

                                    Of course it’s not a given. The question is how often it would happen, and whether the percentage would be such that the resource waste would be larger than the waste due to the actual short lifecycles.

                                    1. 1

                                      Games consoles come to mind - developers are able to wring more and more out of the same hardware over its lifespan.

                                      The problem is that developers aren’t targeting a ten year old device, they’re targeting at most two year old devices. As long as only a tiny portion of their target market is using old devices, this won’t change. In the console case, the developer could motivate the extra optimization work with the knowledge that all their users would see the benefit since they’re all using known hardware.

                                      It’d help if OS vendors would support devices for longer periods, of course. I think we’ll need to give them some slack for the initial period of mobile device growth, since device capabilities grew enormously year to year, but today I don’t it’s unreasonable to require OS updates for ten years.

                                      1. 1

                                        The problem is even worse then this: You don’t even have to look for old devices. Lower end devices are already in the range where you are targeting a spec from 5 years ago.

                                        Apple got this a little in check by reminding developers that the devices get beefier for more multi-tasking, not for one application taking more space. I still run around with an iPhone SE and have absolutely not performance issues - I just have to use less background services over an X. So developers in that ecosystem are already used to supporting at least 5 year old devices.

                                        But this problem is really hard if you want to enter the lower end market: Firefox OS for some parts tanked because it was mainly targeting cheap devices, a device class that well-paid developers would never use. For that reason, the reference devices were also much beefier then the deploy target, which lead to a very unusable ecosystem.

                                        There’s a huge underserved market untapped because serving the top end pays well enough.

                                        1. 1

                                          Yeah, I was imagining a world where mobile devices have a 10-year lifespan and 10-year release frequency to match. I’m guessing batteries are the main thing holding that back at the moment (edit: or they could just be replaceable).

                                    2. 3

                                      People can simply not use the device.

                                      The correct way to vote with your wallet when nobody makes an item that has the attribute you want (longevity) is to not buy any more. Instead, what most people do is buy a new item, and complain on the internet.

                                      Many times I have read and heard “watch what people do, not what they say”. Corporations do.

                                      As long as consoomers continue to consoom, companies will continue to produce.

                                      1. 1

                                        but yet you’re forced to throw a perfectly good piece of hardware into the trash after a few years

                                        at what point is it the ethical thing to do to force “perfectly good piece”s of hardware into the trash if not doing so compromises the security of how many “even better” devices. Is there a threshold? Is it based on the amount of securable but kept insecure devices? Is it based on the difficulty of the exploit? How do you measure that?

                                        I would argue that if supporting a device causes other devices to be less protected against attacks, then that initial device is not “perfectly good”, but is in-fact broken and needs to be fixed or replaced.

                                        While some attacks on TLS 1.1 are still very theoretical, we know that nation states probably have the means to break it at this point and if you keep supporting TLS < 1.2, then by the nature of downgrading attacks, you’re putting every device at risk, even if it would support later TLS versions.

                                        1. 23

                                          at what point is it the ethical thing to do to force “perfectly good piece”s of hardware into the trash if not doing so compromises the security of how many “even better” devices. Is there a threshold?

                                          The tablet in question is capable of running a present-day TLS stack. It doesn’t even really need ported; we’re taking about ARMv6 at worst, and raspbian already has a TLS stack working on that architecture. It just needs a release to be zipped up, signed, and distributed.

                                          This really has little to do with TLS, and nothing up do with the website operators. They’re following best practice to ensure that rogue ISPs don’t modify their page in transit. I blame the OEM, and partly blame Google for tying TLS stack updates to the OEM.

                                          1. 1

                                            And you blame the customer, right? I assume the customer bought a tablet without even trying to choose the vendor with the longest support lifecycle. The blog post doesn’t say “I picked the vendor with the longest support lifecycle.”

                                            EDIT: If that sounds unfriendly, that’s because my phone is from the vendor with the longest support lifecycle, and it’s not long enough for my taste, and I think that if more customers would care about the support lifecycle at the time of purchase then more vendors would promise two years and mine would promise four. Complaining years later is futile, just empty words. The time of purchase is when you can vote with your wallet.

                                            1. 3

                                              my phone is from the vendor with the longest support lifecycle, and it’s not long enough for my taste

                                              Jolla still provides SailfishOS updates for its original Jolla phone which was released about 6 years and a half ago, so you probably didn’t choose the vendor with the longest support lifecycle :).

                                              1. 1

                                                I don’t recall seeing any Jolla phones at the time (around September 2018).

                                              2. 2

                                                The post addresses this and points out that even if they wanted, they couldn’t modernise/service the device themselves. That is independent of the support lifecycle.

                                                1. 2

                                                  In that case the question to ask at purchase time is whether they could modernise or service the device themselves, and the posting doesn’t say “I was careful to buy a tablet with an unlocked bootloader and no MediaTek SoC” either.

                                                  1. 2

                                                    As suppliers rarely document their intended service period, this decision is hard to make. And this is essentially “blame the problem on the customer”.

                                                    1. 1

                                                      I didn’t have much problem finding a phone vendor with a documented period, and reports from third parties that “my” vendor’s period was the longest I could expect to find.

                                                      I suspect OP didn’t even bother to try, then complained about a lack of success.

                                            2. 3

                                              That’s a bad argument. Maybe some years ago it could have been decided that looking forward, TLS stacks should be easily upgradable. Maybe our whole OS design is flawed if we have to throw away heaps of just 2-3 year old devices if they can’t be reused. Oh wait, does anyone throw away a PC because they won’t get any updates to their OS? No, no one does.

                                              Maybe Android was a bad idea.

                                          1. 1

                                            I think it may have been a Lobster that gave me this insight, many moons ago: since there’s usually an upper limit on how many elements can be stored, in-memory binary trees essentially have constant-time access and update. Ruling them out as “too slow” may be a bit pessimistic.

                                            1. 1

                                              If you take things in a very literal sense, sure, but that’s usually not what people mean when they talk about big-O. By that definition, any algorithm that runs in finite-memory is constant time.

                                              The formal definition of big-O is what happens when the size of a data structure approaches infinity. In this context, people are usually talking about an idealized computer in which you have infinite memory.

                                              1. 1

                                                Sure, I know that, and my comment was out of scope for “give the expected answer to this interview question”, but you’re presumably interviewing to work on a non-ideal computer with finite memory. It’s just as important to be able to figure out when worst-case complexity is rendered irrelevant by context and usage patterns. For instance, in the rate limiter, N is the constant upper bound for n, making everything O(1) anyway - you may even find that N=1 everywhere it’s used.

                                            1. 3

                                              I’m surprised that a market for this form factor exists. As far as I know, some of my colleagues use work supplied mobile phones and we all use a tele-conferencing setup.

                                              1. 2

                                                The form factor is really ergonomic in an office environment.

                                                1. 2

                                                  At my place of work (UK, not in a city), mobile signal is really patchy/non-existent. If you wanted everyone to use mobiles, you’d probably have to:

                                                  1. Set up some sort of VOIP (possibly with PSTN integration)
                                                  2. Install more wifi routers/repeaters.
                                                  3. Possibly find some sort of intercom alternative.
                                                  4. Buy everyone a mobile phone and set it up with company contacts, etc.

                                                  That’s a lot of hoop-jumping when you already have a working network of desk-phones. Even if you were setting up the offices from scratch, I think the desk phones might still win.

                                                  1. 1

                                                    I guess I got so used to video-conferencing that I can’t imagine investing in dedicated hardware that just does voice. A typical video-conferencing setup is just a cheap computer, camera and microphone/speaker with software setup in kiosk mode. It does voice, you can call phones AND you can video-conference.

                                                    1. 3

                                                      Desk phones last all day and don’t need a computer. They’re loved for their tactility, reliability, paid support (usually sometimes) and ability to take a beating. If your business takes or makes calls for money (but you don’t want to use headsets for whatever reason) it’s probably your first choice.

                                                      Also: some videoconferencing setups are literally a Win 10 PC in kiosk mode (complete with flashing cmd windows when you turn it on!) but none of them are cheap. There’s a lot of money in flashy meeting rooms!

                                                1. 5

                                                  Since last time: I decided to start trying to replace the GUI in Tesseract with Nuklear. It went okay until it didn’t, and now something, somewhere is causing a GL_INVALID_OPERATION after the fourth frame. It might be to do with glEnable/glDisable pairs for states that the engine was expecting to always be enabled.

                                                  This week I’ll either be tracking this issue down, which may involve wrapping every extension with an error checking macro*, or (more fun and therefore more likely) picking something with few dependencies to port to Zig. Perhaps the octree module, or something to do with shaders because they’re new and interesting to me. Either way I’m going to continue learning a lot!

                                                  *Edit: I just found debug output so this is going to be a lot easier.

                                                  1. 7

                                                    Oh cmon, Joy? An already obscured search result that includes the Forth-like Lisp-ish “Joy” programming language… Does nobody Google these words before using them or something?

                                                    1. 8

                                                      I don’t think you can reserve simple words like “Joy” in a way that nobody else can use them for anything. The most recent release of Joy the programming language is from 2003.

                                                      1. 6

                                                        Sure, but the releases of the actual program are far less interesting than the theory and paradigm the language successfully explores.

                                                      2. 8

                                                        Something something naming things is hard…

                                                        Of course, if everyone tried to move away from the California ideal of sunny optimism, a whole new vista of naming opens: Ennui, Despair, Melancholia, Spleen, Disaster…

                                                        1. 6

                                                          Or awful

                                                          1. 1

                                                            Spleen

                                                            Already taken. That’s the default don’t on OpenBSD.

                                                            1. 1

                                                              Cool! But what is a “don’t” in UNIX software?

                                                              Edit I thought I recognized it, it’s the default font.

                                                              1. 1

                                                                …I blame autocorrect. And I was offline long enough that I can’t fix it.

                                                          2. 4

                                                            Do you know how many people called Wilhelm there are? I googled and it’s more than one.

                                                            To counter this terrible argument, language and frameworks like Go, Rust, Ruby, Python, Java, Rails, Express, Node are all extremely successful with names that would not meet your criteria. So who has the burden of proof here? Do you think we should name things by just assigning a uuid to it?

                                                            When you make something, call it what you want, ignore the haters.

                                                            1. 3

                                                              It’s not a terrible argument. Go made it difficult if not insurmountable to find things about Go!. Rust, Ruby, Python, Java, and Rails (which is Ruby on Rails, anyway) are/were not names already in use by other programming languages lest they doom them to obscurity as well. The languages of the world are not running short on completely random arbitrary words to use when naming your software.

                                                              1. 1

                                                                Python is a snake, searching it would have needed disambiguation from the beginning, same with ruby and java.

                                                                “Joy web framework” is not hard to search the same way that “Ruby programming” is not hard to search. “Go programming language” was never hard for me to find either.

                                                                Ruby even named their package system “gems”. It didn’t seem to have as big of an impact as you are implying.

                                                                1. 2

                                                                  “Go programming language” vs “Go! programming language”. Try it!

                                                            2. 1

                                                              You can just google ‘joy programming language’ or ‘joy web framework’ can’t you?

                                                            1. 3

                                                              Not the author, but I thought this was fantastic. Not even sure how it’s possible

                                                              1. 2

                                                                He’s just doing a very elaborate string parsing to get the ASCII art.

                                                                1. 3

                                                                  Sure looks like it’s doing some sort of simple ray tracing, doesn’t it?

                                                                  1. 2

                                                                    Yeah, it looks like iters section is stepping along the rays (up to 15 times) and seeing if they intersect with the shape function, and lastIters is finding where each ray hits the shape. Everything before iters is there to set up the rays for each pixel, and the final steps are selecting a color. (I think.)

                                                                2. 1

                                                                  SQL is Turing complete, so it was obvious that it is possible.

                                                                  1. 4

                                                                    Obvious to you, maybe. I’m still seriously impressed with this.

                                                                1. 5

                                                                  You can’t write functions with a receiver in a different package, so even though interfaces are ‘duck typed’ they can’t be implemented for upstream types making them much less useful.

                                                                  am i mistaken or does embedding the upstream type this, but in reverse? the composition is often overlooked in go, while it is one of the best things. not being allowed to fiddle around in other packages is a good restriction as this is a symptom for other problems.

                                                                  1. 4

                                                                    Yes, embedding types is one way to solve this in Go. Rust and Go are very different in this regard.

                                                                    In Rust, it’s common to extend a type with additional functionality using traits so you don’t need to convert between the types. In Go this isn’t possible. See this for an example. The basic AsyncRead provides low level methods and AsyncReadExt provides utility functions. It means that if someone else implements AsyncRead for a type, they can use any of the AsyncReadExt methods on it (provided AsyncReadExt is imported). Something like that just isn’t easily possible in Go to the same level because it’s only possible in Rust due to generics.

                                                                    1. 2

                                                                      if you extend a type, can your extension affect what the original code was doing? Part of the motivation for Go’s typing system is that it’s designed to avoid the fragile base class problem. As someone with little Rust experience, it’s not clear how extending types in Rust avoid a fragile base class scenario.

                                                                      1. 2

                                                                        The original code is unaffected. The alternative implementation is only available to code that uses the implemented trait and Rust doesn’t allow conflicting method names within the same scope, IIRC, even if they’re for two different traits on the same type.

                                                                        1. 1

                                                                          You can. But when you try to call such a method, if it is otherwise ambiguous, then Rust will yield a compiler error. In that case, you have to use UFCS (“universal function call syntax”) to explicitly disambiguate: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a602c67af78a73308808e9a45a51ead4

                                                                          One could argue Rust programs could suffer from the fragile base class problem via default method impls on traits. But it’s not something I’ve experienced much (if at all) in practice. Rust doesn’t have inheritance, so you don’t really wind up with complex inheritance hierarchies where this sort of complexity is difficult to manage.

                                                                          1. 1

                                                                            I’ve seen it happen with extension libraries like itertools that want to add functionality that makes sense in the base trait. It’s always possible to avoid it by using UFCS, but at that point you already lost method chaining and might as well use a free function.

                                                                            https://github.com/rust-lang/rust/issues/48919

                                                                        2. 2

                                                                          No, because traits are only available to use if they’re imported. So you’re not actually modifying the actual type, but extending it.

                                                                        3. 2

                                                                          I don’t know rust, but isn’t that kind of having io.Reader in go and other types which take io.Reader implementations and implement other functionality on top of that? Like bufio.Reader?

                                                                          1. 1

                                                                            Wrapping a type to implement an interface is somewhat similar. But in Rust, you do not have to write a wrapper to implement traits. E.g. have a method to reverse code points of a String you can just define a trait and implement it directly for String:

                                                                            trait ReverseCodepoints {
                                                                              fn reverse_codepoints(&mut self);
                                                                            }
                                                                            
                                                                            impl ReverseCodepoints for String {
                                                                              fn reverse_codepoints(&mut self) {
                                                                                // Implementation.
                                                                              }
                                                                            }
                                                                            

                                                                            After that you could just call somestring.reverse_codepoints() when the trait is in scope. It’s often more convenient than wrapping, because you do not have to wrap/unwrap depending on the methods you need (or write delegation methods).

                                                                            That said, there are some limitations in that the orphan rules have to be satisfied. Very roughly, this means that the implementation should be defined in the same crate as the trait or as the type the trait is implemented for. Otherwise, two different implementations could be defined for the same type. If you cannot satisfy the orphan rules (e.g. because the type and trait come from another trait), you do need a wrapper type.

                                                                            1. 2

                                                                              This seems dangerous, since now users of the original type may not realize it has suddenly grown new talents.

                                                                              1. 2

                                                                                It actually doesn’t, because the function is not associated with the type. It’s associated with the pair of (type, trait).

                                                                                You have to import the trait ReverseCodepoints before you can call it.

                                                                                1. 1

                                                                                  Or, worse yet, that existing talents may have been redefined. (Is that possible?)

                                                                                  1. 2

                                                                                    Nope - and even if you could override an impl, the orphan rule would stop you overriding impls you don’t own.

                                                                                    1. 1

                                                                                      👍 Good to hear.

                                                                                2. 1

                                                                                  thanks for the explanation!

                                                                                  It’s often more convenient than wrapping, because you do not have to wrap/unwrap depending on the methods you need (or write delegation methods).

                                                                                  usually the wrapped versions tend to be used from there on (at least the way i use them ;), so that’s not really an issue for me. i like the verbosity of go, which may be a bit unusual, but i like that things are written down explicitly.

                                                                                3. 1

                                                                                  I had forgotten about interfaces somehow. Yes, sort of. But you’re limited to wrapping stuff one level at a time and you have to actually make new wrapper types.

                                                                                  1. 1

                                                                                    i kind-of like that in go i have to add new types for new functionality, but i see why traits may be good (without having written rust yet..)

                                                                            1. 9

                                                                              What about a little checkbox that says “I am not being tortured in exchange for access”? Put it in the Terms of Service, simple as.

                                                                              1. 8

                                                                                “Please select all squares containing your captors. If there are none, click skip.”

                                                                              1. 1

                                                                                I hope y’all are ok with responses from people that aren’t using Common Lisp?

                                                                                1. 1

                                                                                  That seems contrary to the purpose of the poll.

                                                                                  1. 4

                                                                                    The very first answer option says “Never used Common Lisp” so I think they’re okay with it.

                                                                                    1. 2

                                                                                      Oh, i misread the comment i responsen to. Sorry! You’re both correct!

                                                                                      1. 1

                                                                                        No worries! Now I look unnecessarily sassy.

                                                                                        The Haskell and Rust versions of this survey also ask something similar.

                                                                                  2. 1

                                                                                    Definitely okay!

                                                                                  1. 4

                                                                                    I tended to coin and spread my own jargon more when I was in college or startups; now that I’m woking for a big company I usually just go along with what’s current. A few I remember from my past:

                                                                                    • FTP to rhyme with “shut up” when used as a verb (also “scup” for scp, which I still use, but I think that one is more common)
                                                                                    • goatsed to mean “seriously fubared” - coined it when i was working for a startup and it became popular within the company but i didn’t really use it after i changed jobs
                                                                                    • dot to extend the c++ method call usage to real-world operations (e.g. “sam.ask for ‘go ask sam about it’”). was popular with a small group of friends when i was in college, but didn’t really use it afterwards
                                                                                    1. 2

                                                                                      Regarding alternate pronunciations:

                                                                                      For many years, I pronounced SQL as “sqall” and UI as “yooey”. Both save some time when speaking, and both give a nice sense for the feel of working on these things.

                                                                                      1. 1

                                                                                        Do you think there is anyone that pronounces SQL as squeal? That would be hilarious if it came unexpected.

                                                                                        1. 3

                                                                                          I haven’t seen anyone who does, though I’ve heard sequel.

                                                                                          1. 1

                                                                                            That’s the only way we pronounce it in my circles. It took me awhile to adjust to My ESS QUEUE ELL (and I still think of it as My Sequel in my head).

                                                                                          2. 3

                                                                                            I’ve always pronounced it “squirrel”. It started as a joke in protest of “sequel”, but it’s starting to stick at work.

                                                                                            1. 1
                                                                                        1. 4

                                                                                          I wrote another interpreter for my pet language, in Lua, and now I have to decide whether it’s worth continuing work on the “JIT” library I’d started, because it’s now fast enough that it doesn’t need it any more. I’ve lost some momentum on this project recently, and I’ve been putting off choosing from my large laundry list of features to work on next.

                                                                                          I also started prodding around in a neato game engine to see what I can learn, so maybe I’ll sink my time into that instead. Who knows!

                                                                                          1. 2

                                                                                            Have you written about your language, or published the source?

                                                                                            1. 3

                                                                                              Oh, yeah, I never link it in these weekly threads. Here’s its homepage with a couple of articles of interest linked along the top, including the repo. Thanks for reminding me to check it - I haven’t actually pushed the source for the Lua interpreter even though it’s complete!

                                                                                              1. 2

                                                                                                Excellent! Worst is very similar in it’s core to a language I’ve been building over the last few years… And, by “building” I mean, I have a ton of random prototypes in various states, and out of date documents describing it. But, I immediately felt validated! In my case, it’s a reinterpretation of Joy with a Scheme slant. e.g. stack based, s-expressions, macros (like scheme, not just quotations like Joy) etc, etc.