1. 3

    I started into mechanical keyboards with the Cherry G80-3000 which is non-programmable and then switched to the Pok3r which allows remapping keys. What I did then is to have a layer for PC and a layer for Mac and switch the arrow bindings to regular hjkl vi keys.

    I used to have an Ergo Dox EZ which I programmed with my custom layout but I ended up rarely using it. I really like to have my keyboard at my lap which does not work that well with a split layout, so I passed the Ergo Dox to a coworker who also does not use it.

    On Mac I have Karabiner Elements to remap the right alt to F13 so I can use it as compose key as I have on my Linux machines. This is easily the weakest part of the setup since Karabiner tends to repeat keypresses on high load (compiling) or sometimes when waking from standby, therefore making it completely impossible to unlock the Mac.

    1. 4

      It is really surprising he didn’t find jbuilder which is the build system that seems to be displacing all the other build systems in OCaml and has a passable learning curve.

      Maybe because he uses Reason syntax, which is probably not supported very well, if at all.

      1. 3

        It’s called Dune now: https://github.com/ocaml/dune

        1. 1

          Dune has no releases yet, so for now it still is jbuilder.

        2. 1

          Dune supports Reason syntax out of the box and will pick up all *.re files automatically.

        1. 5

          Just git?

          I was kind of hoping that if we’re going to break the github hegemony, we might also start to reconsider git at least a little. Mercurial has so many good ideas worth spreading, like templates (DSL for formatting the output of every command), revsets (DSL for querying commits), filesets (DSL for querying files and path) and changeset evolution (meta-graph of commit rewriting).

          1. 10

            Don’t forget pijul!

            Seriously, though, I don’t think there is any “github plus something” that is going to break the github hegemony. Github won because it offered easy forking while Sourceforge was locked in a centralized model. Sourceforge won because it was so much easier than hosting your own repo + mailing list.

            The thing that will get people away from github has to have a new idea, a new use case that isn’t being met by github right now, and which hasn’t been proposed before. That means that adding hg won’t do it – not because hg is worse than git (honestly, git’s terrible, and hg is fine), but because hg’s already been an option and people aren’t using it.

            Adding email commits won’t do it, because that use case has been available for a long time (as pointed out elsewhere in these comments) and people aren’t using it.

            Until something new is brought to the table, it’s all “let’s enter a dominated market with a slight improvement over the dominant tech”, and that’s just not going to be enough.

            1. 8

              So, one thing that I would use a new contender for is being able to put my work under my own domain.

              The “new thing” here is “have your personal branding on your site” (which is clearly fairly popular given how common personal domain/sites are among developers).

              If I could CNAME code.daniel.heath.cc to your host to get my own github, I’d do it today (as long as any issues/wiki/PR state/etc remained usefully portable).

              1. 8

                That’s a really neat idea. I don’t think I can prioritize it right now but it’s definitely something I would consider implementing.

                1. 3

                  I actually think that GitHub’s lack of branding and customization is a big reason for its success. When I go take a look at a new project on GitHub, I don’t have to figure out how to navigate a new site’s design, and this makes the GitHub ecosystem as a whole easier to use.

                  1. 3

                    I don’t mean corporate/design branding.

                    I want to use my own name (and be able to move providers without breaking links).

                    1. 1

                      I want to use my own name (and be able to move providers without breaking links).

                      But that will happen anyway, unless your new provider uses the same software as the old one.

                      1. 1

                        Yep - so it has to be oss too.

                        1. 1

                          That makes sense actually. sr.ht supporting the ability to use your own domain name (presumably a subdomain of your personal domain name for personal projects?) would make it really easy to migrate away from sr.ht in the future if you felt it was more cost-effective to host your own. Although I don’t know what the pricing model is intended to be.

                  2. 2

                    You can do that with Gitlab (or Gitea if you prefer something lightweight). Only thing is you need to take care of the hosting yourself. But I’m sure there are companies offering a one-click setup, to which you can later point your own domain.

                    1. 2

                      If you host your own gitlab instance, can you fork and submit patches to a project that’s hosted on gitlab,com, as easily/seamlessly as if you were hosted there?

                      Centralization has benefits that self-hosting can’t always provide. If there were some federation which allowed self-hosting to integrate with central and other self-hosting sites, that seems like a new and interesting feature.

                      1. 5

                        Git is already federated with email - it’s specific services like GitHub which are incompatible with git’s federation model (awfully conveniently, I might add). sr.ht is going to be designed to accomodate git’s email features, both for incoming and outgoing communication, so you’ll be able to communicate easily between sr.ht instances (or sr.ht and other services like patchworks or LKML).

                        1. 2

                          As I mention earlier, though, federation by email has been available for a long time and hasn’t been used (by enough people to replace github). The (vast) majority of developers (and other repo watchers) prefer a web UI to an email UI.

                          1. 4

                            I intend to build a web UI which is driven by email underneath.

                        2. 4

                          The gitlab, gitea, and gogs developers are working on this but it’s still very much in the discussion stage at this point. https://github.com/git-federation/gitpub/

                          1. 1

                            Oh, definitely no federation. Didn’t know that federation was what he was looking for.

                            1. 2

                              I don’t know exactly what he was looking for, but It seemed like one of:

                              • hosted, centralized, but with my domain plus some branding, or
                              • self-hosted but with the features of centralization, including community, etc

                              The latter sounds to me like it would need federation.

                          2. 1

                            It’s currently awkward to run multiple domains on most OSS servers which might otherwise be suitable.

                        3. 3

                          hg isn’t really an option right now, though. There’s nowhere to host it. There’s bitbucket, and it’s kind of terrible, and they keep making it worse.

                          If you can’t even host it, people won’t even try it.

                        4. 14

                          I’m afraid you’re not going to find a sympathetic ear in sr.ht. I am deeply fond of git and deeply critical of hg.

                          The GitHug hegemony has nothing to do with its basis on git. If git were the product of GitHub, I might agree, but it’s not. If you really want to break the GitHub hegemony you should know well enough to throw your lot in with the winning tool rather than try to disrupt two things at once.

                          1. 3

                            Do you mind expanding on why you are deeply critical of mercurial?

                            1. 8

                              Perhaps some day I’ll write a blog post going into detail. The short of it is that git is more Unixy, Mercurial does extensibility the wrong way, and C is a better choice than Python (or Rust, I hear they’re working on that).

                              1. 4

                                Git IS more unixy! Using hg feels suspiciously like using a GUI and I can’t figure out why.

                                1. 4

                                  because hg‘s command-line interface was “designed”, whereas git’s command-line interface “evolved” from how it was being used.

                            2. 2

                              The GitHug hegemony has nothing to do with its basis on git.

                              Exactly; it’s the other way around. Git got popular because of github.

                              Git was much worse before github made it popular. It’s bad now and difficult to use now, but it was much worse before 2008. So if you just want to get away from Github, there’s no need to stay particulary enamoured with git either.

                              And whatever criticisms you may have about hg, you have to also consider that it has good ideas (those DSLs above are great). Those ideas are worth spreading, and git for a long time has tried to absorb some of them and hasn’t succeeded.

                          1. 3

                            I quite liked if-let. Interestingly it is very similar to the let%bind name = monadic_value in … in OCaml when using ppx_let and Core which I use a lot. It is also similar to the do notation in Haskell.

                            Both are sort of more general versions of if-let since they don’t hardcode on the truthfulness of the value but rather can be defined per-monad.

                            1. 3

                              Hi @wcrichton, thanks for the post.

                              That part about automatically inferring types of a heterogenous map in OCaml is incorrect. You can create constructors out of nowhere (polymorphic variants), but OCaml will never do this for you and declaring that is also completely typesafe with no runtime errors happening. Also, your link to Stackoverflow is broken (because I wanted to check out what made you conclude such a thing).

                              1. 2

                                Ah, that was a misleading edit, I’ve clarified the article text. Originally I had OCaml in the explicit sum type category with a note about polymorphic variants, but I realized that was similar to Ceylon so I moved it to the implicit sum type category without appropriately updating the pros/cons. Ultimately, I realized that a more nuanced description of the design space around sum types is warranted, which you can now find in the article (i.e. sum types can be broken down as named vs. anonymous, declared vs. inferred, and matched vs. casted).

                                1. 1

                                  Very good, I think this is a nice improvement. I realize my original comment to a good article was unnecessarily grumpy, so I’ll just wish you a nice weekend instead now.

                              1. 14

                                Truth be told, I see very little actual argument in the post. He mentions 4 languages/environments he’s impressed with, 3 of them dynamically typed, one an example of how people would not implement static typing in 2018.

                                Then he lists the points that Swift is meant for. He mentions that it does not achieve these goals. Why does it not? What’s some example of it not working out, in a way that e.g. ObjC does? He then presents a list of features a language should have, but why Swift, a language for writing end-user applications in the Apple ecosystem would care about distributed systems remains mysterious. Also, how is it not focusing on developer productivity? No answer is given.

                                Then it ends up with “maybe Elixir is nice” which, uhm, yes, it is Erlang with a Ruby syntax. We’re back to the beginning of the post.

                                Now, I am not defending Swift but dismissing Swift for what the author himself calls “rant” feels a bit premature to me. I would have liked to see these claims substantiated (e.g. how Swift is difficult to debug, compared to ObjC for instance, how is it not productive, how is it worse than ObjC for App and UI development), because the main point I see is “Swift is not a dynamically typed language”.

                                Any insight on the shortcomings of Swift as an answer are greatly appreciated. I believe lobsters can create a better, more nuanced list than this rant.

                                1. 2

                                  I think “Swift is not a dynamic language” is a decent point. I’m not sure what you mean by dynamically typed, but I’m going to use specific examples of the dynamism I use when writing Cocoa programs in Objective-C to illustrate how I mean dynamism.

                                  A couple of common cases where I use dynamic language features, because the design of Cocoa seems to lend itself to doing so:

                                  • when preparing the display of collections of data (e.g. table views, collection views), I want to be able to say “this property appears in this place”, and “this UI change affects this property. I can do that by composing selectors based on the name of the property being displayed, or by using KVC which is an Objective-C technology that does the same thing.
                                  • when validating the availability of UI actions (e.g. menu items, toolbar items, buttons), I want to be able to ask “are the preconditions for performing this action satisfied?”. I do that by extracting the preconditions to a method whose name is derived from the action’s selector, and then asking the relevant controller object to perform that selector.

                                  Another thing I often do which has nothing (much) to do with dynamism but which Cocoa was designed with as an axiom and that Swift does not support is to use nil as the message sink.

                                  I’m sympathetic to the idea that Objective-C as a language has shortcomings and that a different language would make Apple platform development more accessible. Shortly before Swift was announced I wrote that there already were tons of languages with ObjC bindings, because “ObjC bindings” are just FFI calls to a small handful of runtime functions. My hope at the time was that a language built in such a way - exposing the object runtime but hiding the complexity of all the C interop and memory management - would be the future. It’s not an unreasonable expectation, as Apple had integrated the open source PerlObjCBridge and PyObjC, and had developed MacRuby. But Swift is not that, it is a different model of computation that also has language support for Cocoa and (some) ObjC features.

                                  1. 1

                                    My hope at the time was that a language built in such a way - exposing the object runtime but hiding the complexity of all the C interop and memory management - would be the future.

                                    So, something like Vala is for C+GObject? A C#-inspired wrapper around the idioms of the GObject system.

                                    1. 1

                                      Exactly that sort of thing. Vala appears to be designed to expose the GObject model, whereas using GTK+ in C is merely possible. The actual examples I had in mind were StepTalk and NeXT’s WebScript, but they’re basically doing the same thing.

                                1. 5

                                  What I don’t really understand is how Andrew has a comfortable standard of living in NYC on $600 per/month.

                                  https://www.patreon.com/andrewrk/overview

                                  I’m guessing that there must be another source of Zig donations aside from Patreon?

                                  1. 7

                                    Savings?

                                    1. 2

                                      Oh woops, I misread the first paragraph, I thought it stated that Zig was supporting him entirely, when it’s actually about his programming supporting him.

                                      1. 3

                                        Note that this isn’t his first attempt at doing this. But the project he was working on before Genesis didn’t find the same traction as Zig has. BUT, if I recall correctly, he also didn’t live in NYC the last time… Anyway, he’s got experience with living frugally, so I’m sure he knows what he’s doing here.

                                        1. 2

                                          he extrapolated the donations growth versus his savings.

                                      2. 2

                                        What I don’t understand is if you are not working in NYC anymore, and only working on your own and getting donation, why doesn’t he move to anywhere but NYC to minimise his personal expense?

                                        I’m sure there are cities in the US with 80% the fun of NYC at lower than 80% of the cost.

                                        1. 17

                                          I work remote, and there are places I could move that are < 20% of the cost.

                                          My friends aren’t going to move with me, and I have enough money to live where I am. Why be wealthy and lonely?

                                          1. -10

                                            Didn’t know your city is the only source of friends in the world. That must be good for the economy.

                                            1. 32

                                              I know that this is very hard for some people to believe (seems to be harder the more western the society is), but some people don’t consider their friends a replaceable commodity. Not that I don’t want to make new friends, but these are my friends right now and I am more loyal to them than I am to a meaningless job or to money.

                                              1. 4

                                                Maybe because your partner has a job he/she really enjoys in this city? I mean, we’re lucky in our field to have a lot of different possibilities, in remote or not, mostly well paid. Let’s not forget that it’s a chance and not something everybody has.

                                            2. 2

                                              The usual reason is the significant other.

                                              1. 1

                                                There’s a shit-ton of them. Even Memphis TN that’s close to me with all its problems is low cost of living with all kinds of fun stuff to do. Just don’t live in or shop around the hood. Solves most of problems if you don’t have kids going to school or college.

                                                There’s plenty of cities in the US that similarly have low cost of living with plenty going on. One can also live in areas 30-40 min from cities to substantially reduce their rent. The fun stuff still isn’t that far away. The slight inconvenience just knocks quite a bit off the price.

                                                1. 4

                                                  I don’t remember the details, and I can’t find the link, but a few years ago someone did some research here in Berlin where they compared the cost of rent in more-or-less the city proper, and the cost of rent + public transportation tickets when you lived in the outskirts. It ended up being not much of a difference.

                                                  1. 2

                                                    Well, if you don’t workin in the city and need to commute then you spend even less. Though OTOH, you get tax returns for commutes in Germany so probably the commute is not that expensive to begin with.

                                                    1. 2

                                                      Berlin is currently the city with the highest increase in rent world-wide and a few years ago, it was unusually low.

                                                      Also, Berlin is hard to compare in many aspects, possibly because of a very unique city history.

                                              1. 1

                                                But why everyone blame npm and “micro-libraries” as the main problem in js? Aren’t all other languages (except C/C++) has the same way of dealing with dependencies? Even in conservative Java installing hundreds of packages from Maven is norm.

                                                1. 10

                                                  Something to consider is that JavaScript has an extreme audience. People who barely consider themselves programmers, because they mostly do design use it, or people just doing tiny modifications. Nearly everyone building a web application in any kind of language, framework, etc. uses it.

                                                  I think the reason there is so much bad stuff in JavaScript is not only something rooted in language design. JavaScript isn’t so much worse than other popular bad languages, it just has a larger base having even more horrible programmers and a lot of them also build some form of frameworks.

                                                  Don’t get me wrong, JavaScript is not a great language by any stretch, but blaming the ecosystem of a language who certainly has at least a few of the bright minds designing and implementing (working at/with Google, Mozilla and Joyent for example) it should not result in something so much more unstable.

                                                  Of course this doesn’t mean that it’s not about the language at all either. It’s just that I have yet to see a language where there isn’t a group writing micro-libraries, doing bad infrastructure, doing mostly worst-practice, finding ways, to work around protections to not shoot yourself in the foot, etc. Yes, even in Python, Rust, Go, Haskell and LISP that exists.

                                                  Maybe it’s just that JavaScript has been around for ages, many learned it do so some animated text, they wrote how they did it, there is a ton of bad resources and people that didn’t really learn the language and there is a lot of users/developers that also don’t care enough, after all it’s just front-end. Validation happens on the server and one wants to do the same sending off some form and loading something with a button, updating some semi-global state anyway.

                                                  JavaScript is used from people programming services and systems with it (Joyent, et al.) to a hobby web designer. I think that different approaches also lead to very different views on what is right and what isn’t. Looking at how it started and how the standards-committee has to react to it going into backend, application and even systems programming direction probably is a hard task and it’s probably a great example of how things get (even) worse when trying to be the perfect thing for everything, resulting in the worst.

                                                  On a related note: I think the issue the community, if you even can call it like that (there are more communities around frameworks rather than the language itself, which is different from many other scripting languages) doesn’t seem to look at their own history too much, resulting in mistakes to be repeated, often “fixing” a thing by destroying another, sometimes even in different framework-layers. For example some things that people learned to be bad in plain JavaScript and HTML get repeated and later learned to be bad using some framework. So one starts over and builds a new framework working around exactly that problem, overlooking other - or intentionally leaving them out, because it wasn’t part of the use case.

                                                  1. 2

                                                    there are more communities around frameworks rather than the language itself, which is different from many other scripting languages

                                                    In general I tend to agree, but at least at some time ago I am pretty sure the Rails community was larger than the Ruby community. The Django community in Python also seems to be quite big vocal, but probably not larger than its language community given that the Python community is overall way more diversified and less focused on one particular use of the language.

                                                  2. 9

                                                    A lot of Java frameworks predate maven - e.g. Spring was distributed as a single enormous jar up until version 3 or so, partly because they didn’t expect everyone to be using maven. I think there’s still a cultural hangover from that today, with Java libraries ending up much bigger than those in newer languages that have had good package management from early on (e.g. Rust).

                                                    1. 5

                                                      Even including all transitive libraries, my (quite large) Android app Quasseldroid has 21 real dependencies. That’s for a ~65kLOC project.

                                                      In JS land, even my smallest projects have over 300 transitive dependencies.

                                                      It’s absolutely not the same.

                                                      1. 3

                                                        In technical terms, npm does not differ much from how python does package management. Culturally, however, there are a big difference in how package development is approached. Javascript has the famous left-pad package (story). It provided a single function to left-pad a string with spaces or zeroes. Lots of javascript libraries are like it, providing a single use case.

                                                        Python packages on the other hand usually handle a series of cases or technical area - HTTP requests, cryptography or, in the case of left-pad, string manipulation in general. Python also has PEP8 and other community standards that mean code is (likely to be) more homogeneous. I am using python here as that is what I know best.

                                                        1. 1

                                                          Because npn micro-libraries tends to be much worse than most other languages.

                                                          1. 1

                                                            It’s a problem there too.

                                                          1. 12

                                                            Output should be simple to parse and compose

                                                            No JSON, please.

                                                            Yes, every tool should have a custom format that needs a badly cobbled together parser (in awk or whatever) that will break once the format is changed slighly or the output accidentally contains a space. No, jq doesn’t exist, can’t be fitted into Unix pipelines and we will be stuck with sed and awk until the end of times, occasionally trying to solve the worst failures with find -print0 and xargs -0.

                                                            1. 11

                                                              JSON replaces these problems with different ones. Different tools will use different constructs inside JSON (named lists, unnamed ones, different layouts and nesting strategies).

                                                              In a JSON shell tool world you will have to spend time parsing and re-arranging JSON data between tools; as well as constructing it manually as inputs. I think that would end up being just as hacky as the horrid stuff we do today (let’s not mention IFS and quoting abuse :D).


                                                              Sidestory: several months back I had a co-worker who wanted me to make some code that parsed his data stream and did something with it (I think it was plotting related IIRC).

                                                              Me: “Could I have these numbers in one-record-per-row plaintext format please?”

                                                              Co: “Can I send them to you in JSON instead?”

                                                              Me: “Sure. What will be the format inside the JSON?”

                                                              Co: “…. it’ll just be JSON.”

                                                              Me: “But it what form? Will there be a list? Name of the elements inside it?”

                                                              Co: “…”

                                                              Me: “Can you write me an example JSON message and send it to me, that might be easier.”

                                                              Co: “Why do you need that, it’ll be in JSON?”

                                                              Grrr :P


                                                              Anyway, JSON is a format, but you still need a format inside this format. Element names, overall structures. Using JSON does not make every tool use the same format, that’s strictly impossible. One tool’s stage1.input-file is different to another tool’s output-file.[5].filename; especially if those tools are for different tasks.

                                                              1. 3

                                                                I think that would end up being just as hacky as the horrid stuff we do today (let’s not mention IFS and quoting abuse :D).

                                                                Except that standardized, popular formats like JSON get the side effect of tool ecosystems to solve most problems they can bring. Autogenerators, transformers, and so on come with this if it’s a data format. We usually don’t get this if it’s random people creating formats for their own use. We have to fully customize the part handling the format rather than adapt an existing one.

                                                                1. 2

                                                                  Still, even XML that had the best tooling I have used so far for a general purpose format (XSLT and XSD in primis), was unable to handle partial results.

                                                                  The issue is probably due to their history, as a representation of a complete document / data structure.

                                                                  Even s-expressions (the simplest format of the family) have the same issue.

                                                                  Now we should also note that pipelines can be created on the fly, even from binary data manipulations. So a single dictated format would probably pose too restrictions, if you want the system to actually enforce and validate it.

                                                                  1. 2

                                                                    “Still, even XML”

                                                                    XML and its ecosystem were extremely complex. I used s-expressions with partial results in the past. You just have to structure the data to make it easy to get a piece at a time. I can’t recall the details right now. Another I used trying to balance efficiency, flexibility, and complexity was XDR. Too bad it didn’t get more attention.

                                                                    “So a single dictated format would probably pose too restrictions, if you want the system to actually enforce and validate it.”

                                                                    The L4 family usually handles that by standardizing on an interface, description language with all of it auto-generated. Works well enough for them. Camkes is an example.

                                                                    1. 3

                                                                      XML and its ecosystem were extremely complex.

                                                                      It is coherent, powerful and flexible.

                                                                      One might argue that it’s too flexible or too powerful, so that you can solve any of the problems it solves with simpler custom languages. And I would agree to a large extent.

                                                                      But, for example, XHTML was a perfect use case. Indeed to do what I did back then with XLST now people use Javascript, which is less coherent and way more powerful, and in no way simpler.

                                                                      The L4 family usually handles that by standardizing on an interface, description language with all of it auto-generated.

                                                                      Yes but they generate OS modules that are composed at build time.

                                                                      Pipelines are integrated on the fly.

                                                                      I really like strongly typed and standard formats but the tradeoff here is about composability.

                                                                      UNIX turned every communication into byte streams.

                                                                      Bytes byte at times, but they are standard, after all! Their interpretation is not, but that’s what provides the flexibility.

                                                                      1. 4

                                                                        Indeed to do what I did back then with XLST now people use Javascript, which is less coherent and way more powerful, and in no way simpler.

                                                                        While I am definitely not a proponent of JavaScript, computations in XSLT are incredibly verbose and convoluted, mainly because XSLT for some reason needs to be XML and XML is just a poor syntax for actual programming.

                                                                        That and the fact that while my transformations worked fine with xsltproc but did just nothing in browsers without any decent way to debug the problem made me put away XSLT as an esolang — lot of fun for an afternoon, not what I would use to actually get things done.

                                                                        That said, I’d take XML output from Unix tools and some kind of jq-like processor any day over manually parsing text out of byte streams.

                                                                        1. 2

                                                                          I loved it when I did HTML wanting something more flexible that machines could handle. XHTML was my use case as well. Once I was a better programmer, I realized it was probably an overkill standard that could’ve been something simpler with a series of tools each doing their little job. Maybe even different formats for different kinds of things. W3C ended up creating a bunch of those anyway.

                                                                          “Pipelines are integrated on the fly.”

                                                                          Maybe put it in the OS like a JIT. Far as bytestreams, that mostly what XDR did. They were just minimally-structured, byte streams. Just tie the data types, layouts, and so on to whatever language the OS or platform uses the most.

                                                                  2. 3

                                                                    JSON replaces these problems with different ones. Different tools will use different constructs inside JSON (named lists, unnamed ones, different layouts and nesting strategies).

                                                                    This is true, but but it does not mean heaving some kind of common interchange format does not improve things. So yes, it does not tell you what the data will contain (but “custom text format, possibly tab separated” is, again, not better). I know the problem, since I often work with JSON that contains or misses things. But the problem is not to not use JSON but rather have specifications. JSON has a number of possible schema formats which puts it at a big advantage of most custom formats.

                                                                    The other alternative is of course something like ProtoBuf, because it forces the use of proto files, which is at least some kind of specification. That throws away the human readability, which I didn’t want to suggest to a Unix crowd.

                                                                    Thinking about it, an established binary interchange format with schemas and a transport is in some ways reminiscent of COM & CORBA in the nineties.

                                                                  3. 7

                                                                    will break once the format is changed slighly

                                                                    Doesn’t this happens with json too?
                                                                    A slight change in the key names or turning a string to a listof strings and the recipient won’t be able to handle the input anyway.

                                                                    the output accidentally contains a space.

                                                                    Or the output accidentally contact a comma: depending on the parser, the behaviour will change.

                                                                    No, jq doesn’t exis…

                                                                    Jq is great, but I would not say JSON should be the default output when you want composable programs.

                                                                    For example JSON root is always a whole object and this won’t work for streams that get produced slowly.

                                                                    1. 5

                                                                      will break once the format is changed slighly

                                                                      Doesn’t this happens with json too?

                                                                      Using a whitespace separated table such as suggested in the article is somewhat vulnerable to continuing to appear to work after the format has changed while actually misinterpreting the data (e.g. if you inserted a new column at the beginning, your pipeline could happily continue, since all it needs is at least two columns with numbers in). Json is more likely to either continue working correctly and ignore the new column or fail with an error. Arguably it is the key-value aspect that’s helpful here, not specifically json. As you point out, there are other issues with using json in a pipeline.

                                                                    2. 3

                                                                      On the other hand, most Unix tools use tabular format or key value format. I do agree though that the lack of guidelines makes it annoying to compose.

                                                                      1. 2

                                                                        Hands up everybody that has to write parsers for zpool status and its load-bearing whitespaces to do ZFS health monitoring.

                                                                        1. 2

                                                                          In my day-to-day work, there are times when I wish some tools would produce JSON and other times when I wish a JSON output was just textual (as recommended in the article). Ideally, tools should be able to produce different kinds of outputs, and I find libxo (mentioned by @apy) very interesting.

                                                                          1. 2

                                                                            I spent very little time thinking about this after reading your comment and wonder how, for example, the core utils would look like if they accepted/returned JSON as well as plain text.

                                                                            A priori we have this awful problem of making everyone understand every one else’s input and output schemas, but that might not be necessary. For any tool that expects a file as input, we make it accept any JSON object that contains the key-value pair "file": "something". For tools that expect multiple files, have them take an array of such objects. Tools that return files, like ls for example, can then return whatever they want in their JSON objects, as long as those objects contain "file": "something". Then we should get to keep chaining pipes of stuff together without having to write ungodly amounts jq between them.

                                                                            I have no idea how much people have tried doing this or anything similar. Is there prior art?

                                                                            1. 9

                                                                              In FreeBSD we have libxo which a lot of the CLI programs are getting support for. This lets the program print its output and it can be translated to JSON, HTML, or other output forms automatically. So that would allow people to experiment with various formats (although it doesn’t handle reading in the output).

                                                                              But as @Shamar points out, one problem with JSON is that you need to parse the whole thing before you can do much with it. One can hack around it but then they are kind of abusing JSON.

                                                                              1. 2

                                                                                That looks like a fantastic tool, thanks for writing about it. Is there a concerted effort in FreeBSD (or other communities) to use libxo more?

                                                                                1. 1

                                                                                  FreeBSD definitely has a concerted effort to use it, I’m not sure about elsewhere. For a simple example, you can check out wc:

                                                                                  apy@bsdell ~> wc -l --libxo=dtrt dmesg.log
                                                                                       238 dmesg.log
                                                                                  apy@bsdell ~> wc -l --libxo=json dmesg.log
                                                                                  {"wc": {"file": [{"lines":238,"filename":"dmesg.log"}]}
                                                                                  }
                                                                                  
                                                                            2. 1

                                                                              powershell uses objects for its pipelines, i think it even runs on linux nowaday.

                                                                              i like json, but for shell pipelining it’s not ideal:

                                                                              • the unstructured nature of the classic output is a core feature. you can easily mangle it in ways the programs author never assumed, and that makes it powerful.

                                                                              • with line based records you can parse incomplete (as in the process is not finished) data more easily. you just have to split after a newline. with json, technically you can’t begin using the data until a (sub)object is completely parsed. using half-parsed objects seems not so wise.

                                                                              • if you output json, you probably have to keep the structure of the object tree which you generated in memory, like “currently i’m in a list in an object in a list”. thats not ideal sometimes (one doesn’t have to use real serialization all the time, but it’s nicer than to just print the correct tokens at the right places).

                                                                              • json is “java script object notation”. not everything is ideally represented as an object. thats why relational databases are still in use.

                                                                              edit: be nicer ;)

                                                                            1. 11

                                                                              I can’t imagine a valid use case for shadowing a method argument.

                                                                              In OCaml I use shadowing all the time, since when I shadow a value, I make it impossible to access the previous value by accident. Especially if the type stays the same I never run into the problem where I accidentally pass num around where instead I meant to use new_num by the simple fact that the scoping just prevents me from messing up.

                                                                              First, you need to type and read this noisy colon between names and types. What is the purpose of this extra character? Why are names separated from their types? I have no idea. Sadly, it makes your work in Kotlin harder.

                                                                              Except for this being the accepted type annotation syntax in just about any modern typed language I might concede the point but then again, why does Java have all these { and }? I have no idea. Sadly, they make your work in Java harder.

                                                                              1. 3

                                                                                Yes, that’s how it works in Rust too: shadowing often replaces assignment (and you can even “change” type of the variable, that feels like a dynamically typed language!). To my surprise, this shadowing-as-usual makes me much more aware of shadowing and actually prevents shadowing bugs.

                                                                                1. 2

                                                                                  I don’t know if Kotlin has it, but one thing that is useful for shadowing is a warning for if you don’t use a variable. In that case, the code provided would provide warnings because they don’t use one of the num’s.

                                                                                1. 8

                                                                                  I am sort of wondering whether it wouldn’t be possible to just ship a 32 bit x86 executable instead of amd64, then the 32 bit tricks could potentially be pulled. Since it doesn’t seem to need any libraries it wouldn’t incur any additional dependencies I think.

                                                                                  1. 3

                                                                                    I didn’t think of trying that…

                                                                                    1. 1

                                                                                      I thought he was using 32-bit already? On my system, __NR_pause is defined to be 29 (his number) in asm/unistd_32.h, and 34 in asm/unistd_64.h. He’s also using eax over rax… Perhaps using int 80h and not syscall uses the 32-bit abi?

                                                                                      1. 2

                                                                                        int 0x80 is definitely the 32 bit Linux system call entry point.

                                                                                        1. 1

                                                                                          To be honest, my knowledge of assembler is minimal and even that is 20 years out of date…

                                                                                      1. 10

                                                                                        When web agencies/developers say “full stack”, in my experience they mean “jack of all trades, master of none”.

                                                                                        Someone who is equally happy writing php or nodejs as browser javascript or css. Possibly SQL. In todays climate they probably expect ‘devops’ which for the type of shops saying ‘full stack’ probably means “search for a docker image that sounds reliable and cross your fingers”.

                                                                                        Given your history with compiled languages, perhaps mobile app development is a good route? It’s definitely a market with demand right now.

                                                                                        Alternatively look on some of the remote specific job boards. https://github.com/lukasz-madon/awesome-remote-job/ may also help.

                                                                                        1. 8

                                                                                          When web agencies/developers say “full stack”, in my experience they mean “jack of all trades, master of none”.

                                                                                          I always interpreted it as a way of saying “I am unaware of any abstraction layer lower than the virtual machine”.

                                                                                          1. 2

                                                                                            I always interpreted it as a way of saying “I am unaware of any abstraction layer lower than the virtual machine”.

                                                                                            I think “full stack” is a web term, where the stack basically ends at the virtual machine. In web you basically outsource the lower parts to your SaaS provider anyway.

                                                                                            I have never seen “full stack” desktop developers or “full stack” HPC “full stack” compiler developers or whathaveyou.

                                                                                          2. 1

                                                                                            When web agencies/developers say “full stack”, in my experience they mean “jack of all trades, master of none”.

                                                                                            I worried as much.

                                                                                            […] perhaps mobile app development is a good route? It’s definitely a market with demand right now.

                                                                                            Thank you. I will take a look at that.

                                                                                            https://github.com/lukasz-madon/awesome-remote-job/ may also help.

                                                                                            Thanks for that too!

                                                                                          1. 7

                                                                                            I can get on board with some version of this, but the particular filter recommended is pretty aggressive imo. According to the linked stats, the filter of “>0.25% market share, not ie 11, and not opera mini” covers only 87% of web traffic. Having your site break on one out of 7 visitors is a pretty high failure rate!

                                                                                            If you instead used the filter “>0.1%”, it would cover 95% of traffic, which is at least a bit more reasonable imo.

                                                                                            1. 7

                                                                                              If your site is so dependent on JavaScript that it doesn’t work at all in browsers that get shut out by "browsers": [ ">0.25%", "not ie 11", "not op_mini all" ], I would suggest that your problem isn’t with your implementation but with your design.

                                                                                              1. 2

                                                                                                Sure, you should make your site not be JS-dependent in the first place. But then you don’t need any of this polyfill stuff at all! If the JS is only for optional functionality, you can just write whatever recent dialect of JS you want directly. I’m assuming that people who use stuff like babel and polyfills are doing so because their site actually needs the JS to run, so they need to translate it to maintain compatibility with a range of browsers. And in that case, I think you might as well aim for a wide range of compatibility while you’re at it.

                                                                                              2. 2

                                                                                                One could automatically create optimized bundles for the different browsers, and send the appropriate one to the browser, according to the User-Agent HTTP header.

                                                                                                But unfortunately, the ethics of accessible, diverse and welcoming web contents has long gone.
                                                                                                Now the web is platform and a product, and people should just buy the stereotypical industrial offer.

                                                                                                Please visitor, conform!

                                                                                                1. 1

                                                                                                  according to the User-Agent HTTP header

                                                                                                  This is a bit of a problem, since browsers like to identify as other browsers (think “request desktop site” in mobile browsers, or browsers with a small market share), but they don’t execute JavaScript the same way that the browser they pretend to be does.

                                                                                                  1. 1

                                                                                                    Well, if you even want to support cheating users (:-D) just include a browser detection script first, and then include the proper bundle.

                                                                                                    I think the matter is pretty simple technically.

                                                                                                    The fact is that most companies don’t think user’s freedom has a value because they can’t profit from it.

                                                                                                    So why test for that weird 13% that insists to be different?

                                                                                                    IMHO, intranet enterprise applications are the only case in which such optimisation makes sense.

                                                                                                2. 1

                                                                                                  This is where good defaults come in. I don’t think this is the sort of thing that a developer should be configuring at all, unless there’s a specific browser that they need to support.

                                                                                                1. 7

                                                                                                  I wrote about it in frustration a month ago is that it doesn’t take a little longer to be effective in Rust compared to other languages, it takes 10 to 20 times longer

                                                                                                  I head that and mostly interpret it as “learning a different paradigm” takes just longer. When I started I used to think that languages are very different from each other but actually the differences between Python and Ruby and Perl are mostly syntactical, switching between C# and Java is for the biggest part dominated by knowing the APIs and where to look for things. Whereas going from Java to Rust ist… a bigger leap. But the leap is roughly the same when learning Haskell, OCaml or becoming proficient in Prolog, APL/Factor etc. This time it is a different way to think about the problem instead of where to put the squiggly parens.

                                                                                                  1. 3

                                                                                                    using this as an occasion to trot out one of my favorite essays on naming: https://blog.janestreet.com/whats-in-a-name/

                                                                                                    1. 1

                                                                                                      I like this essay, and it makes me think about a couple things.

                                                                                                      …the length and detail of a name should be proportional to its scope: A variable that is referenced across multiple files ..

                                                                                                      It’s funny, because I like to write CoffeeScript, and you can’t really do that: variables are file-scoped by default. It’s a preference thing. (Some people like to shadow lexical bindings? not I)

                                                                                                      Another issue with picking long names vs short names is that often (depending on language), naming is itself a leaky abstraction, because you just know it’s gonna allocate an entire word if you want “int cc_exp = credit_card_expiration; ..cc_exp..”. I don’t think all languages give you aliases for free. We also contort to make things fit 80 characters. Variables can’t have spaces (except Common LISP?), most can’t have dashes, I really want subscripts!—it feels like those password prompts: “5-8 characters, alphanumeric only”. At least we don’t have 8.3 FILENA~1. We learned to name files! (except the pain with spaces, again..) The tools often give naming a hard/constrained time, since it’s somehow never a priority.

                                                                                                      I wish a lot of code were just a little more wasteful/redundant to be a lot more readable.

                                                                                                      1. 1

                                                                                                        Your point about spaces is a bit confusing because on the one hand you complain you can’t have spaces in variables, but then complain about problems with spaces in filenames. I am not sure what you want at this point? Maybe some kind of `variable notation`?

                                                                                                        Another language that allows spaces in variables is SQL. You can have spaces in e.g. table names just fine.

                                                                                                        1. 1

                                                                                                          I want spaces in variable names & filenames. I do tend to use spaces in filenames, but I also forget to quote my “$@” bash variables so it tends to hurt. I think it’s crazy some people (usually programmers..) always_use_underscores.txt to sidestep it altogether. I actually really like SQL in this regard, since you’re right: spaces are ok, and aliases are free (you can even start a column name with a number). I also much prefer spaces in regexes like Perl 6 does right.

                                                                                                    1. 4

                                                                                                      Why do you want a specifically procedural language, particularly as an OCaml user? Why specifically JSON?

                                                                                                      If you’re willing to relax those requirements then e.g. Qt with QML sounds like exactly what you’re asking for: a proper first-class GUI widget library, but with a simple, high-level, language-agnostic interface available for the simple cases, and good integration between the high-level interface and custom widgets when you need that.

                                                                                                      1. 3

                                                                                                        There are even actively maintained OCaml QML bindings, lablqml.

                                                                                                      1. 4

                                                                                                        In your opinion, are fewer names a good or bad thing?

                                                                                                        As someone who used Clojure’s ->> macro a lot and uses |> in OCaml way more than my coworkers I would say… I prefer to have fewer names and only name “standalone” data, not stuff in the middle of being transformed. In Clojure one can prn in the middle of the chain just fine (same as in JavaScript), in OCaml I usually don’t even need to do that since the type system guarantees that my chain type checks and most of the times I’d mess up it is with the shape of the data not its exact values so the type checker catches most issues I might have when building up pipelines.

                                                                                                        I personally also like to shadow names that I expect not to be using in the future to signal to the reader that the previous binding is “dead” and can’t be accidentally used to do the wrong thing.

                                                                                                        So yes, I think fewer names is less things to keep in mind and potentially misuse. Also, naming some intermediate byproducts is yields bizarre, nondescriptive names sometimes, which already signals that whatever you are naming is probably something that doesn’t really need a name.

                                                                                                        1. 11

                                                                                                          Not a language, but a language feature: in Elixir, there’s a capture operator & that will wrap functions in an anonymous function and also can be used to refer to the nth argument of a function. For example:

                                                                                                          add_one = fn x -> x + 1 end
                                                                                                          

                                                                                                          is replaced by

                                                                                                          add_one = &(&1 + 1)
                                                                                                          

                                                                                                          This helps avoid naming arguments unnecessarily.

                                                                                                          Read more

                                                                                                          1. 10

                                                                                                            This is one of the features inspired by Clojure. In Clojure, #(foo %) is short for (fn [x] (foo x))

                                                                                                            1. 2

                                                                                                              You also have %1, %2 etc. in Clojure.

                                                                                                            2. 4

                                                                                                              There’s also the pipe operator |> which passes the result of the expression on the left side as the first argument of the function on the right.

                                                                                                              https://elixirschool.com/en/lessons/basics/pipe-operator/

                                                                                                              1. 1

                                                                                                                Scala also has _, which in _ + 1 is an alias for x => x + 1, or in the case of f(_), is an alias for x => f(x). Oleg Kiselyov has an interesting take on it.

                                                                                                                1. 1

                                                                                                                  I’m not that familiar with Elixir (only having done a few basic distributed algorithms in it), but this feature has piqued my interest even further in the language, thanks for the handy tip!

                                                                                                                1. 21

                                                                                                                  All the stack based ones: Forth, Cat, PostScript, etc

                                                                                                                  1. 2

                                                                                                                    I only recently saw my first example of a stack-based language. My thought was that it seems terribly difficult, as a programmer, to keep in mind what the stack contains at any given point in time. Is that something one gets used to over time?

                                                                                                                    1. 8

                                                                                                                      I found it fun, when learning Forth, to actually work things out using a physical stack of index cards and a pencil. But yeah, you get used to it pretty quick.

                                                                                                                      1. 2

                                                                                                                        In my experience, words rarely cause more than 7 changes to the stack (like, rot pops 3 and pushes them back in a different order, for 6 changes, while dup pops once and pushes the same thing twice for a delta of one change), so if you get used to chunking in terms of only what a word pops and pushes, you can almost treat it like imperative with implicit args.

                                                                                                                      2. 1

                                                                                                                        I think it is difficult at first but once you get used to use combinator words (common in e.g. Factor) that probably becomes just as obvious as using map and fold in functional languages.

                                                                                                                      3. 1

                                                                                                                        Forth may omit variable names, but makes up for it with many word names.

                                                                                                                      1. 17

                                                                                                                        Knowing german, I read this way differently than the title is trying to convey initially.

                                                                                                                        1. 8

                                                                                                                          For the non-german folks here, du is the german personal-pronoun for you so the title reads: Like you but more intuitive :)

                                                                                                                          1. 2

                                                                                                                            It’s a bit more complex than that: German retained the T-V distinction, which means it has two forms of singular second person pronoun, one for people you’re close to and one for people you’re not close to. Sie is the pronoun for people you’re not close to, du is the one for people you are close to. It also has two forms of the second-person plural pronoun, ihr for people you’re close to and, again, Sie for people you’re not close to.

                                                                                                                            1. 2

                                                                                                                              Still it translates to the same and I don’t know of any way to preserve that intent in English.

                                                                                                                              I always thought the du/Sie distinction makes German very formal but it also seems very ingrained in the culture. The distinction was also in Swedish but it disappeared and is so rare in Denmark I can’t remember when I saw it last. Something I couldn’t imagine happening in Germany.

                                                                                                                              1. 3

                                                                                                                                Sweden is such a small country that a reform of this type, made in the heady days of the 60s, got traction very easily.

                                                                                                                                As a bank cashier in the late 80s I’d sometimes refer to customers using “ni” and occasionally get pushback from people of the “68 generation”.

                                                                                                                          2. 5

                                                                                                                            Also “dust” means dork or idiot in Norwegian.