1. 4

    Where can I find more information about why Plan 9 is amazing, especially how it compares/contrasts to Linux or Unixes?

    1. 9

      I found this paper to be a wonderful walkthrough. I highly recommend getting a copy of 9front running, and going through some the exercises in the paper.

      It’s very long, but definitely a great way to get a feel for how some of the concepts in Plan 9 are applied.

      Edit: Since I was reminded how much I like this paper, I decided to submit it as a story.

      1. 5

        Some goodies from Plan 9 were ported to *nixes, for example procfs, unfortunately not all of them (Plan 9 like process namespaces).

        1. 7

          Unfortunately, the best piece of plan 9 is impossible to port: A unified, interposable way of doing everything, so you don’t have to think about huge numbers of special cases and strange interactions between features. 9p is, more or less, the only way to talk to the OS, and the various interfaces that are exposed over it can be transparently swapped out with namespaces, allowing you to replace, mock out, or redirect across the network any part of the system that you want.

          1. 4

            Well, Linux namespaces got 90% of the way there, although they certainly didn’t get their ergonomics.

          2. 3

            I just watched the video https://www.youtube.com/watch?v=3d1SHOCCDn0

            Found the way the presenter explained the core concept very understandable. It is 40 minutes long.

          1. 6

            This is neat! I was really hoping to see some of the underlying clojure data structures implemented in rust – but I don’t think that’s one of the author’s goals as of now.

            For context, Clojure uses some clever persistent data structures for hash maps and vectors. (Here’s a snippet of Rick Hickey giving an overview of some data structures). The implementation here currently implements persistent vectors as Vec<Rc<T>>, and maps are associated lists instead.

            There is a persistent hash trie crate in rust, and there may be other persistent structures that could be used. I’d love to see how this project develops, and if it takes the route of using these data structures.

            1. 10

              im (https://docs.rs/im/14.3.0/im/) is a collection of all of those types, in a threadsafe and a non-threadsafe version.

              1. 3

                Hey there, author here. I indeed plan to eventually implement the appropriate efficient data structures, as they are implemented in Clojure – or use a library like im. In fact, everything you see will likely change – I’m taking a very iterative approach to this altogether. That particular alist-implemented map is a tide-me-over map for small datasets, implemented at the last minute, and for now is analogous to Clojure’s PersistentArrayMap, which it will likely be replaced with.

                1. 2

                  Awesome! I’m really exited to hear you’re working on this :)

              1. 7

                I think there’s some open source stuff for certain chips, I haven’t experimented with them at all though

                I highly recommend getting a Lattice Icestick to try out! You can buy them for fairly cheap (around $40 - $60 USD). There is an open source toolchain called Yosys, which can be used with icestorm to target the Lattice chips.

                I personally find it much nicer to be able to develop in a Unix-like environment (text files, Makefile, etc.), over the massive Altera and Xilinx IDEs.

                1. 3

                  Second this. I bought a Lattice Icestick for playing with FPGA purposes, and I had relatively little trouble setting up the open source toolchain and flashing circuit designs onto the device. I haven’t so far done much beyond the “hello world” of making an LED blink, but getting that far was relatively painless.

                  1. 2

                    This is a bit late, but Xilinx ISE 14.7 can be invoked without the IDE. If you instantiate a new DDR controller (from the IDE) it generates an example project in a folder in your workspace, which has some .bat files to build it.

                    1. 2

                      Word of warning: the ice sticks tend to be out of stock a lot. If you’re going to end up spending $40-50, check out some of the other ice40 boards. Go for at least an HX8k, since 1k LUTs is not enough to do much. The ice40UP line also has a FOSS toolchain, but the boards are more expensive (around $80).

                    1. 3

                      Java is ideal for large enterprise applications

                      AbstractSingletonProxyFactoryBean

                      1. 11

                        Is that actually used outside of Spring internals? I’m not a Java developer but to my understanding Spring is a very old and very complex framework, so you’d expect to see this kind of thing. If that’s so, it’s no worse than a language having Zygohistomorphic prepromorphisms.

                        1. 4

                          Is that actually used outside of Spring internals?

                          To be honest, I have no idea. I’m also not a Java developer. Though, I have worked with some enterprise C++ libraries that have a similar pattern: classes with long names that try to describe the some abstract design pattern.

                          I’m not necessarily saying that an AbstractSingletonProxyFactoryBean is a bad design. If you’re familar with the design patterns and framework, I’m sure the name “AbstractSingletonProxyFactoryBean” alone probably provides a lot of context clues to developer, in the same way that zygohistomorphic prepromorphisms might.

                          The name itself is pretty funny though – its sounds like a bunch of meaningless buzz words tacked together. I also got a good laugh out of zygohistomorphic prepromorphisms :).

                          1. 3

                            Is that actually used outside of Spring internals?

                            No, this class isn’t used outside of Spring’s internals. But, yes, this pattern is sadly common in Java codebases.

                            IMHO AOP is just as bad in Guice.

                        1. 21

                          Perhaps one of the biggest things worth mentioning here (other than the standard: Vim, ag, LSP, etc.) is gofmt.

                          gofmt takes any valid Go source code and formats it. One of the benefits of this is that it eliminates low-value discussions about where to place braces, spaces, and all of that, but another huge benefit is that it’s quite a productivity win.

                          Before, I would manually muck about to get the indentation, spacing, and all these thing correct. Now? I just write if foo == "" { return } on a single line and let gofmt take care of it. This is especially a massive benefit when you copy/paste some code and the indentation is off, or you eliminate/add an if, and so forth. gofmt will just take care of all of that.

                          goimports does gofmt and also takes care of adding/removing imports; fmt.Println("DEBUG", v), write, and it adds import "fmt" automatically (and removes it again when the line is removed).

                          There are similar tools for other languages; I encourage you to check it out if you haven’t; I never thought I would like it so much until I started using it (“real programmers just get the indentation correct on their own and don’t need a tool!”)

                          1. 2

                            Perhaps one of the biggest things worth mentioning here (other than the standard: Vim, ag, LSP, etc.) is gofmt.

                            Clang-format does the same thing for [Objective-]C[++] codebases. One of the biggest productivity wins is not just using it, but integrating it with the build system and with CI. I’ve recently started doing this with a few projects so that there is a clangformat target that applies the formatting to all source files. CI builds that target one each PR and if it produces a diff then this CI step fails with a message asking the submitter to build with the clangformat target and then update the PR.

                            This means that no human needs to either look for minor style nits, or fix them, during the code review process. You can’t quite represent my preferred style with clang-format, but it’s close enough. Now code review can focus on the important style issues, such as consistent naming in APIs, rather than the trivial ones.

                            1. 5

                              We do an equivalent at work with prettier formatting typescript. I’ve thing I’ve found is that it feels much nicer to have auto formatting on save in my text editor as well as in CI.

                              1. 2

                                The unfortunate thing about clang-format is that you can configure the formatter any way you like. At a large company, you can end up with a huge number of repositories and teams, each with different .clang-format configurations. Unless there’s outside pressure to decide which configuration to go with, you might end up in endless debates over which format is The Best.

                                Go has the beauty of having One True Format™

                                1. 2

                                  That doesn’t really bother me, as long as it’s integrated into the build system and CI pipeline: I write without paying attention to it and then reformat the code before I commit. It’s a slightly higher cognitive load than having a single format, but the go style makes several decisions that are the opposite of what you’d get if a cognitive psychologist had been involved in any part of the process, so I prefer having the option to make the right choice some times than having to always make the wrong choice.

                                  That said, in my ideal world, there would be no global layout style: the revision control system would store an AST and it would be up to the reader how to typeset it. Having a per-project clang-format style is pretty close to this: in theory, I can apply my own preferred style on checkout and then the project’s style before I commit a patch. I’d love to see better tooling around this.

                                  Some years ago, I had a student work on a project called Code Editing in Local Style (CELS), which he presented in EuroLLVM in Paris. It did a lot more trivial reformattings than clang-format (for example, it could have variables declared at the start of a function or at their minimal scope, could handle tabs-for-indent-spaces-for-alignment style, could switch variables of different kinds between conventions like underscore_separated or camelCase, and implemented the TeX line breaking algorithm with weights for badness). I’d love to see that part of a normal editing workflow.

                              2. 2

                                I absolutely agree. I used those tools so often that I just threw them into my vimrc:

                                autocmd VimLeave *.go :!go fmt %
                                autocmd VimLeave *.go :!goimports -w %
                                
                              1. 8

                                There’s also aseprite: https://github.com/aseprite/aseprite I’m very fond of its pixel UI.

                                1. 11

                                  Aesperite is a nice tool, however, they switched from GPL to a custom EULA sometime back. I respect their decision, but I’d rather use GIMP.

                                  1. 7

                                    Oh what a shame, I thought it was still GPL’d. Thank you!

                                  2. 3

                                    Thank you for the link! I had some fun making a little plant for my lobste.rs avatar :)

                                    1. 2

                                      I love it! Very nice

                                  1. 7

                                    I’ve been trying to learn more about dependent types and the theory behind them, and I recently discovered these lecture series on HoTT. Though they go a little over my head, I’ve found the lectures great at providing some additional background that I was missing. I thought I’d share!

                                    The Homotopy Type Theory book is also available, and is open source.

                                    1. 19

                                      I’m going to buy Animal Crossing.

                                      1. 3

                                        Hope you enjoy it! I’m glad I picked it up.

                                      1. 2

                                        For personal servers, I name them after streets that intersect Kickerbocker Ave between Flushing Ave and Cooper St, in New York City.

                                        I.e. George, Melrose, Jefferson, Troutman, etc.

                                        For work, we used to name the servers by number. Everytime you add a server, you count up by one. Sound ridiculous, but its fairly memorable. Everyone has a little 8.5x11 printout with a diagram showing where each server fit in the architecture; so you could visually see that server s157 handled the client facing API, for example.

                                        1. 10

                                          State machines are kinda a huge pain in any language, as far as I can tell. Either you try to make them checked at compile time, like the first example does, and run into issues, or you do lots of checking at runtime and end up asking yourself things like “how did I get into this state?” and “why is it trying to transition into the wrong one?”, or you make a table of transitions and states and altering/updating it becomes error prone. Annoying for such a fundamental pattern.

                                          1. 6

                                            in Rust you can have both strongly-typed transitions and runtime dynamism. This kind of simulates session types, like what Idris is really nice for encoding in a lower boiler-plate way.

                                            1. 4

                                              State machines are kinda a huge pain in any language

                                              I’ve found state machines in dependently typed languages to be wicked cool, and much less painful. You can encode the state transitions into the types, which guarantee that your program is in a given state during compile time. The flexibility of the dependent type system allow you to encode state machines of arbitrary complexity.

                                              For example, in idris, you can do things like ensure that a file handle is open when you call read:

                                              -- legal 
                                              do f <- open "file.txt"
                                                 content <- read f
                                                 close f
                                              
                                              -- illegal 
                                              do f <- open "file.txt"
                                                 close f
                                                 content <- read f   -- won't compile because the file is closed!
                                              

                                              Some documentation on idris state machines, and an example of stateful socket programming

                                              1. 3

                                                I think it’s partially from a mismatch between conceptual model and language semantics, but a lot of it seems to come from people half-assing it, either by generating code that can get into a bad state, or not being explicit on what happens when receiving a message unsupported by the current state, things of that nature. I don’t think any of these issues are fundamental to the model of state machines though, or the semantics of the languages we use. Being more careful about generated code, and probably doing a lot more design-time / compile-time verification of the definitions would make it much more pleasant to use, in which case it would actually be used a lot more often, almost certainly to the improvement of software in general.

                                              1. 3

                                                I looked into doing this once. At work, we had a tool where users could write little boolean expressions to classify bonds (for example something like: highYield = rating < BBB). These expressions got pretty complicated, and versioning them was tricky. I thought that git would be a nice fit.

                                                The main problem was replication. We had a strict requirement at the company that all services be distributed over multiple datacenters. With clustered databases, you can get this for free. With git, you need to commit to one repository, and then have some job/hook push out changes to other replicas. This generates a number of small nightmares: which repository is master? What if replication fails? How do you guarantee that commits aren’t lost when switching master?

                                                Using git turned out to be a pretty awkward thing to do; using a standard RMDBS seemed much more maintainable.

                                                I don’t think I would recommend using git as a database unless:

                                                • All (or almost all) the data you’re storing is plain text
                                                • It’s a non critical service that can withstand some downtime
                                                1. 16

                                                  Moreover we don’t live in 1980 anymore. The view and the purpose of computers had changed completely since this time.

                                                  I feel that the view and purpose of computers hasn’t changed too much. We still solve a lot of the same problems, and even work with a lot of the same tools (especially in unixes). How we interact with computers has changed dramatically (see smartphones, the internet), but things on the “system” level are relatively the same. Operating systems try to provide the same higher-level abstractions on processes as they did in 1980.

                                                  1. 12

                                                    This reminds me of the source code for the original Bourne shell. Stephen Bourne wanted a more ALGOL-like syntax, so he added macros to convert keywords like BEGIN, END, IF, and FI into braces { and }.

                                                    Here’s an example file, macro.c, from the archived UNIX v7 source tree.

                                                    The macros are defined in mac.h. :)

                                                    1. 4

                                                      There was an abomination called MORTRAN

                                                      It was where I learnt the true meaning of “Syntactic Sugar”…..

                                                      You can sugar your syntax as much as you like, if the semantics sucks, life sucks,

                                                    1. 8

                                                      I worked at a place where if you wanted to change your password, you sent a change request to the internal devs, who would patch the list of hardcoded username/password pairs embedded in the application.

                                                      1. 3

                                                        Were the passwords in plaintext?

                                                        1. 5

                                                          Yep.

                                                      1. 26

                                                        iPhone SE. My top reason is the form factor. No idea what I’m going to do when support is dropped. Every other modern phone feels massive in comparison.

                                                        1. 3

                                                          Have you tried Samsung s10e? I feel that modern phones tend to be too big too and this one has been a keeper for me. It’s super comfy!

                                                          1. 2

                                                            With its 5.8” screen, it is significantly bigger than the iPhone SE. It is even bigger than most non-Max iPhone.

                                                            1. 2

                                                              The screen to body ratio is much much higher, so in reality it’s not much bigger whole giving you almost double the screen size:

                                                              S10e: 142 x 70 x 8 mm
                                                              IPhone se: 124 x 59 x 8 mm

                                                          2. 2

                                                            Same here, and also for flat camera. I need a communication device, not a real big camera.

                                                            1. 2

                                                              The quality control had become crap by the time I realized I wanted the iPhone SE. I went through four of them in less than a month before giving up and going to the iPhone 7. I emphatically do not believe that this was a generic iPhone SE issue; I have heard similar from people who bought them too late in their life cycle. I agree with you: that thing was my ideal form factor, and I’m genuinely disappointed I missed out and don’t have one.

                                                              1. 5

                                                                What exactly were the issues you had? Curious, I’m holding on to mine (about to replace the battery for the third time).

                                                                1. 1

                                                                  In no particular order:

                                                                  1. Screen with dead pixels
                                                                  2. CarPlay simply didn’t work. The details varied, but this one was actually pretty consistent across all four phones.
                                                                  3. Screen with dead touch areas or vague touch area so that precision touching was a no-go. This was especially deadly prior to iOS 13, when they let you hold and drag on the spacebar to select individual letters.
                                                                  4. Battery operated as if it were a really forking old battery. It’d go from 100% to 30% over 15 minutes, then recharge back to 100% in as much time.
                                                                  5. Bluetooth would occasionally just decide it had had enough with life and was going to exeunt stage left

                                                                  To be clear, these were, at least nominally, brand-new phones bought directly from the Apple Store. That’s specifically why I gave up and bought an iPhone 7. I’d otherwise have simply gone to them and tried again for an SE.

                                                                  1. 1

                                                                    Thanks for clarifying! Didn’t think those issues could happen with new store-purchased phones.

                                                                    (FWIW, my recent carplay issues turned out to be due to a pile of lint stuck in the lightning connector.).

                                                                2. 2

                                                                  Try craigslist? I’ve never had a problem there.

                                                                3. 2

                                                                  What I wouldn’t give for an iPhone 11 jammed into the case of an iPhone 5.

                                                                  1. 1

                                                                    I hope my SE never dies. I can reach all four corners of the screen with my thumb. Plus, I love having a headphone jack.

                                                                    1. 1

                                                                      That’s sort of why I got an XZ1c (specs). I bought it before my previous phone died, because I worried that they might stop making it. Sigh. There just aren’t very many of us asking for such phones.

                                                                      FWIW, after disabling all the google things I don’t particularly want to use and ticking the right checkboxes, the phone appears not to tell Google anything significant. At least Google’s account history page is just an empty list.

                                                                    1. 1

                                                                      I used the IBM C and C++ compilers (xlc and xlC) for work. I was always surprised at the difference in quality between the two.

                                                                      The C compiler worked well; it had good error messages, and reasonably fast compile times. In addition, the linker that shipped with IBM was really fast, and could handle cyclic object dependencies by default.

                                                                      The C++ compiler always felt unfinished – it was really slow, and the error messages were arcane. We used to run g++ against files that didn’t build in order to get better error messages. In addition, the compiler only supported up to C++03 (as of 2018). IBM started using clang as a frontend to add support for C++11 onward.

                                                                      C has – in someways – fallen into a compiler monoculture. But at least writing a C compiler is an accessible feat! I think that because the C language is small, the ecosystem can continue to grow. It’s really exciting to see new projects like cproc.

                                                                      It’s unfortunate that alternative C++ compilers have the incredible task of supporting the ever-growing complexity of the language. I’d be interested to research a list of C++ compilers as well.

                                                                      1. 1

                                                                        IIRC there’s either no limit (or a very long limit) to the ‘subject’ field specified in the relevant RFC for ‘emails’, so you could (probably) put your entire message in the subject!

                                                                        1. 1

                                                                          Oh it’s possible. My uncle does this and it drives me nuts!

                                                                        1. 9

                                                                          By the time I was ready to ditch the host operating system and install Plan 9 on bare hardware, my desire for the modern web experience had ebbed to an all time low.

                                                                          As much as I love Plan 9, not having a modern web browser is a non-starter. Too much of the world depends on that: I need to be able to read the news, video conference, consult reference materials, do my banking, order pizza, and so on…

                                                                          1. 14

                                                                            Ultimately, the magic of Plan 9 is you can write a file server for the seamless/grubhub API, and then all you need to do is mount your pizza place of choice, and kick off the delivery with

                                                                            echo cheese > /n/pizza

                                                                            1. 8

                                                                              Except someone needs to do the work, which is mostly a waste of time, not to mention api’s for services like that are far from stable.

                                                                              1. 6

                                                                                Mostly a waste of time?

                                                                                Once it’s done, it’s usually done for years. And APIs are getting better, not worse, generally.

                                                                                cat /n/pizza/toppings; echo 'pepperoni' >> /n/pizza/order; echo 'done' >> /n/pizza/order

                                                                                Actually sounds like a super simple way to order pizza. From here a pretty simple UI could be made.

                                                                                My issue with plan 9/9front is as sl says: it just isn’t for me at this time, and maybe never. But the ideas it has, can and have been, used in other places.

                                                                                When it comes to powerful text editing, the tools I use work across practically any OS I touch. And to me its those tools that are powerful as long as they remain small (so that they can maintainable, and portable).

                                                                                1. 3

                                                                                  My point is the comment is making it seem unrealistically easy in terms of effort for reward to use ‘magic’ to implement a 9p filesystem for ordering pizza.

                                                                                  1. 2

                                                                                    I was joking :). Writing a 9p server isn’t exactly easy, but, to extend indirection’s comment, it would be kind of nice to grep and echo for pizza

                                                                                    1. 3

                                                                                      Writing a 9p server is an hour or so of work, at least with lib9p. Maybe less. Getting it to order pizza is harder.

                                                                                  2. 2

                                                                                    Yeah, that sounds like a super simple way to order pizza because its skipping most of the things involved in ordering pizza, like choosing the pizza place and giving them your address and payment info.

                                                                                    1. 2

                                                                                      All that stuff could be done once.

                                                                                      echo '1 north pole' > /n/pizza/address; cat /n/pizza/places; echo 'pizzapizza' >> /n/pizza/place; echo 'mypaymentinfosoateuhstaoheus' > /n/pizza/payment or whatever.

                                                                                      Not saying the same can’t be done with other systems.

                                                                                    2. 0

                                                                                      username checks out

                                                                                2. 5

                                                                                  i lean hard on my smartphone for some of this. so far, for the same reasons as you, i’ve been unable to avoid either one or the other (using a modern web browser on my pc or carrying a smartphone). what i can do is limit the number of vectors exposing me to harm, as often and as thoroughly as possible. it’s fair to say that if the modern web is a hard requirement then living in plan 9 may not be for you. realize, though, that in spite of the many enticements being offered, it is still perfectly possible to get a lot of computing done without directly transmitting data to surveillance companies.*

                                                                                  (* sins of the telecom carriers sadly acknowledged.)

                                                                                  1. 3

                                                                                    You could do it the other way around and run Plan 9 in a browser, according to this little project:

                                                                                    https://github.com/sirnewton01/9webdraw

                                                                                    1. 2

                                                                                      There’s vmx or vnc for when you really need it.

                                                                                      1. 1

                                                                                        As it mentions, you can install another OS in a vm and run a browser there.

                                                                                        1. 1

                                                                                          I know, I just hate switching work environments back and forth…

                                                                                          1. 2

                                                                                            A modern browser is itself a VM.

                                                                                            1. 10

                                                                                              The browser is the new Emacs

                                                                                              1. 14

                                                                                                No, the browser is successful.

                                                                                                1. 8

                                                                                                  M-x oh-snap

                                                                                                  1. 3

                                                                                                    I actually try this, you know…

                                                                                      1. 10

                                                                                        C++ is the only language I’ve worked in, where it is completely normal (and often preferred such as in the games industry) to completely ignore the standard library. It’s also the only language I’ve worked in where the standard library is not written in anything resembling a style you’d find nearly any normal code base written in.

                                                                                        We have a committee with 300+ members. It seems that essentially every member has a feature or two that they’d like to get into the language, and many have several.

                                                                                        This is the problem. I have to study this language constantly to stay up-to-date and know all the in’s and outs of bizarre rules and in that time I could have done so much more with my life.

                                                                                        If we are not careful, C++ can still fail

                                                                                        It’s already failing. I believe it’s pretty much dead on the table, with current projects keeping it alive. I take a lot of flak from a lot of people I know for still being the “C++” person. I love the power of the language, but can’t honestly recommend anyone use it over any other one. C++11 was a great step in the right direction, but the burden of more and more complexity from pet features while not helping me deal with the real complexity issues (#include’s, build systems, usability issues with the standard library) has me really struggling to keep wanting to put in the effort.

                                                                                        1. 2

                                                                                          C++ is the only language I’ve worked in, where it is completely normal (and often preferred such as in the games industry) to completely ignore the standard library. It’s also the only language I’ve worked in where the standard library is not written in anything resembling a style you’d find nearly any normal code base written in.

                                                                                          This hasn’t been my experience. Other than one place with ancient code that avoided templates, I’ve never worked on a C++ codebase that didn’t use the standard library. I think a few high profile talks at C++ cons popularized the idea that the STL was too slow, but for most use cases it’s not really true.

                                                                                          1. 10

                                                                                            Gamedev reasons to not use the STL include:

                                                                                            • Doesn’t play nice with custom allocators
                                                                                            • Insanely bad APIs. C++ committee people love the everything is an iterator model but it’s just crap to use
                                                                                            • Insanely bad compile times
                                                                                            • Insanely bad debug perf
                                                                                            • Insanely bad compile error messages
                                                                                            • Insane algorithm choices. e.g. C++11 RNG stuff
                                                                                            • Insane implementations
                                                                                            • Spec enforced bad runtime perf. e.g. std::unordered_map is specced to be bad so all the implementations have to be bad too
                                                                                            • Certain older consoles had “variable” implementation quality
                                                                                            • It’s like hundreds to low thousands lines of mostly trivial code to write your own array/string/hashtable/etc so why not
                                                                                            1. 1

                                                                                              Doesn’t play nice with custom allocators

                                                                                              What do you mean by this? Every single collection type in the STL supports custom allocators– what about their implementation is bad?

                                                                                              1. 7

                                                                                                STL custom allocators are passed in as template parameters so they can’t have state, which makes them pretty much unusable.

                                                                                                1. 4

                                                                                                  It also means containers with the same types but different allocators are different types.

                                                                                              2. 0

                                                                                                I’m not arguing that it’s a great library, just that most projects don’t bother replacing it. It might be standard practice for game developers, but they’re a small niche.

                                                                                                1. 1

                                                                                                  It might be standard practice for game developers, but they’re a small niche.

                                                                                                  I’d bet even money that the majority of C++ software written these days is game code.

                                                                                                  1. 2

                                                                                                    I’m skeptical, but would be interested to see data if you have any.

                                                                                                    My own evidence is anecdotal - I’ve worked primarily with C++ for 15 years and have never worked on or even been contacted/recruited by any game companies. I haven’t even worked with anybody (to my knowledge) who’s worked on game software. On the other hand I haven’t been seeking them out, so who knows.

                                                                                                    1. 1

                                                                                                      Steam has a pretty good list of programs.

                                                                                                      1. 1

                                                                                                        Do they have any numbers on how many of those games are based on Unity? The game logic in Unity-based games is written in C#, so I’m sure that would make up a good chunk of new games code written nowadays.

                                                                                              3. 8

                                                                                                In my experience, its’ a good point.

                                                                                                • When I was at EA, we started using C++ but not STL. This was a long time ago, but I’m NOT sure STL got significantly better for the console use case.
                                                                                                • At Google string is not std::string. I think the interfaces were slightly different, although I don’t remember the details. This is tens of millions of lines of code linking against a non-standard string, and it’s one of the most common types in the codebase, etc. As far as I remember, the reason was performance and maybe code bloat.
                                                                                                • The fish shell is one of the only shells written in C++, but it explicitly avoids STL. Oil might go that way too. (Right now the only thing we use is std::vector as an implementation detail)

                                                                                                STL also uses exceptions, and many codebases compile with those off, e.g. all of Google’s.

                                                                                                There was a recent cppcon talk by Herb Sutter which noted that the exceptions issue essentially bifurcates the language. And he surveyed the audience and I think at least half of people had SOME restriction on exceptions in their company.

                                                                                                When you write all of your function signatures differently, you’re almost writing in a different language. Those two styles of code are cumbersome to bridge.

                                                                                                1. 1

                                                                                                  STL also uses exceptions, and many codebases compile with those off, e.g. all of Google’s.

                                                                                                  I’ve never worked with C++ - what does it mean to have exceptions off? You’ve disabled the possibility of raising / catching exceptions in the language? I’ve never worked with a language where something like that would be possible. Is error handling then done through a (result, maybeErr) = someFunction(); if (maybeErr) { ...} pattern?

                                                                                                  And why do people turn exceptions off? Does it mean you then can’t use any library that uses exceptions (like STL)? Doesn’t that mean lots of libraries can’t be used together with lots of other libraries?

                                                                                                  1. 3

                                                                                                    Yes, C++ compilers generally allow you to turn off exception support. All the code that deals with handling exceptions is discarded; any code that attempts to raise an exception instead crashes the entire process.

                                                                                                    One reason people turn off exceptions is for efficiency - when an exception is thrown, all the local variables allocated up to that point must be deallocated, which means there’s a bunch of bookkeeping that always has to be done, even though it’s almost never used.

                                                                                                    Another reason people turn off exceptions is for simplicity. If you’re trying to understand what a given function does, you have to understand the control-flow pattern, and more complex patterns are more difficult to understand (Cyclomatic complexity). Exceptions add an extra “exception thrown” edge to the control-flow graph from every line of code to the exit, which makes things much more complex. In garbage-collected languages like Python or Java it’s not as big a deal, because most things will get cleaned up eventually anyway, but C++ expects you to care about more details.

                                                                                                    Generally C++ code designed for “no exceptions” mode will make functions return error-codes, yes. Libraries that use exceptions aren’t incompatible - they just crash the process when something goes wrong, as I said - but if a project is designed for “no exceptions” then it would probably prefer libraries designed under the same constraint.

                                                                                                    1. 1

                                                                                                      Thanks :)

                                                                                                    2. 3

                                                                                                      Yes if you turn it off then the code just crashes. So you don’t want to use throw anywhere.

                                                                                                      C and C++ error handling strategies are very diverse

                                                                                                      • errno style which is a global / thread local
                                                                                                      • boolean result and out params: bool myfunc(const Input& i1, const Input& i2, Output* o1, Output* i2)
                                                                                                      • Result/Maybe objects (this is more “modern C++” that depends on templates)
                                                                                                      • Exceptions

                                                                                                      People turn off exceptions for at least two reasons:

                                                                                                      1. Because they don’t like non-local reasoning. Classic article: https://www.joelonsoftware.com/2003/10/13/13/
                                                                                                      2. Because exceptions bloat the generated code with exceptions tables. This may matter on embedded systems.

                                                                                                      To answer the other questions:

                                                                                                      1. You can use STL, but not in a way that throws an exception. For example, you have to check that a key is in a map first, rather than let it raise an exception.
                                                                                                      2. Yes, lots of libraries can’t be used with others. But many codebases are written in a style where exceptions can be “local”. Most big codebases are a hybrid of C and C++, e.g. Firefox, Chrome, I assume Photoshop. So they use C error handling in some places but C++ in others. For example OpenSSL and sqlite are all C, and use C style error handling, but they’re often linked into C++ programs.
                                                                                                      1. 1

                                                                                                        So, C and C++ error handling strategies are really very different.

                                                                                                        errno style is only used in C, and in practice is rare outside of the standard library and other very very old libraries. It’s not used at all in C++.

                                                                                                        Return codes are used in both, sure. That’s the bog-standard way to handle errors in C or in C-style C++. Result/maybe objects and exceptions obviously don’t exist in C unless you count setjump/longjmp, which is reasonably obscure and doesn’t give you any opportunity to clean up state.

                                                                                                        Result/maybe objects are not used in C++. You might be thinking of Rust. std::optional<T> isn’t a maybe<T> or a result<T, E>, it’s not for error handling but an alternative to using pointers to represent optional values. There’s nothing modern about something like this, it doesn’t ‘depend on templates’ any more than any other C++ code. Templates in C++ are pervasive. There’s nothing unusual or weird about writing or using templates. They’re as much a normal working part of the language as functions are.

                                                                                                        1. 1

                                                                                                          OK what I meant is “result/error parameterized by type”, of which there are many variations, e.g.

                                                                                                          https://llvm.org/doxygen/classllvm_1_1Error.html

                                                                                                          It’s more modern than error codes :) And more modern than exceptions.

                                                                                                          1. 0

                                                                                                            No, it’s not ‘more modern’ than either. It’s unperformant crap used by people terrified of exceptions because they don’t understand them.

                                                                                                        2. 1

                                                                                                          Thanks :)

                                                                                                    3. 4

                                                                                                      Bloomberg LP uses their own standard library, called the bde.

                                                                                                      I think when Bloomberg adopted C++, there were some licensing issues surrounding the std library, so they implemented their own. I could be wrong about this – I’m not fully sure what the rationale was, but I don’t think the stl was dropped for the sake of speed. I’m a little bummed the README doesn’t have a rationale.

                                                                                                      The library is largely compatible with the standard library, with a few key differences. The most important difference is that allocators are passed around as pointers, instead of being specified in templates. Here’s an example of the bsl::vector constructor taking an allocator, here’s an example of a Bloomberg specific bdlcc::Queue taking an allocator. All allocators implement this interface.

                                                                                                      The bde also has a unique coding style (which I personally find extremely readable), and an almost absurd amount of comments. It’s one of the few C++ libraries that I think is easier to read than it was to write – which is quite an accomplishment!

                                                                                                      The library also has tons of goodies in it, but isn’t as featureful as boost. My personal favorite the use of traits to encode/decode objects to arbitrary formats, in a fashion similar to rust’s serde.

                                                                                                  1. 19
                                                                                                    jtm@x1c ~ % ls
                                                                                                    TODO acme aux bin doc down git go mail mnt music rom www xen 
                                                                                                    
                                                                                                    • acme - additional scripts for acme.
                                                                                                    • aux - synonymous with “junk”.
                                                                                                    • doc - images, documents, slides, etc.
                                                                                                    • down - downloads
                                                                                                    • mail - emails in Maildir format.
                                                                                                    • www - source code for a static site.
                                                                                                    • xen - vm configurations.

                                                                                                    I’ve been meaning to add a cron job to delete anything in down that’s older than three days.. that folder tends to blow up.

                                                                                                    To keep junk from accumulating in $HOME, I use a shell function called “t” that will automatically cd to a temporary scratch space, so I don’t have to think about cleaning up junk that I don’t intend to keep. I use this almost every day.

                                                                                                    function t {
                                                                                                      cd $(mktemp -d /tmp/$1.XXXX)
                                                                                                    }
                                                                                                    
                                                                                                    1. 15

                                                                                                      Instead of a t function, I have a ~/tmp folder.

                                                                                                      Because ~/tmp is persistent, I end up with stuff in there that I’m afraid to delete, so I made a ~/tmp/tmp for stuff that’s actually temporary.

                                                                                                      Because ~/tmp/tmp is persistent, I occasionally end up with stuff in there that I'm afraid to delete. I once just needed a temp folder quickly, but didn't feel like stuff in ~/tmp was safe to delete yet, so I made a ~/tmp/tmp/tmp`.

                                                                                                      I should add that t function to my rc.

                                                                                                      1. 3

                                                                                                        Ooo, I love the t function. I make temp dirs for stuff all the time. So simple, but really helpful - thanks for sharing!

                                                                                                        1. 2

                                                                                                          I have a similar j function which creates a named (default: junk) subdirectory in the current directory and cds to it. There is a corresponding jjj function which is essentially rm -fr junk. Because the new directory is under the current directory, I find it is easier to reference the original directory with .. rather than using "$OLDPWD".