Threads for justincampbell

  1. 2

    There have been a few of these articles lately, that push some variant of “don’t worry so much about writing good code, focus on testing when it is branded as TDD.” Is there some reason for this trend?

    1. 8

      If I were to hazard a guess, it would probably be a lot of the Uncle Bob Martin viewpoint that TDD is the only way to build better software.

      It is a dumb viewpoint that only TDD fixes things, but it has understandable roots from a certain perspective. Also before I get down voted for the last phrase, an explanation to why TDD doesn’t solve a lot on its own and can mostly be gamed to demonstrate competence (inspired from real life code):

      def foo(x):
          return x * x    
      
      def test_foo():
          self.assertEqual(foo("x"), "xx")
      

      This is the most useless test ever, and all it did was increase test coverage. But it doesn’t do a damn thing about boundaries, what should happen with different types being passed into the function, what should/should not be allowed as types (something static type systems like Haskell/Idris/Ocaml get for free) etc…

      1. 1

        This is not a useless test! Based on the syntax, I’m assuming the language is Python. There are no compile-time or run-time checks that this code will not throw an error until you actually execute it.

        What does * do when applied to two strings? Maybe you meant +?

        >>> "x" * "x"
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: can't multiply sequence by non-int of type 'str'
        >>> "x" + "x"
        'xx'
        

        These “useless tests” can be thought of as double-entry bookkeeping in accounting. Sure, you’re absolutely certain that the code you meant to write would work. But as demonstrated in your example, even a single line method can have unexpected bugs.

        1. 0

          Yeah, meant +.

          The only issue with this test is it really doesn’t do anything useful, my typo that i’m too lazy to fix aside, it doesn’t actually test anything of substance.

          A bit better example in c, take a function that takes a uint8t and does a divide by 2 and also adds a uint8t that can exceed UINT8_MAX. Writing out all the unit tests in a TDD fashion for this is tedious at best, and as error prone as the code you write at worst. How do you handle overflow? Do you use saturating addition? How do you validate all values are right in this regime? etc…. TDD doesn’t help with the hard problems of logic here.

          Property based tests here would be better, but I guess in the end I see TDD as promoted by most people as being equivalent to ∃ or ∄ versus ∀. This isn’t to discount TDD, but it is at best a step towards better software. I’d argue it is a very small step compared to things like theorem provers and dependently typed languages.

          These all need work as well to become mainstream but I feel much better with things like property based testing and dependent types, or even things like smt solvers with liquid haskell than I ever do with TDD. TDD is too much like ad hoc polymorphism with OO languages to me. I’d rather either use straight c structs or go all in with a more expressive type system.

          1. -1

            I believe you are making their point for them. Writing tests for cases that can be systematically excluded by a type system is a waste of time, and no matter how hard you flail at it you’ll never do as good of a job covering those cases.

            1. 1

              Type systems only guarantee that the input and output types are correct. They do not guarantee that the function does what you expected it to do.

              1. 0

                That’s obvious. What is your point?

                My reading of the example was that they 1) meant + instead of *, 2) were intending for foo to operate on integers, and 3) were showing an example of a useless test that checks the result of foo on strings, when that case would have been excluded by a type system.

      1. 1

        People in this thread are missing the point:

        • An experienced programmer who practices TDD will write better code than if they didn’t.
        • A junior programmer who practices TDD will write better code than if they didn’t.
        1. 2

          That might be the point, but the point is unproven if the metric is not valid.

        1. 6

          It’s not a huge burden to setup and maintain a self-hosted solution for any one service, but doing so for the 10-15 services I use would be a full time job.

          1. 3

            Setting up self-hosted email for a residentially hosted domain is a pretty huge burden. In the US, you can’t just turn on a mail server on port 25, slap up some MX records, and expect to get email delivered to the server hanging at the end of your ISP’s modem. Even if your ISP hasn’t filtered out the standard email ports, most mail servers won’t talk directly to anything located in an ISP residential subscriber address block, and many upstream filters will either spambox or silently discard your mail if try to send it that way.

            One typically ends working through the ISP to get outbound mail accepted through their local outbound servers, and then then still having to employ a third party (fourth party?) service to do authenticated relay for your domain.

            Its doable (I do it) and its really nice to be able to set it all up the way you want it… but It costs money, its complex, and the details are different depending on your ISP and your relay provider so its not like there is a simple recipe for it. Even if you know what you are doing, setting up email is a burden. :‘/

            1. 2

              I used to run my own, well, almost everything! (SMTP, XMPP, HTTP, CalDAV, etc.) But it was just more work, more money, and more hassle. But my migration choices were to providers without lock-in. (Fastmail, nfshost, etc.)

            1. -1
                1. 4

                  I have a folder in my Dropbox, and I sulking it to ~/Notes. I create/edit notes in any of:

                  • Vim. I have a tmux keybinding to open a new window, cd to ~/Notes, launch Vim, and start a fuzzy finder. So at at any time, I can do ctrl+b n <start fuzzy finding notes> or :e a new note.
                  • nvALT, for when I want to edit notes in a GUI. Typically I use this when I’m not currently programming/in a terminal.
                  • Notesy for iOS. I’ve had to change iPhone apps at least 5 times because of bugs/other issues, but Notesy has been going strong for a few years now.

                  This allows me to edit any note from anywhere, and doesn’t tie me in to any specific software. Each note is typically a Markdown file, but I have some others in there too, such as dot.

                  If I need to draw something, I love Rhodia dot-ruled notebooks, and any cheap #2 pencil with a sharp tip.

                    1. 17

                      I will take this opportunity to remind people that Lobsters stickers are also available (but not for free).

                      1. 5

                        Is that 2.64 for one sticker?

                        1. 3

                          Includes shipping

                      1. 5

                        So what? It’s an extremely offensive term on a publicly accessible part of their website. They have every right to remove it.

                        1. 5

                          The comments by the lobsters community on this post are truly fucking dissapointing

                          1. 4

                            Explain? It’s basically me and everyone else. I happen to disagree but I’m not disappointed by their comments. And as for me, well, I don’t think I qualify as the community.

                            1. 5

                              I don’t know how a code of conduct can be seen as anything but a positive step for a community

                              1. 7

                                This discussion has been tedu against pretty much everyone else, and while tedu is, shall we say, a weighty member of the lobste.rs community, he is hardly all or even an appreciable majority of it. I actually think this discussion has gone really well given how poorly discussions of codes of conduct have gone elsewhere on the Internet.

                                1. 6

                                  I would say most of the lobsters community agrees with you.

                            1. 2

                              Excited to give this a try.

                              For those that use Vim, you can also use the conceal functionality to replace sequences with other symbols. Example: https://github.com/enomsg/vim-haskellConcealPlus

                              The original characters are shown when the cursor is on the line.

                              1. 2

                                For emacs, one can use the display text property to show the utf8 characters instead of the sequences that’d normally be displayed (eg replacing -> with )

                                I don’t know of any extensions off the top of my head that’d do all of the haskell ones in one shot, though I’m sure the community would appreciate it if there were one.

                              1. 1

                                I just finished Programming Elixir by Dave Thomas, which is really week written. Also reading Understanding Computation by Tom Stuart for http://csbookclub.com.

                                1. 2

                                  This really excited me, so I bought the pro version, but it crashes the moment I sign in

                                  1. 2

                                    I tried the free version and that worked. Love the layout on the today screen. The realtime number on the right is a nice touch.

                                    1. 1

                                      Appreciate the feedback, and your patience! Let me know if you have any other suggestions or ideas.

                                    2. 1

                                      I’m really sorry about that. It’s a bug that (I’m hoping) is fixed in a release I pushed out moments ago. Let me know if you still have issues.

                                      Message me your email and I’ll send you a free promo code for the desktop version for your trouble!

                                    1. 1

                                      Yeah, I’d like something like that, but for normal files on a system.

                                      1. 2

                                        For space analysis, baobab is great.

                                        1. 2

                                          I’ve been using jdiskreport for the last 10 years or so, it works a treat and it supports all main operating systems where the sun JVM runs

                                          1. 1

                                            Mac

                                        1. 2

                                          I appreciate the organization, but have you thought about just linking to pre-existing kata repositories rather than trying to bring them into one group?

                                          1. 4

                                            They’re not katas per se, but repos to help you practice a kata. The person greeting is intentionally simple and vague so that it doesn’t lead you down a path.

                                            If you can think of a way to make this intention clearer, I’d appreciate the feedback!

                                          1. 10

                                            I took off until the new year to watch our baby. In between that, I plan on livecoding a bunch. Some stuff I plan to broadcast:

                                            • Learning OCaml or Rust
                                            • Exploring microservices, probably with RabbitMQ and Thrift
                                            • Working on some CLI utilities in Go

                                            I’ll post when I’m broadcasting to http://twitter.com/justincampbell.

                                            I’m also pairing with people on Fridays. If you want to pair, contact me on Twitter!

                                            1. 2

                                              “This allows file names that contain newlines…” ಠ_ಠ

                                              1. 3

                                                It’s entirely possible, and yeah, it’s a huge pain in the ass to deal with.

                                                $ touch file$'\n'name
                                                $ echo *
                                                file
                                                name
                                                

                                                In fact, any byte other than null and slash are legal in filenames. It’s a safe bet that a significant majority of software doesn’t correctly handle every possible filename.