S/Sed/Ed
50 points by thunderbong 9 days ago | 29 comments
  • sedatk 9 days ago |
    vi was originally the visual-by-default run mode of ed. And EDLIN on MS-DOS (and maybe CP/M too? don't remember) was based on ed too. That's why EDLIN and vi have similar command sets.
    • susam 9 days ago |
      If I remember correctly, vi was the visual mode of ex. I am trying to find some references for this. Here's one I could find from <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/v...>:

      > While ex and vi have historically been implemented as a single utility, this is not required by POSIX.1-2017.

      Better references would be very welcome. By the way, we can see this even today. For example, first type the following command in your terminal:

        ex
      
      Then at the ex prompt (the colon prompt), type this:

        vi
      
      This should bring up full blown Vim. The reverse is possible too. For example, in Vim, type:

        Q
      
      This takes us to Ex mode. Then in Ex mode type:

        vi
      
      This brings back Vim again.
  • snvzz 9 days ago |
    TIL about Rosetta code[0].

    And I can't help but wonder what the license of the code in the site is.

    If it isn't BSD0 or some similar attempt at preemptive public domain, what is even the point of such a thing.

    0. https://rosettacode.org/wiki/Rosetta_Code

    • jph 9 days ago |
      Rosetta Code is a great resource and uses the GNU Free Documentation License 1.2.
      • snvzz 9 days ago |
        I see this much, but that's not a code license; it is a documentation one.
        • Y_Y 8 days ago |
          Don Knuth might tell you that code and documentation don't need to be different.

          More seriously you can easily imagine Rosetta Code as just a way of teaching something, without an expectation that you'll compile or run it. In other words it is documentation, the fact that some of it is also code isn't a problem.

          • snvzz 8 days ago |
            Why would anyone teach with code that cannot be used for legal reasons?

            Instead of solving simple, common problems in many programming languages so that nobody has to ever do so again, this seems to make programming harder by excluding such solutions from being used.

            So now you have to find work arounds in order to NOT use the simple solutions in Rosetta.

            This is so evil.

            Should be called the tower of babel of code, rather than the rosetta stone.

            • Y_Y 8 days ago |
              > Why would anyone teach with code that cannot be used for legal reasons?

              Ask the Numerical Recipes guys!

              But for real, you can use this code, I don't think anyone said that you couldn't.

              • snvzz 8 days ago |
                >you can use this code

                No, you absolutely cannot. This is how copyright works by default.

                You'd need to relicense your code, with the permission of anyone else who owns copyright to it, to this documentation license.

                • Y_Y 8 days ago |
                  I am your lawyer and this is legal advice, the code is available under the documentation license. It is there for you to use. Not using it is the real tort.
                  • snvzz 7 days ago |
                    The GNU FDL 1.2 isn't compatible with the license of my code, and that of most code out there.

                    There is not anyone who can use code under this license, in practice.

                    • Y_Y 7 days ago |
                      I can use it. You can too. The users of your code can if you grant them a compatible license. You could also potentially relicense the Rosetta Code parts under section 11 of the FDL.
    • wisenull 9 days ago |
      Rosetta Code is hosted on Miraheze. By clicking on Terms of Use at the bottom of any page you can see that the default for any wiki hosted by them is Creative Commons Attribution-ShareAlike 4.0 License: https://meta.miraheze.org/wiki/Terms_of_Use
      • snvzz 7 days ago |
        CC-BY-SA would already be excessively restrictive for what are quite straightforward implementations of basic algorithms.

        But, literally the next string in that ToS:

        >Wiki owners can change this

        And they did. To FDL 1.2, a much less friendly license, in practice unusable.

  • dextercd 9 days ago |
    One time I used Power BI/Power query language to generate an Ed script that contained all versions of all XML documents in a database and turn them into a Git repo.

    I still like writing scripts that generate Git repos but I don't use Ed much.

    • snthpy 9 days ago |
      Do you have anything public on this or similar to this?

      I'm also a fan of Power Query and M-lang and think it's underappreciated by the dev community.

      Why did you use PQ in that instance?

      • dextercd 8 days ago |
        I don't have anything public, unfortunately. It wasn't super complicated. It just generated a long string of all the files with Ed commands around it to change the current file name (f) and invoke Git (!git).

        I don't remember why I decided to do it this way. I probably couldn't easily connect to the database any other way. Getting the right tools installed might've involved some bureaucracy. Nowadays, I probably would've just dealt with that, but I didn't know at the time how important that janky solution would be to my work.

        Power BI is not something I miss working with but Power Query is really nice. The fact that the UI generates code that you can tweak afterwards is a great learning tool. I still use it in Excel sometimes.

  • xg15 9 days ago |
    > No. I stay with ed, because it is

    Forgot the most important point there.

    ...the standard text editor

    • Joker_vD 9 days ago |
      And it doesn't waste kilobytes of space on the cursor-positioning code!
    • kps 8 days ago |
      And ed is in POSIX, so it's available on every minimally conforming system.
  • McUsr 9 days ago |
    Using ed interactively, so you can work out some complex operation step by step, is a valid point for using ed instead of sed. Sometimes however, awk is the correct solution. (Why sit and mess with it, if awk provides a straight forward solution.)
    • sgarland 8 days ago |
      Agreed, though you have to be careful not to rely on gawk (or mawk, etc.) specific features. To be fair, the exact same problem exists between sed and gsed.

      I always install gnu-utils on Macs because I find them to be easier, but if I need to share with coworkers, I have to go back and ensure they’re portable.

    • riedel 8 days ago |
      Actually interactive editing with ed saved my ass once on my FreeBSD server once. Somehow, my terminal driver (actually I actually used my vt520 even for emails at the time) was totally broken so I only had a single line. I actually managed to edit the settings file with ed to get things straight and do a reboot. However, if you know sed you should be able to handle. However, this was 2001 or so and I somehow doubt that I it will happen again ...
  • sherburt3 8 days ago |
    I love me some sed but using that ed syntax to do anything more complex than straightforward regex substitutions makes me feel like a chimpanzee trying jam a square peg into a round hole.
    • danielbln 8 days ago |
      This is me trying to use jq for anything remotely complex. At least LLMs took the pain out somewhat.
  • msephton 8 days ago |
    Capitalisation really didn't help with this title.
  • layer8 8 days ago |
    > Hey, I'm looping for work.

    Freudian slip? ;)

  • gregjor 7 days ago |
    I used ed for actual work decades ago, on a VT-100. My first job. We all used it until we got vi on the DECSystem-20.

    When people look at ed now it seems unusable. Back in the old days we had a printed copy of the code, with line numbers. We annotated the printed copy, then made edits. That made using a line-oriented editor a lot less painful. I haven’t seen programmers looking at code on paper in a long time.