1. 28

    It’s what I’d do even if I weren’t getting paid. It’s my primary hobby, my profession, and what I’ve wanted to do since I can remember.

    1. 6

      This is exactly my feeling. I love solving problems using software I write, I love knowing people are using what I make, and I love reducing the amount of boring and error-prone repetition in my life using my own software.

      I think people who don’t enjoy coding belong in the industry just as much as anyone else. At that level, it’s a job, and we don’t expect people in any other field to love it, necessarily. But it’s a very odd, specialized job which is definitely not for everyone, and anyone smart enough to be a programmer is probably smart enough to make a living in some other field which doesn’t involve the obscure pains programming can expose you to.

      1. 4

        That’s awesome that your hobby and profession aligns 🙂

        Do you have any advice for people who currently don’t enjoy doing what they do for a profession and how to get there?

        1. 11

          Well, I guess my first advice would be to ask, what do you love? There’s absolutely nothing wrong with coding to pay the bills and doing what you love with your free time. My other hobby is Western religious history, which definitely is not a moneymaking industry. :)

          I’d also say, coding is a huge field, like “talking”. There are a million languages, a million techniques. You might find that you like the theoretical side more (math, complexity theory, category theory, etc). You might find out that you really like writing parsers. Maybe you hate Java but you end up loving Erlang. There’s a lot out there.

          But, again, there’s nothing wrong with just having a day job. Life is meant to be enjoyed so don’t worry about what you “should” like, do what you do like however you can.

          1. 1

            I like to ice skate and tinker, mostly with keyboards and other input devices, but the skies the limit really.

            Unfortunately neither pay well so here I am 🙂

            1. 5

              Has it always been the case or in the beginning you used to enjoy programming?

              If you used to like it, but not anymore, it’s worth trying to investigate why. This is something that has also happened to me, and it took me a while to finally find an answer. At first, I thought this was a matter of abstract vs concrete activities and I tried to find concrete activities that I could find interesting. Though I did start cooking (and discovered I enjoy it), this still wasn’t the real issue. You said you like ice skating and tinkering, so maybe this is a good place to start thinking about it.

              Later, I realized that what I really miss from the early days is having everything under control: relatively small code bases that I understand well, none or just a few third party libraries, etc. In contrast, most professional projects I have taken are the complete opposite: large code bases that no one really understands with lots of external libraries. I still don’t know what exactly I can do about this, but just from knowing where my discomfort comes from, I already feel a bit better about programming overall.

              This has been my quest so far to try to start enjoying coding as much as used to. You’ll probably find other topics that I haven’t mentioned, but that are important to you. This is an introspective exercise I think you should do if you also wish to get back to programming with a refreshed feeling.

              1. 4

                I used to like it. I had a really good job at the start of my career with an amazing mentor. However, since that job, I haven’t liked it much.

                I’ll try to reflect on exactly why, but I have a suspicion that it’s when I realized that agile and startups are irrevocably intertwined with coding. Both I can’t stand.

                This is an introspective exercise I think you should do if you also wish to get back to programming with a refreshed feeling.

                That sounds amazing. Hopefully, I can get there. 🙂

          2. 4

            Not the parent commenter, but how about looking into other programming paradigms? e.g. if you only do OOP right now, try looking into functional programming, there’s a lot of interesting and beautiful stuff there that might appeal to you.

            Or perhaps have a look at formal methods, either “lightweight” ones like TLA, or the more heavy weight ones like Coq and Lean. I’ve found writing specifications above the level of abstraction that most programming languages provide and model checking them or writing proofs for them quite an interesting/enlightening experience for me and it’s one of my favourite things to do.

            Lastly, I think generally identifying pain points in your workflows and writing little programs to automate them and scratch your itch could be another way to find joy in programming. For me that’s writing little Haskell scripts or elisp (Emacs Lisp) tidbits here and there.

            1. 2

              Thanks for the reply! I know this is a “me problem” but when I have to learn new technologies I find it very frustrating. Recently I’ve been on a Scala project and FP hasn’t done anything for me.

              It wasn’t always that way though, I used to get excited about new technologies but after a while it just notice it for the revolving door it is.

              1. 2

                […] but when I have to learn new technologies I find it very frustrating.

                I can relate to that :)

                Recently I’ve been on a Scala project and FP hasn’t done anything for me.

                Interesting. I’d say in that specific case, the language and the machinery it offers probably influence that as well. Like, for instance I’d take writing Haskell over Scala any day. But oh well, that’s me.

                It wasn’t always that way though, I used to get excited about new technologies but after a while it just notice it for the revolving door it is.

                Right. Same here actually. I don’t go looking for shiny new things to use just because they’re shiny and new. But I would still gladly consider things that could help improve the quality and correctness of programs that I write, and see if they’d be worth the investment of time for learning/integrating them into my workflow. And that bar has certainly increased over the last couple years.

        1. 2

          In what other languages would it be possible?

          I guess everything with properties (functions disguised as fields) so D, C#, etc.

          Afaik not with C, C++, or Java.

          1. 26
            #define a (++i)
            int i = 0;
            if (a == 1 && a == 2 && a == 3)
            1. 1

              Isn’t that undefined behavior? Or is && a sequence point?

              1. 3

                && and || are sequence points. The right expression may never happen depending on the result of the left, so it would make things interesting if they weren’t.

            2. 10

              This is very easy to do in C++.

              1. 5

                You can also do it with Haskell.

                1. 3

                  Doable with Java (override the equals method), and as an extension, with Clojure too:

                  (deftype Anything []
                    (equals [a b] true))
                  (let [a (Anything.)]
                    (when (and (= a 1) (= a 2) (= a 3))
                      (println "Hello world!")))

                  Try it!

                  Or, inspired by @zge above:

                  (let [== (fn [& _] true)
                        a 1]
                    (and (== a 1) (== a 2) (== a 3)))
                  1. 3

                    Sort of. In Java, == doesn’t call the equals method, it just does a comparison for identity. So

                     a.equals(1) && a.equals(2) && a.equals(3); 

                    can be true, but never

                     a == 1 && a == 2 && a == 3;
                  2. 3

                    perl can do it very simply

                    my $i = 0;
                    sub a {
                    	return ++$i;
                    if (a == 1 && a == 2 && a == 3) {
                    1. 2

                      Here is a C# version.

                      using System;
                      namespace ContrivedExample
                          public sealed class Miscreant
                              public static implicit operator Miscreant(int i) => new Miscreant();
                              public static bool operator ==(Miscreant left, Miscreant right) => true;
                              public static bool operator !=(Miscreant left, Miscreant right) => false;
                          internal static class Program
                              private static void Main(string[] args)
                                  var a = new Miscreant();
                                  bool broken = a == 1 && a == 2 && a == 3;
                      1. 2

                        One of the ‘tricks’ where all a’s are different Unicode characters is possible with Python and Ruby. Probably in Golang too.

                        1. 7

                          In python, you can simply create class with __eq__ method and do whatever you want.

                          1. 4

                            Likewise in ruby, trivial to implement

                            a = Class.new do
                              def ==(*)
                            a == 1 # => true
                            a == 2 # => true
                            a == 3 # => true
                        2. 2

                          In Scheme you could either take the lazy route and do (note the invariance of the order or ammount of the operations):

                          (let ((= (lambda (a b) #t))
                                 (a 1))
                            (if (or (= 1 a) (= 2 a) (= 3 a))
                                "take that Aristotle!"))

                          Or be more creative, and say

                          (let ((= (lambda (x _) (or (map (lambda (n) (= x n)) '(1 2 3)))))
                                  (a 1))
                              (if (or (= 1 a) (= 2 a) (= 3 a))
                                  "take that Aristotle!"))

                          if you would want = to only mean “is equal to one, two or three”, instead of everything is “everything is equal”, of course only within this let block. The same could also be done with eq?, obviously.

                          1. 1

                            Here is a Swift version that uses side effects in the definition of the == operator.

                            import Foundation
                            internal final class Miscreant {
                                private var value = 0
                                public static func ==(lhs: Miscreant, rhs: Int) -> Bool {
                                    lhs.value += 1
                                    return lhs.value == rhs
                            let a = Miscreant()
                            print(a == 1 && a == 2 && a == 3)
                          1. 2

                            Can anyone give me some examples of the sort of things you write on a personal wiki? I’ve always enjoyed the idea of having one, but at the same time I can’t maintain one for a long time. I feel like it’s too much effort, and that I can find whatever I want using Google anyway.