1. 2

    I’ve made UFO in a chat.

    When somebody types one of the dozen special words, like “plane” or “carrot” or “coffee”, with a few added conditions and if it hasn’t been typed chat-wide in the last few hours, then a high quality svg of the thing flies through the screen of all users in the room at the time.

    1. 2

      Lego and snow with the kids. I spent too much time on evenings this week making my nginx log analyzer.

      1. 3

        hjson is buggy, the standard has a “bug” that results in an ambiguity in its representation of certain items (at least when converted from json). I could have sworn I filed a bug on github a few years back when I wrote an automated toml <–> hjson converter in rust (via serde), but I cannot find it now.

        1. 2

          I noticed ambiguities too. I’ve handled them by 1) not allowing free form parsing but only type guided deserialization into Rust types (my crate is named “deser_hjson” and I won’t write a serializer), 2) not allowing quoteless strings in some positions (that’s why I says Hjson is line oriented even if it doesn’t say it). I don’t think Hjson converters are safe, I wouldn’t go that way in Rust even if I used Hjson -> JSON converters in the past in JavaScript and Java.

        1. 9

          I personally enjoy using libucl for config files, and find HCL “ok”.
          hjson looks pretty interesting though! Going to take a deeper look at it.

          1. 4

            UCL looks very interesting, if there’s no trap or ambiguity. The first thing I notice is that you seem to be able to omit the ugly braces around the whole document.

            I might consider creating a Rust deserializer for it… I’ll have to look more at the language.

            I guess my blog post will have to be renamed into “Why broot switched from TOML to Hjson then UCL for its configuration files”…

            1. 2

              FreeBSD has adopted ucl from its core OS configuration files. The interesting thing is that it’s a silently supported format for a lot of files that still use either the old conf format or a subset of ucl that resembles the old conf format. For example, the pkg.conf files can be written in one of two different configuration languages and the default is not ucl, but a completely different ucl syntax is available and automatically detected/supported.

            1. 5

              If there is one thing I wish configuration languages would adopt, its to drop commas all together. Clojure’s EDN format does this and its great. Whitespace is a natural separator for lists.

              1. 3

                i have a config language that i wrote that does that. it converts to json, so for a while i was writing configs with this as a json preprocessor; the moon command converts moon files to json with moon to json; programs would just use the json file. i haven’t used it much recently because it drives other people nuts when you say “hey let’s use this config format that i invented that nobody else has ever seen”. https://github.com/jordanorelli/moon

                1. 1

                  A project with 30 stars isn’t really unknown. It looks like a good configuration language at first glance.

                  It would be interesting to have a precise comparison of the differences with what looks like the nearest one: Hjson.

                2. 2

                  Hjson lets you totally drop commas if you want. There’s none in my example.

                1. 6

                  Correct me if I’m wrong, but it seems hjson suffers from some of the same bugs that yaml has around type ambiguity. Primarily, in formats where unquoted strings are allowed a human may write 1000 in a field which is supposed to be a string, and they’ll get a number.

                  1. 9

                    The main problem with YAML used as a configuration format written by human isn’t that true isn’t interpreted as a string, because you expect it. The real problem in my opinion is those weird rules which makes for example off be interpreted as a boolean. It’s so random most people don’t know it (see the “Norway problem” ( https://hitchdev.com/strictyaml/why/implicit-typing-removed/ ) too). Hjson doesn’t have the same level of insanity (true is only true, not On nor YES or yes).

                    So I think this problem, for Hjson, isn’t really a problem. Or a small one.

                    Now, I said, perhaps in a cryptic way, that even the weird rules of YAML “may matter or not”. Because there’s absolutely no problem here if you use Hjson (or YAML) the way I do.

                    The reason is that the best way to deserialize a configuration, in my opinion, isn’t to use the automatically guessed type but to deserialize into the type required by the strongly typed structure.

                    And that’s the only public API I’ve put in my deserializer: you can’t use my Hjson deserializer ( https://github.com/Canop/deser-hjson) to read a free form file, you can only use it to deserialize into a Rust type, precisely to avoid the dangers related to type ambiguity. If the human typed 1000 in a field which is expected in Rust to be a string, it will be read as a string.

                    1. 3

                      Agreed; deserializing into typed data structures really does make most of the issues with YAML go away in my experience. The other thing that helps when I’m writing YAML to configure code I didn’t write is to always wrap string values in quotes. Yes, it adds a little noise, but it is a pretty easy habit to pick up and then all the “what type is this value, anyway?” problems with YAML become irrelevant. The added noise of quoted strings isn’t too bothersome to me, though that’s obviously subjective.

                      1. 2

                        Ah, yes, forcing deserialization to a datatype is a good way to deal with this, vs having some general HJson type and making an arbitrary decision about the types of fields. That said, I still find syntactic ambiguities like this one to be a major downside of these human readable formats.

                    1. 4

                      What the user wanted here, when adding the last prop, was to set a top level property.

                      But what really happens is that the property is added to the second item of the "chars" array.

                      I have a hard time believing that anyone who has ever written or modified an INI file would be confused about this. Considering that this is the only illustrated criticism of TOML in this entire post, I’m puzzled as to why this person switched away from TOML.

                      Now, I understand what they mean when they call the language alien and confusing. But so are YAML, XML, etc. when you first encounter them, it’s just that people are accustomed to these decades old languages. Is it possible to create a configuration language that is intuitive to inexperienced newcomers and covers all the use-cases of TOML? Time will tell.

                      1. 5

                        The problem isn’t with the software author. Being the author of broot, I wouldn’t have to change the format if I was the sole user. The problem is when people stop trying to configure your software because the changes they do have no effect.

                        Adding a line to a configuration file is something that linux users do all the time.

                        People who’ve been told that to achieve an effect they would have to add this line in their config.toml file won’t read the whole file to scan whether there’s a better location, they’re used to add it at the end as they do for example in their .bashrc file. Of course, coming back later they would probably try to organize everything but they won’t because their first reaction is that there’s a bug in the application since the added line did nothing.

                        I don’t pretend that TOML is bad for everything but that such confusion makes it unsuitable for many programs as it has proven to be for broot.

                        1. 4

                          I see. I wish you went into more detail about this in the blog post because it’s a good point.

                          I think the solution here is not to use the global scope at all in an INI/TOML file, such that it’s always clear what section an attribute belongs to. In addition, your application could throw warnings or even errors if unknown keys are detected (careful with backwards compatibility, though), or it could print the configuration back to the user so that they can check if everything is configured properly. It could also offer a dry run of configuration parsing.

                          Interestingly, I noticed that many Linux utilities have this configuration problem, and many just “swallow” any nonsensical configuration and exhibit default behaviour, something that has often cost me a lot of time. It’s even worse if they use their own configuration language that is often fraught with parser ambiguities and problems. It’s good to see developers like you caring about how users interact with the configuration file.

                          1. 2

                            Thanks, I’m editing my blog post to take this into account, and try to make it clearer.

                            1. 1

                              I think the solution here is not to use the global scope at all in an INI/TOML file

                              That seems the obvious solution to me as well, if this single confusion that users have is the only issue with the format. Generally speaking, I also think this is better than this proliferation of almost-but-not-quite JSON formats, each with their own “conveniences” added that might cause more confusion. Especially the unquoted string values and possibly the implicit comma on newline seem like footguns in disguise.

                              Comments, optional trailing commas and unquoted string keys seem like much more obvious advantages to me. Especially considering unquoted keys don’t have the ambiguity of “should the key be evaluated?” (which JS actually never does, but for example Python does) and “is this key a reserved JavaScript keyword?” like in JavaScript. But then, if you drop that it’s technically not eval() able anymore in a JS interpreter, which was arguably JSON’s biggest “advantage” (with all the security problems that entailed).

                        1. 5

                          It’s fascinating to me that there’s so much diversity in config formats. Maybe it’s just that everyone needs one and they’re easy to quibble with.

                          That said, I like that HJSON explicitly aims “to be used like a user interface for humans, to read and edit before passing the JSON data to the machine.” This seems similar to Strict YAML, which also focuses on giving humans a low-surprise way to define data structures that computers will eventually treat like JSON.

                          I would consider using HJSON over Strict YAML next time I need a config.

                          1. 4

                            I don’t think there so much diversity. There’s less than a dozen common configuration formats, none of them really good (writing a deserializer for Hjson made me more aware of its shortcomings, especially for the quoteless strings and its indecisiveness regarding whether it’s a line oriented format or not).

                            I didn’t know about Strict YAML. It’s interesting and I’ll probably amend the document to mention it.

                            1. 4

                              I personally would also be interested in comparision between various human readable JSONs. There are at least:

                              1. 2

                                In my opinion, Json5, which I do use, is a better JSON, but while it’s suited for data exchange it’s behind Hjson for configuration (which wasn’t probably the main goal). It especially still asks for commas and doesn’t solve the indentation problem for multiline strings.

                                Rome-json (which I didn’t know) seems to be an intermediate between JSON and Hjson.

                                edit: I’ll edit my blog post to link to those alternatives

                            2. 1

                              I don’t think it’s that many, when being compared to programming languages, image formats, etc. I also wouldn’t call all of these config format, in the sense that they were made to be mostly written by humans. JSON (and to a degree YAML) is a human readable data serialization format, and in many situations is generated vs. hand written. UCL/HCL and TOML are way more frequently touched manually.

                              Of course that doesn’t mean you cannot/should under no circumstances use other formats. I think they are tools to choose from and while I would agree there is a lot of “someone trying their own thing” projects, the same is again true for programming languages and many other formats.

                              It’s also a good thing that people experiment. In the majority projects you will still end up with a hand full of variation. So I think it’s more that people are interested in this topic and there is a lot of talk about it.

                            1. 4

                              You make a really good case about why Hugo is failing it’s users here, but I’m concerned that you may one day be saying the same about Zola. One thing that comes to mind is missing features. For example, you might decide that you want to be able to add footnotes, but CommonMark doesn’t have that functionality. Because Zola has no extensibility, you’re SOL as far as I can tell. I also have a suspicion that people might start to use themes as a way to emulate plugins. Something like the difficulty of adding graph tags that you talked about could maybe be solved like that. But then it’s getting into the danger zone of finding documentation in multiple places and having to magically override things again. I think that KayodeLycaon was spot on in pointing out that everyone wants something slightly different. I hope Zola works out for you :)

                              1. 3

                                Yep, the concerns are valid. I don’t have a really good reply to that, but I hope this works out. Ultimately if this required another refactor then I’ll bite the bullet to make my own SSG. Not thinking too much about that situation now, though :)

                                1. 3

                                  I also have a suspicion that people might start to use themes as a way to emulate plugins.

                                  You said something I had trouble articulating for a long time. The problem with a Turing-complete template processor as a sole extensibility mechanism is that presentation and logic are no longer orthogonal.

                                  That is why I chose not to use either Zola or Hugo for a refresh of my own site setup, but went for writing an SSG that is statically linked but extensible with Lua plugins via an embedded interpreter. </shamelessPlug> ;)

                                  Nothing against Zola or its users though, it’s a good project.

                                  1. 2

                                    Just as a small note, Zola totally does footnotes. I think there might be a page that lists which extensions pulldown-cmark enables out of the box. But your main point stands with or without this example :)

                                    1. 1

                                      As a Zola user who used several other solutions before, I’m 100% sure I’ll get tired of it. I already had to hack around limitations (or my lack of knowledge) while my blog is super simple. But it’s all about gaining some time.

                                      I know that at some point I’ll have to do the switch to either another existing system or to one I’ll make. But I don’t spend time on that now and having a blog whose content is only in markdown and related images will make it easy if I decide to keep the content.

                                      Zola is temporary but it’s easy to set up, and should be easy enough to replace when time has come.

                                    1. 2

                                      Apart the tools I built myself, I quite like the set of commands of scm_breeze which shortens a lot of git commands and give aliases like $e1 to the files listed in git status.

                                      1. 2

                                        I love scm_breeze, but I have to go pretty far out of my way to get it to respect the XDG_BASE_DIR spec and to disable a bunch of it’s non-git wrappers. I mainly use this replacement entrypoint script: https://github.com/sethwoodworth/devenv-setup/blob/master/patches/scm_breeze.sh

                                      1. 35

                                        There’s really a problem with this blog post. I don’t know how it’s technically done but having to wait several seconds every time you display the tab is why almost nobody will read it.

                                        1. 20

                                          It is actually super-high-level web development. Kudos to @tedu for pulling it off.

                                          Pages are progressively enhanced using JavaScript if it is available. If it isn’t, users can still read the page. If JS is available, then UX is enhanced with a realtime loading indicator, much like the ten-pixel-bars top bars that are on many pages.

                                          After all, in this Third Age of JavaScript, we cannot simply trust the browser to render the page. We need to tell the user the progress of that.

                                          1. 14
                                            var delay = 100
                                            switch (progress) {
                                            	case 70:
                                            	case 73:
                                            	case 76:
                                            		delay = 250
                                            		progress += 3
                                            		break
                                            	case 79:
                                            		delay = 500
                                            		progress += 2
                                            		break
                                            	case 81:
                                            		progress += 14
                                            		break
                                            	default:
                                            		progress += 5
                                            		break
                                            }
                                            

                                            I have to give props for verisimilitude. And for teaching me where to find uBlock Origin’s “disable javascript on this page” function.

                                            1. 10

                                              I wouldn’t be surprised if @tedu spent a good twenty minutes fine tuning that for maximum annoyingness.

                                              1. 2

                                                You have more patience than me. It taught me where to find uBlock Origin’s domain-level blocklist.

                                              2. 9

                                                I’m sorta ok with progressive enhancement. What ground my gears was that it triggered every time the window (Chrome on Windows) regained focus. It made it really hard to find my place again in a page with lots of code.

                                                1. 19

                                                  I mean, just so we’re all clear, it’s something between a joke and a protest statement, and what you’re complaining about is entirely the deliberate point: it’s a perfectly fine, instantly rendering webpage that’s being “progressively dehanced” by the presence of annoying JS.

                                                  1. 4

                                                    Wow… kids these days 😒

                                                2. 5

                                                  Yeah, I love it. This “protest” is a nice compromise in comparison to sth like “Disable JS to enter the page”. It is annoying but still usable.

                                                3. 12

                                                  The site loads almost instantaneously. Just disable JavaScript ;-)

                                                  1. 11

                                                    What’s really weird is all the markup appears to be there, and the loading is just for…giggles?

                                                    1. 22

                                                      That sounds like something @tedu would do.

                                                    2. 2

                                                      Well, @tedu also had a period with a self-signed certificate, the horror!

                                                      1. 2

                                                        When you have a self-signed certificate, you are expected to trust it on first use, and then the web browser remember it.

                                                        If the web browser remember the certificate of a website, noone, including a MitM possessing the key of a certificate trusted by your web browser, noone can tamper the connection anymore.

                                                        So you suddenly jump from a situation that looks suspicious security-wise, to one that can face the NSA kind of attack vector.

                                                        Of course, in the case of a MitM situation, your “accepted security exception” situation (self signed but trusted manually) would turn into a “green padlock” (certificate signed by the MitM) situation, and I doubt many will choose the “padlock with yellow cross” over the “padlock with green check mark”, even if icons barely have any accurate meaning on their own…

                                                        Simply wandering on an off-topic… Not actually meaning that Cloudflare should switch to self-signed right now… Oh, wait, Cloudflare are self-signing, they are their own trusted certificate authority…

                                                      2. 2

                                                        Just use links? ;)

                                                      1. 4

                                                        Canonical is taking risks by forcing snap onto his users. Two weeks ago, when an automatic chromium upgrade told me that chromium would switch to snap on my computer, didn’t let me the choice to refuse the new installation, and basically broke apt until I accept, I decided to change distribution. The reason I’m not on Ubuntu anymore and probably won’t be back is only this one: I don’t want to have such change forced on me. This isn’t the linux way.

                                                        1. 5

                                                          There are browsers for which !("a" == "a"[0]) evaluates to true ? How ? Which ones ?

                                                          1. 13

                                                            To answer how:

                                                            Accessing characters like "a"[0] was only added in ES5, originally you had to use "a".charAt(0).

                                                            If a browser does not support this way of accessing characters "a"[0] will be interpreted as trying to access a property with the name ‘0’ which does not exist on a string so it will evaluate to undefined.

                                                            To answer which ones:

                                                            Mostly older browsers that do not fully support ES5, I think IE took a really long time to support it.

                                                            1. 2

                                                              Thanks, I didn’t remember about the bracket access being added in ES5.

                                                          1. 42

                                                            Why are these kinds of articles almost always predicated on the authors being completely unaware of Option/Result types?

                                                            It’s the old “beating down the exception strawman” – that no one is even interested in defending.

                                                            (I wonder what happens to all these similar articles when Go gets generics and people start using Option/Result types?)

                                                            1. 16

                                                              The author does give lip service to Option/Result types:

                                                              EDIT: Exceptions are definitely not the only way other languages deal with errors. Rust, for example, has a good compromise of using option types and pattern matching to find error conditions, leveraging some nice syntactic sugar to achieve similar results.

                                                              But in a way that suggests they’re something he’s heard of, rather than personally used. If you’re already used to working with ADTs that contain errors, I can’t imagine finding Go’s system of basically mandatory 2-tuple return types for all error-prone functions to be ergonomic.

                                                              1. 12

                                                                Agreed. Plus all the fun in figuring out whether you actually need to handle the value and error case, because the signature doesn’t tell.

                                                              2. 8

                                                                As someone who was an adamant gopher for like 7 years. Rust’s Option and Result types changed the way I see programming, especially once I fully grokked that Result is basically a monad.

                                                                1. 4

                                                                  Same, although I had that realization when encountering the equivalents of those types in Haskell, rather than Rust. A lot of what I like about Rust is that it’s a mainstream language (more mainstream than Haskell in any case) that lets you easily define and use ADTs.

                                                                2. 12

                                                                  It’s the old “beating down the exception strawman” – that no one is even interested in defending.

                                                                  I dunno, having used Go as my main development language for eight years now, I encounter people defending exceptions far, far more often than people advocating for option types.

                                                                  1. 5

                                                                    Isn’t it that, at this point in time, most people familiar with option types for errors are developing in Rust and not really in the Go world anymore ?

                                                                    Somebody coming from a language with exceptions to Go might say he prefers his old way. And there probably aren’t, today, many people coming from Rust to Go.

                                                                    1. 7

                                                                      sure, I think there aren’t many people coming from Rust to Go, that’s … kinda my point? soc is mad that the article is not written specifically for him, and is instead written for an audience that is more representative of who the author is actually encountering. The idea that exceptions are a straw-man nobody is defending is … honestly a little ridiculous. People defend exceptions all the time. The majority of programmers work in JS, Python, Java, C#, and PHP, all of which have error-handling semantics built around exceptions. A lot of those programmers really do make arguments defending exceptions. Few of them read lobste.rs for recreation. And you know, the few that DO read lobste.rs for recreation need articles like this to learn about things they haven’t encountered yet.

                                                                      I also find it so hilarious that someone flagged my prior comment as “incorrect”. I described my lived experience and someone flagged it as “incorrect”. lol

                                                                      In reality, most people just code because it’s a job. This article is not written for people looking to find self-actualization in a type system.

                                                                      1. 3

                                                                        I also find it so hilarious that someone flagged my prior comment as “incorrect”. I described my lived experience and someone flagged it as “incorrect”. lol

                                                                        Looks like all my comments on this thread have received at least one flag.

                                                                        I don’t know what it is about Go that induces such rage in some people, it’s completely fine (even reasonable!) to not like Go, but Go threads have a tendency to turn in to dumpster fires in a way that I don’t see in other languages (including PHP and JavaScript).

                                                                        1. 1

                                                                          I don’t know what it is about Go that induces such rage in some people

                                                                          classism.

                                                                    2. -10

                                                                      I’d assume that people with higher language quality standards usually don’t intermingle with Go devs.

                                                                      Communicating with Go devs certainly forced me to reevaluate the minimal amount of knowledge I assumed to be absolutely necessary to be a functioning programmer.

                                                                      1. 16

                                                                        Communicating with Go devs certainly forced me to reevaluate the minimal amount of knowledge I assumed to be absolutely necessary to be a functioning programmer.

                                                                        Dude, what the fuck? This has no place here.

                                                                        1. -4

                                                                          I don’t think you need to get emotional over this.

                                                                          I reported my experience, just like other people have in this thread.

                                                                          1. 1

                                                                            I did not downvote your comment, because I did not get emotional over it. What happened here I think is that people read “Go devs” and instinctually took your rather laconic criticism of the technology to be criticism of the members (i.e., themselves) belonging to the said group.

                                                                            It is easy to become a target of put-down by aggravated members of any group if you are not vigilant with your words.

                                                                        2. 5

                                                                          “Enable fresh graduates to contribute effectively” was a core design goal for the language.

                                                                          It’s not surprising, then, that there’s no shortage of beginners to be found there.

                                                                          1. 4

                                                                            In my experience/interactions there are actually comparatively few new programmings in Go; much of the documentation and resources also tend to be aimed more at people who already know how to program in another language, I’ve seen quite a few people complain about the lack of entry-level jobs, the community is not always very welcome to beginners, etc. Generally speaking, I wouldn’t recommend it as a first language.

                                                                            This is just my subjective impression; I don’t have any numbers to back this up and could be wrong.

                                                                          2. 5

                                                                            The Rob Pike quote (which seems to have come from this talk: https://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2014/From-Parallel-to-Concurrent ) was:

                                                                            “The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.”

                                                                            And this left a bad taste in my mouth when I read it originally. Either Rob Pike is right about the sorts of people he needed to optimize for when creating Go, implying that Google hires fresh out of college aren’t skilled enough programmers to deal with things like ADTs; or Rob Pike was wrong about who he was optimizing for and made a language that deliberately limits the tools you have to write correct and concise software because he mistakenly thought those tools were too hard for people to use.

                                                                            1. 5

                                                                              Agreed.

                                                                              It really feels like Go creators think nothing of value was invented/discovered since they left Bell labs.

                                                                              Also, using one of their team members as the language mascot is kinda weird.

                                                                              1. 5

                                                                                Also, using one of their team members as the language mascot is kinda weird.

                                                                                Huh? The Go Gopher was based on one of their team members?

                                                                              2. 3

                                                                                the fact that you find that quote upsetting is rooted in either class dysphoria or class chauvinism. One can only find that statement upsetting under one of the following two conditions:

                                                                                • class chauvinism: you think that programming should be reserved for an intellectual elite, and that opening programming to the labor class is a form of class betrayal by an intellectual elite. What you reject is not the design or implementation of Go itself, but the goals that the Go team has laid out when attempting to create the language. That is, the frustration is with the very goal of creating a programming language that can be used by the unwashed masses because programming should be reserved for the privileged.

                                                                                • class dysphoria: you reject the idea that the majority of software is written by a labor class, and that you are a member of that labor class. You are upset by the phrase “to use them to build good software”. This is only upsetting to you if you don’t accept your position that as a person selling their labor to make a living, your employer is interested in leveraging your labor to serve a business goal, and not because you are in some way special beyond the output of your labor. A person that digs holes for a living would not be bothered by the phrase “to use them to dig a hole”, because they understand the nature of the exchange being made; they understand that they are being used to accomplish somebody else’s goal in exchange for cash.

                                                                                Both of these cases are rooted in hatred of the labor class, because both of these cases are rooted in the idea that members of a laboring class are without dignity. If you are a member of a labor class with an awareness of the fact that you are a member of the labor class and you feel solidarity with the laboring class, Go’s goals seem perfectly reasonable. I like Go because I think it helps me perform my role as a laborer creating software as part of a collective effort. As a manager and team lead, I enjoy that it makes onboarding programmers to a new codebase very easy, and that it makes it easy for my developers to write mutually-intelligible code.

                                                                                If I were rich, I would not write Go for myself for enjoyment unless I was doing so expressly with the goal to turn what I was building into a business, and for the code to be passed on to future wage-earning programmers. Go is not, from my perspective as a person who has been writing Go since 2011, a great tool for writing beautiful, expressive poetry; it is a great tool for building information-processing machines that will actually be used.

                                                                                Go is designed by a corporation to pursue the goals of that corporation. It says as much on the tin. It is hard to argue that Go is unsuccessful at its own goals of being a programming language with which a large labor class can construct stable software. Go is tremendously successful at fulfilling those goals, and its success causes one to deal with issues of socioeconomic class. If you have never thought about class, this can be disturbing, as it lays naked the reality of classism in society, and one’s place within that system.

                                                                                1. 9

                                                                                  I don’t like Go because it was designed for the average programmer or a contempt of them, I don’t like it because it’s a paternalistic and reactionary language that assumes the average programmer is too stupid to handle after anything that wasn’t status quo in 1995.

                                                                                  The average programmer might not have a CS degree, but you don’t need a CS degree to have sum types and pattern matching make error handling less error prone, making their lives (and everyone else’s) easier. Go rejects this premise, because worse is better and Bell Labs got it right - dooming us all to deal with the sharp edges we keep getting cut on.

                                                                                  1. 0

                                                                                    “I’m too smart to program with something that dumb people can program with”

                                                                                    1. 9

                                                                                      It’s not a matter of elitism, it’s a matter of being a dumb person (I’ll admit this - a lot in CS makes my eyes glaze over, I see so many people that are smarter than me), I want smart tools to help me be a more productive programmer, instead of struggling with common mistakes or writing menial boilerplate. I hate that there’s so many new ideas on the horizon, but they remain out of touch in the distance to the average programmer. As an industry, we should be bringing making new ideas and tools more accessible, instead of worshipping what has been already done poorly.

                                                                                      I’m smart enough to know we could have things so much better, but not smart enough to do it by myself.

                                                                                      1. 3

                                                                                        I hate that there’s so many new ideas on the horizon, but they remain out of touch in the distance to the average programmer.

                                                                                        I dunno, that doesn’t really resonate with me all that much because I don’t feel like anyone is discouraging me from learning those things. You can use Rust or Haskell or Lisp or whatever, all of that stuff is freely available to you. Nobody is creating barriers to using or exploring those things.

                                                                                        As an industry, we should be bringing making new ideas and tools more accessible, instead of worshipping what has been already done poorly.

                                                                                        On the one hand, I sorta think that’s what Go does. Structural typing, CSP, and getting rid of exceptions are pretty major changes from the C++/Java/C# model. Go was designed specifically to deprecate C++ and Java at Google. Go is just supposed to be a better Java. It really seems to succeed at that.

                                                                                        On the other hand, I think you’ve twice conflated “new ideas” with “good ideas”. A lot of new ideas are actually bad ideas. Inheritance was a new idea once. Turns out it’s bad. Go isn’t trying to have a lot of ideas or a lot of new ideas.

                                                                                        As for sum types specifically (which is both a good idea and an old idea): if you look at the long arc of the language, one of the driving principles is orthogonality. Each part of the language is expected to have as little overlap as possible with the other existing parts of the language. There is a large surface area of overlap between sum types with pattern matching and interface types with type switching. I’m not saying those are the same things; they are not the same things. Add sum types, cool! They’re useful! But you now have two mechanisms for looking at a value and switching on its type that can be checked at compile time. The design philosophy of Go attempts to reduce instances where different aspects of the language have that much overlap. A major thing that pattern matching does is enforce that the match be exhaustive, and the fact that type switches aren’t exhaustive is a huge source of sneaky and annoying bugs. Type switches will never be exhaustive because, for example, the number of possible types implementing interface{} is innumerable. As it turns out, this is a huge bummer both in theory and in practice.

                                                                                        I’ve been programming Go since r59; before Go 1.0. The discussion about sum types has been around since then. The open proposal to add sum types to the language has many links to past discussions. https://github.com/golang/go/issues/19412

                                                                                        Practically speaking, there is exactly one place where I really wish I could say (T | error), and that’s when managing unreliable procedures over channels. If you have to fan out an operation to N goroutines, but that operation can fail such that you collect all the errors and all the values on a single channel, you wind up having to create an ad-hoc product type every time you do that for the channel, and that’s really damned annoying.

                                                                                        1. 5

                                                                                          It’s sad that this kind of insightful comment is buried under a comment that’s flagged to invisibility…

                                                                                          1. 2

                                                                                            it also got flagged lol

                                                                                    2. 1

                                                                                      This sounds reasonable, and I completely understand this perspective.

                                                                                      As a counter-point, I rather like this approach as it allows me to focus on what I’m doing and not the language; I’ve rather taken a liking to the “dumb” approach in Go (Stockholm syndrome? Perhaps 🙃)

                                                                                      I’ve also programmed a lot with Ruby in the past, and even after several years there were still corner cases and surprises in the language. Don’t get me wrong, I still like Ruby (actually, I miss programming in Ruby, it’s a fun language) but that approach does come with some downsides. Perhaps Go will be “obsolete” in 10 or 20 years when newer languages such as Rust, Zig, or some other have matured and stabilized a bit more (although I’m not sure if I will ever truly like Rust, since some design elements don’t particularly jibe with me, but I’d have to program more in it to be sure).

                                                                                  2. 2

                                                                                    Go is a language designed for software engineering in the large. At scale, there are no good or bad programmers, there are only average programmers, by definition. So it’s appropriate for a language to cater to that invariant. If you’re not programming at scale this design decision makes less sense for you and that’s fine, one tool doesn’t need to be all things to all people.

                                                                                    1. 1

                                                                                      -1 incorrect

                                                                                      I’m pretty sure I’ve attracted my first Hater! Boggles the mind.

                                                                                    2. 1

                                                                                      What alternative do you think is worse?

                                                                                      I think the first one is the correct one, and Pike and the team that created Go knew exactly what kind of language that Google needed - seeing as they worked there, and presumably had talked to a number of stakeholders in the company.

                                                                                      “FizzBuzz” is a meme for a reason. A lot of people with CS degrees literally cannot program. Presumably Google is big enough and prestigious enough to filter those out, but that doesn’t mean the rest is automatically fluent in Haskell or something.

                                                                                    3. 4

                                                                                      yes all programming languages exist on a single dimension of performance called “quality”, that’s definitely how the industry works 👍

                                                                                  3. 6

                                                                                    It’s the old “beating down the exception strawman” – that no one is even interested in defending.

                                                                                    It’s not a straw man when a large percentage of competing languages actually do use exceptions. There are very few mainstream languages that use Option/Result types. Actually, I think Swift might be the only one? And maybe Rust, but I’d argue that’s probably not a mainstream language, not yet anyway.

                                                                                    1. 9

                                                                                      Isn’t it a problem in Go culture that it is content in comparing itself with mainstream languages from an earlier century instead of actively investigating what can be done in contemporary non-mainstream languages?

                                                                                      This attitude often leads to solving the wrong problem.

                                                                                      1. 3

                                                                                        That sounds about right. Go is not designed to break any new ground in computer science or language design, but rather to implement concepts that have been proven to work in various languages and are well understood. I think there is value in this: it gives a stable, reliable, and boring language, which may not be optimal in all respects, but it doesn’t have a lot of “sharp edges” and idiomatic Go code from 10 years ago is quite similar to Go code today. Especially if you want to write an application intended to be maintained for a long period of time (>10 years) then the Go approach can give you some good advantages, I think.

                                                                                        I think there’s a lot of value in the more experimental approach in e.g. Rust too, by the way. Not all languages need to be the same.

                                                                                        Either way, I personally wouldn’t call this a “problem”, just a design ethic.

                                                                                        1. 6

                                                                                          That sounds about right. Go is not designed to break any new ground in computer science or language design, but rather to implement concepts that have been proven to work in various languages and are well understood.

                                                                                          Haskell and OCaml have both been around since the 90s, and those are just the two most obvious examples I could come up with of languages that have been used a fair amount in production and which also provide ADTs. So I’m not sure how your assertion makes sense.

                                                                                          1. 9

                                                                                            Seconded. The “experimental” part of Rust is the borrow checker, the rest (a bit of type inference, sum types/enums, match) is extremely well known and robust stuff that has been around for > 40 years. Go ignores a lot of well known things, not just new ground.

                                                                                            1. 2

                                                                                              And both are also functional programming languages that most people struggle with and see quite little real-world use in the industry.

                                                                                              1. 2

                                                                                                Both languages are used extensively in production and have been for a long time, regardless of how their usage compares to C or Java or what-have-you. And ADTs are quite well understood at this point, and Maybe/Option types specifically even moreso; we’re not talking about these languages’ learning curves here. Maybe/Option has been introduced (badly) into Java, for example, and is present in Kotlin, Scala, Rust, etc. So I don’t see how your comment here contradicts my original point.

                                                                                                1. 2

                                                                                                  We could argue at length on what is and isn’t “well understood” and “widely used”; but it’s not a binary thing, it’s a scale. And it’s also not completely objective either and there is quite some subjectivity involved.

                                                                                                  Go has a very conservative take, which certainly isn’t perfect and you do miss out on some things, but as mentioned I think there is value in this approach too. YMMV.

                                                                                        2. 0

                                                                                          I don’t really feel like defending the 90ies poor error handling approach against a language from the 60ies. ¯\_(ツ)_/¯

                                                                                          The people who care have moved on from such inferior approaches, and those who are still stuck in the last century can’t be helped anyway.

                                                                                      1. 2

                                                                                        The article mentions a few old alternatives but not the more recent Zola which is very similar to Hugo but might have a more approachable templating language.

                                                                                        1. 5

                                                                                          The home page is clear on how smaller the files are but I’d like to see more about the costs (cpu, memory, code size) of encoding and decoding. Is there an article about that ? Does someone here have some answers ?

                                                                                          1. 4

                                                                                            Sounds pretty nice, but how well is this format supported?

                                                                                            1. 3

                                                                                              About not at all. No browser and no major tool apart ImageMagick.

                                                                                            1. 3

                                                                                              I’m trying for the 3rd time to learn Rust with the klabnik book and exercism.io’s exercises, and well, I really suck at it. Is it me or this language is really more difficult that it should be? My main languages are C, golang, php, python usually… I’m starting to believe I’m too old for learning.

                                                                                              1. 2

                                                                                                Is it me or this language is really more difficult that it should be?

                                                                                                More difficult that it should be is hard to answer. Some other attempts at new languages try to aim for easier to use concepts also ensuring the same safety but right now only rust can bring you both safety and performances.

                                                                                                Difficult ? Yes it is, especially if you learn rust at evenings while you spend your days on easier languages. But I think it’s worth it. If it’s any consolation: most developers found it really hard to learn until, progressively, it started to fall in place.

                                                                                                Suggestion: You should maybe start to use it without bothering learning it ? That’s what I did and I found it easier to learn by practicing and being corrected by the compiler (more usually the borrow checher).

                                                                                                1. 2

                                                                                                  I had that same feeling of “Is it me or this language is really more difficult that it should be?” when I tried to learn Rust a few years ago. I see why a lot of people enjoy the language, but it wasn’t my cup of tea.

                                                                                                  1. 2

                                                                                                    Unfortunately it seems to take most people at least one time bouncing off of it, sometimes several as you have experienced… Rust’s type system borrows a lot of ideas from OCaml/F#, which are a pretty big change in the way of doing things from the language you’ve listed, so that might be one level of adjustment to get used to already. Then, between the type system, borrow checker, traits, iterators, generics, and so on there’s a lot of stuff going on in Rust, and most of it gets hidden by the type inference so that you don’t have to constantly bump into it. If you already know how it works.

                                                                                                    What worked for me was two things: first, start by writing a program way simpler than you think you can handle; for me it was just Conway’s Life. Second, get in one of the various chat rooms of one kind or another, find the beginners channel, and ask for help as much as possible. A lot of Rust’s complexity is optional, but things like the standard library use a lot of it, so it’s common for new people to feel like they have to overdesign things.

                                                                                                    1. 1

                                                                                                      I’ve been learning Rust too with the main book for about a month and a half, and it is a doozy. I have been doing every example in every chapter and tweaking to make sure I understand. That has helped. I started a project In Rust but I am realizing the value of working through the whole book, so I put that on hold for now.

                                                                                                      1. 1

                                                                                                        I also tried, and “bounced” (even though I know many languages, and was very good at C++ some time ago). I tried the “start using it and learn as I go” approach, but got overwhelmed by nuance and kinda betrayed when trying to rely on error message hints, which showed up to be occasionally not working or self-contradictory (“You are doing A; maybe try B instead?”, then after doing B: “You are doing B; maybe try A instead?”). However I hope to try revisiting it in future, maybe more than once. I can’t count how many times I bounced off learning vim, but when I finally had to, I went on to love it. So, keeping fingers crossed for you!!!

                                                                                                        Also, one tutorial I found recently that I want to read, maybe you also will find it interesting, is about writing a roguelike game in Rust.

                                                                                                      1. 8

                                                                                                        I didn’t understand the problem. Could someone explain?

                                                                                                        1. 4

                                                                                                          The problem is that some command line tools, like RipGrep, can have you typing out a command that is over 200 characters long. Having a small wrapper script for that can enable a lot of small gains, both in documenting how to use the tool, and making it less painful access more involved command parameters, since you don’t have to type them out so many times.

                                                                                                          This is a small productivity tip, not an earthshattering one, though I do find it moves some tools from “I use this occasionally” to “I can use this a lot more often”

                                                                                                          1. 1

                                                                                                            I still don’t get it. Competent shells support completion and some, like zsh, do fuzzy completion. It would be silly to manually type out 200 characters for a single command. You seem to be using windows though, so maybe this post is better tagged ‘windows’?

                                                                                                            1. 12

                                                                                                              No, I don’t think it’s specific to Windows (other than the fact that they are using batch scripts as their medium). Or 1995, for that matter, as another commenter cheekily suggested. I do this kind of thing all the time despite the fact that I use a “competent” shell (zsh with auto completions enabled). For example, just recently, I was hunting around trying to figure out how to grab an mp3 off a video off of YouTube. I do this very occasionally, so the command isn’t something I keep in my memory. So I just wrote youtube-dl-mp3.

                                                                                                              #!/bin/sh
                                                                                                              
                                                                                                              exec youtube-dl --extract-audio --audio-format mp3 "$@"
                                                                                                              

                                                                                                              The name means I’m likely to discover it when tab completing youtube-.

                                                                                                              1. 5

                                                                                                                Same for me. Shells make it easy to write small scripts that you can keep around like bookmarks. There’s no shame in finding it easier to remember/type the name of a short script you wrote for your need rather than remembering how a program works, even if it’s a well designed one.

                                                                                                                1. 3

                                                                                                                  Now that I’ve picked it up as a pattern, I’d be more than keen on doing something similar on Linux when it makes sense to do so.

                                                                                                                  1. 2

                                                                                                                    I tend to do the same, except I keep these short scripts/commands in my notes rather than as standalone executable files (unless I need it often).

                                                                                                                    1. 1

                                                                                                                      Speaking of “competent” shells, fish has abbreviations, so (e.g. in its example) gco can expand to git checkout. And functions and aliases (which also understand completion for the aliased command!) can be saved on-disk automatically. Fuzzy search also gives you the ability to just type mp3 and hit the up arrow until you get to this command in history.

                                                                                                                      Not to say “my favorite shell is better” - presumably zsh and other friends can do all of this too - just wanted to add other ways of doing this, for interested comment-readers.

                                                                                                                      1. 1

                                                                                                                        Nice yeah. If I’m understanding correctly, I believe my shell (zsh) has all of that too. Although it had to be configured. But it wasn’t too hard. Took about a day to set everything up.

                                                                                                                    2. 3

                                                                                                                      This isn’t a Windows problem as much as a problem with people using cmd. It’s an antiquated shell that was never good to begin with. Now they refuse to use a modern shell like PowerShell. A more fitting tag would be “historical” and to reframe the article as “how we would do this we were in 1995”.

                                                                                                                      1. 4

                                                                                                                        It may sound funny to you, but I’ve actually started to warm up to using CMD a lot more. I’ve more or less had to use it, and batch scripts, at my current job, since we inherited a lot of code that uses batch scripts. One thing I like about CMD is is that it manages to be very low latency on Windows, where both PowerShell and mingw have a lot more latency around starting processes.

                                                                                                                        I realize this is a very different story on Linux and co, and there I usually end up using an alias or the like. But between this and and a jumplist, it makes working with CMD a whole lot less painful.

                                                                                                                        1. 1

                                                                                                                          Inheriting a lot of code is a valid reason to use the language, but I would still attempt to migrate to PowerShell if possible in that case as CMD is notorious for arcane incantations to accomplish things. It’s much easier to understand the program flow using PowerShell.

                                                                                                                          Regarding the startup time of PowerShell; I agree. It’s way too long to spin up a process when needed, but I just keep a terminal open at all times using ConEmu, so it’s always available at a hotkey.

                                                                                                                          Ultimately it’s up to you how you want to work. I just find CMD to be a difficult beast compared to POSH.

                                                                                                                          1. 2

                                                                                                                            So, when it gets to writing anythingore complicated than “start a program or two, maybe passing through some arguments”, then yeah, I prefer to write it in something other than batch. PowerShell works, currently I like Nim for that sort of thing.

                                                                                                                            This has proved a nice way to get quick responsiveness from a shell on Windows, and deal with complicated command invocations, without having to deal with the issues that mingw can have. As a bonus, you can get easy documentation for your uses cases of a particular command.

                                                                                                                        2. 1

                                                                                                                          What other systems use cmd apart from Windows?

                                                                                                                          (I realize DOS does)

                                                                                                                          1. 3

                                                                                                                            DOS uses COMMAND.COM, not CMD. CMD is used by ReactOS, OS/2, and Windows NT and later if I recall correctly. I get your point, but seriously using CMD is analogous to archaeology at this point…

                                                                                                                  1. 2

                                                                                                                    This solves a common issue I have on work machines, of deeply nested files and it being easy to lose context about file moves. The only thing I’m missing, is a way to drop the file path, relative to my current directory, of a file I select in broot. This may exist already, I just haven’t dug deep enough to find it yet.

                                                                                                                    1. 2

                                                                                                                      Do you mean something like z?

                                                                                                                      1. 1

                                                                                                                        Similar yes, but combining the other capabilities of broot would be nice to utilize a single utility. Also, unlike z most of the time I don’t need to jump to the location of the file, but I need to do $something with it.

                                                                                                                      2. 1

                                                                                                                        What do you mean “drop the file path” ?

                                                                                                                        1. 2

                                                                                                                          Once I select (or focus) a file in broot and exit, it’d be nice if my current command line was populated with the relative path to the file I selected. For example

                                                                                                                          $ pwd
                                                                                                                          /home/kevin
                                                                                                                          $ br
                                                                                                                            [ selects file in broot with absolute path of /home/kevin/foo/bar/baz.txt ]
                                                                                                                          $ foo/bar/baz.txt
                                                                                                                          
                                                                                                                          1. 2

                                                                                                                            There’s a verb, :pp which outputs the absolute path. Just like with all verbs, you can define a shorcut (for example ctrl-p).

                                                                                                                            Does that solve your problem?

                                                                                                                            more on verbs: https://dystroy.org/broot/documentation/configuration/#verbs-shortcuts-and-keys

                                                                                                                            1. 1

                                                                                                                              He’s asking for a way to get at just the relative path. In the example given, just foo/bar/baz.txt, and not the full /home/kevin/foo/bar/baz.txt.

                                                                                                                              1. 2

                                                                                                                                I could very easily add a verb for that, just like today’s :print_path, a :print_relative_path.

                                                                                                                                Please kbknapp post an issue or answer here if that’s what you want.

                                                                                                                              2. 1

                                                                                                                                I can make that work! Thanks! In a perfect world it’d place that path on the command line rather than just printing to stdout, but with something like xargs I can still work with this. Thanks for your work on broot!

                                                                                                                                1. 3

                                                                                                                                  If you’re on zsh you can pop the path in with zle.

                                                                                                                                  1. 2

                                                                                                                                    I am. This is exactly what I was looking for, thanks!