1. 22

    Comments really aren’t a “code smell.”

    1. 16

      Nothing stinks quite like uncommented complicated code.

      1. 7

        Exactly! Margaret Hamilton’s code itself, whom the author cites, is full of comments. Possibly more comments than source code. Which, if you’re sending a ship with the processing power of a toothbrush to the Moon, is a great idea.

        1. 10

          This code is not readable on it’s own, if it was possible to use variable and function names most of those comments could be removed. It’s also quite likely that every detail of the program was decided before writing the code. In a modern codebase things are always evolving and comments can get left behind.

          1. 5

            This is my fear with comments. I code in a team of 2, so we don’t really comment stuff. I know it’s bad, but I’m a team of two, we kind of know the whole code anyway.

            We also don’t write tests. We’re bad people.

            1. 4

              Oh man, save yourself some pain and write unit tests. You don’t need 100% test coverage, even non-zero coverage of basic functionality will save you so much time. If you don’t know how to use test frameworks then you don’t have to bother, just write one big main file with a function per test you want to do, and call them all in main. That’s basically what test frameworks are, so if you need a low barrier to entry then don’t bother learning one yet, just do something. If you program in a language with a REPL you can literally just save the stuff you use to manually test into a file so you don’t have to type it more than once.

              I personally couldn’t develop without unit tests. You can test the application and do something that hits the code path you just changed, which is time consuming and tedious, especially to do repeatedly, or you can write a little bit of code that calls the code and run it with zero effort every time all the time for the rest of forever. Even a small sanity test of the happy path is better than nothing, you can at least check your code doesn’t blatantly fuck up with normal input and save yourself the round trip through the application.

              If I had to code without unit tests I’d quit. And I have worked on teams that didn’t want to unit test, so I had out-of-tree tests I wrote for myself. The amount of bugs I fixed a couple hours after someone else committed was mind boggling.

              1. 4

                How do you even develop without unit tests?

                I’d avoid this kind of shaming, especially since the commenter has already noted (in a self-deprecating manner) that they’re aware of the stigma associated with not using tests.

                If the intent is to encourage the use of tests, I would put your last paragraph first and focus on how it would help GP.

                1. 3

                  Revised, thank you for the feedback. 😊

                2. 2

                  Depends on the language and coding style though. I wrote a 25000 line game in C++ without a single test, and I never had a regression. I obviously had occasional bugs in new code, but they’re unavoidable either way. Now my preferred language is Haskell, and I feel the need for tests even less. I generally prefer correct-by-construction to correct-by-our-tests-pass. My purpose isn’t to discredit tests though, just that not every codebase has as much need for them.

                  1. 2

                    I’m just self taught and kind of out of my depth on it. I had a dev friend who did integration tests, and they were really brittle and slowed us down a lot. Are unit tests not as bad at slowing down a small team of two devs who are both self taught? We’re good / mediocre / we build good stuff (I consider ourselves hackers) but we don’t have a ton of time.

                    1. 1

                      Unit tests don’t have to slow things down like integration tests. In your situation, I’d wait until the next bug comes up, then instead of fixing the bug immediately, I’d write a test that reproduces the bug. Usually doing that helps narrow down where the bug is, and after fixing it, the test passes and (here’s the cool part) you will never see that bug again

                      1. 1

                        That’s what i was told about integration tests, but I had to set up all these extra dependencies so that the integration tests continued to work every time we added an external service… we’d have to mock it or shit would break.

                        I’m assuming since Unit tests don’t run like that, they don’t have external dependencies like that? You’d mock on a component by component basis, and wouldn’t have to mock unrelated shit just to keep them running… hmm… maybe i will.

                        Any unit testing video series I could watch as a noob to get started you’d recommend? Or anything like that?

                    2. 1

                      I second saving yourself pain with writing tests! I’ve avoided lots of rakes with a handful of tests

                  2. 2

                    What makes everybody think that the programmers who change code so that it no longer matches the comments they just used to understand it will somehow write code so clear you don’t need comments to understand it?

                    1. 1

                      Often people write code like total = price * 1.10 #This is tax which can be rewritten as total = price * TAX A lot of comments like that can be removed by just putting them in the actual code.

                      1. 2

                        I’m not suggesting it can’t be done I’m suggesting it won’t be done

                  3. 4

                    I’ll also correct the article to say a team did the code and review per the reports I read. She describes it here in “Apollo Beginnings” as a team with a lot of freedom and management backing with unusual requirement to get software right the first time. Unfortunately, a rare environment to work in.

                  4. 5

                    You can’t write test coverage for a comment. You can’t have your compiler warn you that a comment is inaccurate.

                    If you have no tests, and your code is full of dead paths, you can’t even percieve the risk posed by an errant, out of date, or unintentionally misleading comment.

                    Sometimes they’re necessary. But the best default advice to a ‘mediocre’ developer is to write better code, not add more comments.

                    1. 5

                      You can’t write test coverage for a comment. You can’t have your compiler warn you that a comment is inaccurate.

                      https://docs.python.org/3/library/doctest.html

                      If you have no tests, and your code is full of dead paths, you can’t even percieve the risk posed by an errant, out of date, or unintentionally misleading comment.

                      If you have no tests or comments you have no way of knowing whether your code is actually matching your spec, anyway.

                      Sometimes they’re necessary. But the best default advice to a ‘mediocre’ developer is to write better code, not add more comments.

                      That’s like saying that the best default advice to a ‘mediocre’ developer is to write less buggy code, not add unit tests.

                      1. 2

                        doctest is great for testing comments that include code, but nothing else… If a comment says “Framework X is expecting variable foo in JSON format inside the array bar.” I would be inclined to believe it at first and then test the hypothesis that the comment is wrong. That’s the danger of comments.

                        1. 1

                          A couple of times today I caught myself committing deleted or changed lines without deleting or changing the associated comment. Luckily I could go back and fix things so that the comments weren’t complete nonsense. Sometimes though they escape detection.

                      2. 2

                        Once the code is cleaned as much as possible and still is hard to understand, or if something is tricky, comments help a lot!

                        I guess the author talked about comments that could be removed by making the code cleaner.

                        Maybe it depends on what motivates one to add comments, there might be good reasons as well.

                        1. 2

                          True.

                          But Comments that are wrong or out of date stink like dead rats.

                          I view asserts as “executable comments” that are never out of date. Sometimes they are wrong… but testing will tell you that.

                          If a plain comment is wrong… nothing will tell you except a very long, very Bad Day at work.

                          1. 7

                            But Comments that are wrong or out of date stink like dead rats.

                            Valuable comments are something along the lines of “this looks weird, but I did it because of [historical reason that is likely to be forgotten] even though [other implementation] looks like the more obvious solution at first glance; it wouldn’t have worked because [rationale].”

                            The longer I spend working with old codebases, the more I’ve come to treasure such comments. But comments that just explain what the code is doing rather than why are suspect.

                        1. 17
                          1. Overcommunicate - the benefits outweigh the costs. You may sound repetitive, but having everyone be clear and on the same page is a huge win.
                          2. Get out of the house/apt - whether you’re an introvert or an extrovert, social interaction in real life is important. Get out and hang out with people.
                          3. Find a routine that works for you - and stick to it. If working out is important to you, schedule it into the day.
                          4. Set boundaries - let your teammates know you’re on from e.g. 10am to 8pm. Enforce this. For example I do not have Slack on my phone.
                          5. Sequester your workspace - don’t work in the bedroom. Your brain learns and will start to associate the bedroom with work, stress, bugs, Jira, etc.
                          1. 2

                            The big question here seems to be: how will it make money if not by making you a product like Facebook does it? Ads?

                            It seems to me that a (primarily?) self-hosted, decentralized solution is the only sensible way out, and it comes with the obvious downsides: a/ people don’t like things that can’t be easily regulated, b/ it’s hard to gain a market share with this unless your social group is a bunch of nerds.

                            Maybe actually hanging out with your friends in real life and sharing information the old-school way, or simply engaging more in direct messaging, for which there are privacy-focused platforms, is the best choice you have. In the end, people tend to share very superficious things on Facebook and fish for attention (been there) instead of engaging you directly in a meaningful way.

                            What is it that you’re really missing?

                            1. [Comment removed by author]

                              1. 6

                                Not everything can afford to lose money.

                                1. 2

                                  It costs so little to run a small instance that a few small donations often end up funding the whole operation. You can literally run pleroma on a raspberry pi which is a federated solution not decentralized but also a lot LESS centralized than say one website that one person hosts.

                                  1. 1

                                    Heck, my brother runs his own website (a fork, if that’s the right word to use, of lobste.rs) off of a computer he has hooked up in his closet. It’s not particularly cost-prohibitive to run a website unless it’s absolutely massive.

                                    1. 2

                                      If it’s public, please add it to the list of sister sites: https://github.com/lobsters/lobsters/wiki

                                2. 1

                                  I don’t think it needs to make money at all, hence the Wikipedia proposal. But it needs to keep the lights on.

                                3. 2

                                  What I’m really missing is the ability to easily organize somewhat distributed groups of friends and stay updated on their lives. By organize I mean take a group of friends where 2 or 3 live in NJ and 3 or 4 live around NYC, get some kind of a group chat going, and land on a time/place to meet.

                                  I’ve been doing the old school thing for these past 8 months, and what I’ve discovered is that

                                  1. email is a pretty good platform for carrying out long-format discussions
                                  2. my flipphone has terrible audio quality and weak signal to the point where it hampers conversations
                                  3. the inability to quickly shoot off a text message on the flip phone is more debilitating than originally imagined
                                  4. If I’m going back to NY and want to hang out with people, I just ask one of my friends there to use his FB or phone to organize a time and place to catch up, shifting the burden and the price of being on FB onto him

                                  Answering your question helped me realize that something like a simple, standalone alternative to FB messenger and FB events might do the trick. The two biggest barriers I see are:

                                  1. Network effects, obviously
                                  2. How to pay for this

                                  In regards to 2 - is it possible the Wikipedia model would work? Essentially, donations? That would allow the platform to potentially be open source which would strengthen any claims it make towards privacy.

                                  1. 2

                                    it’s always felt like the obvious solution to make money is to charge money for a subscription.

                                    But app.net tried this and failed pretty hard. Wonder if it’s ever possible. I would totally pay money to get ad-free Facebook/Twitter, but that would go against their overall business models.

                                  1. 22

                                    I think the Fediverse (GNU Social / Mastadon) is the decentralized social network with the closest to critical mass so far. You can either join a node run by someone you trust, or run your own. If by privacy you mean you don’t want the server operator collecting usage profiles on you and so on, that might be a good fit. Messages are still usually public though.

                                    If you want messages private and not easily scrapeable on the public internet, the Fediverse isn’t quite as good of a fit, although there are ways to do it with GNU Social at least, by setting up private groups on a single node. But that’s not as widely used, and you’d have to get your social group all on a GNU Social node. Another approach might be to make an ad-hoc Signal group (you can add multiple people to a group-messaging session). Messages there are end-to-end encrypted and it’s relatively easy to get people on Signal (many people I know are already on it), but messages do go via a centralized server infrastructure, so Signal can collect metadata even if not the message contents (I think I probably trust them more than I trust Facebook/Twitter, but still).

                                    1. 2

                                      I used Mastodon a few months back. I found its feature set closer to Twitter than Facebook; to me it’s a good platform for seeing news, cool tech trends, or following people I respect in the tech world. Not so much for staying in contact with real-world friends, organizing outings, etc.

                                      I also find the “join a node run by someone you trust” to be a barrier to joining. My non-tech friends probably will as well.

                                      I really don’t mind the server being centralized. As long as (1) the company has a clear mission statement and has not given reason to doubt that mission, and (2) has a zero-knowledge infrastructure (I think metadata is ok), I am happy to use it.

                                      1. 9

                                        One option with Mastodon is to just run your own private instance for friends. It’s pretty easy to setup, and will run fine on a $5 a month Linode instance.

                                        1. 7

                                          Maybe give Diaspora a try; same basic ideas, but I believe is closer to facebook than twitter.

                                          Edit: I think the idea of not minding a centralized solution and only using a company you can trust are sort of opposed. If your solution is centralized and you lose trust in the company, you’re stuck with abandoning the network or your principles. If you’re using a federated network then you can still use the network without supporting that specific company (node/instance). And I’m not sure what’s so hard about trusting an individual/small group of people instead of a company.

                                          1. 3

                                            Agreed on the last part. Companies are composed of constantly changing and potentially large groups of people all hidden behind a shallow corporate identity.

                                            Trusting individuals makes a lot more sense to me.

                                      1. 2

                                        Have you looked into ZeroNet?

                                        1. 3

                                          I have, but it requires a Bitcoin wallet and downloading a binary. Whatever I end up using needs to be simple and accessible enough for me to convince at least some of my friends to use.

                                          It needs to be the kind of thing where privacy is inside the Trojan Horse. The experience is great, and if you happen to care about it, it also has privacy. It can’t be the kind of thing where the user has to jump through hoops.

                                          1. 3

                                            ZeroNet doesn’t require a bitcoin wallet. In fact it doesn’t use bitcoin at all. I don’t know why this became a thing. Maybe because ZeroNet site addresses are valid bitcoin addresses, and you can import the private key for a site into bitcoin if you want, then people can send coins to your site address and you can receive them. I don’t know of anyone who actually does this though.

                                            You don’t need to download a binary. It’s written in Python and open source. Clone the repository and run if you want. If you have non-tech friends there are “bundles” which contain everything needed to run and stay updated.

                                            I wrote about using their decentralized microblogging system on a post about ZeroMe if you want to look at it further.

                                            1. 2

                                              In fact it doesn’t use bitcoin at all.

                                              Huh, that’s new to me. I had assumed it was more deeply tied in because the front page mentions bitcoin prominently, and even uses the phrase “your bitcoin wallet” (which seems to imply I have one). Although on closer reading, to be fair, it just says that it uses “the same cryptography as” my bitcoin wallet, not the actual wallet. There’s also another blurb saying “Decentralized domains using Namecoin cryptocurrency”, which added to my impression that I probably needed to be deep into the cryptocurrency scene to use this.

                                              I’ll give it another look!

                                        1. 5

                                          There’s quite a rigid type system implemented in Sanskrit. I wrote a high-level overview of it a few years back. Sanskrit has gone on to, indirectly, give rise to the Backus Normal Form.