Threads for doug-moen

  1. 16

    By default, GCC optimizes for performance at the expense of security, safety and the ability to audit code.

    This is not the right choice for everybody, and I don’t think it should be the default. Nevertheless, there is a compiler flag: -fwrapv:

    This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This flag enables some optimizations and disables other.

    The Linux kernel has used -fwrapv since 2009. There are open bugs in Mozilla and Chrome to enable the flag.

    1. 2

      By default, GCC doesn’t optimise. You have to pass a -O flag to make GCC optimise.

    1. 9

      When I was younger, I heard that girls are ahead of boys in social skills (during the age range that these ads target – don’t worry, the boys eventually catch up). Thus, the average boy is more likely to be interested in things, and the average girl is more likely to be interested in people. Social activities for boys are thus oriented around these things, and computers are the ultimate “thing”, with games being the dominant activity, but programming was in there too. In the very early days of home computers, games would be printed in magazines as basic programs, and you would type them in and run them. As a boy, I heard reports that the girls were more interested in social status games.

      Another interesting fact: in my high school, the math classes were segregated by ability, and the high level math classes were dominated by girls. Girls were better at math. So they ought to have been better at programming, too?

      When the home computer boom happened, from a girl’s perspective, computer science probably changed from being a high status, high paying career option to something associated with the home computers that her annoying brother and his friends were obsessed with. Just speculating.

      1. 18

        Not disputing anything in the article, but I think there is another important angle to consider:

        Big companies with huge development budgets are also able to afford huge marketing budgets. This means they get a lot of users regardless of the quality of their design. A lot of these users had little experience with software until they started using commercial software (I am talking historically now, I think modern kids grow up with a smartphone in their crib). So even though the software might have been badly designed, people got used to it because it was all they knew. So ‘good design’ is to a large degree defined by big commercial software, not always by actual merit or sensible usability principles. On the other side of that coin, a lot of computer nerds and developers are used to command line interfaces, and these can be quite elegant and powerful. Calling them badly designed is missing the point slightly.

        What it comes down to for me is design that teaches vs. design that hides how things work. Take for example the wifi signal icon on most mobile devices. 3 bars is good, 1 bar is bad, 0 bars means not working at all. Everyone uses it, the industry standard. This actually hides a large number of values like signal to noise ratio, signal power, packet loss rate, ping and bandwidth (actually probably only 1 or 2 of those even have an effect on the icon in most cases). If on the other hand each of these values - to the degree it is measurable - were available to the user, the user might learn a lot about how wireless communication works and be more effective at troubleshooting and optimising their digital experience. I am not suggesting valuable screen space should be taken up always showing these values, but if the user tries to interact with the icon in some way they should be available as a pop-up or tooltip or expanded icon or whatever.

        People often reply that no one would be interested in this, that users ‘just want things to work’. But I am arguing they have been trained to want that on purpose by UI design. Having the extra information available will result in people building up experience gradually, over time. People care a lot during periods where connectivity is an issue and that is when these values matter. Once there is some familiarity the whole language and understanding of networks among the entire population is elevated to a new level and this has consequences across everything.

        Big companies can afford to domesticate their users, to iron out every wrinkle in the UI so people can use it without thinking and contact customer support if something inexplicable happens. They also have a a vested interest in doing this, and making their specific design standards familiar to the users so that others are forced to emulate them. Not only can FOSS developers not afford this, it also goes against the principles of FOSS to even try.

        My call to designers is to try and make a UI that teaches the user how the tech works. I know this is a big ask, but it will be worth it.

        tl:dr Corporations can afford to make their users into cattle, ‘good’ design would be to make your users into better humans.

        1. 2

          What it comes down to for me is design that teaches vs. design that hides how things work. Take for example the wifi signal icon on most mobile devices. 3 bars is good, 1 bar is bad, 0 bars means not working at all. Everyone uses it, the industry standard. This actually hides a large number of values like signal to noise ratio, signal power, packet loss rate, ping and bandwidth (actually probably only 1 or 2 of those even have an effect on the icon in most cases). If on the other hand each of these values - to the degree it is measurable - were available to the user, the user might learn a lot about how wireless communication works and be more effective at troubleshooting and optimising their digital experience. I am not suggesting valuable screen space should be taken up always showing these values, but if the user tries to interact with the icon in some way they should be available as a pop-up or tooltip or expanded icon or whatever.

          On MacOS, if you click on the wifi icon with the option key held down, then you do see a lot of low level information, including most of the information you are asking for. I use the Cinnamon DE on Linux, and there’s no corresponding key binding that I can find. No doubt I can find and install a CLI command that shows the same information, but that would be a lot of effort. So MacOS is better designed, for this specific case.

        1. 1

          For integers in the range [-((2^52)-1), (2^52)-1], you can evaluate floor and ceiling division using float math (ie rounding twice), and get correct results. This is pretty easy to see if you consider that:

          1. Division is monotonic

          2. All integers within the range are exactly representable

          3. Roundoff can never exceed the threshold where rounding twice would be a problem, because the denominator always has magnitude >1, meaning that the precision of the result will be at least that of the inputs

          Something similar applies to sqrt. Knowing this—and when it’s true—is valuable, because many processors provide optimised vectorised instructions for floating-point numbers which can run faster than the corresponding integer operations (if they even exist at all).

          (Floats can represent all integers with magnitude <=2^53, but when I tried to prove that sqrt gave correct results for all integers in that range, I encountered some annoyances; leaving a bit of buffer simplified matters. I have a strong intuition that it works for the full range, but haven’t bothered working out the details yet.)

          1. 1

            Float precision for integers breaks at 2²⁴. You can try it with this:

            #include <stdio.h>
            
            int main()
            {
                for (unsigned i = 0; i != ~0U; i++) {
                    float f = i;
                    if ((unsigned)f != i) {
                        fprintf(stderr, "precision breaks at i=0x%x (f=%g)\n", i, f);
                        return 0;
                    }
                }
                return 0;
            }
            

            => precision breaks at i=0x1000001 (f=1.67772e+07)

            What code snippets are you actually suggesting for floor and ceil?

            Note that the reason for working with integers are multiple, performance is one but not the main one. Working with floats can be problematic for all sort of reasons, and sometimes you want to avoid them entirely: in kernel land, with specific arch with inefficient or unavailable floating point, when precision/determinism is needed (don’t want system/libc approximations to slip in), …

            1. 1

              I meant double-precision floats, obviously.

              precision/determinism

              The basic arithmetic operations are guaranteed to be deterministic and faithfully rounded. And my comment described circumstances under which floating-point math will give exact results. Floating-point math is not magical fairy dust that sprinkles imprecision over your code; it can be understood and tamed.

              I agree that in a kernel or on a float-free arch, it’s desirable to avoid float-free math, but both of those are the exception rather than the rule for most code.

              1. 2

                The basic arithmetic operations are guaranteed to be deterministic and faithfully rounded. … Floating-point math is not magical fairy dust that sprinkles imprecision over your code;

                This is not true for GPU programming, where float arithmetic is not guaranteed to follow the IEEE standard. Also, if you are coding to certain GPU APIs, like WebGPU or Metal, then you do not have access to 64 bit floats. With other APIs, like Vulkan, you have to test at runtime if doubles are available. On GPUs, float arithmetic is fast, but you give up reproducible results across different GPUs.

                1. 2

                  It’s not about imprecision. One of the argument I made was determinism: depending on the system, arch, toolchain version, etc the float operations won’t be the same (different instructions, exploiting different implementation-free behavior, or differently implemented maths functions on the system, etc) and you may get different results depending on your environment. This makes tests much more complex typically (implies a threshold infrastructure of some sort, which is not always doable).

            1. 2

              I noticed that your round function rounds away from zero, just like C and Posix. This jumped out at me because the languages I’ve been using recently, which care about numerics, use round-to-even semantics instead for their round function. In fact, the IEEE float standard defaults to round-to-even for rounding arithmetic results, and doesn’t have a round-away-from-zero rounding mode. This is because round-to-even reduces bias.

              So I went down a rabbit hole. Why does C round use round-away-from-zero? My first guess is that it’s because that’s how the PDP-11 works, and C was originally designed as a thin layer of abstraction over PDP-11 assembly language. I checked, and indeed, the PDP-11 floating point unit had pre-IEEE float semantics, and defaulted to rounding away from zero. So that’s probably it.

              It’s weird that we are still building software that prioritizes PDP-11 floating point semantics over IEEE float semantics and modern best practice for floating point computation. It’s because of C – the way C works is often more important than those other considerations.

              1. 1

                Yup that’s explained in the article, notably when I’m mentioning the Python rounding. Rounding to even needs a different method which I didn’t investigate yet. Do you have a proposition for that? With a proof? I’m curious if it’s going to be simpler or not

                1. 1

                  Edited the post to add a version for the round to even choice.

              1. 2

                I agree with the general sentiments, and I prefer to program in a dynamic, pure functional programming language.

                Although you can do some functional programming in Python, not all functional programming idioms are supported, efficient or convenient, and the library ecosystem is mostly imperative rather than functional. I would rather use a language that is designed from the ground up to support pure functional programming, with features like proper tail calls, immutable data structures with efficient update, and the ability to do everything without using shared mutable state.

                1. 1

                  I totally agree. Which ”dynamic, pure functional programming language” do you prefer these days?

                  1. 1

                    That’s a good question. Any suggestions? There seems to be a shortage of the kind of language I want to use. Highly expressive and dynamic, in the Lisp/Smalltalk sense, yet pure functional, with no shared mutable state, and simple, in the sense of minimizing cognitive load and enabling you to use local reasoning to understand code.

                    I created my own language called Curv a while back, which is used for creating 2D and 3D art. I’m working on a new one which will be more general purpose.

                    1. 2

                      Clojure seems to be a great fit for your criteria. The only thing that keeps it being close enough to perfect for me is that I want strong typing.

                      1. 1

                        I’m working on something like this. Would be interesting to hear what you’re doing too. Probably will release what I have early next year. I’ll check out Curv.

                        1. 1

                          I would be interested in talking to you about your project. My email address is in the Curv readme. If you have anything online that describes your language, post a link or send it to me.

                  1. 2

                    Hey @chreke, you said

                    The end result of STEPS was KSWorld, a complete operating system including both a document editor and spreadsheet editor, which ended up being about 17 000 lines of code.

                    Do you know if the source code is available? Can people actually download and run KSWorld?

                    1. 1

                      I don’t think so unfortunately, which I think is kind of weird. However, you can find Gezira, JITBlt and Nile on Dan Amelang’s GitHub page: https://github.com/damelang

                    1. 3

                      Yikes.

                      And it’s still dominant for turning up new platforms, just because existing compilers are so easy?

                      1. 11

                        If you create a new operating system, and there is no C/C++ compiler available, then the majority of free / open source software can’t be compiled and run, because C/C++ are the foundation for everything we use. You will have no web browser, no shell, no Python, no Rust, no Javascript, no Ruby, and so on. C is also the foundation for interoperability between programming languages. If Haskell code wants to interoperate with Rust code at the function call level, it is done via C.

                      1. 9

                        I’ve much respect for Archive.org and Brewster but “Ever try reading an ebook you paid for 10 years ago?” and “Without active maintenance, we will be lucky if our digital books last a decade.” are stretching it by quite a lot.

                        I still have ebooks from Amazon from more than 10 years ago and I can read them with no problem. Maybe that won’t be the case in another 10 years, and there may be formats that don’t make it a decade – but there’s a lot of us walking around with 10+ year old collections via the Kindle or similar that aren’t (yet) having problems with our libraries.

                        While I agree with Kahle on a lot of the larger points, I worry that an average person reading this is going to note that they’ve had a Kindle for a decade and still manage to read “old” content just fine and consider the larger points suspect.

                        1. 14

                          They’re concerned because they store books in arcane formats designed to be difficult to download, because you have to “borrow” ebooks from the Internet Archive digital library. No, don’t just convert it to EPUB 3 and add a download link, that’s too complicated - reprocess and “re-invigorate” it yearly for some reason and make it really hard to read. Borrowing ebooks with an hour lease… inane.

                          1. 5

                            you have to “borrow” ebooks from the Internet Archive digital library. No, don’t just convert it to EPUB 3 and add a download link, that’s too complicated

                            You realize that if Internet Archive did what you suggest, they would be sued out of existence by book publishers? In fact, there is an ongoing lawsuit right now by 4 publishers asking $19,000,000 damages and the deletion of 1.4 million e-books. https://www.dailydot.com/debug/internet-archive-lawsuit/

                            1. 2

                              They’re being sued out of existence by book publishers for offering to let you “borrow” ebooks so, I don’t imagine things would be any different if you could just scrape them. :D

                            2. 1

                              I think it’s worth beating a drum that the Gutenberg Project is a failure. Every person you know, nerd or not, has heard of and used Wikipedia. Only a handful of nerds have heard of the Gutenberg Project. A major reason for this is that GP thinks that the only hard part of the problem is text entry. But distribution is just as important! Without making an easy to use and easy to read product, GP basically might as well not exist at all. The only people it benefits are grey market scammers who sell free books on Amazon for 99 cents.

                              1. 10

                                The Gutenberg project offers 60,000 out of copyright books, which are mostly over 100 years old. It’s pretty niche.

                                This thread is about the Internet Archive, which is a much larger project offering a vast amount of current material, including books, movies and a historical archive of the world wide web. I use it frequently.

                            3. 7

                              As someone who switched from Kindle to Kobo, my Amazon ebooks are useless unless I download them to my PC (Amazon already makes this a little annoying), download Calibre, download the De-DRM plugin, and strip the DRM from them. Maybe most people stick with Kindle for a longer period of time than me, but the fact that they might lose access to all of their Amazon books also makes it hard to switch away.

                              1. 5

                                I stopped using my Kindle after Amazon pushed an OTA update that bricked my device. Now I’m on Kobo, but I’m still subject to the same problem if the Kobo people ever screw up my device.

                              2. 6

                                Yeah, and there’s also a lot of stuff being swept under the rug here.

                                You can keep a physical book readable long enough for multiple future generations to enjoy it. But that requires both up-front and ongoing effort. Up-front to ensure the book was made using materials of sufficient quality and resilience to last that long. Ongoing to ensure it’s stored and cared for in a way that will minimize long-term damage to it from its environment, and potentially restoring it occasionally – new binding, new covers, careful cleaning, etc.

                                And most infrastructure for book storage is not particularly high quality these days. Home bookshelves/bookcases are also often made of cheap/lower-quality materials and designed to be thrown away and replaced every few years.

                                So when the article laments that digital books require “active maintenance”, my only response is “Well, so do physical books”. The implication that physical books just automatically last for centuries is not only wrong, it’s bordering on insulting to the people – librarians and curators and collectors and amateurs who love their books – who do put in the “active maintenance” work to preserve physical books, and whose work is simply erased by this framing.

                                1. 1

                                  Agreed—if you live in an area with relatively dry air then it’s not much of a problem, but humidity really does a number on books. Not to mention that if you don’t get expensive hardbacks the only thing holding a book together nowadays is a mixture of cheap glue and wishful thinking.

                              1. 7

                                Thinking locally, the author should do what’s needed for their project to succeed. I’m sympathetic.

                                Thinking globally, I guess this is posted to Lobsters to discuss the larger philosophical issues? Okay, what would the world look like if the entire toolchain used by the author for their project was licenced as BSL (and always had been). Linux, gcc/clang, vi/emacs, etc. Or should all those other projects also now move to BSL, since they are clearly valuable to large parts of the software industry? What are the consequences for society? Do things get better or worse? If Open Source had been defined as “BSL” back in the day, then would the open source landscape today have even more and better choices, with better funding and salaries for developers, or would open source today be a wasteland?

                                1. 13

                                  While I have mixed feelings about the BSL, and it’s not clear what their plan is int this specific case, it’s also important to note that BSL is an actual attempt at a compromise, unlike Commons Clause or other nonfree licenses. The code ends up as open source eventually, which is a big step up from some things they might be considering.

                                  1. 5

                                    I am almost completely sure if BSL were more popular back in the day, we would have even more and better choices, with better funding and salaries for developers.

                                    1. 4

                                      I think you’re posing a wrong question. BSL and alike are not the enemy of Open Source. After all Open Source was a “business-friendly” response to Free Software. Like Free Software was a response to proprietary software. Each solved its own problem.

                                      Free Software tried to make software accessible. And it succeeded. However, there was a problem. Business was reluctant to use that free software because of its viral lienes. No one knew what to make of it and tried to stay on the safe side. So FS was left mostly to hobbyists for the time.

                                      Open Source came along to directly address adoption. By being more permssive OS licenses allowed the whole idea to spread beyond idiologic users and researchers. And OS succeeded.

                                      However, now we have another problem. software widely adopted and used but there’s a lack of resources on the mantenance/development side of it. Too many requests from users, too much demand of developers’ time. BSL is an obvious thing to try. It’s hard to tell whether it will solve the issue but at least it’s a capitalist solution to a capitalist problem so there’s hope.

                                      Now, let’s take your proposed scenario. I think it’d be just different. Maybe slightly better. The hole FOSS boom would’ve probably took a little longer as there would be some financial pressure agains software adoption but otherwise nothing would’ve changed much. There still would’ve been great demand for software. However, maintainers would’ve been in a much healthier position. And the whole idea of paying for software would be a little bit more acceptable. We probably wouldn’t see as many rants denouncing great software for authors wanting to pay their bills.

                                      Just to reiterate. BSL is not an enemy of FOSS. Facebook would still push React under Open Source License, as would Google push Kubernetes and so on. Corporations are getting completely different thing out of it and for them Open Source licenses are as good as it can get.

                                      1. 5

                                        Free Software tried to make software accessible. And it succeeded. However, there was a problem. Business was reluctant to use that free software because of its viral lienes. No one knew what to make of it and tried to stay on the safe side. So FS was left mostly to hobbyists for the time.

                                        I think this oversimplifies the history of these two camps to the point of false abstraction. The free software movement was never interested in business use of free software; they only cared about the agency of individual users. GNU was born out of a situation where commercial software was already taking over, commercial software will always be fine.

                                        Open Source came along to directly address adoption. By being more permssive OS licenses allowed the whole idea to spread beyond idiologic users and researchers. And OS succeeded.

                                        You make this sound as if free software underwent a licensing change to increase adoption, but this is not the case. No one can dispute that the Linux kernel is probably the most successful free software project in history. It remains GPL licensed. This has not changed since it’s inception.

                                        The commercial adoption came first, and then more permissive licenses became more fashionable as using free software in business became normal. If permissiveness of licensing was the core issue, then surely a BSD derivative would have succeeded over Linux.

                                        Open Source came about by a faction of people who wanted to commercialize free software. The new language was a rhetorical change intended to assuage the fears business had about viral licenses and open development. It was an attempt to sever the material differences in how software was developed under free licenses from the moralism of the FSF.

                                      2. 2

                                        I’m not sure - Ghostscript did this before with its dual license scheme. It makes one think twice before contributing - because now you’re contributing for free to something that makes money for someone else. It would also typically require you to sign a copyright assignment agreement so that the original author can legally continue doing what they are doing. For the original author(s), it also makes the decision to add someone to the core team more difficult, assuming it means they would now have to pay them. And I would expect so, because who would willingly spend more of their free time and work to fatten another man’s wallet?

                                        On the whole, I don’t think open source would be a wasteland, per se. On one hand, it would slow down contributions, so maybe we wouldn’t be where we were today and have a lot less choice and products that are a lot less polished. On the other hand, it might mean people got paid and didn’t burn out so easily, and perhaps give them the opportunity to work on free software full-time, so like you said it might also be that we’d have more and better choices now, and more software would be source-available (so basically achieving the FSF’s goals, if in a somewhat diluted form)

                                        1. 6

                                          It makes one think twice before contributing - because now you’re contributing for free to something that makes money for someone else.

                                          I don’t mind that they make money, I mind the asymmetry: they can make money in a way that I cannot, from a project that we both contribute to. This principle of fairness is critical in most F/OSS licenses: if you and I collaborate on something then we both have the same rights to the result. There are a few exceptions but they tend to be unpopular.

                                          1. 6

                                            This issue becomes especially relevant when the original project becomes abandoned and someone has to start a fork to keep it alive. There is no clause in BSL that covers that. If the original authors do not explicitly re-license the code (which they may not even be able to do, in case of a hostile takeover, for example), then forking isn’t a practical possibility at all.

                                            I suppose it may even make companies that have popular products under BSL attractive targets for takeovers, since communities cannot do anything to keep the open-source version alive — everyone who wants to keep using the software has to buy it from the new owner on their new terms.

                                            1. 4

                                              That’s an excellent point. From a corporate perspective, the ability to create a second source if none exists is one of the key values of F/OSS. If a company takes a project in a direction that you, as a customer, don’t like then you can pay any other company that is willing to bid to maintain a fork that goes in the direction that you want. That’s a last resort, but the fact that it’s possible is generally enough of an incentive to stop the maintainers going too far off the rails. With dual licensing, you lose this. You may be happy to pay for version X, but if version X + N drops features that you depend on, has show-stopper bugs for you, or whatever then you can’t just pay someone to fix the open version you need to negotiate with the maintainers to add the features that you need. That makes it much higher risk than a real F/OSS license that is sufficiently permissive for whatever you want to be able to do with it.

                                              1. 2

                                                With dual licensing, you lose this

                                                I think we need a specific term for BSL-like licenses. “Dual licensing” is broad and includes situations like licensing the code under two different FOSS licenses (like GPL + MPL), which isn’t harmful at all. Any dual licensing where one of the licenses is FOSS and both are applied at the same time also doesn’t prevent forks.

                                                Maybe “delayed dual licensing” could be a good term.

                                                1. 1

                                                  Sorry, I was thinking of the GhostScript case, where it was GPL’d or proprietary.

                                                  A lot of F/OSS dual licensing is probably not legally binding, because one license grants a superset of the rights of the other. This means that the ‘reasonable person’ test that the court would use will assume no one would ever choose to receive fewer rights and so the licenses are equivalent to the most permissive one. In cases where the licenses are incompatible (e.g. GPL + CDDL), then it’s far more complex and you probably need to take it to court to figure out what it actually means.

                                      1. 2

                                        Lil blisters and oozes with a remarkable and innovative collection of Bad Ideas.

                                        • JSON can’t represent NaN or Infinities, so Lil can’t represent them in its numbers, either.

                                        If you are doing this, then also get rid of -0 as a special number distinct from 0, but also mysteriously equal to 0. The IEEE -0 value is not an integer, it is not a real number, and the behaviour of various common mathematical operations on this value is entirely arbitrary and impossible to predict based on a knowledge of mathematics. Just keep things simple for the user, I say.

                                        Uniform operator precedence. PEMDAS be damned, I say- expressions evaluate right-to-left unless acted upon by parentheses or brackets.

                                        Good idea. Most new languages think is a good idea to have 20 or so levels of operator precedence, and there’s no way I will ever memorize all these levels. Much better to keep the grammar simple enough that you can learn it.

                                        • Absolutely no runtime errors. Except for, y’know, the kind that are caused by interpreter bugs, the host OS, sunspot activity, or a general malaise. Lil has excruciatingly straightforward control flow and operates upon the highly dubious yet daring, even brave, premise that any consistent behavior at runtime is conceivably more useful than a crash.
                                        • A mushy, coercion-happy closed type system that generally aims at that lofty and deeply problematic goal of “doing the right thing” and generalizing operations over all reasonable datatypes.

                                        This is the opposite of simple. Based on personal experience using such languages, this is a terrible idea, for several reasons.

                                        • If there is no static type checking, then I want to get runtime errors so that I get notified of the exact time and place when my program attempts to do something meaningless. Otherwise code is much harder to debug.
                                        • Code is easier to understand if the operations have clear semantics. For example, I prefer that x + y means we are adding numbers, and that + supports the usual identities (x + y can be changed to y + x without changing the value computed, x + 0 == x for any valid argument of +, etc).

                                        I do see one possible reason for making this terrible design decision, which is ease of implementation, so you don’t have to add a lot of error handling code to your interpreter, design good error messages, present errors to the user in a helpful way, etc. In my experience, good error handling adds a non-trivial amount of complexity to a hobby language interpreter.

                                        1. 1

                                          The IEEE -0 value is not an integer, it is not a real number, and the behaviour of various common mathematical operations on this value is entirely arbitrary and impossible to predict based on a knowledge of mathematics.

                                          Like what? As far as I can tell, -0 behaves equivalently to +0 in basically all cases, most importantly comparisons. There’s a few weird edge cases that can produce -0 instead of +0, but since -0 is equal to +0 you aren’t going to notice unless you do a bitwise compare.

                                          Section 6.3 of the 2008 standard appears to specify all the edge cases quite clearly, and there’s basically three ways to produce -0: rounding a negative with the result being 0, the rounding implicit in the fused-multiply-add operation can produce -0, and sqrt(-0) equals -0. As far as I’ve read, -0 as an input to basically any operation functions identically to +0.

                                          1. 2

                                            The primary edge case I’ve seen cited as a problem is how they in division. x/0 = Inf, x/-0 = -Inf

                                            1. 1

                                              That’s a good one I didn’t know about, thanks.

                                            2. 1

                                              Let’s turn the question around. Suppose you started using a language similar to Python or Javascript, except that there is no difference between +0 and -0. They are the same number: -0 as an input to any numeric operation returns the same result as +0, without any exceptions. In fact, the expressions -0 and +0 both print as the string “0”. This violates the IEEE standard, but would you even notice the difference? Would you care? My theory is that most people don’t know about the magic properties of -0, and don’t care. For an end-user programming language like Lil, or like the new language I’m designing, getting rid of the special magic associated with -0 simplifies the language and removes a footgun.

                                              1. 1

                                                Let’s answer the question instead. I’m not arguing that anyone wants or needs a sign bit, I’m asking for what nasty edge cases its current implementation introduces.

                                                1. 1

                                                  -0 behaves equivalently to +0 in basically all cases

                                                  -0 as an input to basically any operation functions identically to +0

                                                  You are using the word “basically” as a weasel word, meaning that -0 is equivalent to +0 most of the time, except when it isn’t. The nasty edge cases all lie in those cases where -0 isn’t equivalent to +0. Those are the cases where your code can go wrong.

                                                  People learn the properties of the real numbers in elementary and high school. The problem with the IEEE standard is that it contains two elements, NaN and -0, which are not real numbers, and which violate the axioms of important arithmetic operations. Having learned real numbers in high school, and not being trained in the correct use of floating point numbers, most people will probably just write code as if floats were real numbers, and not think through the consequences of “what if this expression returns NaN” or “what if this expression returns -0” every time they write an arithmetic expression. That creates opportunities for code to go wrong if these values arise. If you eliminate NaN and -0 from a programming language, then these footguns go away.

                                                  The infinities are also not real numbers, but they cause fewer problems in practice, because there is a sensible way to extend the real number system with +infinity and -infinity in a way that doesn’t break the axioms of real arithmetic.

                                                  1. 1

                                                    One of the laws of real arithmetic is the law of trichotomy. Every real number is either negative, zero, or positive.

                                                    The NaN and -0 values in IEEE floats violate the law of trichotomy. -0 sometimes represents a small negative number, and sometimes represents zero, it depends on the context. This context is not stored in the number itself, so you may need to track it externally in order for your code to work. As a result, -0 by itself, without this context, cannot be unambiguously be treated as being definitely zero, or definitively a small negative number. Instead it is something different, just its own thing. This creates a problem when defining new numeric operations that aren’t speced by the IEEE standard. What happens when you pass -0 as an input? Often there is no right answer that produces the correct behaviour for all use cases.

                                                    For example, how would you implement the sign(x) operator, which returns 0 if the input is 0, -1 if the input is negative, or +1 if the negative is positive? If the input is a real number, then the input obeys the law of trichotomy, and the code is trivial. There are multiple ways to write the code that produce the same results. If the input is -0, then then different ways to write the code (see previous sentence) may produce different results, and these different behaviours may be unexpected if you have internalized the law of trichotomy. No matter what sign(-0) returns, it will be incorrect for some reasonable use cases. Different languages produce different results for sign(-0), and in some cases this might be by accident: maybe the library code is written by somebody who unconsciously assumes that the law of trichotomy is true. Ultimately, the way you work around this problem is by providing multiple different versions of the sign operator and training people on which version to use in different circumstances. This complexity isn’t necessary if you don’t include -0 in your language.

                                                    1. 1

                                                      Another issue is the equality operator. In the real number system, the equality operator x==y satisfies the following requirements:

                                                      1. It is an equivalence relation, which means that if x, y, z are real numbers, then:
                                                        • x==x
                                                        • x==y implies y==x
                                                        • x==y and y==z implies x==z
                                                      2. x==y is true if and only if x and y and the same number.

                                                      NaN violates the first requirement, -0 violates the second requirement. This matters when writing code, because people internalize these axioms and may subconsciously assume that they are true when reasoning about code.

                                                      The new language I’m working is very simple. All data is represented by immutable values. There is a single generic equality operator that satisfies the above requirements and works on all values, and there is code that doesn’t work correctly unless the equality operator satisfies the requirements. If I allow the NaN and -0 values into my language, then I need a second floating point equality operator that satisfies the IEEE requirements. I need to give different names to the two equality operators, and I need to train users on which equality operator to use in which cases. Similar to the problem of needing two sign operators.

                                                      Other language designers care less about these issues. They put multiple equality operators in their language (Scheme has =, eq, eql and equal, for example). They provide generic abstractions that fail in various ways when you put -0 or NaN into the abstraction, but so what, the code does what it does, floating point numbers are evil, just deal with it. Eliminating footguns is less important than other issues, such as simplicity of implementation and conformance to the IEEE standard. I’m not saying other people are wrong if their priorities are different than mine, I’m just saying that things don’t have to be this way, there are other ways to design a programming language.

                                                      1. 1

                                                        Other language designers care less about these issues. They put multiple equality operators in their language (Scheme has =, eq, eql and equal, for example).

                                                        Scheme has multiple equality relations because of mutability (and because floating-point numbers are inexact, but that’s a a whole clusterfuck I don’t want to touch right now), not because of -0 or nan. Take for example common lisp, which has the same equality relations as scheme, but which has no infinities or nans.

                                                        -0 sometimes represents a small negative number, and sometimes represents zero, it depends on the context …

                                                        This is a highly misleading thing to say, when exactly the same thing applies to +0 (or unsigned 0, if it is the only 0). Toggle the inexact bit if you care.

                                                    1. 1

                                                      Augh, my head. XD I think I managed to extract some particles of meaning out of that though, thanks.

                                                      1. 1

                                                        Kahan doesn’t speak for all numeric analysts. The Posit standard doesn’t have a signed zero, and fixes all the problems I described in my extended reply elsewhere in this thread.

                                                  1. 3

                                                    Perfect Replayability sounds like a great language feature. Deterministic execution guarantees even with multiple threads, no undefined behaviour, no Heisenbugs.

                                                    1. 1

                                                      Replay provides this for web development.

                                                    1. 1

                                                      This is a followup to a story that was on the frontpage earlier this week. Does it really need its own submission?

                                                      1. 30

                                                        Yes, it’s a good submission. There’s a lot of technical detail about why JPEG XL is the best image format for a wide range of use cases.

                                                        1. 9

                                                          This post is a reaction to that initial news and the original post didn’t much of the technical merits, just that removal had happened.

                                                          As the article stated, many organizations have come out publicly on the issue tracker to show that the reaction of little interest in JPEG XL was premature and unfounded. There’s more to see than there was a 2 days ago.

                                                        1. 2

                                                          Interesting that someone would put years of effort into writing scientific code in C++ and Python, then replace all of that code with Common Lisp, for purely pragmatic reasons, despite no previous experience with Lisp. Also, the Molecular Lego project is awesome, so glad I learned about it.

                                                          1. 6

                                                            The Malleable Systems community may also be of interest. It draws from many related works, both historical and ongoing.

                                                            (Disclaimer: I am the organiser of the community.)

                                                            1. 2

                                                              Cool. The mission is well stated and I fully support it. And it’s great that you are running a community. Suppose I want to get involved. I want to use a modern, general purpose malleable software system, with the power of the Lisp Machine or Smalltalk, but designed from the ground up for the concerns of the 21st century. Should I:

                                                              1. Build a new system from scratch that meets these requirements, or
                                                              2. Get involved with an existing project that has these goals and is already usable? If so, which one? Yes there is a catalog.

                                                              Here are my 21st century concerns:

                                                              • Not interested in Software as a Service, where the system can only be run in a web browser using $CORPORATION’s web servers, with my data locked up in said servers.
                                                              • The software must run locally, with data stored locally on my hard drive. But not in a web browser, with all my data enclosed in the browser’s local storage, because then my data can’t be shared with other local programs. Must be capable of offline operation.
                                                              • I can sync my data with other computers/devices I own, across MacOS, Windows, Linux, Android. I’d like to use my NextCloud for this, the cloud sync options can’t be limited to $CORPORATION. Syncing is seamless and automatic, so I can switch from one device to another while working on the same code, data and documents.
                                                              • I can share code, data and documents with other people over the internet, using URLs of some sort to reference other people’s shared stuff. I can link to or transclude hypertext, or I can pull library dependencies into code, using the same mechanism.
                                                              • The programming model has to be secure and support trustworthy code. If I transclude someone else’s active document, this cannot have the side effect of encrypting all my files and displaying a ransom message, or running a bitcoin miner in the background. I’ve thought about this a lot: I don’t think 20th century languages are up to the job, and I have a model in mind for designing a trustworthy programming language.
                                                              • It’s possible to create beautiful looking, modern user interfaces. Text is beautifully typeset using proportional fonts (even when it is code). You can use a touchscreen to control the UI when available, you can create zoomable UIs, or use UI techniques found in 3D video games.
                                                              • The UI is GPU accelerated. You can create and manipulate 3D objects as documents. GPU programming is smoothly integrated into the programming system, but at a high level, don’t just give me low level OpenGL or Vulkan or WebGPU. The high level programming language used by this system is automatically compiled into GPU shader code when necessary (instead of requiring me to write shaders in a separate language, GLSL or WGSL). Note, I’ve already prototyped many of these ideas in my Curv language.

                                                              So who’s working on this?

                                                                1. 1

                                                                  Nobody, because that (excellent) laundry list would cost many millions of dollars to build, and nobody is willing to pay for software infrastructure any more.

                                                                  1. 1

                                                                    Well, it could be built with the labour of maybe dozens of volunteers over a period of several years. Smalltalk-80 was built from scratch with fewer people than this. There are 170 people in the Malleable Systems matrix room, so if 10% of them could be convinced to work together on the same project, we could probably do this. I have no special skills in organizing a large team of radical, visionary iconoclasts to work together on a common project, however, so I don’t know how to get started.

                                                                    1. 1

                                                                      Smalltalk-80 was built from scratch with fewer people than this.

                                                                      True, but they were paid full time salaries for years to play around, and they were immersed in a community of people who had the same luxury of long timeframes and generous funding.

                                                                  2. 1

                                                                    I want to use a modern, general purpose malleable software system, with the power of the Lisp Machine or Smalltalk, but designed from the ground up for the concerns of the 21st century.

                                                                    Sounds like a good high-level vision. I believe many in the community would be interested in such a project.

                                                                    Should I:

                                                                    1. Build a new system from scratch that meets these requirements, or
                                                                    2. Get involved with an existing project that has these goals and is already usable? If so, which one? Yes there is a catalog.

                                                                    My mindset thus far has been that we need many people experimenting with different pathways towards malleable ideals because it’s not at all clear what the “right” answer is for these challenges. It seems best therefore to have many people trying different things so we can see what resonates.

                                                                    Of the people with active projects, most are operating in a solo or small group fashion currently. (The same seems to be true of many projects in the semi-related Future of Coding community you are already part of.)

                                                                    Of course, this type of solo approach makes it harder to achieve larger goals where there’s far too much that needs to be done for a single person to complete in any reasonable time frame. I don’t have easy answers for this aspect yet… Perhaps we still need more projects to bubble away first.

                                                                    Beyond the catalog on the site, there’s also a long queue in our issue tracker of even more things to be added. I’m planning to convert the site into a wiki so it’s easier for anyone to add entries.

                                                                    So who’s working on this?

                                                                    Your vision seems quite compelling, at least to me personally, and I believe it would be for others in the community too. Some aspects overlap with the local-first vision as well. At the moment, I’d say there are pockets of people working on a few bits and pieces related to this. Let’s discuss more in the Matrix room. 🙂

                                                                1. 1

                                                                  I quickly skimmed the PhD thesis. The ideas are interesting. The software, Tangler, seems to be a prototype with limited capabilities, not developed enough to be fully practical, and it doesn’t seem to be available? If it is available, someone post a link, please. Thanks.

                                                                  1. 2

                                                                    Quote from the Boxer Salon 2022 program:

                                                                    Boxer, initiated by Andy diSessa and Hal Abelson as a breakaway from the Logo programming group at MIT in 1978, is arguably the world’s greatest success in creating a malleable, reconstructible, convivial computing medium. Attested through many years of successful deployments in schools throughout the 80s and 90s, Boxer was the subject of three major NSF grants and a landmark text, Changing Minds, written by Andy DiSessa in 2000, setting out a cultural manifesto for two-way computational literacies mediated by reconstructible media.

                                                                    The Boxer Reconstruction Project, directed by the diSessa Family Foundation, for the last few years has been steadily modernising and stabilising the Boxer codebase to run on modern systems, leading to Boxer Sunrise at https://boxer-project.github.io/.

                                                                    1. 1

                                                                      I looked at this in more detail. On the plus side, it has documentation and you can download an executable. But it is indeed an historic artifact from the 1980’s and 1990’s. It has a primitive programming and graphics model based on Logo and Turtle Graphics, and a klunky visual esthetic. Not something we would create or want to use today. “World’s greatest success” is rather depressing if true. I would rather play with a modern malleable programming system. So I will keep looking.

                                                                    1. 2

                                                                      I agree with the author’s criticism of format.

                                                                      However, the out macro doesn’t address all of the problems that were identified.

                                                                      • out introduces a formatting minilanguage that must be parsed using a macro, and the language is complicated enough to contain a conditional operator. (Even though the author criticizes the format language for containing a conditional.)
                                                                      • The out minilanguage contains the format minilanguage as a subset. This is required for formatting numbers. So format is not eliminated from Lisp, even though the article’s title is “Eliminating FORMAT from Lisp”.

                                                                      Gilad Bracha uses the term “shadow world” to describe a DSL that reinvents features of a general purpose language (like conditionals and loops). https://gbracha.blogspot.com/2014/09/a-domain-of-shadows.html

                                                                      It ought to be possible to create a string formatting API that is both pleasant to use and also free of shadow worlds and format strings.