1. 9

    The README doesn’t really describe what makes this different from something like screen or tmux, although it implies that it is.

    The website describes what seems to be a difference:

    https://zellij.dev/about/

    With an example of a plug-in. But it doesn’t make it clear what the difference is between running a plug-in and running a “full screen” executable.

    Zellij uses Webassembly and WASI in order to load these panes and give them access to the host machine, so they can be written in any compiled language.

    That’s the only differentiator I can find, and it’s kind of a strange one, since you can already run programs written in any compiled language natively.

    I assume that plug-ins have some control over multiple panes/allow some kind of multi-process coordination that distinguishes them, but this isn’t touted as a feature anywhere. So I’m not sure. Is there a provided UI toolkit that makes it very easy to write terminal UIs, maybe?

    I am happy to see a new terminal multiplexer, but since this project doesn’t bill itself as such, I spent a few minutes trying to understand why that is, assuming I was missing something. But I just came up confused. Declarative pane setup is a nice feature for a terminal multiplexer: although tmux is scriptable imperatively, you need a plug-in if you want the “yaml layout” model. But it’s still a feature for a terminal multiplexer.

    https://github.com/rothgar/awesome-tmux#tools

    If anyone from the project is reading this, a little section on “why it’s more than a multiplexer” or “differences between zellij and tmux/screen” (or whatever) would be very helpful for people encountering the project blind like this.

    1. 4

      That’s the only differentiator I can find, and it’s kind of a strange one, since you can already run programs written in any compiled language natively.

      What “pane access” means is that these programs get access to terminal state like scrollback while other programs are running as usual in the terminal. This can be used to extend the terminal to add features like:

      1. Copy selected terminal text to clipboard as HTML with color codes
      2. Extract all URLs from scrollback, save to clipboard

      It sounds very useful and hacker friendly to me. Kitty has had a similar feature: https://sw.kovidgoyal.net/kitty/kittens/custom.html

      When launching a kitten, kitty will open an overlay window over the current window and optionally pass the contents of the current window/scrollback to the kitten over its STDIN. The kitten can then perform whatever actions it likes, just as a normal terminal program. After execution of the kitten is complete, it has access to the running kitty instance so it can perform arbitrary actions such as closing windows, pasting text, etc.

      The differentiator here is that you can write Zellij plugins in any language that compiles to WASM, while Kittens are python scripts.

      1. 2

        That does sound very useful, but the things you described are also available in tmux and screen. They work by providing commands that output relevant pieces of scrollback or your selection to stdout, so you can compose tmux with standard filters or fzf or something like tmux thumbs (which, despite the name, operates on arbitrary text via stdin). You can do this from within tmux (via keybindings or the :command line), or from outside of a tmux session, by interacting with it as a server (which the tmux executable does by default, if you give it a command).

        This means you can “script” tmux in whatever language you want – rather than having a plugin architecture, it thinks in terms of stdin/stdout, which feels very hacker friendly to me – although I realize this is a personal preference.

        (Actually, I’m lying: as far as I know tmux doesn’t have a way to extract the current selection while preserving color escape codes. If you want to preserve escape codes, I think you have to output entire lines of the scrollback buffer. This would make it very annoying to implement (1) in tmux as a simple series of pipes; you’d either need to patch tmux or write a script that queries the scrollback contents and selection indices and do the slicing yourself. Which would maybe end up looking similar to a zellij plugin?)

        I’m not trying to be a shill for tmux here – I really am happy to see a new terminal multiplexer. The reason I want to dig into it to see what makes it tick is that I’m currently working on my own “terminal workspace” program (which is not quite a multiplexer) and I’m looking for good ideas to steal. :)

      2. 2

        […] what makes this different from something like screen or tmux

        At a superficial layer, having the powerline style cheat “menu” showing shortcuts, and sane shortcut defaults setup out of the box is a big enough difference that a few people at my office have started using zellij regularly where their efforts to get into tmux/screen were tenuous at best.

        1. 1

          Does it support copy/paste yet? I don’t see that in the docs or the code so I’m assuming not.

          1. 1

            I couldn’t say for sure. In my limited testing of it this far, I’ve only used the terminal emulator for copy/paste.

      1. 37

        Honest question: why should I care it’s written in Rust? I keep seeing these posts of new software and the authors highlight its “written in Rust.” I’ve never before seen such an emphasis on the language rather than the features it offers.

        1. 33

          I care that it isn’t written in C/C++. Memory safety catches a lot of security bugs. And language communities have different cultures, so knowing the actual language can be a signal as well.

          1. 17

            Okay, but in that case, it would be cool if the submission at least highlighted some of the neat use cases for which the language is relevant. E.g. if the description would at least mention an example – a particular module that’s very easy to get wrong in C, but Rust is particularly suited to, the way e.g. Julia is so well-suited for writing a FEM program. Or a “this module would’ve been 600 lines of inscrutable C but look how neat it is when you have explicit lifetime management features baked in the language”.

            If there’s none of that, but it’s just a very good program, that’s great (even better, in fact) – but at least let’s talk about that. Is it remarkably fast, in which case can we have some benchmarks? Is it super secure, as in, has anyone tried to do even an informal review, it’s cool that it’s written in Rust but what I’d really like to know is if someone checked it to make sure that attempting to view an attachment called /dev/null; rm -rf ~ won’t nuke my home folder, which is a far more straightforward exploit than anything involving memory safety.

            Better – hell, best yet – if it’s none of that, and the author just wrote a cool program and wants to share it with everyone else and wants some feedback. Great, but can we at least get that? Hey, fellow lobsters, here’s a thing I made, it’s super early, it won’t be big and professional like Outlook, do you like it? Would you like to send in a patch? What do you think about X?

            Otherwise it’s just another program written in Rust. I get it’s cool but hundreds of programs get written in Rust every day.

            As far as security bugs are concerned, if being written is C would be a red flag, what colour would you say is best ascribed to the flag raised by a tool whose installation script – which you’re supposed to curl straight into bash, of course – downloads an unsigned archive and `sudo mv’s the stuff in it into $PATH ;-)?

            1. 8

              I believe 4 out of these 5 would’ve been unlikely if mutt and libraries were written in rust, for example:

              https://www.cvedetails.com/vulnerability-list/vendor_id-158/product_id-274/year-2018/opov-1/Mutt-Mutt.html

            2. 10

              Any GC language is memory-safe.

              1. 3

                Which is why written in Go is also a popular thing, and deserves to be. People want single binaries and fast, safe programs but for whatever reason they also want to pretend there’s no reason to care what language something is written in.

                1. 3

                  Apart from the fact that garbage collection brings its own issues (although probably none that would affect a mail client), Rust offers much more than just memory safety.

                2. 2

                  What is the most likely security attack surface for a email client?

                  1. 10

                    Untrusted input: message body, attachments, headers; protocol implementation (tls negotiation, authentication)? [ed: and in particular string handling and path handling]

                    1. 2

                      This is a great argument for making MUAs just deal with MH/Maildirs and leaving the server interface to existing programs (mbsync, msmtp).

                      Not only do you sidestep a good chunk of problems you mentioned - no worries about protocols, network, etc - you also are likely to fit into existing workflows. And it engenders trust: honestly, I’m unwilling to try software that speaks to my mail server. I risk anything from a bug inconveniencing me to something more malicious. Keep it local and I’m not as worried.

                    2. 2

                      HTML & images mostly

                      1. 1

                        If you want to support it, html display.

                    3. 29

                      I really have trouble understanding why people ask this. What’s so hard to understand about folks caring about which language a program is written in? There are literally oodles of reasons why it might be relevant. For example, if the title of the post were, “email client written in Zig,” it would actually attract my interest more than the current title. I would probably wind up spending some time reviewing the source code too. But if the title left that out, I probably would have skipped right by it.

                      1. 2

                        I think “written in [L]” makes sense, if the fact that it was written in a language is interesting. If a more complex program is written in APL, it is interesting because APL is know to be diffucult. If something is written in C89 is is interesting because that will probably make it very portable. If something is written in Zig, it might be interesting because a lot of people are not familiar with it’s strengths and weaknesses in real world systems. If something is written in Go, it might be interesting because it provides a easy static binary that can be installed without a big fuss.

                        Most of the time, I’m not surprised about Rust because why shouldn’t you be able to write a CLI tool in Rust? It has been done over and over again. If writing something in Rust has practical advantanges (”… written in Rust making it 4x faster”, “… written in Rust avoiding 90% of all security issues”, …) then it might be interesting.

                        1. 14

                          One aspect of that is that what is “interesting” varies from person to person and from time to time. Just as an example, I know I would be more interested if the title were “written in Zig,” but I’m sure there are plenty of others that would be less interested because of it. And that actually makes the “written in Zig” part of the title useful. Because it lets people filter a bit more, even if it means it’s less interesting.

                          More to the point, “interest” is just one reason why “written in [L]” makes sense. It’s not the only reason. As others have mentioned, some programming languages tend to be associated with certain properties of programs. Whether that’s culture, barriers to contribution (for some definition of “barrier”), performance, UX and so on. Everyone here knows that “email client written in C” and “email client written in Rust” likely has some signal and would mean different things to different people.

                          I truly don’t understand why people are continually mystified by this. It’s like the most mundane thing in the world to me. Programmers are interested in programming languages and how tools are built. Who woulda thunk it.

                          To be clear, this doesn’t mean everyone has to be interested in the underlying technology 100% of the time either. So I’m under no illusions about that. Most of the users of my software, for example, not only don’t care what language it was written in, but probably don’t even know. I’d even bet that most of my users (via VS Code) not only don’t know what language their “find in files” is written in, but probably haven’t even heard of Rust.

                          But we’re on a tech forum. It self selects for nerds like us that like to talk shop. What a surprise that we would be interested in the tools used to build shit.

                          Apologies for the minor rant. This is just one of those things that pops up over and over on these forums. People are continually surprised that “written in [L]” matters to some people, and I guess I’m just continually surprised that they’re continually surprised. ¯\_(ツ)_/¯

                        2. 1

                          Yeah, I agree that the underlying tech can be interesting and makes sense in some cases to be in the title. We’re all hackers lobsters here, right?

                          I’m a little surprised you’d show so much interest in Zig. I think of you as one of the “gods of rust”. Are you interested in a “keeping tabs on the competition” sort of way? Or is there some use case that you think Zig might shine more than rust for? In other words: are you interested in ideas you can bring to rust, or because you’re evaluating or interested in using Zig in its own right?

                          1. 4

                            No, I’m legitimately interested in Zig. I’ve always loved the “simplicity” of C, for example, for some definition of simplicity. (That one can cut a lot of different ways.) It’s also why I really like Go. And I think Zig is taking an interesting approach to memory safety and I’m very interested to see how well it work in practice. I’m also quite interested to see how well comptime does and how it balances against readability and documentation in particular.

                            But I haven’t written a single line of Zig yet. I’m just following it with interest. I’m also a Zig sponsor if only for the amazing work that Andrew is doing with C tooling.

                        3. 11

                          Personally I care because I am trying to learn Rust and projects like this are nice to explore and figure out stuff.

                          1. 6

                            I’m not sure either. I do occasionally see the “written in Go” or “written in Crystal” or “written in pure C99”, however.

                            1. 4

                              This was a trend 5 years ago with Python I feel, now it’s a trend with Rust. In case of Python, in my experience, it boiled down to “we improved the UI massively (compared to existing alternatives) and our error handling is nonexistent”, while with Rust it’s more likely to be “we’re obsessed about efficiency and everything else is secondary” ;)

                              In practice, the “in X” is likely a call for contributors, not the users – as a user, when I see “it’s written in X” I assume that it’s probably got no real upsides aside of that, as if writing it in X was the whole point.

                              1. 3

                                It makes it interesting to me because I’m interested in Rust, so I’d like to check out the source and learn something!

                                1. 3

                                  As an email client for users, it isn’t interesting at all (no disrespect to the creator). But, as an expression for the possibilities of an up-and-coming language, it is useful. This post has the same similar feel to a “hello world” for a new language.

                                  1. 2

                                    People still writing new software in C in TYOOL 2021 also like to brag online about their choice of language. I don’t get it.

                                    1. 2

                                      I first thought “written in Rust” seems boisterous, then rethought and realized it’s beneficial specifying such, not just in boistering, but as an example for folks wanting to learn.

                                      1. 2

                                        Well,one reason to care is to make sure they don’t fall victim to the RIIR question from the Rust Evangelism Strike Force. (Have you considered rewriting it in rust?) (https://transitiontech.ca/random/RIIR).

                                        (Note: this is a joke. You probably don’t care about rust and nor should you, but the author does.)

                                      1. 2

                                        Not to be confused with the Pike programming language: https://pike.lysator.liu.se/

                                        1. 4

                                          Pike is based on LPC, which you might have used if you were a creator / wizard / admin on an LPmud. I believe there’s some kind of continuity in development too; the lysator.liu.se domain hosted a lot of MUD content.

                                          1. 2

                                            Wow, that takes me back! Roxen AB, one of the backers of Pike, is named after the lake and apparently pike can be fished there.

                                          1. 35

                                            There are no inline links (every link goes on its own line), no formatting, and no inline images

                                            So it’s borderline useless for all but the simplest use cases, and even there it does a very subpar job. I’d like to have an inline image every now and then, or organize things in some multi-column layouts or the like, or a table. 19th century newspapers could do this, and if your technology can’t emulate typography produced on a daily basis – often in a hurry – 150 years ago then your tech is rather limited.

                                            These protocols keep shooting themselves in the head with stuff like this, not even in the foot because this entire thing is dead on arrival for all but a few niche tech folk.

                                            1. 17

                                              I see this a lot, and I really, really wish that the people making this case would actually try to use Gemini for what it is before bringing their preconceptions into it. Easily a full third of the people I’ve spoken to about Gemini immediately start talking about some $FEATURE that they would add to it - and I’ve heard a lot of different features. Do you see the problem with this? This is just a recipe for re-inventing the bloat of the web.

                                              You must first use, then understand, then change the software. You can’t skip steps one and two. It is possible to express yourself within these constraints (you’re already expressing yourself within some fairly arbitrary constraints right now, for instance, imposed by Lobsters’ strict markdown rules), and you should first apply a little bit of creativity to the new medium before you try to bend the medium to your will. We don’t really want it bent, we’re doing something different for a reason.

                                              By the way, your comment can be losslessly represented in Gemtext.

                                              1. 8

                                                Easily a full third of the people I’ve spoken to about Gemini immediately start talking about some $FEATURE that they would add to it - and I’ve heard a lot of different features. Do you see the problem with this? This is just a recipe for re-inventing the bloat of the web.

                                                I’d argue that this is because the problems it solves are inherently complex, so any good solution to it will be complex as well. That doesn’t mean I don’t think the web can’t be improved or made simpler – it’s an organically grown mess of 25 years – but it will never be replaced by a dead-simple solution such as Gemini.

                                                And yeah, my Lobsters comments can be expressed in Gemini without much loss (except the inline links thing), but Lobsters isn’t my website though and I wouldn’t be able to express my fairly simple website on Gemini, or a fairly simple site as Wikipedia. And even the entire Lobsters website would be a worse UX in Gemini as it precludes any sort of design.

                                                1. 1

                                                  Gemini does not preclude any sort of design, not at all - it just gives the responsibility for design to the client, not to the server.

                                                  1. 2

                                                    But isn’t this very limiting? Like, it would work for your blog, but in its current iteration adding a table would already be difficult, never mind something more advanced like the fivethirtyeight election forecast and results.

                                                    I suppose it all depends what your vision for Gemini is; if you want it to replace large parts of the web then it’s got basically 0 chance in its current state; if you just want some alternative to use yourself and like-minded people, then sure, go for it.

                                                    1. 1

                                                      Of course Gemini doesn’t preclude design: It’s a networking protocol. You can use it to move HTML and JS and CSS and images and whatever else just fine.

                                                      Attempting to conflate a protocol with a document format is wrong.

                                                      1. 1

                                                        The specification also includes a document format, as well as a networking protocol.

                                                        Arguably, things would have been clearer if they were separated out more clearly, but this would kind of defeat the point of Gemini. The networking protocol and document format are intended to be used together.

                                                  2. 7

                                                    It seems interesting; to make it clear, I do hate tracking too, as well as inaccessibility & various Flash-equivalents of today. And dependency on the complexity tower of Chrome/Firefox/… So I’m certainly curious about alternatives to the current status quo.

                                                    I do understand that the protocol seems to allow for a lot of expression, and more “slow-food” style, relaxed consumption. Yet, I cannot escape immediately having a feeling of loss. If I understand this correctly, with no mathematical equations support, I would not be able to write or consume an article trying to explain Shor’s algorithm. With no graphs support, I assume whenever I’d want to display graphs, I’d have to resort to ASCII-Art as a workaround, with necessarily limited precision (for example, no smooth curves or complex 3D surfaces). Finally, I assume I would not be able to write or consume an article about typography, or bysantine icons. Or am I wrong?

                                                    Having the concerns mentioned above, I’m immediately starting to think about possible workarounds. I am assuming people would start resorting to “rich clients” - for example, with support for rendering of some kinds of mathematical equations. This, I am guessing, would quickly lead to on-site recommendations like: “This page requires support for LaTeX-Super-Renderer-3.7”. De-facto becoming in-band signaling of the kind Gemini apparently tries to dispell by “only allowing one field in response, the mimetype”. But wouldn’t people start doing that anyway, and start writing such plugins anyway, and start de-facto reinventing HTML anyway? With the likes of Flash plugins of yore raising from the dead in new clothes?

                                                    With regards to just graphs and images, I believe it could be somewhat easier actually. I am now reminded of the days of my childhood, when books in my country were mostly in black and white, with a few pages in the center being in color, and being referenced to by the b&w pages (“See illustration 7.b.”). I imagine something like that could work with images being listed, or linked, or attached (?) at the end of a Gemini page. But even then, I don’t think that would be usable for math-heavy documents. And from glancing through the few links around here, it’s not fully clear to me if any images at all, even at the end of a document, are expected to be supported? (Though mimetypes support kinda seems to hint at allowing this?)

                                                    So, with the ideal of simplicity sounding theoretically interesting and alluring, at the same time I’m concerned about losing access to, especially, maths-related content. (Assuming that some image-heavy, yet comparatively sparse in that regard, content could be possibly approximated with a list of image links at the end, referenced from the main article. Which kinda already sounds like a hack, that would probably soon lead to reintroducing inline images via specialized clients…) That feels like a pity to me.

                                                    1. 2

                                                      I do understand that the protocol seems to allow for a lot of expression, and more “slow-food” style, relaxed consumption. Yet, I cannot escape immediately having a feeling of loss. If I understand this correctly, with no mathematical equations support, I would not be able to write or consume an article trying to explain Shor’s algorithm. With no graphs support, I assume whenever I’d want to display graphs, I’d have to resort to ASCII-Art as a workaround, with necessarily limited precision (for example, no smooth curves or complex 3D surfaces). Finally, I assume I would not be able to write or consume an article about typography, or bysantine icons. Or am I wrong?

                                                      I’ve brought this issue about math up in the past, but remember, nothing is stopping you from using HTML or PDF. Gemini uses Gemtext as a lowest-common-denominator form of markup, but if you are writing a client, you can always built in HTML support or shell out to something else that does.

                                                    2. 5

                                                      I think that the reason that people keep trying to suggest features is that Gemini is marketed as a replacement for “the web”, but designed (and only useful) as just a plain text delivery mechanism - there’s (rightly) some cognitive dissonance going on.

                                                      That is, “the web” includes plain text, hypertext, rich documents, audio/video media, and interactive content. I don’t think that most people expect Gemini to implement the last two, but there’s some reasonable expectation that something trying to replace “the web” should at least be able to represent reasonably interesting documents - such as scientific papers, which Gemini clearly cannot.

                                                      Perhaps if proponents of Gemini stopped trying to claim that it could actually replace anything but the tiniest slice of the web that is pure, plain text (not hypertext, as inline links are really important), you would stop getting people talking about adding features.

                                                      Edit: that is, there’s no “preconception” going on here. GP post is responding to the argument that Gemini is a viable replacement for the web by pointing out that it is missing critical features for actually acting as a sane replacement, which has no “preconception” - it’s just a statement of fact. You cannot replace the web without inline links, formatting, or inline images, full stop.

                                                      1. 1

                                                        You cannot replace the web without inline links, formatting, or inline images, full stop.

                                                        As a matter of fact, you can. Full stop.

                                                        1. 9

                                                          …that’s so obviously false that I shouldn’t need counterexamples, but here they are:

                                                          https://graphicallinearalgebra.net/2015/04/26/adding-part-1-and-mr-fibonacci/

                                                          http://foldr.org/mw/emacs/

                                                          http://507movements.com/

                                                          https://lobste.rs/

                                                          https://www.av8n.com/physics/clifford-intro.htm

                                                          None of these sites, or the majority of the thousands of other bookmarks that I have, can be replaced without inline links, formatting, or images.

                                                          Linked files do. Not. Cut. It.

                                                          Not only are linked (vs. inline) files objectively and meaningfully different (and, therefore, you cannot replace the web with them), but they are inferior from an information-processing standpoint. From both a practical and theoretical level, you cannot replace the web with Gemini as it currently stands. People will not use it, they are not equivalent, and I, personally, will discourage people from using it - it is a cognitive anti-tool, similar to a reverse printing press. Useful for implementors, terrible for anyone who actually wants to read documents and exchange information that will actually help them to learn and reason.

                                                          1. 0

                                                            I can provide another counter-example: you had 5 links in your comment, none of which were inlined, despite having access to inline links on lobsters.

                                                            You can’t place identical content on Gemini as you can on the web. You can reformat your content for the new medium. Nothing transitions between mediums without change.

                                                            Gemini replaces a subset of the web, which I stated in the opening article and have re-iterated dozens of times.

                                                            1. 5

                                                              I can provide another counter-example: you had 5 links in your comment, none of which were inlined, despite having access to inline links on lobsters.

                                                              …that’s not a counter-example. I never claimed that you can’t replace any of the content on the internet, which is what that statement would be a counter-example to. Perhaps you should take a logic course. Edit: that was too aggressive, my apologies.

                                                              Edit: I claimed that you cannot replace “the web”, which implies replacing the majority of the content at least, and all of the content at most.

                                                              You can’t place identical content on Gemini as you can on the web. You can reformat your content for the new medium.

                                                              …and, as it should be very clear, that re-formatting process is (1) lossy and (2) causes a significant decrease in readability and information processing - meaning that it is not a replacement. The format of the web is part of the web, therefore you cannot replace the web with Gemini.

                                                              Gemini replaces a subset of the web, which I stated in the opening article and have re-iterated dozens of times.

                                                              You have tried to claim that Gemini can replace anything but the tiniest trivial slice of the web that is pure, un-hyperlinked plain-text - which, as shown above, is false. The format of the web is part of the web. The content and the medium are entwined.

                                                              1. 2

                                                                Anything with “less features” is lossy, but that’s not correlated with a “significant decrease in readability”. On the other hand, putting the presentation entirely into the client’s control is a significant win for readability, because the user can configure fonts, contrast, and layout to their preferences and usability needs. The screen reader experience, for instance, is WAY better. Inline links and inline formatting are less accessible to some.

                                                                1. 4

                                                                  Anything with “less features” is lossy

                                                                  Only true in the most needlessly pedantic sense. You can easily build systems with a small set of carefully-chosen features that still implement the vast majority of the functionality of larger systems that were poorly-built. This…does not describe Gemini. Gemini picked a basis of features that do not allow it to implement more complex functionality or richer documents.

                                                                  that’s not correlated with a “significant decrease in readability”

                                                                  Not in general, sure - but in the case of Gemini, it’s pretty clear that there is a significant decrease in readability (and, therefore, cognitive processing ability). Requiring users to click through to a separate document for each image, animation, or individual mathematical equation is extremely unreadable for anything with a reasonable density of those things - while “only” being merely slightly less readable for documents with only a few of those objects.

                                                                  On the other hand, putting the presentation entirely into the client’s control is a significant win for readability the user can configure fonts, contrast, and layout to their preferences and usability needs

                                                                  You can already almost entirely control presentation with major browsers for the current web, through userscripts and stylesheets.

                                                                  Moreover, HTML is actually structured, unlike Gemtext, so I have anchor points and document metadata that I can use to exert more control over my content than with unstructured Gemtext - so your statement is actually untrue.

                                                                  The screen reader experience, for instance, is WAY better.

                                                                  Modern web gives you more options to make a good screen reader experience - such as image alt text. Is it really inconsistently used? Sure, but that’s not a technical problem, that’s a social one - a social one that manifests itself in an equally bad way with Gemini, because Gemtext doesn’t have any way to bind accessibility-related metadata to document structure, because there is no document structure.

                                                                  Inline links and inline formatting are less accessible to some.

                                                                  Expanding links and controlling inline formatting are very basic features for screen readers.

                                                                  So, to summarize, modern web gives you a much richer interface for screen readers, as well as a better interface for people who don’t use screen readers (which is the majority).

                                                                  Gemtext is straight-up less conducive to thought and information transfer.

                                                                  1. 2

                                                                    I think “significant decrease in readability” is interpreted a little too literally here.

                                                                    Many of the documents linked by fouric would be way more inconvenient to read if they were adapted to fit in gemini’s limitations because of how heavily they rely on tables, anchor links to a specific part of the same document, and inline images (especially with how inconsistent most clients available today are at dealing with non-gemtext content types).

                                                                    I personally am a big fan of how gemtext files only ever result in a single request due to the lack of stylesheets, scripting, and inline resources, and have pushed back on the adoption of HTML and Markdown as alternate document content types because I think that is a valuable part of the protocol. I’m also not delusional: the stance I hold also directly limits the mass appeal of gemini as a technology, because normal people who just want to read these kinds of documents are unlikely to accept what seems like massive inconvenience for technical reasons they don’t fully understand. They’ll just stick to the Web.

                                                                    I am willing to put up with that inconvenience as a reader and writer of gemtext content because I think the other benefits of gemini are worth it, but I don’t expect anyone who isn’t another disillusioned Web developer to get on board quite as easily.

                                                        2. 3

                                                          By the way, your comment can be losslessly represented in Gemtext.

                                                          This isn’t quite true, is it? His comment included the clearly-delineated metadata of his name and the time, including an inline graphic element (his avatar) to aid the eye in scanning the page for it. Gemtext as currently defined precludes any such niceties because they are perceived as ornament by the early community (who ironically see a need for some headings, lists, quotes, and … ASCII art).

                                                          It also included a simple method for you to add a reply. POST is a slippery slope, but I hope Gemini someday gains a sort of Micropub.

                                                          (I am one of those $FEATURE users, where $FEATURE is inline images and metadata or some sort of “secondary” text. But I’ll finish building my capsule and client and see how things evolve.)

                                                          1. 2

                                                            How would metafilter-style writing look, with lots of inline links? Examples appreciated.

                                                            1. 7

                                                              You just wouldn’t have lots of inline links. You’d have a separate list of references, perhaps. Here are some examples of Gemini posts I have written with lots of links:

                                                              https://portal.drewdevault.com/2020/11/01/What-is-Gemini-anyway.gmi

                                                              https://portal.drewdevault.com/2020/10/22/Firefox-the-embarassment-of-FOSS.gmi

                                                              https://portal.drewdevault.com/2020/10/01/Spamtoberfest.gmi

                                                              Let me put it this way: how would inline links work in a newspaper, book, or magazine? The answer is: they wouldn’t, and you just work within those limitations. That doesn’t mean the medium is bad.

                                                          2. 6

                                                            19th century newspapers could do this, and if your technology can’t emulate typography produced on a daily basis – often in a hurry – 150 years ago then your tech is rather limited.

                                                            Not arguing against you, but when it comes to web browsers, then they still haven’t learnt to properly hyphenate text. Another thing we could do 150 years ago. One of the reasons (another being rather poor support for rendering maths, or, in the case of Chromium, complete lack of it) I’m relieved whenever I get to read a PDF generated from LaTeX instead of a webpage.

                                                            1. 6

                                                              You can manually hyphenate with soft hyphens like you did 150 years ago just fine.

                                                              Automating hyphenation is nearly impossible. LaTeX certainly requires some manual help.

                                                              1. 2

                                                                If I use soft hyphens, then copying He­re are rhi­nos. to terminal results in He re are rhi nos. visually, because it copied the text with the soft hyphens even though everything was on a single line.

                                                                LaTeX certainly requires some manual help.

                                                                It never required it when I used it. When you enable correct language support, it should just work.

                                                                1. 4

                                                                  That’s because your terminal is 1970s computer technology.

                                                                  1. 1

                                                                    No. That’s because I copied text, but received bytes instead.

                                                                    FWIW it doesn’t happen with hyphenate: auto in CSS, but that’s only supported by Firefox, so it’s irrelevant.

                                                                  2. 2

                                                                    150 years ago you couldn’t copy manually-hyphenated text from your newspaper in to your terminal.

                                                                    1. 2

                                                                      I thought this analogy was cute for a little bit. But seriously, why is 150 years ago the standard? Are we really that painfully nostalgia-blind that we can’t recognize there’s a medium point between the old and the new?

                                                                      1. 3

                                                                        It isn’t my standard, and frankly I don’t really care what we could / couldn’t do 150 years ago because I don’t believe it matters in the context of what are we doing, trying to do, and can’t do today.

                                                                2. 5

                                                                  Firefox does hyphenation with hyphens: auto; if you set the document language.

                                                                  1. 1

                                                                    Does Gemini support setting the document language?

                                                                    1. 2

                                                                      A quick search on the specification shows it does. So hyphenation working on gemini or not would be a matter of the client implementing it.

                                                                  2. 3

                                                                    Well, 150 years ago it was a manual process, and not an automatic one :-) I regularly insert &shy for this on my website by the way. But yeah, I agree that the lack of a universally supported hyphenate: auto has been long overdue (only Firefox supports it, and it doesn’t even do a great job at it, although I don’t know if there are technical reasons that prevent it from doing a better job; I think I saw someone on HN detail some issues with automatic hyphenation on the web years ago, but I forgot what they were).

                                                                    Math rendering has also been supported by Firefox for 15 years with MathML, but for some reason Chrome doesn’t (but Safari does). Actually, looks like they removed it in Chrome years ago, although it looks like there’s work to add it back soon-ish.

                                                                    1. 1

                                                                      Actually, along with Firefox, some versions of Chrome (Android & Mac) support auto hyphenation, and Safari has it hidden behind a prefix: https://caniuse.com/css-hyphens I feel that together these may cover enough of the market to make it worth adding to web pages.

                                                                      If you want to see a quick and stupid demo, here’s my very unfinished Hugo theme I’m working on developing: https://www.maximumethics.dev/blog/2020/07/my-first-post/ If you shrink the viewport width until it’s skinny like a phone, you’ll see the longer 90 chars “alphabet” line break to hyphenate (on the aforementioned supported browsers), as well as random words in the text.

                                                                      1. 2

                                                                        Ah yeah, it’s just the desktop version that doesn’t support it for some weird reason; I forgot about that detail.

                                                                        I suppose it depends what you use it for: most of the time I really wanted auto hyphenation is for comparatively narrow pieces of text and/or for text-align: justify (e.g. a sidebar or info box). In those cases the hyphenation (manual or automatic) is pretty much a must-have rather than a nice-to-have, because without it it just looks ugly. Your site, on the other hand, looks fairly decent without hyphenation even on smaller screens, but it won’t hurt to add it for browsers that support it.

                                                                      2. 1

                                                                        Math rendering has also been supported by Firefox for 15 years with MathML, but for some reason Chrome doesn’t (but Safari does). Actually, looks like they removed it in Chrome years ago, although it looks like there’s work to add it back soon-ish.

                                                                        That’s what I was on about. If something isn’t available in Chrome, it’s irrelevant these days. I’ve been aware that “it looks like there’s work to add it back soon-ish” for quite some time now. I don’t have hope.

                                                                    2. 5

                                                                      I think the idea is that the publisher delivers only the information, not the presentation. This constraint allows for greater user control over presentation, for example one might configure Gemini to lay out news articles (maybe on a site by site basis) in a column style, to suit their preferences. I think it’s an interesting idea as a way of making better typesetting more widely available to content published on sites without the budget / know-how to tune their CSS for readability.

                                                                      I agree that Gemini would be better off if it supported inline images. That’s pretty often part of the information layer.

                                                                      1. 8

                                                                        I think the idea is that the publisher delivers only the information, not the presentation.

                                                                        Wait! That is HTML! (as compared to PDF)

                                                                        1. 6

                                                                          Not really, HTML still focuses a lot on presentation. Headers, side bars, footers, nagivation line, footnotes, etc. are all concepts foreign to the browser, that have to be manually re-implemented in the markup language, again and again. That’s actually what I think that protocols like Gemini misunderstand: HTTP/HTML is not too systamatically complicated (at most it’s “organically” complicated), it’s actually too simple. If for example the <head> section had made it possible to describe how a web-page is navigated, it would have been possible for the browser to render that part of the site, leaving the <body> to be actual content. It’s something you see with other simple languages too: Scheme has various implementations, that implement a common core, but diverge in their additional libraries, that are regarded as useful, but do not allow for code to be portable. So too, had HTTP/HTML has the foresight to recognize what people would want from websites (which is probably too much to ask), or at least the foresight to allow a certain degree of extensibility, a lot of implementation-specific complexity could have probably been avoided.

                                                                          So the issue might not be “simplicity vs compexity”, but “what kind of complexity”.

                                                                          1. 3

                                                                            Years ago I came across a browser extension that would build a navigation bar if it found certain <link> tags in the header. I modified my blogging engine to automatically add said links. Sadly, the extension no longer runs (because of course the extension mechanism changed—at least twice—since then) but I still generate the data in the vain hope it’ll be useful again.

                                                                        2. 5

                                                                          A strict separation of information and presentation is something that sounds great in theory, but doesn’t really work all that well in practice once you move beyond the simple use cases, or use cases that are pre-defined and supported in some way.

                                                                          1. 1

                                                                            I don’t know if this was part of the design goal - from what I can see, Gemini doesn’t have any sort of mechanism to describe or annotate what content/information is being delivered, which would make any presentation strategy necessarily heuristic, as there would be no way to delineate e.g. where the “author” of the article is.

                                                                            1. 1

                                                                              I guess you’d just put that information into the document itself.

                                                                              One underappreciated tag in HTML is the <address> tag, which is a nice place to put stuff like author, publication date, etc.

                                                                              1. 1

                                                                                I’m not quite sure what you mean - when you say “just put that information into the document itself” do you mean in a machine-readable format? Because if so, that’s not part of the Gemini text spec - which is the thing being discussed. Adding tags like <address> would be extending the Gemini spec to add features, which is what proponents of it are fiercely against.

                                                                                1. 1

                                                                                  No, I just meant to add something like

                                                                                  • Author: Gustaf Erikson
                                                                                  • Date: 3 Nov 2020

                                                                                  in the body of the text somewhere.

                                                                          2. 4

                                                                            As it has been stated on the mailing list, “you can always serve up text/html or text/markdown, you aren’t limited to text/gemini.” There are sites out there serving up images and even music.

                                                                            1. 12

                                                                              Well, that’s not really what’s advocated for in this post (or on the Gemini website as far as I could see), and serving HTML over Gemini just sounds like a s/HTTP/Gemini/, and you can serve text or Markdown over HTTP as well. I don’t really see the point if you’re going to serve HTML over Gemini.

                                                                            2. 4

                                                                              I’m sick of how complex html+css+js gets, and how complicated extracting the actual content can be, in order to view it on “unusual” platforms (small screens. ereaders, etc.), where a good experience depends on the client controlling the presentation of the content. Something like gemini could be the solution to that, but I have to say, the lack of inline images is a deal-breaker for me.

                                                                              I view multi-column layouts as part of the presentation, not the content (I don’t want two columns of text on a phone screen: if I do want two columns of text on the desktop, I can write that into the client), but the images are part of the content.

                                                                              I did wonder whether technically a gemini-ish client could fetch urls which look like they point to images and display them inline, but this is explicitly banned by the specification:

                                                                              Clients can present links to users in whatever fashion the client author wishes, however clients MUST NOT automatically make any network connections as part of displaying links whose scheme corresponds to a network protocol (e.g. gemini://, gopher://, https://, ftp://, etc.).

                                                                              I can sort of see what they’re aiming for, presumably trying to avoid the sort of nonsense some websites have become, where the initial request just gets a jumble of html elements that require the client to fetch and execute tons of javascript before they can be assembled into something resembling content, but I think they should have made an exception for images (They could still leave it up to the client whether it displays inline images or not).

                                                                              Interestingly, gemini probably works really well with screen readers, until you get to an image link (or any link for that matter), at which point it depends entirely on whether the author bothered to provide a caption, or explain what the link is as part of the text (Although that’s arguably no worse than html, where the existence of alt text doesn’t mean that it is always used or used correctly).

                                                                              1. 6

                                                                                Another reason to not allow non-user-initiated network connections is that’s abused to track users (Facebook pixel etc).

                                                                                IMHO this could be sufficiently solved by allowing additional requests to the same domain as the document request.

                                                                                1. 4

                                                                                  One big reason I’m excited about Gemini is the possibility of escaping the web’s bloat, which we need to do in order to reduce energy usage / emissions in the climate crisis. For this reason, I support Gemini’s decision to ban inline images. If you have inline images, next people will want inline video, and soon even if Gemini is “simpler” it’s using as much storage+bandwidth+processing as a web page.

                                                                                  Inlining images, especially from other locations, is also a plausible method for sneaking user tracking back into the protocol, and I also approve of Gemini’s strong efforts towards privacy. I also hate ads even when they don’t track people, I’d love to live someplace where billboards are banned so I can escape the constant background hum of marketing. Eliminating inline images is also a great way to reduce the annoyance of advertising.

                                                                                  I’m going to have to agree with everyone in this thread that refusing to implement inline links was a mistake, though. That was one of the biggest problems I had with Gopher, and I was hoping Gemini would do a better job with hypertext.

                                                                                  1. 4

                                                                                    Inlining images, especially from other locations, is also a plausible method for sneaking user tracking back into the protocol, and I also approve of Gemini’s strong efforts towards privacy.

                                                                                    It’s a very difficult balance to strike between simplicity and functionality. You could probably avoid trackers by, as @m_eiman says, only allowing additional requests from the same domain as the original document.

                                                                                    Alternatively, you could create/use a format which embeds the images directly in the original document (similar to how pdf or epub does). Some might argue that this is inefficient, as you need to serve multiple copies of the image data if it appears on multiple pages. However, in this context, it could be seen as a feature, as we don’t want the kind of images (such as ads) which aren’t actually “part of the document”.

                                                                                    There will always be some people who abuse any protocol, but not having inline images is very limiting and means it isn’t any good for a significant portion of (what I consider) “good content that doesn’t need javascript/css”.

                                                                                2. 4

                                                                                  I’m just going to drop a link to the FAQ page, in the hopes that it’ll answer some questions here.

                                                                                  1. 1

                                                                                    I’d like to have an inline image every now and then

                                                                                    Might I ask what’s wrong with merely providing a link to the image?

                                                                                    or a table.

                                                                                    This can be easily done with some ASCII art (which is what you do for Markdown, anyways) coupled with a preformatted block.

                                                                                    1. 12

                                                                                      This can be easily done with some ASCII art…

                                                                                      But ASCII art is pretty much the quintessence of mixing presentation and content, which is very specifically what Gemini seeks to avoid. It can’t wrap or scroll differently on small devices, it can’t be extracted (easily and reliably) to a machine-readable data format, and it isn’t accessible because there’s no semantic information about the table structure.

                                                                                      1. 3

                                                                                        You’re right. I kinda hope some kind of table syntax does make it into the Gemini spec after all.

                                                                                      2. 4

                                                                                        I need to click a link to an image? It seems pretty obvious to me that this is worse UX than just displaying it.

                                                                                        ASCII art relies on a monospaced font, which I don’t really like for reading text. I think Lobsters would be significantly worse if it was all monospaced text for example. It also relies on a certain screen size, which doesn’t work for smaller screens (or very big ones, for that matter). I mean, it kinda works but it’s a hack.

                                                                                        1. 2

                                                                                          I need to click a link to an image? It seems pretty obvious to me that this is worse UX than just displaying it.

                                                                                          Yeah. You’re completely right, this is worse UX. I’m beginning to think of proposing an inline-image syntax for the gemini spec.

                                                                                          ASCII art relies on a monospaced font, which I don’t really like for reading text.

                                                                                          I admit I was wrong. ASCII tables are a hack, I suppose. Hopefully the simple table syntax I’m thinking of right now makes it into the spec!

                                                                                          I think Lobsters would be significantly worse if it was all monospaced text for example. It also relies on a certain screen size, which doesn’t work for smaller screens (or very big ones, for that matter). I mean, it kinda works but it’s a hack.

                                                                                          FYI there are gemini clients that support variable-width fonts.

                                                                                          1. 4

                                                                                            FYI there are gemini clients that support variable-width fonts.

                                                                                            I tried to use it with Gopher years ago (I hacked up an existing client), and many sites don’t really work all that well because they assume stuff will be displayed as monospaced text (such as tables you mentioned, but also things like code examples, or other alignment things).

                                                                                            Gemini is a bit of an improvement because the spec at least recognizes that proportional text exits and has “code blocks”, but it also leaves much to the clients. In other words: I wouldn’t be surprised if people would just keep using it as they used Gopher, and the weird (and IMO, broken) way line wrapping works in Gemini doesn’t help either. I suppose time will tell how it will be used in practice (but as mentioned, I don’t think it will be used much in practice beyond a few “Hacker blogs” like Drew’s).

                                                                                            One of the big mistakes of HTML was, ironically, to “leave it up to the clients” which resulted in a big mess which had to be unified so that people could get a reasonably consistent experience irregardless of which browser they use, but that just unified the mess instead of clearing it up.

                                                                                        2. 1

                                                                                          I use HTML to add tables to my Markdown content.

                                                                                          1. 1

                                                                                            I personally find HTML’s table syntax difficult to read and use.

                                                                                            1. 4

                                                                                              Yep, I usually whip up a quick Perl script with the (deprecated) CGI module to generate it from plain text ;)

                                                                                        3. 1

                                                                                          Gemini is only a protocol, but the specification also propose a basic text/gemini format as a de-facto document type. It however supports any mimetype, including text/html:

                                                                                          5 The text/gemini media type
                                                                                          5.1 Overview

                                                                                          In the same sense that HTML is the “native” response format of HTTP and plain text is the native response format of gopher, Gemini defines its own native response format - though of course, thanks to the inclusion of a MIME type in the response header Gemini can be used to serve plain text, rich text, HTML, Markdown, LaTeX, etc.

                                                                                          You could totally sent the following HTML document over gemini:// and enjoy inline images:

                                                                                          <html>
                                                                                            <body>
                                                                                            <p>My favorite cat picture:</p>
                                                                                            <img src="gemini://domain.tld/cat.png" />
                                                                                            </body>
                                                                                          </html>
                                                                                          

                                                                                          It would then be up to the gemini client to process this document, fetch required resources (the cat picture) and render it nicely for you. The advantage of the gemini protocol here is that it would put a limit on the HTML subset one could put in a document. For example, <form> tags won’t be any useful. There would also be no need for <script> tags, as they wouldn’t be able to “phone home” over gemini.

                                                                                          One of the biggest problem of the web is that the HTTP protocol itself grew in an enormous monster that’s impossible to understand, where sometimes the headers of a requests can be 10 times bigger than the content itself.

                                                                                        1. 8

                                                                                          Counterpoint on thin: After years of using ThinkPads, I’m much happier with my MacBook Air as a laptop. I don’t need ports or performance on the go, I want battery life and lightness. It’s nice having a laptop I can lift effortlessly with one hand. The MBA makes appropriate compromises for a laptop; one of the few things I miss from my ThinkPad is a nub. If it’s your only system, then it probably isn’t an appropriate choice, but I have faster computers (my desktop at home and many servers) if I need more .

                                                                                          1. 5

                                                                                            One of the authors points is that companies are trying to take away computing power on move it to their cloud. Working on a beefy server in a data center somewhere is kinda similar though. In the end, it is (most likely) not your computer you can’t be sure nobody is interfering with.

                                                                                            Not that I am not guilty of doing it myself.

                                                                                            1. 2

                                                                                              Does that really hold true for Apple though, who doesn’t have their own cloud business? I mean, most of the laptop hardware manufacturer’s aren’t directly involved in cloud services either, so I’m not sure that argument holds up. It’s not like most aren’t still offering beefy ‘portable workstation’ types, it’s just a tradeoff of battery/portability and power.

                                                                                              1. 1

                                                                                                This point might not be true for Apple, however they are going in a direction which is problematic in other ways: To me it feels like macOS is becoming more restricted with every major OS release. My guess is that sooner or later they will take away the possibility to run unsigned code on their computers. My prediction is that with the advent of ARM Macs iOS and macOS will eventually merge into the same product, leaving you with a powerful device and not a computer anymore.

                                                                                                1. 3

                                                                                                  Given how many of the MBP devices get sold to developers, I think it’s unlikely they’ll restrict unsigned code entirely. They will almost certainly make it more of a pain, but tbh, I’m personally fine with that. The “average” Mac OS user generally needs their hand held and is better served having safety nets to prevent them from doing something dangerous. Power users, who know what they’re doing, can figure out the mechanisms to do whatever they want. iOS and Mac OS may merge in the future, but I think it would result in iOS becoming more ‘open’ than Mac OS being more closed. Even the most recent releases of iOS have things like scripting automation, (finally!) decent file handling, changing default browser (still webkit afaik, uhg), etc..

                                                                                              2. 1

                                                                                                I have that computing power at home. I can SSH into it, or if I’m at home, just use it, right there.

                                                                                                You’d be surprised how performant low voltage designs can be anyways.

                                                                                                1. 1

                                                                                                  Some people don’t feel comfortable or cannot afford to leave their computer running 24/7

                                                                                                  1. 1

                                                                                                    So that’s when you leave a rpi running 24/7, hooked up to a USB-controlled finger which presses a key on your desktop’s keyboard and wakes it up when you want to ssh to it

                                                                                              3. 2

                                                                                                Nothing portable about having to carry an additional “real” keyboard around …

                                                                                                1. 2

                                                                                                  I’ve never needed to carry around a keyboard. Unless you actually have a disability that prevents you from using a traditional keyboard layout, I actually like the keyboard on my ThinkPads and don’t think mechanical keyboards are a huge leap. The MBA is a slight downgrade on that front, but it’s perfectly usable.

                                                                                                  1. 3

                                                                                                    I think the previous commenter is talking about Mac keyboards vs external keyboards. Employer requires me to use a Mac, and I’ve used the built-in keyboard for maybe thirty hours, and it’s starting to act weird already.

                                                                                                    While I’m able to write code on my personal ThinkPad keyboard, the work Mac keyboard sacrifices usability for smaller size to the point that I find it unusable. I think that’s what the previous poster is trying to say.

                                                                                                    1. 1

                                                                                                      And you are so right. What a horrendous keyboard (and laptop in general). I’m shocked and disgusted by how bad it is.

                                                                                              1. 5

                                                                                                This feels cruel and pointless to do, but this page pulls in 143k of CSS and 152kb of JS, which all in compresses to 150kb, bigger than the youtube page (with video player) the poster’s referring to.

                                                                                                1. 4

                                                                                                  What was the page’s weight in 2012, I wonder? And the same youtube page in 2020 (and 2012; the 1.5M page was in 2009)? It would be interesting to track page weight for long-lasting URLs over time.

                                                                                                1. 1

                                                                                                  Do any common editors not have this functionality?

                                                                                                  1. 19

                                                                                                    ed, the standard editor, does not include this functionality.

                                                                                                    1. 9

                                                                                                      Many don’t. And frankly speaking, while you’re reaching for the mouse to open a bunch of menus sequentially then scroll, I am already looking at the relevant diff bit without even moving my eyes from the relevant area on my screen, let alone my hands from the keyboard.

                                                                                                      Point and click UIs can be great for discoverability, but they fall short when it comes to maximize productivity.

                                                                                                      1. 3

                                                                                                        You’re putting words in the parent poster’s mouth, which comes across either as condescending, or at best assumes bad faith, and is hard to address. They don’t mention a workflow with menus or using the mouse, so why did you argument against that?

                                                                                                        And, you say “fall short when it comes to productivity” as if it is a fact when of course it’s not (or cough up som empirical research, thank you).

                                                                                                        Finally, I personally haven’t used any tools without diffing builtin and the most common ones I use daily, emacs’ magit and IDEA (the conflict resolution part, using ‘structural’ (? editable, at least) diffing) are both very usable/fast/your arguments here, without needing to use the mouse.

                                                                                                      2. 7

                                                                                                        I don’t see your point? What’s wrong with having it as a dedicated tool?

                                                                                                        1. 2

                                                                                                          I’m surprised anyone wants or needs this as a stand-alone tool

                                                                                                          1. 21

                                                                                                            I don’t even know how to respond to this.

                                                                                                            1. 16

                                                                                                              I think it’s just lack of imagination. For example, I told git to use it. Works nicely.

                                                                                                              1. 4

                                                                                                                I do the same :)

                                                                                                              2. 4

                                                                                                                diff is essential part of my workflow. I use it as a way to double check that I agree with everything before a git commit.

                                                                                                                1. 4

                                                                                                                  I believe that GP meant something along the line “this diff tool is built-in editors like PyCharm or Visual Studio Code, why use this standalone tool?”

                                                                                                                  I don’t know whether I’m becoming 27 y.o. old man, but the new cool kids on the block don’t use Vim and/or Emacs any more. In my professional experience, most think that vim is just a tool to edit files on a Linux server. These old editors (“old”, kakoune is 5 years old) are now considered a relic from the past.

                                                                                                                  1. 5

                                                                                                                    I know what you’re trying to say, but Emacs and Vim have both had built in diffing tools for decades. It’s not a feature modern IDEs invented.

                                                                                                          1. 11

                                                                                                            That bit about “Rust itself can’t even properly clean up its memory” is not that it leaks (it doesn’t), but that the standard library calls abort() when it fails to allocate memory.

                                                                                                            The reasoning behind that design was that programs literally can’t run out of memory due to Linux’s overcommit and OOM killer. Fortunately, this is changing, and there will be an option to have it panic.

                                                                                                            1. 4

                                                                                                              As I’ve mentioned on lobsters before, abort-on-OOM isn’t good enough for implementing commercial databases either. So I’m pretty stoked for panic-on-OOM to land.

                                                                                                              Rust would be the perfect language to build a database. And in the 3 years since I wrote those comments Rust has only gotten better. I eagerly await the day Rust supplants C++ in every domain—I love writing Rust!

                                                                                                              1. 5

                                                                                                                I think you will find C itself does not ship with alternative allocators, you must build those yourself. C programmers build these core abstractions themselves a lot of the time, but nothing in rust stops you from doing the same with a slightly different mindset. In rust it is entirely possible to write your own collections and smart pointers that use custom allocators.

                                                                                                                I feel if you had the resources to write a commercial database, writing an alternative String or Vec would not be a challenge for you. You just have to avoid using ‘std’ for everything, which I feel is not that hard.

                                                                                                                1. 5

                                                                                                                  Yes. However in C/C++, such things have been done for decades. My concern is less about what is technically possible, and more about what is a defensible business decision.

                                                                                                                  1. 3

                                                                                                                    You just have to avoid using ‘std’ for everything, which I feel is not that hard.

                                                                                                                    Not totally necessary either, because even your custom-written types which use your special allocator will be able to yield &str and &[u8], and impl iterators.

                                                                                                                    1. 2

                                                                                                                      Even when using custom types, other functions in std allocate, and thus could potentially abort your entire database process. Using no_std would be the best option at this time.

                                                                                                                      Of course there are useful databases without such levels of crash resiliency, e.g. Cassandra written in Java. But people don’t pay money to license Cassandra, do they?

                                                                                                                      1. 2

                                                                                                                        If you’re trying to avoid allocations at all, just don’t use libstd. Libcore has no allocator and has everything you need language wise. You can always copy non-allocating parts of libstd that you want into your code (or a supporting llibrary) directly, or copy allocating parts and modify them to handle failure.

                                                                                                                  2. 3

                                                                                                                    Rust would be the perfect language to build a database. And in the 3 years since I wrote those comments Rust has only gotten better. I eagerly await the day Rust supplants C++ in every domain—I love writing Rust!

                                                                                                                    It is already. Rust already powers banking systems through TiKV by Pingcap. Just not as much in the US as rather in Asia.

                                                                                                                    1. 2

                                                                                                                      Indeed! Do you happen to know whether TiDB gets used as well as TiKV?

                                                                                                                      1. 2

                                                                                                                        Oh, sorry. My mistake. Actually, they all use TiDB, TiKV just being the storage layer.

                                                                                                                1. 11

                                                                                                                  This could be painful for the BSDs. I doubt anybody wants to require rust in base.

                                                                                                                  1. 20

                                                                                                                    Rust keeps growing, so it’s only going to get harder to ignore. The focus should be on what needs to be improved to have it in, rather than how to keep it away.

                                                                                                                    1. 10

                                                                                                                      It is not about ignorance and more about compatibility.

                                                                                                                      “Such ecosystems come with incredible costs. For instance, rust cannot even compile itself on i386 at present time because it exhausts the address space.

                                                                                                                      Consider me a skeptic – I think these compiler ecosystems face a grim bloaty future.”

                                                                                                                      https://marc.info/?l=openbsd-misc&m=151233345723889

                                                                                                                      1. 3

                                                                                                                        I wasn’t implying. I was stating a fact. There has been no attempt to move the smallest parts of the ecosystem, to provide replacements for base POSIX utilities. As a general trend the only things being written in these new languages are new web-facing applications, quite often proprietory or customized to narrow roles. Not Unix parts.

                                                                                                                        There may also be compatibility issues but, in 2017, that is a pretty ignorant thing to say about Rust when the uutils project had already existed for years. Or maybe Theo is simply sneering about GNU’s implementation of the POSIX utilities, which uutils attempts to emulate.

                                                                                                                        edit: also, started in early 2017, redox-os’s BSD-compatible coreutils project.

                                                                                                                        1. 3

                                                                                                                          Theo buried the lede in the email. In 2017, it was his considered opinion that it was essentially impossible to include Rust in the OpenBSD base distribution because Rust couldn’t be compiled by base.

                                                                                                                          It’s possible that in 2020, this situation has improved, which would mean that a necessary precondition to include Rust programs in OpenBSD base has been fulfilled. It still needs to be proven that replacing tried and true utilities written in C with ones written in Rust would result in meaningful improvements of the quality of the OpenBSD system as a whole.

                                                                                                                          1. 4

                                                                                                                            It may have improved for i386 (I don’t know) but there are additional platforms that OpenBSD needs to consider.

                                                                                                                            Today there are platforms that use clang and some other platforms that can’t use clang and are stuck with the last gcc, but at least 99% of OpenBSD base is just C and so generally most things can compile with either clang or gcc. Bringing rust into base then escalates this “have” vs “have nots” situation and then you start to have “tier 1” (amd64, arm64, i386?) vs “tier2” (sparc64, macppc, etc). Maybe that is already happening though. I imagine NetBSD will be in a similar situation.

                                                                                                                            1. 4

                                                                                                                              You’re correct, I didn’t even consider the other architectures that OpenBSD supports.

                                                                                                                              So to summarize

                                                                                                                              1. Rust isn’t supported on all platforms
                                                                                                                              2. Rust is too large and complicated to be compiled from source via OpenBSD’s base
                                                                                                                              3. Rust offers dubious advantages for OpenBSD
                                                                                                                              1. 1

                                                                                                                                Rust offers dubious advantages for OpenBSD

                                                                                                                                In the context of mesa or in OpenBSD using Rust internally?

                                                                                                                                I think those are 2 different arguments. OpenBSD might not want to commit to using (or supporting) Rust, but it cannot decide if another project wants to use Rust for reasons they consider good.

                                                                                                                                1. 1

                                                                                                                                  In the context of OpenBSD using Rust internally (as part of base).

                                                                                                                              2. 3

                                                                                                                                Hm, so in general, the whole thing would start with upstreaming an OpenBSD target and working with upstream to get it maintained and then getting support in for things they need. i386 is a hard case though, because LLVM support may be lacking (I have no assessment of that).

                                                                                                                                The hard reality here is that all project need to find maintainers for those things and they are few and far between.

                                                                                                                                On the Rust side in general, I’m happy to see that OpenBSD currently maintains their own patches. I tried to encourage OpenBSD folks I met to upstream, but have yet so see that happening. We’re generally happy to accept them given bandwidth and maintenance commitment (bandwidth is a regular issue, but we’re always working to improve that).

                                                                                                                                https://github.com/openbsd/ports/tree/master/lang/rust/patches

                                                                                                                                1. 1

                                                                                                                                  Speaking for illumos, for which support ought to appear natively in the next Rust stable release, upstreaming has been a generally pleasant experience. It all took way longer than I expected, at least in part due to the long pipeline from master to stable, but everybody with whom I interacted along the way has been polite and helpful!

                                                                                                                                  1. 2

                                                                                                                                    Thanks for letting me know! BTW, this is the first time I got the pipeline from master to stable described as “long”, but I can understand where you are coming from!

                                                                                                                                    I’m happy to hear that the interaction was pleasant. That’s a good baseline to get the contribution speed up!

                                                                                                                            2. 1

                                                                                                                              I think should understand the other aspects of it. Rust, at the time, not being able to compile on i386.

                                                                                                                      1. 4

                                                                                                                        Plus, for technical reasons, you can’t have multiple versions of ring linked into a single crate like you can with most crates – there’s some asm embedded in there, and the symbols in the asm code don’t get mangled by rustc and so can clash.

                                                                                                                        This is also a problem for portability, because Ring is extremely anal about correctness (for good reason, it’s a crypto library), so they’re hesitant about merging support for other platforms. Combined with no Rust-only fallback, and you have a disaster for any platform that doesn’t have an assembly implementation in Ring.

                                                                                                                        1. 2

                                                                                                                          Maybe the Ring authors could manually implement symbol mangling on their asm symbols with a build script.

                                                                                                                          1. 2

                                                                                                                            From the Ring authors:

                                                                                                                            Further, for some obscure technical reasons it’s currently not possible to link two different versions of ring into the same program; for policy reasons we don’t bother to try to work around that.

                                                                                                                        1. 1

                                                                                                                          1.14 — Rustup 1.0

                                                                                                                          I’ve never really liked it. The fact that the official website still tells me to use curl ... | sh to install yet another tool still makes rust seem unprofessional, at least in this regard. And of course I could install it from my package manager’s repositories, building relatively simple tools like a linter or a completion engine fail because they depend on some nightly features.

                                                                                                                          I guess it’s my problem that I expect these things, but either way those have been the things that have been keeping me away from the language.

                                                                                                                          1. 14

                                                                                                                            We’ve had many dicussions on the topic of whether you should let people pipe your malware(tm) directly into their shell or not. Every time with varying arguments of

                                                                                                                            • but I want signatures
                                                                                                                            • nobody checks signatures
                                                                                                                            • you have to trust those signatures at one point also
                                                                                                                            • which is like the first rustup installation, you don’t pipe into shell afterwards anyway
                                                                                                                            • but I want my malware(tm) downloaded to HDD before piping it into shellexecuting the installer blindly
                                                                                                                            • but I always inspect the malware(tm) I download, before executing it anyway
                                                                                                                            • you can always build rustc by yourself, enough about that in the readme
                                                                                                                            • but you can’t verify the correctness of every line in the compiler anway
                                                                                                                            • you can’t verify the integrity of the binary, as you can’t verify the code and thus not create a clean build to compare with anyway
                                                                                                                            • you can just use your package manager

                                                                                                                            Pick your poison..

                                                                                                                            1. 3

                                                                                                                              My issue isn’t even security, I just want to centrally manage all software on my system.

                                                                                                                              1. 7

                                                                                                                                Then… install rustup or rust through your package manager not from the official website? Just like every other piece of software you want managed centrally?

                                                                                                                                1. 0

                                                                                                                                  I use Debain, and as far as I see, no version packages rustup. And the versions of Rust that are packaged appear to lack something that nightly versions have. And that’s what annoys me, that if you want tooling you need to use nightly (whatever the technical or political reason for this may be). Imagine having to use the dev-build for Java to get autocompletion or track the master branch for Go if you want static analysis.

                                                                                                                                  1. 1

                                                                                                                                    I dunno, I’ve never really used nightly but the tooling works just fine in my experience. What features do you want that are nightly-only? rust-analyzer builds just fine on stable.

                                                                                                                                    As an outside observer, I’m given to understand that Rust is a tricky thing to package for the Debian crew, since they want to be able to package Rust libraries but the Rust ABI is only stable within a particular compiler version. So, not packaging Rustup is kinda the best of bad options there: either you use Debian’s rustc (1.34 on current Stable which seems to be a sorta informal “if you want to use a stable version this is a good one”, 1.42 on Testing which is pretty close to the current most-recent) and can use the libs that Debian distributes, or you use rustup and it’s up to you to provide the libs you want that are built with the compiler you want.

                                                                                                                                    1. 1

                                                                                                                                      rust-analyzer needs the latest stable though, I think this might be where the confusion about nightly features comes from (ra uses “nightly” features from the perspective of 1.34). If folks want to build rust-analyzer from source with old compilers, they have to stick to old versions of rust-analyzer as well.

                                                                                                                                      1. 1

                                                                                                                                        Is there a way to tell cargo what version to use? If yes, that should be better documented.

                                                                                                                                        1. 1

                                                                                                                                          Yes, I think cargo install can accept tags/commits when building from a git repo. When building from source, it’s possible to check out the required commit.

                                                                                                                                      2. 1

                                                                                                                                        I tried to install racer a while ago, and it failed because of missing nightly features. Because of your comment, I tried again, but it still seems to fail, citing a lot of “unstable” or “experimental features. This all just aggregates to a very bad introductory experience.

                                                                                                                                        1. 4

                                                                                                                                          The README for racer tells you that it requires nightly Rust. Its dependencies tell the story: it depends on a bunch of rustc specific crates.

                                                                                                                                          racer bootstrapped the IDE experience for Rust using what I’m guessing was the quickest possible method: using the compiler directly. The future of IDE for Rust is being concentrated in rust-analyzer, which I guess does compile with Rust stable. But probably not the version of Rust in Debian, because Debian packages an older version of Rust, as I’m sure you’re aware. The simplest way to build an older version of rust-analyzer is to clone its repository and checkout an older version. But at that point, you’re now faced with the research task of figuring out which version is compatible with your Rust compiler, if such a version even exists.

                                                                                                                                          In general, if you’re writing Rust code, the Rust ecosystem generally assumes that you’re not only using rustup, but are using the latest version of the compiler. Archlinux, for example, has no problems packaging rustup. I don’t know why, off hand, Debian doesn’t. There isn’t a lot of flexibility built in for folks using a compiler older than, say, two releases. That work flow is not well supported, but is possible. It is certainly not a good way to introduce yourself to the language, and I don’t really see that changing any time soon. There has been talk about LTS releases, but it’s not particularly popular. There’s also been some effort toward making the minimum supported Rust version (“MSRV”) an officially supported concept by Cargo, which I think would, at minimum, give you better error messages.

                                                                                                                                          It’s a sad hill to die on in my opinion, but I guess you have your requirements. Personally, if I were stuck using Debian, I’d be thankful for the easy curl ... | sh command I could run to liberate myself and use the latest version of the Rust compiler. Not even necessarily because I have to, if only to get the latest compilation time improvements, which are happening pretty frequently.

                                                                                                                                          1. 1

                                                                                                                                            There’s also been some effort toward making the minimum supported Rust version (“MSRV”) an officially supported concept by Cargo, which I think would, at minimum, give you better error messages.

                                                                                                                                            That sounds great, thanks for the insight!

                                                                                                                                            It’s a sad hill to die on in my opinion …

                                                                                                                                            I don’t have to use Rust, I just want to explore and play with it. That’s why I’d want things like completion and static analysis (preferably without LSP, but that’s getting harder and harder). If I had to use it, then all these things wouldn’t be requirements or I would use rustup.

                                                                                                                                            1. 2

                                                                                                                                              Gotya. Yeah, LSP appears to be the future. In a couple years time, I’d be surprised if there were any actively maintained non-LSP solution for Rust.

                                                                                                                                              I’ve made my peace with LSP. I used to use ctags for goto-definition, but it was just plain wrong a noticeable number of times. The only way to fix that AFAIK, for Rust at least, is to use one of the smarter tools which are all LSP based.

                                                                                                                                              LSP stuff outside of VS Code still appears to be early days. The user experience has overall just not been great from my perspective, and that’s coming from someone using vim (well, now neovim) which actually enjoys a wide variety of LSP client implementations to choose from. I shutter to think what it’s like for folks using less supported editors. Hopefully it will get better though.

                                                                                                                                        2. 1

                                                                                                                                          For example, just yesterday

                                                                                                                                          • I used miri (which requires nightly) to help decide if I had any faith in some unsafe code being correct.
                                                                                                                                          • I used -Z macro-backtrace to help debug some macros I was using (only available on nightly as a unstable compiler flag). Using the flag was suggested by the compiler.
                                                                                                                                        3. 1

                                                                                                                                          I’m not 100% clear on what the debian packing story is in general these days, but google suggests this?

                                                                                                                                      3. 1

                                                                                                                                        If you need nightly and your distribution doesn’t package it, it sounds like that the instructions telling you to use your distribution’s package manager wouldn’t help anyway. Certainly you could package rust-nightly yourself. Or, install rustup and manage toolchains that way.

                                                                                                                                        1. 1

                                                                                                                                          If your distro doesn’t package rustup (which is reasonably common to package) or nightly (which would be really weird to directly package), then ya, you’re out of luck and need to install it by hand. So… use a distro that packages a wide variety of things if you care about a wide availability of packages.

                                                                                                                                          Here is a arch package in the official repos, here is a void linux package in the official repos. I’m not 100% clear on how it fits in the packaging story, but ubuntu seems to be moving towards “snaps” and here is a rustup snap for ubuntu and a rustup snap for debian.

                                                                                                                                    2. 11

                                                                                                                                      At least it’s not asking you to pipe it as root, and I really appreciate the one solution for most *nix-y systems, at least after dealing with Python’s installation and package ecosystems. I’m pretty confident I won’t break my rust install and be stuck wondering which environmental variable should point where.

                                                                                                                                    1. 4

                                                                                                                                      Cool! On the other hand, this is a lot longer of a command than grep foo

                                                                                                                                      docker run --rm -v "${PWD}:/home/repo" returntocorp/semgrep --lang python --pattern '$X == $X' test.py
                                                                                                                                      
                                                                                                                                      1. 1

                                                                                                                                        For programs that run in Docker, it’s handy to wrap the boilerplate in a shell function. For example, you might stick something like this in your Bash or ZSH startup script.

                                                                                                                                        semgrep() {
                                                                                                                                          docker run --rm -v "${PWD}:/home/repo" returntocorp/semgrep "$@"
                                                                                                                                        }
                                                                                                                                        

                                                                                                                                        Then running your example looks a little better:

                                                                                                                                        semgrep --lang python --pattern '$X == $X' test.py
                                                                                                                                        
                                                                                                                                        1. 1

                                                                                                                                          Wouldn’t an alias be more appropriate? But yes, a function works fine.

                                                                                                                                          1. 1

                                                                                                                                            I think the alias wouldn’t be able to interpolate the working directory into the volume mount with -v "${PWD}:/home/repo".

                                                                                                                                            1. 1

                                                                                                                                              It can; why wouldn’t it?

                                                                                                                                      1. 25

                                                                                                                                        Suggest -a11y

                                                                                                                                        I also use set -e quite a lot. There is a very large and useful BashFAQ describing ways that set -e doesn’t do what authors might expect: https://mywiki.wooledge.org/BashFAQ/105

                                                                                                                                        1. 9

                                                                                                                                          Suggest -a11y

                                                                                                                                          If you mean anything other than “accessibility”, could you please define what you’re talking about, or provide a link to a write-up of it? The abbreviation “a11y” is so universally used for “accessibility” (in the same way “i18n” is “internationalization”) that it’s effectively impossible to perform a search for other potential meanings.

                                                                                                                                          1. 4

                                                                                                                                            The article was originally tagged a11y, and:

                                                                                                                                            Suggest -a11y

                                                                                                                                            is as far as I know common syntax to instruct other lobsters to make a suggestion to remove the a11y tag.

                                                                                                                                            You can see the moderation log here: https://lobste.rs/moderations?utf8=%E2%9C%93&moderator=%28Users%29&what%5Bstories%5D=stories

                                                                                                                                            Edit: Seeing as the automatic moderation event took place 5 minutes after my comment, it appears that my understanding of it being common syntax is true.

                                                                                                                                            1. 26

                                                                                                                                              Here I was thinking -a11y was a Bash option.

                                                                                                                                              1. 3

                                                                                                                                                Same here :)

                                                                                                                                              2. 3

                                                                                                                                                OK. I didn’t realize this was trying to suggest something about the metadata of the post; the context of the rest of the comment made it seem as if you were suggesting some strange set of bash flags that I’d never heard of.

                                                                                                                                                1. 1

                                                                                                                                                  My bad. I don’t know how I ended up adding -a11y

                                                                                                                                                2. 3

                                                                                                                                                  This is exactly why I think these type of abbreviations are i5c [1]. It’s just a way to obfuscate words and confuse people. (Sorry for the overly salty reaction, but it’s a pet peeve.)

                                                                                                                                                  [1] idiotic

                                                                                                                                                  1. 0

                                                                                                                                                    Same here, I would love to learn about this as well.

                                                                                                                                                  2. 5

                                                                                                                                                    Thanks for that link, I never suspected there were so many undefined corner cases with set -e

                                                                                                                                                    1. 4

                                                                                                                                                      Yes, great link. I think especially example 5 demonstrates that set -e might be more trouble than it’s worth.

                                                                                                                                                      1. 4

                                                                                                                                                        I wonder how many security issues are lurking underneath these inconsistent and weird semantics. This is the kind of muddled thinking that used to cause (and probably still causes) problems in PHP scripts.

                                                                                                                                                    2. 2

                                                                                                                                                      I also use set -e quite a lot. There is a very large and useful BashFAQ describing ways that set -e doesn’t do what authors might expect: https://mywiki.wooledge.org/BashFAQ/105

                                                                                                                                                      Thanks. This is great learning for me. Fortunately, I switch to Python before such complications usually arise but you are right, one should not blindly add “set -e” to an existing BASH script they didn’t write.

                                                                                                                                                    1. 6

                                                                                                                                                      Big fan of the relaxed orphan rule. That has gotten in my way many times. I’m now going to excise some newtypes from our codebase. And, if I’m not mistaken, the C ABI change will allow a lot of unsafe transmutes in FFI to be avoided, right?

                                                                                                                                                      Congrats and thanks to everyone involved!

                                                                                                                                                      1. 5

                                                                                                                                                        Agreed, the strict orphan rules were something I also encounter frequently, this makes it possible to do the ‘correct’ thing, avoiding newtype wrappers.

                                                                                                                                                        I also like that they redesigned the lock file format to avoid conflicts. A practical change that really makes everyone’s love’s easy.

                                                                                                                                                        Rust now really seems to be in a phase of very gradual refinements to reduce/remove papercuts. I love it!

                                                                                                                                                        1. 1

                                                                                                                                                          https://twitter.com/TJCarpenterShow/status/1222526307247878144?s=19

                                                                                                                                                          They just released async await, a huge new language feature!

                                                                                                                                                        2. 1

                                                                                                                                                          It was and remains incorrect to transmute between Box<T> and *mut T. This just avoids having to use Box::from_raw() and Box::into_raw() at the FFI boundary.

                                                                                                                                                          1. 1

                                                                                                                                                            On the FFI front, yeah it looks like we doing need to do the basic dance of immediately wrapping C pointers. It looks like the guidance here is to only do it on Rust functions exposed to C and not the other way around.

                                                                                                                                                            I’m sure there are a whole bunch of caveats, but I’m thinking if the memory is owned by rust and passed to C and then passed back into Rust, we don’t have any concerns around alignment and other initialization issues. If the memory is allocated by C, don’t use this technique.

                                                                                                                                                          1. 32

                                                                                                                                                            To me the big deal is that Rust can credibly replace C, and offers enough benefits to make it worthwhile.

                                                                                                                                                            There are many natively-compiled languages with garbage collection. They’re safer than C and easier to use than Rust, but by adding GC they’ve exited the C niche. 99% of programs may work just fine with a GC, but for the rest the only practical options were C and C++ until Rust showed up.

                                                                                                                                                            There were a few esoteric systems languages or C extensions that fixed some warts of C, but leaving the C ecosystem has real costs, and I could never justify use of a “weird” language just for a small improvement. Rust offered major safety, usability and productivity improvements, and managed to break out of obscurity.

                                                                                                                                                            1. 38

                                                                                                                                                              Ada provided everything except ADTs and linear types, including seamless interoperability with C, 20 years before Rust. Cyclone was Rust before Rust, and it was abandoned in a similar state as Rust was when it took off. Cyclone is dead, but Ada got a built-in formal verification toolkit in its latest revision—for some that stuff alone can be a reason to pick instead of anything else for a new project.

                                                                                                                                                              I have nothing against Rust, but the reason it’s popular is that it came at a right time, in the right place, from a sufficiently big name organization. It’s one of the many languages based on those ideas that, fortunately, happened to succeed. And no, when it first got popular it wasn’t really practical. None of these points makes Rust bad. One just should always see a bigger picture especially when it comes to heavily hyped things. You need to know the other options to decide for yourself.

                                                                                                                                                              Other statically-typed languages allow whole-program type inference. While convenient during initial development, this reduces the ability of the compiler to provide useful error information when types no longer match.

                                                                                                                                                              Only in languages that cannot umabiguously infer the principal type. Whether to make a tradeoff between that and support for ad hoc polymorphism or not is subjective.

                                                                                                                                                              1. 15

                                                                                                                                                                I’ve seen Cyclone when it came out, but at that time I dismissed it as “it’s C, but weird”. It had the same basic syntax as C, but added lots of pointer sigils. It still had the same C preprocessor and the same stdlib.

                                                                                                                                                                Now I see it has a feature set much closer to Rust’s (tagged unions, patterns, generics), but Rust “sold” them better. Rust used these features for Result which is a simple yet powerful construct. Cyclone could do that, but didn’t. It kept nullable pointers and added Null_Exception.

                                                                                                                                                                1. 12

                                                                                                                                                                  Ada provided everything except ADTs and linear types

                                                                                                                                                                  Unfortunately for this argument, ADTs, substructural types and lifetimes are more exciting than that “everything except”. Finally the stuff that is supposed to be easy in theory is actually easy in practice, like not using resources you have already cleaned up.

                                                                                                                                                                  Ada got a built-in formal verification toolkit in its latest revision

                                                                                                                                                                  How much of a usability improvement is using these tools compared to verifying things manually? What makes types attractive to many programmers is not that they are logically very powerful (they are usually not!), but rather that they give a super gigantic bang for the buck in terms of reduction of verification effort.

                                                                                                                                                                  1. 17

                                                                                                                                                                    I would personally not compare Ada and Rust directly as they don’t even remotely fulfill the same use-cases.

                                                                                                                                                                    Sure, there have been languages that have done X, Y, Z before Rust (the project itself does not lay false claim to inventing those parts of the language which may have been found elsewhere in the past), but the actual distinguishing factor for Rust that places it into an entirely different category from Ada is how accessible and enjoyable it is to interact with while providing those features.

                                                                                                                                                                    If you’re in health or aeronautics, you should probably be reaching for the serious, deep toolkit provided by Ada, and I’d probably be siding with you in saying those people probably should have been doing that for the last decade. But Ada is really not for the average engineer. It’s an amazing albeit complex language, that not only represents a long history of incredible engineering but a very real barrier of entry that’s simply incomparable to that of Rust’s.

                                                                                                                                                                    If, for example, I wanted today to start writing from scratch a consumer operating system, a web browser, or a video game as a business venture, I would guarantee you Ada would not even be mentioned as an option to solve any of those problems, unless I wanted to sink my own ship by limiting myself to pick from ex-government contractors as engineers, whose salaries I’d likely be incapable of matching. Rust on the other hand actually provides a real contender to C/C++/D for people in these problem spaces, who don’t always need (or in some cases, even want) formal verification, but just a nice practical language with a systematic safety net from the memory footguns of C/C++/D. On top of that, it opens up these features, projects, and their problem spaces to many new engineers with a clear, enjoyable language free of confusing historical baggage.

                                                                                                                                                                    1. 6

                                                                                                                                                                      Have you ever used Ada? Which implementation?

                                                                                                                                                                      1. 15

                                                                                                                                                                        I’ve never published production Ada of any sort and am definitely not an Ada regular (let alone pro) but I studied and had a fondness for Spark around the time I was reading “Type-Driven Development with Idris” and started getting interested in software proofs.

                                                                                                                                                                        In my honest opinion the way the base Ada language is written (simple, and plain operator heavy) ends up lending really well to extension languages, but it also can make difficult for beginners to distinguish the class of concept used at times, whereas Rust’s syntax has a clear and immediate distinction between blocks (the land of namespaces), types (the land of names), and values (the land of data). In terms of cognitive load then, it feels as though these two languages are communicating at different levels. Like Rust is communicating in the mode of raw values and their manipulation through borrows, while the lineage of Ada languages communicate at a level that, in my amateur Ada-er view, center on the expression of properties of your program (and I don’t just mean the Spark stuff, obviously). I wasn’t even born when Ada was created, and so I can’t say for sure without becoming an Ada historian (not a bad idea…), but this sort of seems like a product of Ada’s heritage (just as Rust’s so obviously written to look like C++).

                                                                                                                                                                        To try and clarify this ramble of mine, in my schooling experience, many similarly young programmers of my age are almost exclusively taught to program at an elementary level of abstract instructions with the details of those instructions removed, and then after being taught a couple type-level incantations get a series of algorithms and their explanations thrown at their face. Learning to consider their programs specifically in terms of expressing properties of that program’s operations becomes a huge step out of that starting box (that some don’t leave long after graduation). I think something that Rust’s syntax does well (if possibly by mistake) is fool the amateur user into expressing properties of their programs on accident while that expression becomes part of what seems like just a routine to get to the meat of a program’s procedures. It feels to me that expressing those properties are intrinsic to the language of speaking Ada, and thus present a barrier intrinsic to the programmer’s understanding of their work, which given a different popular curriculum could probably just be rendered as weak as paper to break through.

                                                                                                                                                                        Excuse me if these thoughts are messy (and edited many times to improve that), but beyond the more popular issue of familiarity, they’re sort of how I view my own honest experience of feeling more quickly “at home” in moving from writing Rust to understanding Rust, compared to moving from just writing some form of Ada, and understanding the program I get.

                                                                                                                                                                    2. 5

                                                                                                                                                                      Other statically-typed languages allow whole-program type inference. While convenient during initial development, this reduces the ability of the compiler to provide useful error information when types no longer match.

                                                                                                                                                                      Only in languages that cannot unabiguously infer the principal type. Whether to make a tradeoff between that and support for ad hoc polymorphism or not is subjective.

                                                                                                                                                                      OCaml can unambiguously infer the principal type, and I still find myself writing the type of top level functions explicitly quite often. More than once have I been guided by a type error that only happened because I wrote the type of the function I was writing in advance.

                                                                                                                                                                      At the very least, I check that the type of my functions match my expectations, by running the type inference in the REPL. More than once have I been surprised. More than once that surprise was caused by a bug in my code. Had I not checked the type of my function, I would catch the bug only later, when using the function, and the error message would have made less sense to me.

                                                                                                                                                                      1. 2

                                                                                                                                                                        At the very least, I check that the type of my functions match my expectations, by running the type inference in the REPL

                                                                                                                                                                        Why not use Merlin instead? Saves quite a bit of time.

                                                                                                                                                                        That’s a tooling issue too of course. Tracking down typing surprises in OCaml is easy because the compiler outputs type annotations in a machine-readable format and there’s a tool and editor integrations that allow me to see the type of every expression in a keystroke.

                                                                                                                                                                        1. 2

                                                                                                                                                                          Why not use Merlin instead? Saves quite a bit of time.

                                                                                                                                                                          I’m a dinosaur, that didn’t take the time to learn even the existence of Merlin. I’m kinda stucks in Emacs’ Tuareg mode. Works for me for small projects (all my Ocaml projects are small).

                                                                                                                                                                          That said, my recent experience with C++ and QtCreator showed me that having warnings at edit time is even more powerful than a REPL (at least as long as I don’t have to check actual values). That makes Merlin look very attractive all of a sudden. I’ll take a look, thanks.

                                                                                                                                                                    3. 5

                                                                                                                                                                      Rust can definitely credibly replace C++. I don’t really see how it can credibly replace C. It’s just such a fundamentally different way of approaching programming that it doesn’t appeal to C programmers. Why would a C programmer switch to Rust if they hadn’t already switched to C++?

                                                                                                                                                                      1. 43

                                                                                                                                                                        I’ve been a C programmer for over a decade. I’ve tried switching to C++ a couple of times, and couldn’t stand it. I’ve switched to Rust and love it.

                                                                                                                                                                        My reasons are:

                                                                                                                                                                        • Robust, automatic memory management. I have the same amount of control over memory, but I don’t need goto cleanup.
                                                                                                                                                                        • Fearless multi-core support: if it compiles, it’s thread-safe! rayon is much nicer than OpenMP.
                                                                                                                                                                        • Slices are awesome: no array to pointer decay. Work great with substrings.
                                                                                                                                                                        • Safety is not just about CVEs. I don’t need to investigate memory murder mysteries in GDB or Valgrind.
                                                                                                                                                                        • Dependencies aren’t painful.
                                                                                                                                                                        • Everything builds without fuss, even when supporting Windows and cross-compiling to iOS.
                                                                                                                                                                        • I can add two signed numbers without UB, and checking if they overflow isn’t a party trick.
                                                                                                                                                                        • I get some good parts of C++ such as type-optimized sort and hash maps, but without the baggage C++ is infamous for.
                                                                                                                                                                        • Rust is much easier than C++. Iterators are so much cleaner (just a next() method). I/O is a Read/Write trait, not a hierarchy of iostream classes.
                                                                                                                                                                        1. 6

                                                                                                                                                                          I also like Rust and I agree with most of your points, but this one bit seems not entirely accurate:

                                                                                                                                                                          Fearless multi-core support: if it compiles, it’s thread-safe! rayon is much nicer than OpenMP.

                                                                                                                                                                          AFAIK Rust:

                                                                                                                                                                          • doesn’t guarantee thread-safety — it guarantees the lack of data races, but doesn’t guarantee the lack of e.g. deadlocks;
                                                                                                                                                                          • guarantees the lack of data races, but only if you didn’t write any unsafe code.
                                                                                                                                                                          1. 20

                                                                                                                                                                            That is correct, but this is still an incredible improvement. If I get a deadlock I’ll definitely notice it, and can dissect it in a debugger. That’s easy-peasy compared to data races.

                                                                                                                                                                            Even unsafe code is subject to thread-safety checks, because “breaking” of Send/Sync guarantees needs separate opt-in. In practice I can reuse well-tested concurrency primitives (e.g. WebKit’s parking_lot) so I don’t need to write that unsafe code myself.

                                                                                                                                                                            Here’s an anecdote: I wrote some single threaded batch-processing spaghetti code. Since it each item was processed separately, I decided to parallelize it. I’ve changed iter() for par_iter() and the compiler immediately warned me that in one of my functions I’ve used a 3rd party library which used an HTTP client library which used an event loop library which stored some event loop data in a struct without synchronization. It pointed exactly where and why the code was unsafe, and after fixing it I had an assurance the fix worked.

                                                                                                                                                                            1. 6

                                                                                                                                                                              I share your enthusiasm. Just wanted to prevent a common misconception from spreading.

                                                                                                                                                                              Here’s an anecdote: I wrote some single threaded batch-processing spaghetti code. Since it each item was processed separately, I decided to parallelize it. I’ve changed iter() for par_iter() and the compiler immediately warned me that in one of my functions I’ve used a 3rd party library which used an HTTP client library which used an event loop library which stored some event loop data in a struct without synchronization. It pointed exactly where and why the code was unsafe, and after fixing it I had an assurance the fix worked.

                                                                                                                                                                              I did not know it could do that. That’s fantastic.

                                                                                                                                                                            2. 9

                                                                                                                                                                              Data races in multi-threaded code are about 100x harder to debug than deadlocks in my experience, so I am happy to have an imperfect guarantee.

                                                                                                                                                                              guarantees the lack of data races, but only if you didn’t write any unsafe code.

                                                                                                                                                                              Rust application code generally avoids unsafe.

                                                                                                                                                                              1. 4

                                                                                                                                                                                Data races in multi-threaded code are about 100x harder to debug than deadlocks in my experience, so I am happy to have an imperfect guarantee.

                                                                                                                                                                                My comment was not a criticism of Rust. Just wanted to prevent a common misconception from spreading.

                                                                                                                                                                                Rust application code generally avoids unsafe.

                                                                                                                                                                                That depends on who wrote the code. And unsafe blocks can cause problems that show in places far from the unsafe code. Meanwhile, “written in Rust” is treated as a badge of quality.

                                                                                                                                                                                Mind that I am a Rust enthusiast as well. I just think we shouldn’t oversell it.

                                                                                                                                                                              2. 7

                                                                                                                                                                                guarantees the lack of data races, but only if you didn’t write any unsafe code.

                                                                                                                                                                                As long as your unsafe code is sound it still provides the guarantee. That’s the whole point, to limit the amount of code that needs to be carefully audited for correctness.

                                                                                                                                                                                1. 2

                                                                                                                                                                                  I know what the point is. But proving things about code is generally not something that programmers are used to or good at. I’m not saying that the language is bad, only that we should understand its limitations.

                                                                                                                                                                                2. 1

                                                                                                                                                                                  I find it funny that any critique of Rust needs to be prefixed with a disclaimer like “I also like Rust”, to fend off the Rust mob.

                                                                                                                                                                              3. 11

                                                                                                                                                                                This doesn’t really match what we see and our experience: a lot of organisations are investigating their replacement of C and Rust is on the table.

                                                                                                                                                                                One advantage that Rust has is that it actually lands between C and C++. It’s pretty easy to move towards a more C-like programming style without having to ignore half of the language (this comes from the lack of classes, etc.).

                                                                                                                                                                                Rust is much more “C with Generics” than C++ is.

                                                                                                                                                                                We currently see a high interest in the embedded world, even in places that skipped adopting C++.

                                                                                                                                                                                I don’t think the fundamental difference in approach is as large as you make it (sorry for the weak rebuttal, but that’s hard to quantify). But also: approaches are changing, so that’s less of a problem for us, as long as we are effective at arguing for our approach.

                                                                                                                                                                                1. 2

                                                                                                                                                                                  It’s just such a fundamentally different way of approaching programming that it doesn’t appeal to C programmers. Why would a C programmer switch to Rust if they hadn’t already switched to C++?

                                                                                                                                                                                  Human minds are sometimes less flexible than rocks.

                                                                                                                                                                                  That’s why we still have that stupid Qwerty layout: popular once for mechanical (and historical) reasons, used forever since. As soon as the mechanical problems were fixed, Sholes imself devised a better layout, which went unused. Much later, Dvorak devised another better layout, and it is barely used today. People thinking in Qwerty simply can’t bring themselves to take the time to learn the superior layout. (I know: I’m in a similar situation, though my current layout is not Qwerty).

                                                                                                                                                                                  I mean, you make a good point here. And that’s precisely what’s make me sad. I just hope this lack of flexibility won’t prevent C programmers from learning superior tools.

                                                                                                                                                                                  (By the way, I would chose C over C++ in many cases, I think C++ is crazy. But I also know ML (OCaml), a bit of Haskell, a bit of Lua… and that gives me perspective. Rust as I see it is a blend of C and ML, and though I have yet to write Rust code, the code I have read so far was very easy to understand. I believe I can pick up the language pretty much instantly. In my opinion, C programmers that only know C, awk and Bash are unreasonably specialised.)

                                                                                                                                                                                  1. 1

                                                                                                                                                                                    I tried to switch to DVORAK twice. Both times I started to get pretty quick after a couple of days but I cheated: if I needed to type something I’d switch back to QWERTY, so it never stuck.

                                                                                                                                                                                    The same is true of Rust, incidentally. Tried it out a few times, was fun, but then if I want to get anything useful done quickly it’s just been too much of a hassle for me personally. YMMV of course. I fully intend to try to build something that’s kind of ‘C with lifetimes’, a much simpler Rust (which I think of as ‘C++ with lifetimes’ analogously), in the future. Just have to, y’know, design it. :D

                                                                                                                                                                                    1. 3

                                                                                                                                                                                      I too was tempted at some point to design a “better C”. I need:

                                                                                                                                                                                      • Generics
                                                                                                                                                                                      • Algebraic data types
                                                                                                                                                                                      • Type classes
                                                                                                                                                                                      • coroutines, (for I/O and network code, I need a way out of raw poll(2))
                                                                                                                                                                                      • Memory safety

                                                                                                                                                                                      With the possible exception of lifetimes, I’d end up designing Rust, mostly.

                                                                                                                                                                                      1. 2

                                                                                                                                                                                        I agree that you need some way of handling async code, but I don’t think coroutines are it, at least not in the async/await form. I still feel like the ‘what colour is your function?’ stuff hasn’t been solved properly. Any function with a callback (sort with a key/cmp function, filter, map, etc.) needs an async_ version that takes a callback and calls it with await. Writing twice as much code that’s trivially different by adding await in some places sucks, but I do not have any clue what the solution is. Maybe it’s syntactic. Maybe everything should be async implicitly and you let the compiler figure out when it can optimise things down to ‘raw’ calls.

                                                                                                                                                                                        shrug

                                                                                                                                                                                        Worth thinking about at least.

                                                                                                                                                                                        1. 4

                                                                                                                                                                                          Function colors are effects. There are two ways to solve this problem:

                                                                                                                                                                                          1. To use polymorphism over effects. This is what Haskell does, but IMO it is too complex.
                                                                                                                                                                                          2. To split large async functions into smaller non-async ones, and dispatch them using an event loop.

                                                                                                                                                                                          The second approach got a bad reputation due to its association with “callback hell”, but IMO this reputation is undeserved. You do not need to represent the continuation as a callback. Instead, you can

                                                                                                                                                                                          1. Define a gigantic sum type of all possible intermediate states of asynchronous processes.
                                                                                                                                                                                          2. Implement each non-async step as an ordinary small function that maps intermediate states (not necessarily just one) to intermediate states (not necessarily just one).
                                                                                                                                                                                          3. Implement the event loop as a function that, iteratively,
                                                                                                                                                                                            • Takes states from an event queue.
                                                                                                                                                                                            • Dispatches an appropriate non-async step.
                                                                                                                                                                                            • Pushes the results, which are again states, back into the event queue.

                                                                                                                                                                                          Forking can be implemented by returning multiple states from a single non-async step. Joining can be implemented by taking multiple states as inputs in a single non-async step. You are not restricted to joining processes that were forked from a common parent.

                                                                                                                                                                                          In this approach, you must write the event loop yourself, rather than delegate it to a framework. For starters, no framework can anticipate your data type of intermediate states, let alone the data type of the whole event queue. But, most importantly, the logic for dispatching the next non-async step is very specific to your application.

                                                                                                                                                                                          Benefits:

                                                                                                                                                                                          1. Because the data type of intermediate states is fixed, and the event loop is implemented in a single centralized place, it is easier to verify that your code works “in all cases”, either manually or using tools that explicitly model concurrent processes using state machines (e.g., TLA+).

                                                                                                                                                                                          2. Because intermediate states are first-order values, rather than first-class functions, the program is much easier to debug. Just stop the event loop at an early time and pretty-print the event queue. (ML can automatically pretty-print first-order values in full detail. Haskell requires you to define a Show instance first, but this definition can be generated automatically.)

                                                                                                                                                                                          Drawbacks:

                                                                                                                                                                                          1. If your implementation language does not provide sum types and/or pattern matching, you will have a hard time checking that every case has been covered, simply because there are so many cases.

                                                                                                                                                                                          2. The resulting code is very much non-extensible. To add new asynchronous processes, you need to add constructors to the sum type of intermediate states. This will make the event loop fail to type check until you modify it accordingly. (IMO, this is not completely a drawback, because it forces you to think about how the new asynchronous processes interact with the old ones. This is something that you eventually have to do anyway, but some people might prefer to postpone it.)

                                                                                                                                                                                          1. 3

                                                                                                                                                                                            I agree that you need some way of handling async code, but I don’t think coroutines are it

                                                                                                                                                                                            Possibly. I actually don’t know. I’d take whatever let me write code that looks like I’m dispatching an unlimited number of threads, but dispatches the computation over a reasonable number of threads, possibly just one. Hell, my ideal world is green threads, actually. Perhaps I should have lead with that…

                                                                                                                                                                                            Then again, I don’t know the details of the tradeoffs involved. Whatever let me solve the 1M connections cleanly and efficiently works for me.

                                                                                                                                                                                  2. 5

                                                                                                                                                                                    I agree with @milesrout. I don’t think Rust is a good replacement for C. This article goes into some of the details of why - https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html

                                                                                                                                                                                    1. 17

                                                                                                                                                                                      Drew has some very good points. Its a shame he ruins them with all the other ones.

                                                                                                                                                                                      1. 25

                                                                                                                                                                                        Drew has a rusty axe to grind: “Concurrency is generally a bad thing” (come on!), “Yes, Rust is more safe. I don’t really care.”

                                                                                                                                                                                        Here’s a rebuttal of that awful article: https://telegra.ph/Replacing-of-C-with-Rust-has-been-a-great-success-03-27 (edit: it’s a tongue-in-cheek response. Please don’t take it too seriously: the original exaggerated negatives, so the response exaggerates positives).

                                                                                                                                                                                        1. 11

                                                                                                                                                                                          So many bad points from this post.

                                                                                                                                                                                          • We can safely ignore the “features per year”, since the documentation they are based on don’t follow the same conventions. I’ll also note that, while a Rust program written last year may look outdated (I personally don’t know Rust enough to make such an assessment), it will still work (I’ve been told breaking changes are extremely rare).

                                                                                                                                                                                          • C is not really the most portable language. Yes, C and C++ compilers, thanks to having decades of work behind them, target more devices than everything else put together. But no, those platforms do not share the same flavour of C and C++. There are simply too many implementation defined behaviours, starting with integer sizes. Did you know that some platforms had 32-bit chars? I worked with someone who worked on one.

                                                                                                                                                                                            I wrote a C crypto library, and went out of my way to ensure the code was very portable. and it is. Embedded developers love it. There was no way however to ensure my code was fully portable. I right-shift negative integers (implementation defined behaviour), and I use fixed width integers like uint8_t (not supported on the DSP I mentioned above).

                                                                                                                                                                                          • C does have a spec, but it’s an incomplete one. In addition to implementation defined behaviour, C and C++ also have a staggering amount of undefined and unspecified behaviour. Rust has no spec, but it still tries to minimise undefined behaviour. I expect this point will go away when Rust stabilises and we get an actual spec. I’m sure formal verification folks will want to have a verified compiler for Rust, like we currently have for C.

                                                                                                                                                                                          • *C have many implementations… and that’s actually a good point.

                                                                                                                                                                                          • C has a consistent & stable ABI… and so does Rust, somewhat? OK, it’s opt-in, and it’s contrived. My point is, Rust does have an FFI which allows it to talk to the outside world. It doesn’t have to be at the top level of a program. On the other hand, I’m not sure what would be the point of a stable ABI between Rust modules. C++ at least seems to be doing fine without that.

                                                                                                                                                                                          • Rust compiler flags aren’t sable… and that’s a good point. They should probably stabilise at some point. On the other hand, having one true way to manage builds and dependencies is a god send. Whatever we’d use stable compile flags for, we probably don’t want to depart from that.

                                                                                                                                                                                          • Parallelism and Concurrency are unavoidable. They’re not a bad thing, they’re the only thing that can help us cheat the speed of light, and with it single threaded performance. The ideal modern computer is more likely a high number of in-order cores, each with a small amount of memory, and an explicit (exposed to the programmer) cache hierarchy. Assuming performance and energy consumption trumps existing C (and C++) programs. Never forget that current computers are optimised to run C and C++ programs.

                                                                                                                                                                                          • Not caring about safety is stupid. Or selfish. Security vulnerabilities are often mere externalities, which you can ignore if it doesn’t damage your reputation to the point of affecting your bottom line. Yay Capitalism. More seriously, safety is a subset of correctness, and correctness is the main point of Rust’s strong type system and borrow checker. C doesn’t just make it difficult to write safe programs, it makes it difficult to write correct programs. You wouldn’t believe how hard that is. My crypto library had to resort to Valgrind, sanitisers, and the freaking TIS interpreter to eke out undefined behaviour. And I’m talking about “constant time” code, that has fixed memory access patterns. It’s pathologically easy to test, yet writing tests took as long as writing the code, possibly longer. Part of the difficulty comes from C, not just the problem domain.

                                                                                                                                                                                          Also, Drew DeVault mentions Go as a possible replacement for C? For some domains, sure. But the thing has a garbage collector, making it instantly unsuitable for some constrained environments (either because the machine is small, or because you need crazy performance). Such constrained environment are basically the remaining niche for C (and C++). For the rest, the only thing that keeps people hooked on C (and C++) are existing code and existing skills.

                                                                                                                                                                                          1. 4

                                                                                                                                                                                            Rust compiler flags aren’t sable… and that’s a good point. They should probably stabilise at some point. On the other hand, having one true way to manage builds and dependencies is a god send. Whatever we’d use stable compile flags for, we probably don’t want to depart from that.

                                                                                                                                                                                            This is wrong, though. rustc compiler flags are stable, except flags behind the -Z flag, which intentionally separates the interface between stable and unstable flags.

                                                                                                                                                                                            1. 2

                                                                                                                                                                                              Okay, I stand corrected, thanks.

                                                                                                                                                                                            2. 0

                                                                                                                                                                                              But the thing has a garbage collector, making it instantly unsuitable for some constrained environments (either because the machine is small, or because you need crazy performance).

                                                                                                                                                                                              The Go garbage collector can be turned off with debug.SetGCPercent(-1) and triggered manually with runtime.GC(). It is also possible to allocate memory at the start of the program and use that.

                                                                                                                                                                                              Go has several compilers available. gc is the official Go compiler, GCC has built-in support for Go and there is also TinyGo, which targets microcontrollers and WASM: https://tinygo.org/

                                                                                                                                                                                              1. 5

                                                                                                                                                                                                Can you realistically control allocations? If we have ways to make sure all allocations are either explicit or on the stack, that could work. I wonder how contrived that would be, though. The GC is on by default, that’s got to affect idiomatic code in a major way. To the point where disabling it probably means you don’t have the same language any more.

                                                                                                                                                                                                Personally, to replace C, I’d rather have a language that disables GC by default. If I am allowed to have a GC, I strongly suspect there are better alternatives than Go. (My most major objection being “lol no generics”. And if the designers made that error, that kind of cast doubt over their ability to properly design the rest of the language, and I lose all interest instantly. Though if I were writing network code, I would also say “lol no coroutines” at anything designed after 2015 or so.)

                                                                                                                                                                                                1. 1

                                                                                                                                                                                                  I feel like GC by default vs no GC is one of the biggest decision points when designing a language. It affects so much of how the rest of a language has to be designed. GC makes writing code soooo much easier, but you can’t easily put non-GC’d things into a GC’d language. Or maybe you can? Rust was originally going to have syntax for GC’d pointers. People are building GC’d pointers into Rust now, as libraries - GC manages a particular region of memory. People are designing the same stuff for C++. So maybe we will finally be able to mix them in a few years.

                                                                                                                                                                                                  1. 1

                                                                                                                                                                                                    Go is unrealistic not only because of GC, but also segmented stacks, thick runtime that wants to talk to the kernel directly, implicit allocations, and dynamism of interface{}. They’re all fine if you’re replacing Java, but not C.

                                                                                                                                                                                                    D lang’s -betterC is much closer, but D’s experience shows that once you have a GC, it influences the standard library, programming patterns, 3rd party dependencies, and it’s really hard to avoid it later.

                                                                                                                                                                                                    1. 1

                                                                                                                                                                                                      Can you realistically control allocations? If we have ways to make sure all allocations are either explicit or on the stack, that could work.

                                                                                                                                                                                                      IIRC you can programmatically identify all heap allocations in a given go compilation, so you can wrap the build in a shim that checks for them and fails.

                                                                                                                                                                                                      The GC is on by default, that’s got to affect idiomatic code in a major way.

                                                                                                                                                                                                      Somewhat, yes, but the stdlib is written by people who have always cared about wasted allocations and many of the idioms were copied from that, so not quite as much as you might imagine.

                                                                                                                                                                                                      That said - if I needed to care about allocations that much, I don’t think it’d be the best choice. The language was designed and optimized to let large groups (including many clever-but-inexperienced programmers) to write reliable network services.

                                                                                                                                                                                              2. 1

                                                                                                                                                                                                I don’t think replacing C is a good usecase for Rust though. C is relatively easy to learn, read, and write to the level where you can write something simple. In Rust this is decidedly not the case. Rust is much more like a safe C++ in this respect.

                                                                                                                                                                                                I’d really like to see a safe C some day.

                                                                                                                                                                                                1. 6

                                                                                                                                                                                                  Have a look at Cyclone mentioned earlier. It is very much a “safe C”. It has ownership and regions which look very much like Rust’s lifetimes. It has fat pointers like Rust slices. It has generics, because you can’t realistically build safe collections without them. It looks like this complexity is inherent to the problem of memory safety without a GC.

                                                                                                                                                                                                  As for learning C, it’s easy to get a compiler accept a program, but I don’t think it’s easier to learn to write good C programs. The language may seem small, but the actual language you need to master includes lots of practices for safe memory management and playing 3D chess with the optimizer exploiting undefined behavior.

                                                                                                                                                                                              1. 1

                                                                                                                                                                                                A nice write-up of the problem and solution. I especially like that main() is just a bunch of tests! Example inputs and outputs are enormously helpful for comprehension. The conclusion is too strong, however:

                                                                                                                                                                                                This implementation is constant-time in the length of the input, which is optimal.

                                                                                                                                                                                                I think that, rather, the implementation is O(n) (linear) in the length of the input. It’s probably still optimal, because by necessity, an RLE algorithm must “see” each character of the input string at least once. As a lower bound, the strlen() call on the input at the start of rle() is linear, for the same reason.

                                                                                                                                                                                                1. 16

                                                                                                                                                                                                  This has too little explanation for me and I do not understand what the author is getting at. It could use more examples, more detailed photos and / or a more elaborate explanation.

                                                                                                                                                                                                  For example, which connector is he talking about? The one on the product shown, or the one meant to be inserted into the product?

                                                                                                                                                                                                  1. 4

                                                                                                                                                                                                    I agree, I don’t understand this post at all. Should have more images pointing to the problem. Don’t see how inserting some usb device there would be a problem.

                                                                                                                                                                                                    1. 9

                                                                                                                                                                                                      The USB (Type A, female) ports fitted in this device have a flange on them intended to be pressed up against the internal surface of a chassis.

                                                                                                                                                                                                      He specifies female, so he’s referring to the ports on the product shown.

                                                                                                                                                                                                      The post makes no sense if you don’t know what a flange is, so:

                                                                                                                                                                                                      a projecting flat rim, collar, or rib on an object, serving to strengthen or attach

                                                                                                                                                                                                      If you zoom in on the image, you can more clearly see the flanges on each port, the little tabs of metal bent outward. Check out this similarly mis-fitted USB port, which makes the flanges a bit easier to see. Or this even more outrageously mis-fitted USB port, with the flanges entirely outside the casing. You can see what the flanges look like in this unmounted USB port.

                                                                                                                                                                                                      Those little tabs should be inside the casing, to brace the port. Compare with this better fitted USB port, where you can clearly see the flanges bracing against the inside of the casing. And these properly fitted USB ports on a device similar to the example in the original post.

                                                                                                                                                                                                      1. 1

                                                                                                                                                                                                        thanks for that, I see now. Well it doesn’t look good that for sure, but don’t think it really compromises the usability.

                                                                                                                                                                                                        1. 1

                                                                                                                                                                                                          Seems like unplugging a cable might cause more wear on the port when it’s not properly braced.

                                                                                                                                                                                                        2. 1

                                                                                                                                                                                                          Right, thanks for the explanation. As someone more into software than hardware (and not at all into electronics) I think I get it now!

                                                                                                                                                                                                      2. 2

                                                                                                                                                                                                        The port is what the connector or plug jacks in to. So in this case, he’s talking about the ports on the product shown. You can see the edge of a metal shell; really, you shouldn’t see that.

                                                                                                                                                                                                      1. 1

                                                                                                                                                                                                        I feel like a good vcs tool is now as scared as containerization and orchestration tool in the past. Its waiting for some good open source initiative thats is viable and scalable to become a “trend”. Then it stops become an enterprises closed source tool and get adopted widely

                                                                                                                                                                                                        1. 1

                                                                                                                                                                                                          Scared?

                                                                                                                                                                                                          1. 1

                                                                                                                                                                                                            I think they mean “sacred”

                                                                                                                                                                                                            1. 1

                                                                                                                                                                                                              maybe a typo for “scarce”

                                                                                                                                                                                                          1. 4

                                                                                                                                                                                                            The Python example immediately stands out to me as having two more alternatives:

                                                                                                                                                                                                            • crash (unironically, just crash, because you shouldn’t be dividing by zero)
                                                                                                                                                                                                            • use a typed language and specify division as only being allowed for non-zero divisors

                                                                                                                                                                                                            (Someone told me monads were Fourier transforms but for function execution and that somehow made them click for me. I like the article.)

                                                                                                                                                                                                            1. 7

                                                                                                                                                                                                              I think that I grok monads and Fourier transforms, but don’t see a connection. Could you elaborate?

                                                                                                                                                                                                              1. 3

                                                                                                                                                                                                                @tomjakubowski my mind jumped to convolutions after seeing Fourier transforms, and a convolution is an operation on two functions to produce a third function which serves as a translation between one method to another. I think the declaration of a convolution would map to a functor.

                                                                                                                                                                                                                I’m reading Wikipedia and my brain is melting from the definition of the convolution theorem, but it basically says you can transform convolution in one domain into multiplication into another domain. I guess that’s akin to binding (or using some operand to restructure a monolithic calculation into a pipeline), which is a property of monads.

                                                                                                                                                                                                                1. 6

                                                                                                                                                                                                                  Theorems are about what logically follows from definitions, not about what you or anyone else “can” do. In particular, the convolution theorem asserts that, given two absolutely integrable functions f and g, the Fourier transform of their convolution ℱ(f ⋆ g) equals the ordinary product of the Fourier transforms of the original functions ℱ(f) ℱ(g). Provided we accept the usual definitions of “Fourier transform” and “convolution”, the convolution theorem is simply true. It would still be true even if nobody had been smart enough to prove it.


                                                                                                                                                                                                                  Convolutions are not “translations”. The easiest way to think of convolutions is as follows. Suppose you have two independent random variables X and Y that could be either 0, 1, 2, 3, with some given probabilities. Then X + Y could be any of 0, 1, 2, 3, 4, 5, 6. But, what is the probability that X + Y equals, say, 4? We need to take into account every way in which X + Y = 4 could happen, namely:

                                                                                                                                                                                                                  • X = 1 and Y = 3
                                                                                                                                                                                                                  • X = 2 and Y = 2
                                                                                                                                                                                                                  • X = 3 and Y = 1

                                                                                                                                                                                                                  What are their respective probabilities? Since X and Y are independent,

                                                                                                                                                                                                                  • Pr[X = 1 and Y = 3] = Pr[X = 1] Pr[Y = 3]
                                                                                                                                                                                                                  • Pr[X = 2 and Y = 2] = Pr[X = 2] Pr[Y = 2]
                                                                                                                                                                                                                  • Pr[X = 3 and Y = 1] = Pr[X = 3] Pr[Y = 1]

                                                                                                                                                                                                                  Since the three cases are mutually exclusive,

                                                                                                                                                                                                                  • Pr[X + Y = 4] = Pr[X = 1] Pr[Y = 3] + Pr[X = 2] Pr[Y = 2] + Pr[X = 3] Pr[Y = 1]

                                                                                                                                                                                                                  One convenient way to write this is as follows:

                                                                                                                                                                                                                  • Pr[X + Y = 4] = sum_{i + j = 4} Pr[X = i] Pr[Y = j]

                                                                                                                                                                                                                  We had a nice finite sum, because our space of possibilities is finite. When X and Y may take arbitrary real numbers as values, the sum becomes an integral.


                                                                                                                                                                                                                  Finally, none of this has any relationship to monads or monadic bind whatsoever.

                                                                                                                                                                                                                2. 2

                                                                                                                                                                                                                  Honestly I’m sorry I ever brought it up. I too understand both and cannot remember why that off-handed explanation made sense to me, I’ve been trying to remember all day.

                                                                                                                                                                                                                  1. 1

                                                                                                                                                                                                                    There is no need to be sorry. This just means that you have to be careful with other people’s claims. If you do not understand why something has to be true, it is healthy to doubt it, at least a little. The stronger a claim is, the more you should doubt it. And the claim “This complicated thing becomes super simple if you just use this trick or analogy!” is super duper strong.

                                                                                                                                                                                                                    1. 1

                                                                                                                                                                                                                      It’s not like that at all. It’s not a stupid trick (type theorists hate her!), it was an off-the-cuff comment that triggered my synapses to wire up correctly and turned my knowledge to understanding.

                                                                                                                                                                                                                      1. 1

                                                                                                                                                                                                                        Ah, okay.

                                                                                                                                                                                                                3. 3

                                                                                                                                                                                                                  @WilhelmVonWeiner thanks for replying! Those are great points you raised, and I talked a little bit about them in my blog post, but to respond to you directly:

                                                                                                                                                                                                                  1. I would agree with you that crashing is the appropriate solution for most OLTP workloads (esp. those where the runtime is accessible by the developer). Worst case scenario, you lose one record, but you get a crisp error handled by the runtime. But for OLAP workloads it may be a bit different. In my last job I was handling 10^8 / 10^9 records for a OLAP job, and the tool was a monolith. Crashing may mean halting job execution or losing context of runtime state. You can’t crash on one “0” input if you have many records to process. I think crashing would also be inappropriate because the execution path differs based on the current job context (sometimes a 0 is okay, sometimes not). It was also an on-premise tool, so high-latency customer feedback loops was the only way I could resolve bugs as opposed to SSHing into a server.

                                                                                                                                                                                                                  2. Compile-time guarantees like static typing are really nice, and I’m not terribly familiar with them at the moment (I’m working through a Haskell book so I should have more knowledge by the end of the year), but I don’t see how that translates to correctness guarantees at runtime. What if you wanted to break out a monolith into services and each portion communicated to another through a protocol (e.g. stdin/stdout/stderr)?

                                                                                                                                                                                                                  Yeah, you can think of monads as a convolution! And thank you for the like :)

                                                                                                                                                                                                                  1. 4

                                                                                                                                                                                                                    Regarding 2.: The general idea is that when you parse data from the outside world (like stdin) you don’t just validate if the input is correct but you also transfer the data into your type safe data model. That’s how the compile time guarantees also hold at runtime. You would normally use some kind of parser for this, like aeson for JSON or ReadP for general text processing.

                                                                                                                                                                                                                    1. 1

                                                                                                                                                                                                                      Got it. I’m guessing since Haskell makes it easy to define types or typeclasses, there shouldn’t really be a situation where an external type could not map to a Haskell type, or if there is, there’s a catch-all bytes type acting as a container of bytes?

                                                                                                                                                                                                                      IIRC I encountered some weird issues with various binary encodings where I found it difficult to map to any data type in Python without being forced to apply an encoding (and then having to strip out that encoding during export). For example, reading PostgreSQL bytea into a binary column in another database using a custom process, or capturing and rendering Java log4j stdin within a parent Python process. If Haskell was flexible enough to design parsers for arbitrary bytestreams from various protocols that would be a major selling point to data engineers.

                                                                                                                                                                                                                      1. 2

                                                                                                                                                                                                                        Sure, you can leave parts of your data in a more general data structure. Of course you can’t interact with these parts as easily, but if you just want to pass them through that’s ok. E.g. in aeson there is the Value type which is just a sum type over all possible JSON elements. This is still perfectly safe, because if you want to work with these values you always have to consider every possible case of the sum type. And of course there is stuff like ByteArray.

                                                                                                                                                                                                                1. 6

                                                                                                                                                                                                                  Like a lot of these “falsehoods” articles, for many cases these “falsehoods” are perfectly true.

                                                                                                                                                                                                                  Take the “all currencies currently in circulation are subdivided in decimal units” point for example. There are only two currencies in use that are non-decimal: those of Madagascar and Mauritania. I don’t want to be dismissive of these countries, but they’re small developing countries, and the chances that code you create will have to deal with these currencies are quite small, so for most practical purposes it’s just fine to assume all currencies are decimal.

                                                                                                                                                                                                                  The world is a big and complex place, and you can’t deal with every single edge case. Most of the time there is no need to, and it’s much easier to just “believe the falsehoods” and deal with the common cases in a straightforward way.

                                                                                                                                                                                                                  1. 17

                                                                                                                                                                                                                    The world is a big and complex place, and you can’t deal with every single edge case. Most of the time there is no need to, and it’s much easier to just “believe the falsehoods” and deal with the common cases in a straightforward way.

                                                                                                                                                                                                                    Project management has talked about known unknowns and unknown unknowns. These lists turn the latter into the former. Knowing these edge cases exist can help design the solution space around them, explicitly design them out of the system, or at least document their presence.

                                                                                                                                                                                                                    So yes, most of the time handling the common cases straightforwardly is right, but you can at least do it with eyes open.

                                                                                                                                                                                                                    1. 8

                                                                                                                                                                                                                      Seconded.

                                                                                                                                                                                                                      1. A price can be at most 10^N for some value of N.

                                                                                                                                                                                                                      Let me interpret this: Whatever prices your system can process, it’s never enough. Using computers with infinite resources and processing power is therefore recommended.

                                                                                                                                                                                                                      1. 1

                                                                                                                                                                                                                        Right, and your boss might want you to write out that sandwich price as R$14,999,999,999.99 instead of RB$15 because it sounds cheaper that way.

                                                                                                                                                                                                                      2. 2

                                                                                                                                                                                                                        There are only two currencies in use that are non-decimal

                                                                                                                                                                                                                        Another small country you may have heard of is Japan

                                                                                                                                                                                                                        1. 2

                                                                                                                                                                                                                          I’m not sure what your point is, because that Wikipedia article specifically states that it’s decimal in the lead section.

                                                                                                                                                                                                                          1. 1

                                                                                                                                                                                                                            I stressed the wrong point, what I meant to point out is that yen are not subdivided at all.

                                                                                                                                                                                                                            I agree with you that it’s pointless to support iraimbilanja and khoums though, as both their respective currencies have more standard and more used decimal subdivisions.

                                                                                                                                                                                                                            1. 2

                                                                                                                                                                                                                              Well, yes. But that’s the next point on the list:

                                                                                                                                                                                                                              All currencies are subdivided. (counter-examples: KRW, COP, JPY… Or subdivisions can be deprecated.)

                                                                                                                                                                                                                              Japanese Yen, Indonesian Rupiah (which I use every day), and quite a few others are still decimal, even though not subdivided.

                                                                                                                                                                                                                          2. 1

                                                                                                                                                                                                                            The page you link to mentions 2 subdivisions of the yen, in 1/100 and 1/1000.

                                                                                                                                                                                                                            In practical terms it’s a single unit though.

                                                                                                                                                                                                                            The Indonesian rupiah is another currency with low real unit value, but its 1/100 subdivision is explicitly noted as “obsolete”.

                                                                                                                                                                                                                            1. 4

                                                                                                                                                                                                                              Not since 1953. (Sorry, can’t find an English article on it.) The words ‘sen’ and ‘rin’ are still used when referencing fractions when trading and whatnot, but no, they do not actually exist anymore.

                                                                                                                                                                                                                              1. 1

                                                                                                                                                                                                                                I think we can be charitable and assume that what the author means with “non-decimal” is

                                                                                                                                                                                                                                • a “unit” currency (yen, rupiah, ex-Italian lira), which cannot be subdivided
                                                                                                                                                                                                                                • a currency that is subdivided, and then always in multiples of 10.