1. 35

    Use a library or framework.

    So the best code is actually somebody else’s code.

    Use a third party SaaS tool.

    Somebody else’s code on somebody else’s machines.

    if you can solve a problem without doing anything, it is better to not do anything

    you don’t say…

    1. 24

      If I had to rank problems with modern software development, “devs don’t use enough third-party libraries and frameworks” would be way, way, way down the list. Much higher on the list would be “few devs bother to learn how to write code that can be reused without causing more problems than it solves”.

      Relevant: Designing and Evaluating Reusable Components (2004) by Casey Muratori

      1. 10

        I think this is a fair reply to the literal interpretation of the post, but wholly irrelevant to its spirit.

        Yes, using someone else’s code is still using code, but the important things are:

        • It’s code you don’t have to maintain and support (at least not nearly as much as code you’d write yourself)
        • It’s already done, so you save time by integrating with it rather than having to write and test it
        • If you pick a decent module/framework/tool, it’s likely the author has spent significantly more time refining it than you would if you wrote it yourself, as it’s the purpose of the whole module versus your need of the hour

        It’s also worth mentioning that picking which third-party code or tool to use and (more importantly) which not to use is a skill which gets better with experience. Those less experienced in making those critical distinctions are sometimes bit by bad choices, and revolve to reinvent the wheel.

        you don’t say…

        Regarding this, it may be obvious to you that solving a problem with little or no code is better than the alternative, but this is far from obvious to every developer.

        An outsized portion of developers, even experienced ones, are more oriented toward writing code than solving problems. I’ve seen more than one occasion where a developer starts down the path of designing a complex system to avoid asking a user to make a tiny, effortless tweak to their workflow. Asking them to do so is a win by every measure, and yet many developers fail to consider it.

        1. 9
          • It’s code you don’t have to maintain and support (at least not nearly as much as code you’d write yourself)
          • It’s already done, so you save time by integrating with it rather than having to write and test it

          These are both terrible assumptions. They can be true, but they’re by no means guaranteed. And if you do end up having to make changes to that third party code, it’s going to be a massive pain. Vendoring the code into your repo can alleviate some, but not all, of that pain.

          • If you pick a decent module/framework/tool, it’s likely the author has spent significantly more time refining it than you would if you wrote it yourself, as it’s the purpose of the whole module versus your need of the hour

          Time =/= Quality. Specific solutions to specific problems almost always outperform general solutions in every metric.

          1. 5

            Like I said, evaluating whether to use a library or to write it yourself is a skill. I hoped I’d made that clear in my original post, but those points are assuming you’ve done your due diligence in choosing a library. I’m not arguing that picking any old module will automatically save you time and it’ll just work effortlessly, but if you do that due diligence you can have pretty good luck.

            The project I work on at my job had a sizable number of dependencies and we spend relatively little time dealing with those downsides because we do a decent job mitigating those risks.

            Like everything else, it’s a tradeoff. Sometimes the odds favor writing it yourself, and sometimes they favor using someone else’s code.

            1. 4

              Totally agree. I just think the far bigger problem is devs piling on layers and external dependencies due to the belief that it will save them time or make their code more “clean”.

              There are very few truly general abstractions. Compilers/Interpreters and Relational databases are probably the two most obvious (in software). And they took decades to reach sufficient maturity to be the obvious choice over rolling your own special-purpose solution. And still, they come with a considerable complexity cost.

              1. 2

                Like I said, evaluating whether to use a library or to write it yourself is a skill.

                I think it’s worth highlight this, given the blog domain is called letterstoanewdeveloper.

            2. 1

              It’s already done, so you save time by integrating with it rather than having to write and test it

              I’ll add this is only true if integration effort is less than effort of writing and testing a solution. At first glance, it seems like it obviously would be. Many 3rd-party libraries will be more complex than one needs, have poor documentation, maybe miss corner cases, etc.

              I can’t give any guidance outside “learn from experience” on how to evaluate when you’re running into this problem. Lean, focused, and well-documented libraries seem to be a good pattern. Personal example for development server in Python was choosing Flask over Django since I figured I’d get working code out faster. It’s been working fine outside one problem that might not even be Flask.

          2. 6

            Fair points. I did mention manual processes as an alternative.

            I think some developers are enamored of writing code for code’s sake. I was when I was younger.

            Maybe a better title would be “The best code is no custom code”?

            1. 18

              Surprisingly often, there’s more work in gluing together frameworks than there is in just writing the code. And you lose visibility into what’s going on, so when it goes wrong, it’s much harder to debug.

              There’s a balance to be made. I try to restrict dependencies to ones solving hard problems.

              1. 4

                Surprisingly often, there’s more work in gluing together frameworks than there is in just writing the code.

                In my experience that is true for the golden path, sometimes. But once you, or your users, stray off the happy path, I find that libraries and frameworks help a lot. Yes, it’s less fun for me to read a doc and learn how to use a third party lib than to write my own, but long term the former is the better solution.

                1. 4

                  Glue code is rarely bug free, and commonly misses edge cases between what one library outputs and another accepts.

                  The libraries also get special cases wrong more than you’d expect. If I’m lucky, I can get upstream to ship a fix quickly. But often, I just need to work around it.

                  Popular libraries too: I’ve spent days dealing with issues in grpc, core Android APIs, and similar.

              2. 4

                It’s certainly valuable to re-use mature, maintained solutions whenever possible. I think we need a new metric to capture evaluate this. Maybe something like “Maximize annual maintenance dollars per Line of Code”?

                This encourages you to think through who’s actually maintaining the stuff you’re using. You can write it yourself and pay 100% of the maintenance cost. You can use an open source library and benefit from community maintenance investments. You can pay a vendor with a dedicated staff for maintenance investment. Somebody has to do the work or your code rots.

                You have to think carefully about your unit of analysis though. There are some LOC that matter more to your business than anyone elses’. Are those features actually benefiting from investment received by their parent libraries?

                1. 1

                  Great idea. I think you meant minimize, though?

                  1. 2

                    I was thinking in terms of maximizing the total investment in your code base, not necessarily your own investment. For example, it’s probably not a good idea to write your own Operating System. You can choose one that already has millions and millions of developer dollars invested in it. Sometimes you can get it for free! This lets you start way further ahead. The same logic applies to almost anything. Use stuff where lots of other people also care about making it work well, so you combine forces. Then focus you internal efforts on the stuff that really matters to your organization.

                    This is somewhat related to the Choose Boring Technology argument. You have to choose where to spend your resources, so you have to put them where they can do the most good.

              3. 6

                Ahem. Economics, Mr. Llama!

                So the best code is actually somebody else’s code

                They’ve already paid for it. You get to use it for free, maybe pay a little maintenance cost. Is that a good deal? Depends, but probably worth consideration.

                Somebody else’s code on somebody else’s machines.

                Infrastructure costs money too. Do you really want to be in that business?

                If you’re writing code for fun, great, have fun. But if you’re writing code to make money, I think it’s your responsibility to actually make some money. Or at least, not just throw it away merely because it’s more fun to reinvent stuff.

                1. 2

                  Use a library or framework.

                  Perhaps a library is a good idea in many circumstances if it is sufficiently well designed but frameworks can be a lot of trouble.

                  1. 1

                    I’m upvoting both you and the post on this one. The deep irony here is that you can say things like “the best code is no code” and seem trivial, trite, pointless. You’re just restating the obvious!

                    Everybody can agree, get a nice chuckle. Then they go out and write a bunch of code they didn’t need.

                    Profound statements tend to be facile as well. For me, folks kept saying things like this over and over again until one day the light went off. I’m not sure if I just had to wait until somebody said it the right way, I had to hear it X times, or personal experience demonstrated to me how much I said the words but didn’t actually live the life. Took a long while, though.

                  1. 8

                    I think the author of this post is correct in surmising that the proliferation of feature-rich, graphical editors such as Visual Studio Code, Atom, and Sublime Text have a direct correlation to the downturn of Emacs usage in recent years. This might seem a little simplistic, but I think the primary reason for most people not even considering Emacs as their editor comes from the fact that the aforementioned programs are customizable using a language that they are already familiar with, either JS or Python. Choosing between the top two interpreted languages for your editor’s scripting system is going to attract more people than choosing a dialect of Lisp. The fact that Emacs Lisp is one of the most widely-used Lisp dialects tells you something about how popular Lisp is for normal day-to-day programming. It’s not something that most are familiar with, so the learning curve to configuring Emacs is high. Meanwhile, VS Code and Atom let you configure the program with JSON and JavaScript, which is something I believe most developers in the world are familiar with at least on a surface level. If you can get the same features from an editor that is written in a familiar language, why would you choose an editor that requires you to learn something entirely different?

                    I use Emacs, but only for Org-Mode, and I can tell you with experience that editing the configs takes a bit of getting used to. I mostly use Vim and haven’t really compared it to Emacs here because I don’t feel like the two are easily comparable. Although Vim’s esoteric “VimL” scripting language suffers from the same problems as Emacs, the fact that it can be started up and used with relatively minimal configuration means that a lot of users won’t ever have to write a line of VimL in their lives.

                    1. 14

                      I might be mistaken, but I don’t think that most “feature-rich, graphical editors”-users don’t customize their editor using “JS or Python”, or at least not in the same way as one would customize Emacs. Emacs is changed by being programmed, your init.el or .emacs is an elisp program that initializes the system (setting the customize-system aside). From what I’ve seen of Atom, VS Code and the like is that you have JSON and perhaps a prettier interface. An Emacs user should be encouraged to write their own commands, that’s why the *scratch* buffer is created. It might just be the audience, but I don’t hear of VS Code users writing their own javascript commands to program their environment.

                      It’s unusual from outside, I guess. And it’s a confusion that’s reflected in the choice of words. People say “Emacs has a lot of plugins”, as that’s what they are used to from other editors. Eclipse, Atom, etc. offer an interface to extend the “core”. The difference is reflected in the sharp divide between users and (plugin) developers. Compare that to Emacs where you “customize” by extending the environment. For that reason the difference “users” and “developers” is more of a gradient, or that’s at least how I see it. And ultimately, Lisp plays a big part in this.

                      It was through Emacs that I learned to value Free Software, not as in “someone can inspect the code” or “developers can fork it”, but as in “I can control my user environment”, even with it’s warts. Maybe it’s not too popular, or maybe there are just more easy alternatives nowadays, but I know that I won’t compromise on this. That’s also probably why we’re dying :/

                      1. 13

                        Good defaults helps. People like to tweak, but they don’t want to tweak to even get started. There’s also how daunting it can appear. I know with Vim I can get started on any system, and my preferred set of tweaks is less than five lines of simple config statements (Well, Vim is terse and baroque, but it’s basically just setting variables, not anything fancy.). Emacs, there’s a lot to deal with, and a lot has to be done by basically monkey-patching - not very friendly to start with when all you want is say, “keep dired from opening multiple buffers”.

                        Also, elisp isn’t even a very good Lisp, so even amongst the people who’d be more in-tune with it could be turned off.

                        1. 3

                          Also, elisp isn’t even a very good Lisp, so even amongst the people who’d be more in-tune with it could be turned off.

                          I agree on the defaults (not that I find vanilla Emacs unusable, either), but I don’t really agree with this. It seem to be a common meme that Elisp is a “bad lisp”, which I guess is not wrong when compared to some Scheme and CL implementations (insofar one understands “bad” as “not as good as”). But it’s still a very enjoyable language, and perhaps it’s just me, but I have a lot more fun working with Elisp that with Python, Haskell or whatever. For all it’s deficiencies it has the strong point of being extremely well integrated into Emacs – because the entire thing is built on top of it.

                          1. 1

                            I also have a lot more fun working with Elisp than most other languages, but I think in a lot of regards it really does fail. Startup being significantly slower than I feel that it could or should be is my personal biggest gripe. These days, people like to talk about Lisp as a functional language, and I know that rms doesn’t subscribe to that but the fact that by default I’m blocked from writing recursive functions is quite frustrating.

                        2. 3

                          It’s true, emacs offers a lot more power, but it requires a time investment in order to really make use of it. Compare that with an editor or IDE where you can get a comfortable environment with just a few clicks. Judging by the popularity of macOS vs Linux for desktop/workstation use, I would imagine the same can be said for editors. Most people want something that “just works” because they’re busy with other problems during the course of their day. These same people probably aren’t all that interested in learning a the Emacs philosophy and getting to work within a Lisp Machine, but there are definitely a good amount of people who are. I don’t think Emacs is going anywhere, but it’s certainly not the best choice for most people anymore.

                          1. 8

                            Most people want something that “just works” because they’re busy with other problems during the course of their day.

                            This has been my experience. I learned to use Vim when I was in school and had lots of free time to goof around with stuff. I could just as easily have ended up using Emacs, I chose Vim more or less at random.

                            But these days I don’t even use Vim for programming (I still use Vimwiki for notes) because I simply don’t have time to mess around with my editor or remember what keyboard shortcuts the Python plugin uses versus the Rust plugin, or whatever. I use JetBrains IDEs with the Vim key bindings plugin, and that’s pretty much all the customization I do. Plus JB syncs my plugins and settings across different IDEs and even different machines, with no effort on my part.

                            So, in some sense, I “sold out” and I certainly sacrificed some freedom. But it was a calculated and conscious trade-off because I have work to do and (very) finite time in which to do it.

                            1. 7

                              I can’t find it now, but someone notes something along those lines in the thread, saying that Emacs doesn’t offer “instant gratifications”, but requires effort to get into. And at some point it’s just a philosophical discussion on what is better. I, who has invested the time and effort, certainly think it is worth it, and believe that it’s the case for many others too.

                              1. 3

                                IDEs are actually quite complicated and come with their own sets of quirks that people have to learn. I was very comfortable with VS Code because I’ve been using various Microsoft IDE’s through the years, and the UI concepts have been quite consistent among them. But a new user still needs to internalize the project view, the editing view, the properties view, and the runtime view, just as I as a new user of Emacs had to internalize its mechanisms almost 30 years ago.

                                It’s “easier” now because of the proliferation of guides and tutorials, and also that GUI interfaces are probably inheritably more explorable than console ones. That said, don’t underestimate the power of M-x apropos when trying to find some functionality in Emacs…

                              2. 3

                                Yeah, use plugins in every editor, text or GUI. I’ve never written a plugin in my life, nor will I. I’m trying to achieve a goal, not yak-shave a plugin alone the way.

                                1. 3

                                  I’m trying to achieve a goal, not yak-shave a plugin alone the way.

                                  That’s my point. Emacs offers the possibility that extending the environment isn’t a detour but a method to achieve your goals.

                                  1. 5

                                    Writing a new major mode (or, hell, even a new minor mode) is absolutely a detour. I used emacs for the better part of a decade and did each several times.

                                    I eventually got tired of it, and just went to what had the better syntax support for my primary language (rust) at the time (vim). I already used evil so the switch was easy enough.

                                    I use VSCode with the neovim backend these days because the language server support is better (mostly: viewing docstrings from RLS is nicer than from a panel in neovim), and getting set up for a new language is easier than vim/emacs.

                                    1. 1

                                      It’s not too surprising for me that between automating a task by writing a command and starting an entire new project that the line of a detour can be drawn. But even still, I think it’s not that clear. One might start by writing a few commands, and then bundle them together in a minor mode. That’s little more than creating a map and writing a bare minimal define-minor-mode.

                                      In general, it’s just like any automation, imo. It can help you in the long term, but it can get out of hand.

                                2. 2

                                  Although I tend to use Vim, I actually have configured Atom with custom JS and CSS when I’ve used it (it’s not just JSON; you can easily write your own JS that runs in the same process space as the rest of the editor, similar to Elisp and Emacs). I don’t think the divide is as sharp as you might think; I think that Emacs users are more likely to want to configure their editors heavily than Atom or VSCode users (because, after all, Elisp configuration is really the main draw of Emacs — without Elisp, Emacs would just be an arcane, needlessly difficult to use text editor); since Atom and VSCode are also just plain old easy-to-use text editors out of the box, with easy built-in package management, many Atom/VSCode users don’t find the need to write much code, especially at first.

                                  It’s quite easy to extend Atom and VSCode with JS/CSS, really. That was one of the selling points of Atom when it first launched: a modern hackable text editor. VSCode is similar, but appears to have become more popular by being more performant.

                                3. 7

                                  but I think the primary reason for most people not even considering Emacs as their editor comes from the fact that the aforementioned programs are customizable using a language that they are already familiar with, either JS or Python

                                  I disagree.

                                  I think most people care that a healthy extension ecosystem that just works and is easy to tap in to is there - they basically never really want to have to create a plugin. To achieve that, you need to attract people to create plugins, which is where your point comes in.

                                  As a thought experiment, if I’m a developer who’s been using VS Code or some such for the longest time, where it’s trivial to add support for new languages through an almost one-click extension system, what’s the push that has me looking for new editors and new pastures?

                                  I can see a few angles myself - emacs or vim are definitely snappier, for instance.

                                  EDIT: I just spotted Hashicorp are officially contributing to the Terraform VS Code extension. At this point I wonder if VS Code’s extension library essentially has critical mass.

                                  1. 3

                                    Right: VS Code and Sublime Text aren’t nearly as featureful as Emacs, and they change UIs without warning, making muscle memory a liability instead of an asset. They win on marketing and visual flash for their popularity, which Emacs currently doesn’t have, but Emacs is what you make of it, and rewards experience.

                                  1. 36

                                    I really have a different POV from the author. Most of the world is not a special snowflake and should not be building (and maintaining!) their own custom infrastructure. Like cars and trucks, there are millions of mechanics around the world but only a few companies building new vehicle platforms from scratch. Companies need software mechanics to customize, diagnose and fix “glue” issues but they really shouldn’t be building complex infrastructure from scratch (that’s literally not their business) when COTS or OSS will suit their needs just fine.

                                    1. 11

                                      Most of the world is not a special snowflake and should not be building (and maintaining!) their own custom infrastructure.

                                      I don’t really understand this viewpoint–why not? I think companies are hurt more by trying to customize overly-generalized solutions like SAP.

                                      1. 5

                                        Or for a more contemporary example, Kubernetes. This is why the Unix principle is still important – we should have many small tools (/ services), all doing a single thing very well but nothing else. That way people can pick out the correct combinations for each occasion.

                                        It seems this conflicts with capitalism though – fattening up your own product/service seems to be good for the bottom line, unfortunately. People dream about single products that fix all their problems even when it bogs them down.

                                        1. 1

                                          I’d be interested to hear more about your experiences with Kubernetes. What were the big mistakes in the implementations you’ve seen?

                                          1. 1

                                            I wasn’t implying that people deploy it badly, just that it’s a huge “fix everything” sort of thing, which is generally speaking not a good thing, but which is also a thing that many people seem to want.

                                        2. 5

                                          I think there’s a balance to be struck. In my personal experience, if you find yourself working to customise a third-party/open-source tool you’re in one of a few situations:

                                          • There’s a fix that can be contributed upstream, either because it’s open source or thanks to a responsive vendor. If your vendor isn’t responsive, it’s my own opinion that you’re not in this situation no matter how simple the fix, so carry on down the list
                                          • You are using the tool wrong and would benefit from adjusting your workflow to use the tool as it was intended
                                          • You chose a tool that doesn’t work for your use case

                                          The last two points can be difficult to distinguish and require some honesty during assessment. Sometimes the answer to “but our use case is special” is to stop being special, but sometimes we have good reasons.

                                          If you find yourself in the last situation, it’s time to look for a new tool or build something. But not everybody does, and that’s fine.

                                        3. 8

                                          Agreed. There are definitely tools that I’ve used at various companies that I’ve enjoyed working with and that I’ve been grateful to have been exposed to, but they were pretty much all open-source projects that some person or team at the company found and decided to use in some official or recommended workflow, rather than bespoke tooling written by people at the company. I view this as a good thing - it means that I don’t actually have to give up the use of a useful tool when I switch jobs, and also that if anyone at my company makes a fix or improvement to a tool, that change can get propagated to everyone who uses it.

                                          1. 6

                                            Far from all problems have a generic open source solution. So your viewpoint implies that the company should create such a solution rather than a bespoke, solving-just-the-problem-at-hand thing.

                                            That is a tall order. Creating something for a very specific task usually means a simpler implementation, which usually means lower maintenance, fewer bugs, better performance characteristics, and so on.

                                          2. 5

                                            I mostly agree with you. Most companies can do fine without custom tools. I don’t see how the lack of custom tools implies that the company sucks.

                                            The one aspect I can see: If your company needs no custom tools then the business is not revolutionary/world changing/unicorn.

                                            1. 2

                                              This is an extremely revisionist point of view. Your not-custom architecture initially was someone’s custom architecture. Standard solutions we’ve converged on are/were either maintained by companies who built them to solve their problems or by non-profit organizations that couldn’t use stock solution because it didn’t exist.

                                              And last, but not least, calling someone who worked primarily for large orgs that build custom solutions because they need to “a special snowflake” while not recognizing that you’re bashing something you’re doing yourself requires some creative thinking.

                                            1. 2

                                              I think it would be good if Go were to become a enterprise programming language, because it’s absolutely unfit for teaching algorithms – which would mean that universities wouldn’t use it in their programming courses either, and perhaps consider to use something that teaches computational thinking instead of boilerplate-coding.

                                              1. 7

                                                Why is it unfit for teaching Algorithms?

                                                1. 1

                                                  Thinking about it, “unfit” probably isn’t the best word, but let’s say if you want to have nice code, you’re going to have to write nice Go, which is it’s own discipline, seeing as Go has it’s own peculiar limitations (which might/often make sense from a specific engineering standpoint). And it’s this gap in method between Go and “regular imperative languages” that employ OO, Generics, … that would make Go a very unusual choice as a language for a (introductory) algorithms course.

                                                  1. 1

                                                    I’d question whether an algorithms computer science course should be teaching you OO and Generics, or whether that’s the way it’s been done up until now because a lot of Algorithms courses have been taught with Java.

                                                    I’d raise with you that many courses are taught using Python. Open ended type support, as such, but it’s so seamless that it hasn’t actually taught you anything about generics as much as you’ve ignored it at that point.

                                                    Regarding OO - the industry has broadened its notions of acceptable software and OO is no longer a must have. Hasn’t been for a while. Probably better taught in another course to be honest.

                                                    1. 2

                                                      To be clear, I’m not a fan of using Java either, and I don’t see a necessity to teach OO and Generics (as examples). In most cases, Python would be much more preferable, yes.

                                                      But you seem to have misunderstood my point: What you learn about OO and Generics (let’s generalize: Software Design, something that’s usually burdened onto Algorithms courses) in Java is more easily applicable to other languages – since Java ultimately isn’t that different – than you would if you were thought good Go design (for example the sort package).

                                                2. 5

                                                  I feel like your response contradicts itself. You think it would be good for enterprise and that’s good because Universities wouldn’t teach it? That sounds bad to me.

                                                  1. 5

                                                    No, universities wouldn’t use it for algorithms classes, as they commonly use Java nowadays, which is what I care about.

                                                1. 16

                                                  It was a late evening. My colleague has just checked in the code that they’ve been writing all week. The code worked. It wasn’t clean.

                                                  Author rewrites code in one night that someone else has been working on all week based on some subjective measurement of “clean”. The boss was right to have the 1-on-1, but it has less to do with “code cleanliness” than basic respect for teammates. This type of behavior belittles the work of your teammates, makes you look like an prima donna asshole, and starts people polishing resumes because it creates a horrible work environment.

                                                  1. 13

                                                    The author clearly already states as much in the article:

                                                    I see now that my “refactoring” was a disaster in two ways:

                                                    Firstly, I didn’t talk to the person who wrote it. I rewrote the code and checked it in without their input. Even if it was an improvement (which I don’t believe anymore), this is a terrible way to go about it. A healthy engineering team is constantly building trust. Rewriting your teammate’s code without a discussion is a huge blow to your ability to effectively collaborate on a codebase together.

                                                    So I don’t really see a point in discussing it further, certainly not without adding some substantial contribution to the debate.

                                                    1. 4

                                                      I’m going to be controversial and say that this is a problem. Either a single person owns the code and has to review all changes or it is owned by a community and can be modified by anyone in the direction of better.

                                                      1. 3

                                                        The issue isn’t code ownership, it’s someone staying late to rewrite working code, based on a subjective metric of “better code”. If you’re going to stay late, it’d better be for a contractually obligated “must-hit” deadline, or because of a major issue in production.

                                                        1. 1

                                                          I dunno - if someone wants to stay late and work on something, I’m not particularly interested in policing that.

                                                          1. 2

                                                            In the environments where I’ve worked, working late sets a bad precedent, and it eventually boils up to management complaining, “Why isn’t Joe (the only one not peer pressured into working late) working late tonight!?” Especially when used to complete non-essential work, it can lead to management failing to prioritize because there’s “more hours in the day.” I’ve been salaried working 80+ hours a week because of this type of mess.

                                                        2. 3

                                                          Years later, sure. Team and human factors always matter in the immediate time frame, regardless of future ownership constructs.

                                                        3. 3

                                                          I’m not so sure. Not talking about this case, but first of all it doesn’t matter how long person A spent on the code and if person B objectively improves it… At least I have zero problems with people improving my code, all that matters is the result at the end, I’m not married to my code. That said, I don’t do this to other people’s code because they might react like you did :) I would have a stern talking to the people who let me work on something for a week and not giving any input how I could speed it up. I usually do ask for help if tasks seem huge and while it doesn’t help anyone if the same people do their special thing very quickly all the time, I suppose pairing for a few hours might have helped get better code quicker.

                                                          1. 1

                                                            first of all it doesn’t matter how long person A spent on the code and if person B objectively improves it…

                                                            This isn’t why the author “improved it”. The author said it wasn’t “clean” which isn’t some sort of objective measurement.

                                                            not giving any input how I could speed it up

                                                            The author didn’t do it any faster. It was rewritten to match the stylistic tastes of the author, late at night on the day the it was originally submitted, instead of the author going home for the day.

                                                            I don’t do this to other people’s code because they might react like you did

                                                            I’ve had this happen to me I don’t care. I’ve seen this happen to other people too and it was just another notch in them moving closing to the door and eventually leaving.

                                                            1. 1

                                                              Author rewrites code in one night that someone else has been working on all week based on some subjective measurement of “clean”

                                                              I was referencing this part of your post, you repeated it, I thought it was to underline that fact.

                                                              That’s what I meant. It’s possible that coworker A who has intricate knowledge can do it in a fraction of the time. In this case it sounded like the author could have done it faster, but I may have misread - but it’s moot if I was misreading your sentence.

                                                        1. 4

                                                          Is this a common use of the word “manifesto”? Or am I right to think it should not be tolerated?

                                                          1. 22

                                                            Or am I right to think it should not be tolerated?

                                                            You seem to have strong opinions on this topic. Perhaps you should release a document describing your reasoning and the rules you propose for future usage of the word. ;)

                                                            1. 9

                                                              “How to Write a Manifesto: A Manifesto”.

                                                              1. 1

                                                                If I did maybe I would

                                                              2. 10

                                                                I think this is something the Swift community does for large overarching proposals. There are several other manifestos in the docs: ABI Stability Manifesto, Generics Manifesto, Ownership Manifesto, String Manifesto.

                                                                1. 8

                                                                  Gah that makes me cringe.

                                                                2. 6

                                                                  Wikipedia sez:

                                                                  A manifesto is a published declaration of the intentions, motives, or views of the issuer, be it an individual, group, political party or government.

                                                                  1. 3

                                                                    Yeah I don’t get it (nor the point of the software itself tbh), isn’t this just a language extension / library proposal?

                                                                    1. 3

                                                                      Is this a discussion to have here, where we can do nothing about it, or as an issue in the repository, where:

                                                                      1. The people arguably most familiar with the process of doing things in Swift will respond
                                                                      2. The people arguable most likely to be able to initiate some change in Swift will (hopefully) listen
                                                                      3. We don’t end up with 13 of the 14 comments in this thread being about the least interesting part of this submission; a single word in the title.
                                                                      1. 1

                                                                        My two cents, a 15th commentary ill at ease with this word:

                                                                        Personally, and maybe for the other 13/14 who comments you talk about, the word Manifesto was entry point for reading the article.

                                                                        The 3 Manifestos I know of in programming are:

                                                                        • The Agile Manifesto
                                                                        • The Software Crafsmanship Manifesto
                                                                        • The Test Driven Development Manifesto (not sure it’s been published though, it was written in a SoCraTes UK conference)

                                                                        The 4th Manifesto I know of, is the Manifesto of the Communist Party written by Marx and Engels in the years 1850’s I think. There are probably numerous other Manifesto I don’t know of.

                                                                        Contrarily to your opinion about the “least interesting point”, I think that the philosophical content of those Manifesto is their “Raison d’Etre”, the reason why they are Manifestos and why they are refered as such. (Whether we agree or not on the content).

                                                                        The fact there already exists a library in Haskell (as puffnfesh noticed) that does that kind of stuff, and that there is no mention about it in the Differentiable Manifesto is also to be noticed.

                                                                        One of the other comments says that it’s a habit in the swift community to call important stuffs Manifesto… So…

                                                                        1. 1

                                                                          The question I raised was whether this is a nonstandard and misleading usage of the word from the standpoint of the wider software community, so I believe it is a discussion to have here.

                                                                          If someone with a GitHub account feels there is a consensus that this usage of “manifesto” is wrong, and cares enough about the Swift community to raise the issue with them, they can certainly do that.

                                                                          1. 2

                                                                            That’s closer to what I think of as a manifesto, but this Swift proposal is not the same type of thing.

                                                                          2. 2

                                                                            Or am I right to think it should not be tolerated?

                                                                            … as in you’d resist or otherwise fight against it? Are you a prescriptivist?

                                                                            1. 2

                                                                              Is it prescriptive to want people to use language which is not misleading?

                                                                              1. 1

                                                                                Were you mislead?

                                                                                1. 1

                                                                                  Yup

                                                                            2. 1

                                                                              It makes me think of this, so to me it’s a weird use of the word as well.

                                                                            1. 1

                                                                              The team seems to use Scrum, so…

                                                                              What is the Definition of Done for such stories? Learning is so fuzzy it becomes meaningless.

                                                                              Why would a product owner create such stories? Every story should provide value to the user.

                                                                              1. 1

                                                                                So Scrum wasn’t designed to manage learning. Would you argue for ditching learning, or for (selectively) ditching Scrum?

                                                                                1. 2

                                                                                  I would argue not to use Scrum to track learning because it is not designed for that.

                                                                                2. 1

                                                                                  The team seems to use Scrum, so…

                                                                                  I didn’t even think of that to be honest.

                                                                                  The system the team uses (I feel) is not so important in this instance, rather it’s the principle of what we prioritize, which is in my eyes, separate from how that work is then scheduled (scrum vs. kanban vs. whatever).

                                                                                  What is the Definition of Done for such stories? Learning is so fuzzy it becomes meaningless.

                                                                                  It feels possible to define some set of outcomes. It may be as simple as scheduling something easy to be done, but then allocating a lot of time for it, to account for the learning curve.

                                                                                  Why would a product owner create such stories?

                                                                                  A Product Owner probably wouldn’t, you’re right. That doesn’t feel like their role. At some stage, I would say there needs to be somebody advocating for the improvement of the team itself over time. I think making the process of teaching and learning passive is a mistake; it’s hard to keep track of something you’re not actively doing.

                                                                                  Every story should provide value to the user.

                                                                                  It feels possible to reconcile the two to me. I mean it’s not unbounded learning I’m speaking about, somebody learning about Bitcoin in a front-end agency role doesn’t make so much sense, for instance. It’s not so rare, in my experience, to find areas of mutual benefit that an Engineer can learn about, and has an (eventual) payoff for the user/company.

                                                                                1. -1

                                                                                  Comments should almost never exist. They are untyped and often get outdated and then cause more harm than good. There are no refactoring tools for them. It’s generally a sign that the language is lacking necessary features or the code needs to be rewritten. An exception can be made for temporary comments like “todos”, but that’s it.

                                                                                  Instead of comments, make your code describe exactly what it does. useLongVariableAndMethodNames. Never have single letter variables(Yes: even use the word “index” instead of “i”). Put the time you would spend writing comments into better tests and code.

                                                                                  Check out the book Clean Code if you want some great advice.

                                                                                  1. 12

                                                                                    I don’t see how using “index” instead of “i” helps. If you’re obviously looping through an array, and the for loop isn’t stupidly complicated, the letter “i” conveys exactly as much information as the word “index” to the reader.

                                                                                    Nobody read “for (i = 0; i < len(elements); ++i) do_thing(elements[i])” and wonders what that cryptic “i” could possibly mean.

                                                                                    1. -4

                                                                                      Next generation dev tools will rely increasingly on machine learning to aid in development. When you write “index” instead of “i”, you are providing a whole lot of additional information (reduction in entropy through narrowing of the search space). This helps folks building data driven tools.

                                                                                      You can start using this sort of thing today. I highly recommend TabNine.

                                                                                      1. 6

                                                                                        I get your point, but I hope (perhaps in vain) that the next generation learns from everything the previous generations have worked to provide. For instance, the almost universal convention of i meaning ‘index’.

                                                                                        My vision for next-gen development involves eDSLs and metaprogramming more than machine learning. In this case, perhaps a “comment” sublanguage that is human-readable but could be used to mechanically check the invariants and reasoning that our current comments are attempting to provide.

                                                                                        1. 2

                                                                                          perhaps a “comment” sublanguage that is human-readable mechanically check the invariants

                                                                                          I agree with this. In my Tree Languages I try to avoid having any global “comment” node type, and instead only add very specific comment nodeTypes to langauges when necessary, (such as the “todo” comment nodeType in my Grammar Language https://jtree.treenotation.org/designer/#standard%20grammar and a “reference” nodeType in a data flow language which only takes a strongly typed URL). If someone needs to add a different type of comment, there’s no mechanism to do that itself and instead they must bring their problem upstream so we can examine it and either add some new semantics to the language or add a new subclass of comment for that particular category.

                                                                                    2. 19

                                                                                      I’d take Robert Martin with a grain of salt. While he’s a good writer, he’s also anti a lot of powerful coding techniques, including strong type systems, formal verification, and property testing.

                                                                                      Re “make your code describe exactly what it does”, comments are really good for describing things that aren’t what the code exactly does. Descriptive code describes the implementation at the same degree the implementation itself is, and cannot speak outside that implementation. Some comments where that matters:

                                                                                      • “While the public method is Shutdown.run, the API call actually happens in RequestBuilder.send via ResponseParser.”
                                                                                      • “While this is a performance bottleneck, we’re not at a scale which it matters. If we have performance problems, optimize this first.”
                                                                                      • “We’re using the Runge-Kutta approximation with the Fehlburg adjustment.”
                                                                                      • “We do not need to call foobar() here for reasons XYZ. Please do not submit a pull request adding it.”
                                                                                      • “This is not the event invocation module. You want file ABC. See issue #452 for the naming reasons.”
                                                                                      • Any of the 2D data representations here.

                                                                                      Sure, comments fall out of date, but that’s less because there’s something wrong with comments and more because programmers never bothered to treat comments with dignity and care. I’ve never seen a truly self-describing codebase, but I’ve seen plenty that needed a lot more comments.

                                                                                      1. 2

                                                                                        [against] strong type systems, formal verification, and property testing.

                                                                                        I use xmobar, which was written in Haskell, which professes all of the above.

                                                                                        Every 30 minutes it segfaults on my system. I literally wrote a program to start it, and restart it when it segfaults, because it’s cheaper on my time than figuring out why it segfaults.

                                                                                        Those things are part of good code, but they don’t make good code. They don’t guarantee that a system is failsafe, bulletproof, or otherwise stable.

                                                                                        1. 7

                                                                                          That’d be a good argument if he made it. But he’s saying they’re all fundamentally inferior to unit testing:

                                                                                          the reason we are facing bugs that kill people and lose fortunes, the reason that we are facing a software apocalypse, is that too many programmers think that schedule pressure makes it OK to do a half-assed job. […]

                                                                                          Better REPLs are not the answer. Model Driven Engineering is not the answer. Tools and platforms are not the answer. Better languages are not the answer. Better frameworks are not the answer. […] I stood before a sea of programmers a few days ago. I asked them the question I always ask: “How many of you write unit tests on a regular basis?” Not one in twenty raised their hands.

                                                                                          1. 1

                                                                                            fundamentally inferior to unit testing

                                                                                            I’d hands down agree with this. If I had to get in a plane with software that was tested, or one with software that wasn’t tested but was written in a very strongly typed language, I’d choose the former every time.

                                                                                            Now, he is NOT against strong typing, and he specifically says that. He’s just saying that unit testing is more important, which I agree with. He is for BOTH, which I am too.

                                                                                        2. 0

                                                                                          These are good points, and I appreciate the examples.

                                                                                          anti..strong type systems

                                                                                          Is that true? Source? I never got that impression from his writings, but maybe I overlooked it.

                                                                                          Your examples reminded me of a 2nd place where comments are good (besides temporary todos): links to references. But I don’t think you should put untyped blobs of 2D art or anything like that in source code directly. Instead, have something like “reference http://foo.url”. Almost by definition, comments are the wrong grammar for anything/everything. If something can’t be explained well in code, it certainly can’t be explained well in comments, which are a completely untyped grammar. Instead, perhaps a link to an SVG or some other explanation is the proper channel.

                                                                                          1. 13

                                                                                            Is that true? Source? I never got that impression from his writings, but maybe I overlooked it.

                                                                                            He straight up calls them the dark path. He also says “You don’t need static type checking if you have 100% unit test coverage.”

                                                                                            Almost by definition, comments are the wrong grammar for anything/everything. If something can’t be explained well in code, it certainly can’t be explained well in comments, which are a completely untyped grammar.

                                                                                            I’d argue the exact opposite. Comments aren’t tractable to analyze, but they have infinite expressiveness. Some things we can’t explain well in code because code’s expressiveness is limited by its need to be tractable. Code can only tell us what “is”, it cannot tell us anything else. That’s the price of having something that’s implementable.

                                                                                            1. 4

                                                                                              Comments aren’t tractable to analyze, but they have infinite expressiveness. Some things we can’t explain well in code because code’s expressiveness is limited by its need to be tractable.

                                                                                              I’d disagree with this. Natural language has finite expressiveness, and is also limited by its need to be tractable to analyze. You can’t write only for yourself, but have to write in a way that is actually tractable to analyze by an external reader, who is a finitely limited human, not some kind of magical being living outside of space and time!

                                                                                              Granted, humans are much better at this currently than computers, so the difference can seem huge, to the point where humans can be glossed as having “infinite” ability. But I’m not sure it’s a difference in kind rather than amount. The quantitative difference can even narrow very quickly if you don’t make strong implicit assumptions about your reader. For example, say your comment is written in a C++ codebase in English, and your reader is a strong C++ programmer, but has weak English fluency. Are your comments still infinitely expressive and tractable for the reader to analyze?

                                                                                              1. 1

                                                                                                He specifically says he is not anti strong systems:

                                                                                                I don’t want you to think that I’m opposed to statically typed languages. I’m not.

                                                                                                That being said, thanks for pasting that. Very interesting read. The crux of the article is that you should always be “writing lots and lots of tests, no matter what language you are using!” which i agree with.

                                                                                          2. 15

                                                                                            This is some of the worst advice I’ve ever seen with respect to comments. If someone followed these rules, their code wouldn’t pass my code review.

                                                                                            Much better advice: do what is necessary to communicate understanding of code to others reading it. If comments are required, then do it. Whether the language is expressive enough or not is immaterial. Reality dictates.

                                                                                            1. -2

                                                                                              It’s forward looking. Comments should only be temporary. They are code smell. Temporary todo comments are okay. Comments that are links to references (which then can be in a language more appropriate to an “Explanation”) are okay.

                                                                                              I highly recommend reading Clean Code if you haven’t before.

                                                                                              Untyped blob comments are by definition a terrible grammar with infinite entropy and no tooling help and should be used very sparely.

                                                                                              1. 9

                                                                                                This is the most ridiculous take on commenting I’ve ever seen. If this is what’s in Clean Code, then it only reinforces my opinion that reading Bob Martin’s writing is a complete and total waste of time. (Which I initially formed by trying to read his writing.)

                                                                                                I don’t care about being “forward looking.” I care about whether myself and others can read my code and understand it. Comments are one of a few critical tools that help make that happen. Removing that tool because of some ideological nonsense about it being “untyped” and it therefore possibly being incorrect is one of the most crazy cases of “don’t throw the baby out with the bathwater” that I’ve ever seen.

                                                                                                1. -2

                                                                                                  my opinion that reading Bob Martin’s writing is a complete and total waste of time.

                                                                                                  My god sir, stop spending time reading my silly comments and go get yourself a paper copy of Clean Code! It will be worth its weight in gold, if you care about improving your skills.

                                                                                                  don’t throw the baby out with the bathwater

                                                                                                  I do live in the future a bit, as my time is spent designing new languages. But I stand 100% by my advice, if you’ve mastered most of the other aspects of programming. And perhaps that’s too much of an ideal, and indeed I almost always do provide an escape hatch in my languages to not throw the baby out, as you put it. But if you are resorting to comments other than for a very small few categories of buckets such as 1) temporary todos 2) links to references, you are doing something wrong. Perhaps it’s using the wrong language, perhaps it’s not understanding all features available in the language, perhaps its bad identifier names, perhaps its functions that are doing more than one thing, perhaps its not writing tests, perhaps its function bodys that are too long, perhaps its because your readers dont understand the programming language, perhaps its flag arguments, perhaps its too many parameters, perhaps its side effects…and on and on….There should never be a reason why you need to describe something in an undefined implicit grammar for a “human machine”. I 100% stand by this and have an immense amount of data on my side (I’ve read and worked on code and worked on language design in probably more languages than nearly anyone on earth at this point, ftr, so it would take some really novel evidence and data, and not some exposition, to convince me otherwise).

                                                                                                  1. 6

                                                                                                    Your experience is so far removed from mine (and many others that I know) that there is just no way we are going to see eye to eye. It is a waste of my time to get into it with you and give you data. You throwing your experience around is also really off putting to be honest. Others have plenty of experience too and strongly disagree with you, like I do. As I said, your methodology wouldn’t pass my code review. Not even close.

                                                                                                    1. 0

                                                                                                      that there is just no way we are going to see eye to eye

                                                                                                      That’s fine.

                                                                                                      You throwing your experience around is also really off putting to be honest.

                                                                                                      I know I was afraid of that, I just wanted to put out that to convince me otherwise would take lots of data, not argument, since my corpus is quite large.

                                                                                                      Others have plenty of experience too and strongly disagree with you

                                                                                                      That’s fine. I work on the future looking at data from the past to find new things and if everyone agreed with me I wouldn’t be inventing anything novel.

                                                                                                      As I said, your methodology wouldn’t pass my code review. Not even close.

                                                                                                      And I think it’s good that you take code reviews seriously. I work on different types of things where the goal of good language design is that you’d never have to write a comment to explain what the heck is going on, as the language should allow for it.

                                                                                                      But again, thank you for that chat (and I would read Clean Code. It’s a fantastic book!)

                                                                                                    2. 5

                                                                                                      if you are resorting to comments other than for a very small few categories of buckets such as 1) temporary todos 2) links to references, you are doing something wrong

                                                                                                      I find these kind of nuance-less “strong” opinions very tiresome. Observational evidence clearly shows that there are many highly productive programmers working on high quality code bases which use comments in ways other than you described. Indeed, the entire concept of Literate Programming is pretty much the exact opposite of what you’re advocating.

                                                                                                      Sometimes, there is more than one path to excellence. And what works for one person, might not work so well for another. Quite frankly, every time I see someone way “do X or you’re doing it wrong” – where “X” is a reasonably popular practice – especially without showing any understanding of why people do “X” (other than “they’re stupid” or “they’re wrong”) my response is something along the lines of “oh, he just hasn’t bothered to actually understand why people are doing the thing he’s so aggressively opposed to”. Turns out, that most of the time people are not complete idiots, and have actual valid reasons for doing the things they do (both in software dev and outside of it).

                                                                                                      I 100% stand by this and have an immense amount of data on my side

                                                                                                      You can’t say something like that and then not show your alleged “immense amount of data”.

                                                                                                      1. 0

                                                                                                        Literate Programming is pretty much the exact opposite of what you’re advocating.

                                                                                                        I love LP and I would say Literate programming and no comments are not opposed. In fact, I would say the opposite. Great programming languages should be self-documenting and readable. IMO we are barely scratching the surface of great programming languages, and my research is focused on this.

                                                                                                        just hasn’t bothered to actually understand why people are doing the thing he’s so aggressively opposed to”.

                                                                                                        What are you talking about? I am clearly demonstrating at least 2 buckets of categories for why people are commenting code (todos and references) that I think should always be there in languages for comments. I am also very open to more buckets. I am against again type of “# or // or /* “ syntax however, as that just shows the language designers have put little thought into why people are using comments and what they are using them for.

                                                                                                        You can’t say something like that and then not show your alleged “immense amount of data”.

                                                                                                        Well, for starters, the OP should read Clean Code. I’ve read that book probably 5 times by this point (and about 500 other programming books – Practice of Programming, Pragmatic Programmer, Pattern on the Stone, ANTLR 4 Definitive Reference, Learn you a Haskell, SICP, Bray’s Intel x86 assembly book, Mastering Regex, Programming Collective Intelligence, Data Structures + Algos equals Programs, are some good ones to start with). Here are 19 new languages I’ve designed https://github.com/treenotation/jtree/tree/master/langs. One of those took me an hour and sat at #1 on Lobsters for 2 days. We’ve also built the largest database of computer languages in the world by far, and will be releasing it soon, here: https://github.com/treenotation/cldb.

                                                                                                        Turns out, that most of the time people are not complete idiots,

                                                                                                        I never said this and don’t think anything of the sort. I just think the OP’s comments were a bit sophmoric (nothing wrong with that, we all go through phases of that). The OP started his response with “This is some of the worst advice I’ve ever seen with respect to comments”. That would be like me going up to Lebron James and saying “your basektball tips are some of the worst I’ve ever seen”. As Guido once said to me ‘When your reputation precedes you, I might answer your questions’. I think OP has a long way to go before I might take his opinions seriously over Bob Martin’s.

                                                                                              2. 7

                                                                                                One loop: index.

                                                                                                Two loops: index, jndex.

                                                                                                1. 1

                                                                                                  Generally you’d be iterating through collections of 2 different types, or 2 orthogonal directions. So you’d want something like manufacturerIndex, modelIndex.

                                                                                                  1. 2

                                                                                                    What if you’re iterating twice through the same data?

                                                                                                    For example, day 2, part B of 2018’s advent of code is essentially the following problem: Given a list of strings, all of the same length, find the unique pair that differs by one character in one position only. (That such a pair exists and is unique is promised by the problem statement.)

                                                                                                    Pretty much everyone will solve this by doing:

                                                                                                    for (int i = 0; i < len; i++) {
                                                                                                      for (int j = i+1; j < len; j++) {
                                                                                                        // check the condition, return
                                                                                                      }
                                                                                                    }
                                                                                                    

                                                                                                    Is the time spent coming up with longer loop variable names worth it, when you could call them i and j and maybe comment that the condition being checked is commutative so we’re essentially checking a symmetric matrix and can start the inner loop at i+1?

                                                                                                2. 6

                                                                                                  What language features are you thinking of that can explain why the code was written one way instead of another?

                                                                                                  As far as out of date comments go, it’s a code review problem.

                                                                                                  1. -1

                                                                                                    If you can’t explain in the language itself, then choose a more appropriate language for an explanation (Diagrams, for example) and add a comment with a link to that.

                                                                                                    As far as out of date comments go, it’s a code review problem.

                                                                                                    No. When you write a comment you are also making up an ad hoc, implicit grammar on the spot, with no tooling. Grammars are important to help people and tools communicate. You are asking a code reviewer to infer what the grammar is in a comment, to parse that example, and then run checks in their head to make sure nothing broke. That should be obvious why that is a big problem.

                                                                                                  2. 5

                                                                                                    Instead of comments, make your code describe exactly what it does. useLongVariableAndMethodNames. Never have single letter variables(Yes: even use the word “index” instead of “i”). Put the time you would spend writing comments into better tests and code.

                                                                                                    How about this as a guiding principle; do what needs to be done for people to understand your system.

                                                                                                    The key bit about this is that there are people on the other side of this equation, with different ways of understanding and picking up information. It’s all good and well for me to say, well, my unit tests describe the behavior of the system, but if people struggle to pick up information quickly that way, it’s not an efficient means of documenting the system (though it continues to serve a purpose in partially enforcing the behavior of the system).

                                                                                                    I like the useLongVariableAndMethodNames technique - I also don’t think it works for every situation, and in those times, you need other tricks.

                                                                                                    1. -1

                                                                                                      How about this as a guiding principle; do what needs to be done for people to understand your system.

                                                                                                      I like the intent behind it, but generally comments to me are a code smell that something has been done wrong. So I like the principle better: “if you are resorting to comments figure out what you are doing wrong”. But as there are dozens of things (at least) you have to master to avoid resorting to comments, switching to temporary comments (todos) is fine.

                                                                                                    2. 3

                                                                                                      I have a program where the following three lines of code are preceded with a block comment:

                                                                                                      if not location.path:match "/$" then
                                                                                                        return HTTP_MOVEPERM . uurl.escape_path:match(location.path .. "/")
                                                                                                      end
                                                                                                      

                                                                                                      The context is a web server, having gone though a path were it ends up pointing to a directory. Now, can you explain why this code exist? And why do I even care to check this case? If you can answer this, then maybe the comment block that precedes this could be removed.

                                                                                                      1. 1

                                                                                                        Two ideas for how you could improve this. 1) is to create a long method name that explains what/why something is happening. 2) is to add a temporary todo comment.

                                                                                                        Very rough pseudocode:

                                                                                                        # todo We had some bad links that pointed to an invalid url. Keep this here until those are all gone.
                                                                                                        this.redirectBadLins()
                                                                                                        
                                                                                                        redirectBadLinks()
                                                                                                         return HTTP_MOVEPERM . uurl.escape_path:match(location.path .. "/")
                                                                                                        

                                                                                                        I suggest reading Clean Code though, does a message better job of explaining great practices than I can.

                                                                                                        1. 5

                                                                                                          You are partially correct. On the server, it’s not a bad link—it does lead to the proper resource. But a close reading of RFC-3986 reveals that <http://example.com/foo> and <http://example.com/foo/> have to be treated as two separate URLs. Fine, but I can’t control what links people use. And without the trailing ‘/’ the path merging rules break (section 5.2.3).

                                                                                                          You may counter that a comment in the form of -- see RFC-3896 sec. 5.2.3 is enough, but not really. Or perhaps a pointer to document elsewhere in the repository, but that’s another file that needs to be maintained along with the code. You might be fine with that, I’m not.

                                                                                                          Another aspect of comments is working around bugs in libraries. It’s a sad fact that not everyone gets to use open source and fix every bug they come across in third party code. But I have a project that is littered with comments about working around bugs in a proprietary third party library that we have no access to the source code.

                                                                                                          Oh, I found another example of a good comment in come code I’ve written (not the one dealing with the proprietary library):

                                                                                                          /*--------------------------------------------------------------------
                                                                                                          ; Basically, if g_poolnum is 0, then idx *has* to be 0.  That only
                                                                                                          ; happens in two cases---when the program first start ups, and when the
                                                                                                          ; program has received too many requests in a short period of time and
                                                                                                          ; just gives up and resets back to 0.
                                                                                                          ;--------------------------------------------------------------------*/
                                                                                                          
                                                                                                          if (g_poolnum == 0)
                                                                                                          {
                                                                                                            idx = 0;
                                                                                                          }
                                                                                                          

                                                                                                          Can the variables name be better? Perhaps. Am I going to wrap this up into a function like reset_pool_if_number_left_is_zero()? No. It would be a) one more bloody function to test, b) only called from one location in the entire code base. Not worth it to me (not a fan of the large number of small functions).

                                                                                                          I think we’re going to have to agree to disagree on your view of comments.

                                                                                                          1. 2

                                                                                                            In the limit, method names have exactly the same problem that comments do: they are written in natural language and can become out of sync with what the method actually does.

                                                                                                            I could have answered that “why” posed above (when eventually I parsed the regex: sunday morning brain), but only because I’ve encountered the problem before. If foo matches a directory name on the server and you have (say) an index.html file inside it, if you serve the index instead of first doing the redirect then any relative links in it will be resolved incorrectly by the browser

                                                                                                            1. 0

                                                                                                              In the limit, method names have exactly the same problem that comments do: they are written in natural language and can become out of sync with what the method actually does.

                                                                                                              This is true in theory, but in practice I find it much less likely, if you are following other best practices (like having short function bodies, functions that do what they say and only what they say, functions that do one thing, etc). But it does indeed happen, and when I see it occur I’ll drop a “todo This fn name is out of date”

                                                                                                      1. 4

                                                                                                        Thumbs up for this feature. It’s a site that really doesn’t need an app, which I love, but it’d be nice to get some of the niceties, such as dark mode.

                                                                                                        Thanks for exposing me to https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme by the way; I just did the job on my own site in fairly short order

                                                                                                        1. 1

                                                                                                          Thank you for that! As someone who has a strong preference for dark mode everywhere I’m grateful to those taking advantage of the new CSS standards.

                                                                                                        1. 11

                                                                                                          Mobile Firefox has plugins.

                                                                                                          1. 6

                                                                                                            Yes, for example, https://darkreader.org/ on mobile Firefox works like a charm for most pages, not only lobste.rs

                                                                                                            1. 0

                                                                                                              iOS/iPadOS Safari doesn’t have plugins that can do that. Saying the user should be able to modify the website to view it as they want is a nice buzzword, but doesn’t actually pan out in reality. iOS/iPadOS LITERALLY DOES NOT ALLOW YOU TO DO THAT. That is not a solution. Let’s focus on actual solutions instead of elitist buzzwords please.

                                                                                                              1. 9

                                                                                                                Responding with an honest-to-machine-code option to the statement

                                                                                                                However, it leaves mobile browsers without any options.

                                                                                                                is neither elitist nor particularly buzzwordy, but a very legitimate addition to the discussion.

                                                                                                                1. 3

                                                                                                                  Honestly if it was a more broader discussion of dark mode, for sure, but when it’s a proposal to add code that supports dark mode to the website, it’s not really useful. People use iOS, others might prefer Chrome, Safari, etc. I get where you’re coming from, but there’s nothing reasonably actionable emerging from the statement, which itself is pretty hit and run - “Mobile Firefox has plugins” is pretty glib, all told.

                                                                                                                2. 4

                                                                                                                  You can’t use Firefox on iOS?

                                                                                                                  1. 11

                                                                                                                    Apple doesn’t let third party browsers use their own engines.

                                                                                                                    1. 10

                                                                                                                      That’s crazy

                                                                                                                  2. 3

                                                                                                                    iOS has a feature called “Smart Invert Colors.” On my iPhone 8, I configured triple clicking the home button to enable/disable it. Works great in Mobile Safari, and Lobste.rs looks fantastic in that mode.

                                                                                                                    1. 1

                                                                                                                      Presumably it just inverts the colors of everything except for images?

                                                                                                                      1. 1

                                                                                                                        That is correct.

                                                                                                                    2. 1

                                                                                                                      With very few exceptions, most people chose to get an iPhone. This seems like a “them” problem, and isn’t elitist to push back on at all.

                                                                                                                  1. 2

                                                                                                                    It’s interesting when you see in the wild quite mock heavy tests, and you realise there’s not particularly a great way to not mock a bunch of stuff out for certain kinds of code (whether through explicit mocking of imports or injecting dummy objects).

                                                                                                                    You could definitely make the case that the test should be an integration test, but that’s not necessarily a silver bullet, you can end up with fragile/flaky integration tests, and in any case, integration tests tend to take longer to run.

                                                                                                                    What I sometimes do is something closer to consumer driven contracts, without explicitly using CDC’s where I’ll verify the behaviour of some impure function with an integration test, keeping the scope of that function very tight, then mock that out in my unit tests, assuming the true behaviour is checked by the integration tests, kind of treating that behaviour as an axiom of the system. It’s not perfect, but I’ve found it works.

                                                                                                                    How have you peeps dealt with this problem?

                                                                                                                    1. 2

                                                                                                                      Is it bad when it’s the only bullet point. Perhaps.

                                                                                                                      Is it an invalid bullet point? The wrong assumption is that the difference is always purely quantitative. It is not. Time sharing in the age when card punches and batch jobs were the standard would overshadow any other bullet point.

                                                                                                                      1. 1

                                                                                                                        Yeah, there’s definitely a dimension that I missed where the world is moving on whether you like it or not, and you need to keep pace.

                                                                                                                      1. 3

                                                                                                                        On a related note it’s been nice seeing pattern matching making its way into languages recently. It’s not revolutionary but is handy for the exclusion of doubt when debugging.

                                                                                                                        1. 6

                                                                                                                          I originally posted this aware that anti TypeScript opinions were unpopular. But I wasn’t aware quite how much people dislike Eric Elliot.

                                                                                                                          It is a shame if Eric is misconstruing data to make an argument. But I think there are valid considerations in the article. Namely:

                                                                                                                          • There is an overhead to using typescript. Such as additional complexity to debug and dealing with @types libraries that not up to date.
                                                                                                                          • tooling exists that gives you much of the same developer experience in JavaScript
                                                                                                                          • hiring experienced typescript developers is hard (especially if you’re in a market with a developer shortage already)

                                                                                                                          I’ve enjoyed writing typescript in the past. But what I take from reading this is the reminder that a team should assess and be aware of the cost of implementing typescript.

                                                                                                                          1. 4

                                                                                                                            hiring experienced typescript developers is hard (especially if you’re in a market with a developer shortage already)

                                                                                                                            This is a weird concept to me, I wouldn’t really look to explicitly hire for somebody ‘experienced with Typescript’. I mean, I wouldn’t even think about it. Sure there are certain things which are trickier to apply types to but those are honestly usually pretty rare. If you’re handling hiring like that, you’re going to create your own developer shortage.

                                                                                                                            1. 2

                                                                                                                              There is an overhead to using typescript. Such as additional complexity to debug and dealing with @types libraries that not up to date.

                                                                                                                              The overhead is mostly in upfront setups costs, and these days it’s pretty minimal. It’s quite rare to find outdated type definitions - I think it’s happened once in the ~4 years I’ve been using TS. In terms of debugging, it’s (all-but) invisible these days.

                                                                                                                              tooling exists that gives you much of the same developer experience in JavaScript

                                                                                                                              Not in my experience. The tools can guess at what you mean when you try to refactor, but it really has nothing on what can be done using types. I’d hate to go through a web framework upgrade without the benefit of compilation errors.

                                                                                                                              hiring experienced typescript developers is hard (especially if you’re in a market with a developer shortage already)

                                                                                                                              Again, not in my experience. Hire a C# + JS dev and they’ll likely pick up typescript in a week and be highly productive in a month. TS itself doesn’t require any special knowledge and is easy to learn.

                                                                                                                              1. 2

                                                                                                                                How can there be valid considerations in the article if he is falsifying evidence? How can we take it that they’re valid? Do we take it on trust? Doesn’t his actively presenting false evidence erode your trust in his argument? If not, why not?

                                                                                                                                1. 2

                                                                                                                                  It is a shame if Eric is misconstruing data to make an argument. But I think there are valid considerations in the article.

                                                                                                                                  This is one of those cases where I realize my value system might not be universal for people. For me, “misconstruing data but valid considerations” is incompatible: intentionally warping data is deeply wrong, and making up sources is unforgivable.

                                                                                                                                  1. 1

                                                                                                                                    Unfortunately. I think this is pretty much the root cause of the current replication crisis we’re seeing in many of the sciences.

                                                                                                                                    1. 1

                                                                                                                                      I was having a conversation about software choices. Not moral value systems. I agree with you to be clear. That’s why the 3 points I came up with were all based on subjective elements of the article and not part of the contensious data. The points I choose were also generally known frictions with adopting typescript.

                                                                                                                                      While I appreciate and agree with your passion for ethical writing, it really was not the conversion I was originally trying to have. Clearly in the future I will think twice before citing an Eric Elliot article.

                                                                                                                                  1. 1

                                                                                                                                    If you’re already writing the whole frontend in React anyway then sure why not.

                                                                                                                                    At work we use styled-components with Reactstrap (which is a project that exports React a component for each of the many things in Bootstrap) It’s pretty nice. Much of the time you don’t write CSS at all because Bootstrap looks nice straight out the box with vanilla markup. Then when you do write CSS, half the time it’s just like:

                                                                                                                                    import styled from 'styled-components';
                                                                                                                                    import {Row} from 'reactstrap';
                                                                                                                                    
                                                                                                                                    const PostRow = styled(Row)`
                                                                                                                                      background-color: pink;
                                                                                                                                    `;
                                                                                                                                    
                                                                                                                                    1. 1

                                                                                                                                      This seems like a nice way of achieving a pretty high efficiency workflow. I think even if you’re not using Bootstrap, you aim to end up build a back catalog of components, which could totally be styled like this.

                                                                                                                                    1. 1

                                                                                                                                      I’d love to hear from people that have tried styles-in-code in production. I’m broadly optimistic that it’s a good idea, but I’m not sure yet what kind of patterns / idioms will emerge and what libraries need to do to be able to support these cleanly.

                                                                                                                                      1. 1

                                                                                                                                        I think that’s the kicker for me. Discovering the best practices in production can be a painful experience.

                                                                                                                                      1. 4

                                                                                                                                        I’ve been thinking about this for a while, but as everything shifts towards the big cloud providers hosting everything, I wonder if there’s going to be point on the price/utility curves where small self hosted companies build an advantage over small cloud hosted companies. Not just on a price basis, but also all the things OP mentions, like stronger control over data sovereignty etc as a service provider.

                                                                                                                                        1. 6

                                                                                                                                          They’ve been doing that. We’re hosted by one, Prgmr, that focuses on simplicity, good service, and transparency. There’s steadily been security-focused hosts that charged extra for stronger security. There’s been Swiss and crypto everything that focus on privacy, charging extra for it, with legal and technical measures.

                                                                                                                                          The thing is that the market as a whole… I’m talking massive number of people/companies with massive buying… collectively vote in favor of whoever offers the most CPU, RAM, HD, and bandwidth at the lowest price. Some of those companies I refer to are still around. Many others perished. People voted with their wallet for no privacy/security along with oligopolies. That’s what they’re getting. The quality/reliability market still exists with most of those buyers going for bare metal. That market isn’t cheap by any means due to cost of servers plus fact that most buyers are enterprises with money. Softlayer did bring us a cloud-like experience to that market, though.

                                                                                                                                          Best route for small players might be to start in VM’s differentiating along Prgmr’s lines, sell some high-profit services on the side, grow their server collection gradually, and offer their highest, steadiest users deals on dedicated boxes. That last part keeps from overextending themselves or needing VC money. This business model is a long-term one that would require more patience than greed. Also, make it a non-profit or public-benefit company ensuring things like privacy and FOSS support so customers’ dollars invested are assured to keep paying off.

                                                                                                                                          @alynpost I’m curious what you think of that proposal for small cloud-to-bare-metal company since your company already went down most of this path.

                                                                                                                                          1. 6

                                                                                                                                            I’m curious what you think of that proposal for small cloud-to-bare-metal company since your company already went down most of this path.

                                                                                                                                            I have all of colocation (owner purchase), managed hardware (leasing dedicated compute resources) and virtual machine (shared compute resources) customers. By and large I replace, upgrade, or improve the disk, RAM, CPU, and network infrastructure faster for the VPS customers than the colocation customers do for themselves. Whatever brings folk to running bare-metal it is decidedly not shorter hardware lifecycles. The managed hardware is a compromise there: I can ensure the hardware meets minimum requirements (like say redundant PSUs) and replace it when I add to (improve) those minimum requirements. Broadly though the managed hardware folk behave like the colo folk: insensitive to hardware lifecycles. They essentially don’t want any changes after install.

                                                                                                                                            If you have the right know-how (i.e., if you ignore labor costs or have otherwise idle labor available) it is cheaper to run your own hardware over the lifecycle of that hardware than paying for it in the cloud. I think that’s basically what I’m seeing in the colo market: buy the hardware, run it cheaply, and stretch the real depreciation of that equipment out as much as possible.

                                                                                                                                            I also seek out and spend time working on other people’s networks, as it helps me avoid ‘tunnel vision’ in over optimizing my own by giving me a broader set of problems to work on. One tell for the age of a company is whether they have a rack of servers in a utility closet somewhere. You don’t see it as much as you used to. That said, if you have an inside sales team or handle walk-ins it’s not unusual to have on-prem telco infrastructure. It also used to be pretty common to run accounting on-prem as a combination of desktop software and shared storage. Hardware companies need labs, software development for products installed on-prem needs the necessary hardware to QA.

                                                                                                                                            To come around then to @verlet64’s question: self-hosting, either by having a rack in a utility closet or by doing colocation works when you have the necessary skills in your organization and don’t want or require the redundancy, density, or electrical power needed or provided by the ‘cloud.’ As nickpsecurity observers this is rare (i.e., a niche).

                                                                                                                                            As to nickpsecurity’s question: I haven’t personally seen a single instance of people moving infrastructure out of the cloud. I have helped a few people do lateral (cloud provider to cloud provider) moves, and I did field questions about colo last year after Meltdown/Spectre but nothing I would consider indicators of a change in sentiment from what I’ve said here. If anything, people want more managed services, simple or otherwise.

                                                                                                                                            It’s personally important to me that we be able to put open source operating systems on a public IP address and that server operators be able to manage those system without requirement for [proprietary] infrastructure mediating their ability to stay online. (e.g., mandatory firewall products.) The security landscape may well make that harder, particularly as we see consolidation amongst network operators. Right now automated intrusion detection systems are coming online at scale and that is putting necessary backpressure on ignored, nonoperative, or misconfigured systems and creating demand for security middleware.

                                                                                                                                            As to data security: the scale of the informational crimes being committed is terrifying.

                                                                                                                                            1. 3

                                                                                                                                              Fascinating reply. Thanks.

                                                                                                                                              “ They essentially don’t want any changes after install.”

                                                                                                                                              I especially think it’s interesting that they keep the hardware as long as they can. I would’ve thought they’d replace it periodically like enterprise, refresh cycles. There could be some potential for high-assurance security in there if the marketing tells them code injections become mere DOS’s where they can delay patches or buying new hardware. I mean, they always advertised that but not to this type of crowd.

                                                                                                                                              “I also seek out and spend time working on other people’s networks, as it helps me avoid ‘tunnel vision’ “

                                                                                                                                              Smart move. Far as company age, those are good signs: my old-ass company has all of those. Another I’ll add is a mix of applications that, if company chased fads, reflects one of most-marketed technologies of each time period. Usually integrated with duct-tape middleware. So, in mine, you got mainframes to Microsoft/UNIX native apps to Java to web apps all trying to work on the same stuff.

                                                                                                                                              “don’t want or require the redundancy, density, or electrical power needed or provided by the ‘cloud.’ As nickpsecurity observers this is rare (i.e., a niche).”

                                                                                                                                              Even I would prefer a bare-metal setup for semi-paranoid apps just to get the benefits of professional datacenters, mainly spreading cost of all that stuff. Could be another niche for those with adequate monitoring, like by customers cover cameras, so we could know nobody messed with our stuff. The hardware would be walked in by company personnel into some cages or something. They could be there to observe if any maintenance needed to be done. Some of these already exist in some places. I think almost all of them require the customer to take their eyes off the box(es) at some point. Eliminating that last part would then just leave side channels and manipulation during camera downtime as last risks.

                                                                                                                                              “ If anything, people want more managed services, simple or otherwise.”

                                                                                                                                              Then, the solution for folks wanting what I want may be to build more managed services in a modular way where their pieces can be swapped out overtime. Start with hardened, reliable stuff. Get market share. As money rolls in, dedicate a certain amount of it to secure building blocks that get plugged into the network after extensive testing. Build secure, private hosts brick by brick. Not too unlike OpenVMS’s strategy of build for a week, break/fix for a week. Obviously, not literally that but some ratio could work.

                                                                                                                                              “Right now automated intrusion detection systems are coming online at scale and that is putting necessary backpressure on ignored, nonoperative, or misconfigured systems and creating demand for security middleware.”

                                                                                                                                              Good. Also develop secure middleware while we’re at it. Make it compatible with some popular one like a drop-in replacement or something. Old-school solution, guards, seems ripe for a comeback, too.

                                                                                                                                              “As to data security: the scale of the informational crimes being committed is terrifying.”

                                                                                                                                              Almost all of it starts with an easily-prevented attack on a computer or a con on a support person. Lots of mitigation potential for companies that aren’t apathetic. Most are. That’s the problem to solve. Courts are best place to solve it. I’ve been letting possibilities tumble in my head on that. Prefer a claim in federal law. A state, law action in a state that’s high profit might force a roll-out that benefits national userbase, though, kind of like how Facebook’s whole service was modified due to European requirements. Even I in the U.S. got a copy of my data. Gotta establish the theory in a few cases followed by real damage from class actions and/or piles of people in small, claims court. As liabilities go through the roof, tech and practices that provably reduce them get more uptake, too.

                                                                                                                                              That’s the theory anyway. They’ll also try to lobby the liability away. Competing with two types of players simultaneously.

                                                                                                                                            2. 2

                                                                                                                                              The thing is that the market as a whole… I’m talking massive number of people/companies with massive buying… collectively vote in favor of whoever offers the most CPU, RAM, HD, and bandwidth at the lowest price. Some of those companies I refer to are still around. Many others perished. People voted with their wallet for no privacy/security along with oligopolies. That’s what they’re getting. The quality/reliability market still exists with most of those buyers going for bare metal. That market isn’t cheap by any means due to cost of servers plus fact that most buyers are enterprises with money. Softlayer did bring us a cloud-like experience to that market, though.

                                                                                                                                              I agree, but want to emphasize that “voting with your wallet” isn’t like voting in an election because it’s always going on and in many cases people can change their votes later. In the past people have “voted” for more CPU, RAM, HD, and bandwidth over anything else, but times change and as the situation evolves and more security breaches and data leaks happen people can change their vote to favor more privacy/security.

                                                                                                                                              In the future companies focusing on privacy and security may very well do better than their counterparts offering the cheapest possible solution.

                                                                                                                                              1. 3

                                                                                                                                                Oh yeah, that’s true. The biggest boost coming after Snowden. They’re still mostly not making money compared to non-private and insecure products. So, my recommendation for anyone wanting to do something like that is to either do it after they have an established, profitable service or otherwise have a fall-back option. Another possibility, since many companies start this way, is to build the product or service as part of taxpayer-funded research which is then spun out into an open-source release and commercial offering.

                                                                                                                                          1. 7

                                                                                                                                            Most of the marketing done by Firefox is precisely of the form you describe here. I’m not sure why you feel that’s not the case.

                                                                                                                                            1. 6

                                                                                                                                              Yeah I didn’t mean Firefox’s own marketing but more the community word of mouth message.

                                                                                                                                              Added a footnote outlining as such, thanks for making the ambiguity clear to me.

                                                                                                                                            1. 8

                                                                                                                                              This is interesting, because it also comes down to how the reviewer reviews code. If the reviewer just looks at the changes in a PR as a whole, a lot of the value in careful commits becomes about the historical record than ease of reviewing. Still valuable, but there’s something to be said for learning to review code.

                                                                                                                                              1. 4

                                                                                                                                                That was one of my motivations to write this in the first place. Now I can just send a link to the ones on my team.

                                                                                                                                                I agree that how we write history is important on its own merits. You commit once, but it will be read a lot more. Both during review, but also as part of later debugging.

                                                                                                                                                1. 4

                                                                                                                                                  It’s something I try and stick to even if it takes a bit of time. git add -p <filename> is invaluable for this too.

                                                                                                                                                  When I see people reviewing things as a giant chunk of code, I feel that sometimes it comes from a history of commits not being very useful. When commits are more noise than signal, I don’t blame people for not looking at them.

                                                                                                                                                  Another thing is familiarity with rebasing. I think there’s a lot of talk about rebasing being difficult, which means people don’t attempt it because they’re scared to lose work, which is entirely reasonable, but we need to talk more about recovery techniques like the reflog, etc.

                                                                                                                                                  1. 3

                                                                                                                                                    git add -p <filename> is invaluable for this too.

                                                                                                                                                    Magit makes it painless.

                                                                                                                                                    1. 2

                                                                                                                                                      The simplest being to make a test branch on which to test. If all goes well, you can reset you branch to the test branch’s commit and proceed from there.

                                                                                                                                                      I don’t know if people understand the lightness and ease of branches, but it’s simpler than cherry-picking from reflog.

                                                                                                                                                      Git is excellent in how hard it is to truly fsck up, and people should learn these techniques and not consider them magic tricks.

                                                                                                                                                    2. 1

                                                                                                                                                      Your motivation resonates with me; I’ve been writing something partially for my coworkers about my thoughts on commits and reviews, plus explaining some of my workflows… Part one is here: https://medium.com/p/c0966a562b10

                                                                                                                                                  1. 2

                                                                                                                                                    I think one challenge with correlating NPM package usage data is that NPM usage itself has changed considerably in the 5 or so years since. There are not only more users now, but I would say there is the potential for the usage patterns themselves to differ.