1. 16

    I still don’t understand the backlash against “generics” (i.e. parametric polymorphism). If you’ve ever programmed in a dynamic language, then much of the code you’ve written in that language is generic, e.g. len() in python.

    “generics” is just a language feature to bring this flexibility to statically-typed languages. What is complicated about this? Writing val length : 'a list -> int is simpler than writing val length_of_int_list : int list -> int and val length_of_string_list : string list -> int.

    1. 20

      My guess is that you probably haven’t used Go. In particular, len is actually polymorphic in Go, but only because it’s a builtin function. Go does have interfaces, which provide some limited ability to write generic code. The famous thing that they don’t support well are generic type safe data structures. But they can sometimes support generic algorithms, for example, sorting.

      Either way, if you really, truly, don’t understand the backlash against generics and you want to, then there are a number of things out there explaining the draw backs. Russ Cox kind of kicked it all off with this blog post. You might reject his argument, which is fair, but you might at least understand it. ;-)

      If you keep searching, folks (like Ian Lance Taylor) have made some fairly involved proposals for adding generics to the language, and IIRC, they include reasons why they didn’t move forward. See here for a starting point. Note the links at the bottom.

      1. 6

        Oh, I didn’t understand it was a performance concern. My only Go experience was writing a fairly simple command line app. If the core team doesn’t accept a particular tradeoff between static and dynamic method dispatch, how did interfaces become part of the language?

        One option is to provide for both static and dynamic dispatch as language-level features, like Rust.

        1. 6

          I found the relevant portion from the generics proposal for you:

          Polymorphism in Go should be implementable both at compile time (by repeated specialized compilation, as in C++) and at run time, so that the decision about implementation strategy can be left as a decision for the compiler and treated like any other compiler optimization. This flexibility would address the generic dilemma we’ve discussed in the past.

          In other words, under this proposal, you wouldn’t get static vs dynamic dispatch as a language feature. Rather, it would be an implementation detail.

          1. 5

            One option is to provide for both static and dynamic dispatch as language-level features, like Rust.

            Yes. Read the Go 2 generics proposals for more on that point. (You may not like what you find.)

          2. 0

            Either way, if you really, truly, don’t understand the backlash against generics and you want to, then there are a number of things out there explaining the draw backs. Russ Cox kind of kicked it all off with this blog post. You might reject his argument, which is fair, but you might at least understand it.

            All he mentions is C++. I don’t think there’s any effort to benchmark generics, and I don’t think the algorithms involved in typechecking them are pathological. I really don’t see any fundamental problems with them, just complaints about C++ and C++ compilers.

            1. 6

              I provided other links. Go read them instead of trying to rehash everything with me, which I am absolutely not interested in doing because I don’t think you’re commenting in good faith.

          3. 9

            Generics bring complexity. People tend to over-abstract their code and to make it a lot less readable.

            1. 13

              Not using the right abstraction can also make your code harder to follow.

              In any case, not having a feature and then pretending that you only didn’t include the feature because of “bad” or “ivory tower” programmers is ridiculous and we can all see through the bullshit.

              1. 7

                No, it really is a feature. I can’t pretend I like it, because I’d rather have generics in Go, but I understand it and I’ll try to explain it:

                Go is designed around simplicity. Its whole design (minus the null pointer problem) helps you make simple, obvious and reliable codes. You don’t think much: you just build the thing the simple way. And reading the code of fellow programmers is easy too. You lose some power or elegance because of that but the programming flow is uninterrupted and remarkably quiet.

                Go is ideal for big teams because of that. You don’t have to dive into tricky modules and bugs are rarer and simpler than in most languages (with the possible exception of some concurrency problems).

                Not all languages share the same goal.

              2. 2

                This argument proves too much. Substitute generics<->functions.

              3. -1

                “Generics” in this context means C-style templates. You don’t need those in dynamic languages because you have a base class. You don’t need them in statically typed languages either where you can add a base class, but that’s not the world of C++ or Java.

                1. 1

                  I’m not sure it has to do with inheritance. Dynamic languages allow for parametric polymorphism because values are boxed, and type errors are caught at runtime; you can write a function to append two lists, and as long you treat each element as a generic value (e.g not calling list_item.assumed_field), you’ve engaged in generic programming.

              1. 21

                Hot take: $GOPATH is The Only Good Part of Go. I now clone all git repos as ~/src/github.com/user/project.

                Super hot take: Go is an anti-intellectual language. The attitude of the creators of Go sounds a lot like “hurr durr screw these academics with their dependent linear generic polymorphic magic types, we want the good old days of C back but with concurrency now” and “programmers can’t be trusted to use advanced constructs, just give them simple C stuff anyone can learn in a day”. Rob Pike thinks that “Syntax highlighting is juvenile”. WTF?

                Extra hot take: the most offensive part of Go is the internals of the main implementation. Don’t ever let people with a Plan 9 fetish design a compiler. Why? Just read the readme of c2goasm, a workaround that lets you call non-Go code without cgo overhead. And look at the Go assembler itself. If there’s one thing that AT&T and Intel syntax fans will 200% agree on, it’s that the Go/Plan9 syntax is an abomination. (Also it doesn’t fucking support the instructions (and even addressing modes!) you might need. Literally that documentation page tells you with a straight face to just encode your fancy instructions as byte constants: BYTE $0x0f; BYTE $0x6f; BYTE $0x00. Are you kidding me?!)

                1. 14

                  Cold take: 99% of people programming in go will not be writing plan9 syntax assembly.

                  1. 11

                    99% of people programming in go are welcome to ignore anything about go internals. But I think people deserve to know that the internals are very weird.

                    1. 6

                      I heard/read that the rationale was that plan9 stuff might have been weird, but Rob Pike and Ken Thompson (soon followed by Russ Cox) were all deeply familiar with the entire toolchain and figured they could get cross architecture/cross OS compilation working quickly and build from there. It might have been a weird toolchain, but they did write it, so they were starting with a known quantity.

                      1. 8

                        That doesn’t sound like a great rationale for a production language sponsored by a huge serious company.

                        Wait, actually, this is a very Google thing to do. There’s a history of big complex projects built at Google that are mostly incomprehensible to anyone outside of Google and don’t integrate well with the outside world. Like GWT.

                        1. 9

                          Google was only incidentally involved in the design of Go. Go was made by 3 smart people, and bankrolled by a “huge serious company”.

                  2. 2

                    Super hot take: Go is an anti-intellectual language.

                    That’s good, actually.

                    1. 1

                      It’s an anti-“hurr durr I’m an intellectual so do as I say because I know what’s best for you” language and that is not a bad thing. Every single go team member probably has a more solid understanding of (any arbitrary aspect of) compsci than you do.

                      1. 18

                        Every single go team member probably has a more solid understanding of (any arbitrary aspect of) compsci than you do.

                        … And therefore you aren’t allowed to have dissenting opinions?

                        Come on now.

                        1. 5

                          Which part of my comment made you think I want to police opinions? I just made a counter argument to the “go is bad because it’s anti-intellechual” line, dunno how you got to the meta level. I do get the feeling now though that you would very much like to police my “dissenting” opinions, hmm?

                          Anyways, Miles understands the point I was trying to make and put it quite well I think, so no need to elaborate on that.

                          1. 1

                            Your comment is based on an assumption that the OP isn’t as smart as Rob Pike et al.

                            I don’t care about your opinion. Have whatever shitty opinion you want—that’s your prerogative.

                            1. 2

                              While that seems like a fairly safe assumption to me (for suitable meanings of “smart”), it is not actually a prerequisite to my point.

                              All I am assuming is that the Go designers do in fact know a decent amount of compsci but chose not to include various concepts for reasons that go beyond “academics came up with it”, i.e. they evaluate ideas on their own merits, instead of assuming anything originating in academia is either good or bad. Now, obviously their reasons and decisions can be debated, but implying they boil down to nothing more than a dislike of academia is either dishonest or idiotic (or both) and contributes nothing of any value to the decision making process.

                          2. 3

                            No, but therefore you aren’t allowed to describe them as anti-intellectual. Intellectual giants aren’t anti-intellectual.

                            1. 4

                              Hmm. I am not sure you understand anti-intellectualism, but maybe it, as a concept, needs to change to be more inclusive of experience gained from years in industry.

                              Calling Rob Pike et al, anti-intellectual makes sense from the text book definition because they’ve eschewed everything but garbage collection from academic CS from the last 30+ years, defining the language, instead, based on personal feelings from industry experience.

                              I am certainly open to citations that suggest otherwise…please include the citation’s publish date as well.

                              1. 5

                                Just because academics have designed a feature, doesn’t mean that feature needs to exist, nor does it make the feature useful

                                1. 3

                                  Just because Rob Pike says no to a feature, doesn’t mean that the feature shouldn’t exist, nor does it make the feature not useful.

                                  1. 4

                                    Nobody is saying that Rob Pike’s word alone is a good reason to not have a feature in a programming language.

                                    You say Rob Pike et. al. have ignored everything from academic CS from the last 30+ years. Maybe, but if you actually look at the last 30+ years of academic CS (in the area of programming languages) the most visible portion of it is an intense focus on very strongly and statically typed pure functional programming languages: ML derivatives, Hindley-Milner type inference algorithms extended to extensions of System F, dependent typing, etc.

                                    What widely programming language out there, other than Haskell, doesn’t ignore everything from the last 20 years of programming language research at least? Java? C++? C#? Javascript? Python? Rust? What about Rust’s type system is actually based on research done in the last 20-30 years?

                                    Parametric polymorphism is a lot more than 30 years old.

                                    1. 4

                                      Rust? What about Rust’s type system is actually based on research done in the last 20-30 years?

                                      As a matter of fact, more than the Type System has been influenced by academia… https://doc.rust-lang.org/1.2.0/book/academic-research.html

                                      As for the rest of the languages you mention… research is trying to unfuck C. C++ — I don’t follow its development well. Python has always ignored academic influences, and its creator has said some really dumbfounded things over the years, to boot.

                                      Java was born directly out of industry, but over the years, heavy research (not sure how much is purely academic vs industry) has gone into implementation, the garbage collection algorithms, nio, the recent proofs if the type system’s unsoundness…

                                      JavaScript was built in 2 weeks, but recent ECMAScript has authors like, Dave Herman, who has a PhD with a PLT focus from Northeastern…

                                      So, I think your statement, and position are categorically wrong.

                                      (Please excuse the lack of links, and brevity, I am on my phone and eating doughnuts)

                                      1. 0

                                        As a matter of fact, more than the Type System has been influenced by academia… https://doc.rust-lang.org/1.2.0/book/academic-research.html

                                        And Go’s concurrency system is influenced by academia. Everything in every language is influenced by academia. What I asked was what about Rust’s type system was influenced by recent research, given that the criticism of Go is that its type system isn’t based on recent research.

                                        As for the rest of the languages you mention… research is trying to unfuck C. C++ — I don’t follow its development well. Python has always ignored academic influences, and its creator has said some really dumbfounded things over the years, to boot.

                                        All of this seems to suggest that being based on recent research isn’t actually a relevant factor for comparing how good languages are, and thus that the criticism of Go as not being based on recent research and being bad as a result, or bad because its creators ignore recent PLT research, or whatever, is clearly bogus.

                                        1. 4

                                          And Go’s concurrency system is influenced by academia. Everything in every language is influenced by academia. What I asked was what about Rust’s type system was influenced by recent research, given that the criticism of Go is that its type system isn’t based on recent research.

                                          Your original “recent” was “within the last 20-30 years”. Incidentally, the thing from Go that is most often cited as “influenced by research” is it’s weird interpretation of CSP by Hoare, originally published > 30 years ago in 1978…

                                          The Academic Research page I linked for Rust (Specifically, the Types Influence):

                                          • Region based memory management in Cyclone (2002)
                                          • Safe manual memory management in Cyclone (based on it’s references, after 2005)
                                          • Typeclasses: making ad-hoc polymorphism less ad hoc (1997?)
                                          • Macros that work together (2012)
                                          • Traits: composable units of behavior (2003)
                                          • Alias burying (2001?)
                                          • External uniqueness is unique enough (2002?)
                                          • Uniqueness and Reference Immutability for Safe Parallelism (2012)
                                          • Region Based Memory Management (1994)

                                          Now that I’m not eating doughnuts, nor on my phone:

                                          All of this seems to suggest that being based on recent research isn’t actually a relevant factor for comparing how good languages are, and thus that the criticism of Go as not being based on recent research and being bad as a result, or bad because its creators ignore recent PLT research, or whatever, is clearly bogus.

                                          What is a “good language”? It’s pretty subjective. What’s good to me, isn’t good to you. What’s interesting is how well the Blub Paradox, describes what’s going on here.

                                          When I use Go, I cringe at the fact that I can’t safely create a closed enumeration that can’t be nil. You can do weird things with interfaces (in fact, there’s a solution in this very thread), but as soon as you do, then a value can be nil, and now you’re broken. Which leads me to the inclusion of nil, The Billion Dollar Mistake… somewhat hilariously proclaimed by the influencer of Go’s crowning feature, “Something CSP like,” go routines!

                                          Many Go programmers I talk to suggest “being careful and using iota is good enough.” Those same programmers will say that “there’s no way you can be careful enough to use C.” I guess carefulness is a spectrum? I’d prefer computers to remove some of my need to be careful instead. After all, research has shown that computers are much better at it than humans…

                                          So, when Go’s type system is a small step up from C in power, despite 47+ years of “we can do better than that,” you’ve gotta wonder what’s going on?

                                          My theory is that years of developing operating systems with C taught the Go authors how to avoid getting shot with their foot gun. However, instead of destroying the foot guns, they figured, “well, if we keep the foot guns on a shelf and tell people not to touch them, they won’t get shot.” The people yelling loudly about Go not adopting PLT research are the people who clearly see the foot guns on the shelf, and the stool right next to shelf.

                                          ~~

                                          BTW, an important question that we’re not bringing up here is “what is even research?” Obviously, the folks making proposals to change Go are doing some sort of textbook definition research. Is it any different than Brian Goetz’s work on Project Valhalla, who is doing “research” within Oracle? Do we constrain the set of relevant articles to those appearing at a major conference, like OOPSLA, POPL, ICFP? That seems silly. A bigger question, for sure.

                          3. 7

                            Do you know the person you’re responding to or are you just insulting them because they said something you don’t agree with?

                            1. 3

                              I do not know them and I did not write what I did to insult them, just to put what they said in some context. My comment applies equally well to me and with some specific exceptions probably to everyone in this thread. No shame in not being a genius.

                            2. 4

                              that’s literally just more anti-intellectualism lol

                              1. 4

                                If you aren’t ready to admit that some kinds of intellectualism can be bad, I don’t think I have anything to say to you.

                            3. 2

                              Hot take: $GOPATH is The Only Good Part of Go. I now clone all git repos as ~/src/github.com/user/project.

                              GOPATH is the single worst misfeature of any language I’ve ever used. Any language that tells me how to lay out my code, where to put it? I hate them all. Java forces you/encourages you heavily to put one public class per file. Blergh. Go forces you/encourages you heavily to use GOPATH. Blergh. Anything like that is just shit. C is one of the best, because all of its ‘module’ stuff is an emergent property of people using the language and its preprocessor, not some pre-designed over-engineered module system with namespaces and complicated lookup paths.

                              Super hot take: Go is an anti-intellectual language. The attitude of the creators of Go sounds a lot like “hurr durr screw these academics with their dependent linear generic polymorphic magic types, we want the good old days of C back but with concurrency now” and “programmers can’t be trusted to use advanced constructs, just give them simple C stuff anyone can learn in a day”.

                              That’s not anti-intellectual. It’s not fucking anti-intellectual to not want to write Haskell or some exceedingly overly complex reimplementation of the worst half of Haskell like most languages have become.

                              Rob Pike thinks that “Syntax highlighting is juvenile”. WTF?

                              Syntax should be readable without syntax highlighting.

                              1. 7

                                That’s not anti-intellectual. It’s not fucking anti-intellectual to not want to write Haskell or some exceedingly overly complex reimplementation of the worst half of Haskell like most languages have become.

                                I thought you might want to know that this reads like you’re misdirecting your anger at Haskell towards programming languages as a whole. In general, it’s difficult to be told to accept something by someone who is not very accepting.

                            1. 19

                              I always find it kind of funny that Google didn’t want generics in Go, but hacked it into one of their projects: https://github.com/google/gvisor/blob/master/tools/go_generics/generics.go

                              1. 26

                                There are many people in google, surely not all teams agree on this issue.

                                1. 16

                                  There’s also a bit of a difference between an implementation that works for one project and The Solution built into the language, which is supposed to (ideally) be a choice in the design space that’s fairly good across a broad range of uses. There are a bunch of solutions that work for various definitions of work, but the ones I’ve read all still have weird warts and edge cases (but different ones). Besides lower-level questions like how they interact with other parts of Go syntax and semantics, there’s also still quite a bit of disagreement, I think, on which of the basic tradeoffs in generics design are right for Go. Some people want Go generics more along the lines of ML-style parametric polymorphism or Java-style generics, while others want something more like C++ or D-style templates that instantiate specialized versions per-type. (The implementation linked above looks like the 2nd type.) Probably only one of these mechanisms will end up in the core language, not both.

                                  Edit: This “problem overview” from August 2018 has more details on the tradeoffs and current draft proposal.

                                  1. -2

                                    And yet apparently the language was shitty enough to force them to do this?

                                1. 26

                                  I’m pretty surprised by the amount of hate for Go in the comments here. I definitely agree with the author. For me the simplicity of Go has been an absolute breath of fresh air. It really feels like a better C.

                                  C doesn’t have generics and yet you don’t hear people complain about that. Right now if you want a statically typed, garbage collected language, your only real options are Java (JVM languages) or Go. The cross platform support for C# is still pretty poor, and many of the smaller languages just don’t have the library support.

                                  I just don’t see the lack of generics as an issue right now, but I hope that the new generics proposals for Go2 get it right.

                                  1. 29

                                    Generics weren’t really a thing until 1973 with ML. C was released in 1972, so it gets some slack. Generics were pretty well understood for decades before Go came out which is why people go off about it.

                                    1. 13

                                      The problem is that many people aren’t advocating Go as a better C, but as better, period. And many other people are denouncing Go as a bad language, period. The result is polarization which shows up as ‘hate’ (I would prefer to call it ‘unmoderated negativity’, because I don’t know (and cannot really imagine) if people actually feel hate).

                                      It would be much nicer if everyone applied the principles of humanity and charity

                                      1. 6

                                        C has the preprocessor, which lets you build things like generic redblack trees. Of course, in go, you have go generate. So I think it comes out about even, but because the two features aren’t identical people don’t really consider them.

                                        For that matter, c++ templates frequently boil down to tons of duplicated code generation, which then the linker has to sift through. Go’s solution requires a touch more work, but eliminates a lot of eventual waste.

                                        1. 5

                                          C Preprocessir and go generate might be about equal in what they can do, but there’s no question that C Preprocessir has a lower barrier to entry for the basic things.

                                          1. 2

                                            Preprocessor a separate language and tool from C, though. It’s not like having the feature built into the language with the compiler being able to understand the context as it applies the feature.

                                          2. 5

                                            I’m not sure that I agree about the C# bit. Why do you say that the cross platform support is poor?

                                            1. 10

                                              Seriously, it feels bizarre using Mono for about a decade, yet people act like .NET only appeared outside of Windows when .NET Core was busy being born a few years ago.

                                            2. 7

                                              It really feels like a better C.

                                              So… if you ignore the past 30 years of academic research, it’s a good language? How exactly is that impressive?

                                              C doesn’t have generics and yet you don’t hear people complain about that.

                                              I’ve never used generics, and I’ve never missed ’em.

                                              1. 4

                                                I more or less begrudgingly agree. Every now and then I find myself wishing for generics or operator overloading in Go (not as often as I would have guessed)… then I remember how refreshing it is to be able to read some unfamiliar Go code and know that I don’t have to wonder what an innocuous looking “+” might be doing.

                                                1. 9

                                                  You can have generics without operator overloading, though. See also: Java 5.

                                                2. 0
                                                  1. 12

                                                    Not in the sense that anyone cares about. It doesn’t allow for user-defined generic code – the library author has to write the specialized implementations ahead of time, and exhaustively enumerate what types their macro is generic over. This feature exists almost exclusively for the benefit of tgmath.h.

                                                    C would have been better off without this poorly thought out solution.

                                                1. 10

                                                  Just wow. I can read a lot of things with a straight face, but the liberal use “no true Scotsman” combined with copious amounts of fanboyism really made me cringe hard.

                                                  Maybe it’s time to remind people that the things they put on the Internet are there forever and might cause embarrassment to their children and grand-children, especially articles like these.

                                                  Articles like these make me lose my hope that software development will ever rise above alchemy, superstition and wishful thinking during my lifetime.

                                                  1. 24

                                                    Agreed, you can substitute the name of some other programming language, and the content doesn’t really change.

                                                    The constraints imposed by the lack of generics (and other things FORTH lacks) breed creativity. If you’re fighting FORTH’s lack of generics trying to do something Your Way, you might want to step back and consider a solution to the problem which embraces the limitations of FORTH instead. Often when I do this the new solution is a much better design.

                                                    I try to hold myself to “if I’m going to complain, show examples of how to do better” so here we go.

                                                    I would prefer to see content like “Here’s a problem commonly solved with generics, and here’s one way to implement that same thing in Go”.

                                                    I would like to point out that Go does have generics for two three of the system types, list and array and map. One way to sort-of get generics is to wrap those system types inside whatever data structure you actually wanted to build. That is, you can build a generic tree datatype, but under the covers it’s actually some combination of list and array, and you still sort-of get the behavior of generics in other languages. To get more generic type signatures, you can declare types as “empty interface” which is roughly the “superclass of all values” and then most things will work. You will still have runtime errors if you try to cast a value from the “any” type to a type that doesn’t match, so you have to be very careful.

                                                    I guess a more thorough response would include code demonstrating the above, but I’m busy writing Python today. Does anyone already have handy examples of the above solutions?

                                                    (Bias statement: my favorite language is Haskell!)

                                                    (edited to add maps to the list of generic system types)

                                                    1. 13

                                                      Problem: implement a custom container data structure.

                                                      Solution:

                                                      “empty interface” which is roughly the “superclass of all values”

                                                      Conclusion: why have a static type system at all if you can’t even use it for typechecking the use of your container? :)

                                                      One way to sort-of get generics is to wrap those system types inside whatever data structure you actually wanted to build. That is, you can build a generic tree datatype, but under the covers it’s actually some combination of list and array, and you still sort-of get the behavior of generics in other languages

                                                      I’m not sure I understand. If you wanted to define a FancyThing<T> that consists of List<T> and Map<int, T>, you’d still need actual generics support to parameterize FancyThing and pass these types into the members’ types. Otherwise you can only instantiate the builtins with interface{}.

                                                      1. 7

                                                        Problem: implement a custom container data structure.

                                                        “Implement a custom container data structure” is never your problem. Problems are more like “serve web pages to users” or “crunch data from this database”.

                                                        1. 24

                                                          Yes, if you’re an application author, you have these problems, and Go is 100% made for you.

                                                          If you’re a library author, “implement a data structure” is your problem, and Go suuuucks for you.

                                                          1. 7

                                                            I don’t think that Go is really oriented towards writing libraries rather than writing applications. Sure, lots of people write libraries in Go (I have!), but the language itself feels like it’s meant to be used rather than abstracted with. That’s okay, I think.

                                                            1. 5

                                                              Yes, it does. Remember the part where I said I’m okay with certain classes of problems being off the table?

                                                              1. 11

                                                                “I need a data structure for my application that is flexible enough for different frobz and widgets that has faster amortized access than go’s map, but I have to duplicate the code because the author of a red black tree library can’t do their job generically and safely.”

                                                                1. 0

                                                                  Go has a way to do this called go generate. It adds an extra step to builds which is an ergonomic downside but on the other hand it doesn’t suffer from type erasure and the debugging messages are way way better than C++ templates.

                                                                  The author of your red black tree library can absolutely do their job generically and safely. They just don’t want to.

                                                                  1. -1

                                                                    Go generate is a way to invoke an external generator, isn’t it? So you’d have to make a generator that’s essentially a “TypeScript for Go”. TypeGo. LOL.

                                                                    1. 4

                                                                      First, go generate is intended§ to be run by the author of a package, not the client of it. The author of the package generates the required Go files and includes them in the package; the client does a regular go get or go build. Generation through go generate is not part of the build, just a tool for package authors. This avoids complicating the dependency analysis done by Go build.

                                                                      https://docs.google.com/document/d/1V03LUfjSADDooDMhe-_K59EgpTEm3V8uvQRuNMAEnjg/mobilebasic

                                                                      (In other words, an RB tree distributed like this is not intended usage)

                                                                      Also, plot twist: nothing forces a script run by go generate to actually generate anything.

                                                                2. 6

                                                                  What an incredibly user-hostile attitude. You’re okay with penalizing library authors, precisely the people that contribute most to the community?

                                                                  1. 4

                                                                    A library-author-hostile attitude, you mean. And this is only a particular kind of library, e.g. the ones which implement some kind of generic data type. Many libraries don’t need to do this, and get by fine with just interfaces. It’s similar to the situation in C: everyone just implements their own data structures and that’s fine.

                                                              2. 5

                                                                “Implement a custom container data structure” is never your problem.

                                                                I forget that gophers have such a crippled type system that they say stuff like this. In a sensible language such as Haskell, one might have

                                                                data Day = Monday | Tuesday | ... | Sunday
                                                                
                                                                type Schedule = Map Day [String]
                                                                

                                                                Just because Go’s type system has so few interesting features that you don’t want to ever implement a custom container, doesn’t mean that’s the case for everyone.

                                                                1. 3

                                                                  Quality snark!

                                                                  The limits of my language are the limits of my world

                                                                  1. 1
                                                                    type Day interface{}
                                                                    type Monday Day
                                                                    type Tuesday Day
                                                                    type Wednesday Day
                                                                    // ...
                                                                    type Sunday Day
                                                                    type Schedule map[Day]string
                                                                    
                                                                    1. 10
                                                                              s := Schedule{}
                                                                      	var k interface{}
                                                                      	s[k] = "zoink"
                                                                      	var j Saturday
                                                                      	fmt.Println(s[j])
                                                                      

                                                                      What a safe way to write programs in 2019! All those silly academics with their type safety nonsense!

                                                                2. 2

                                                                  You can cast the empty interface to a specific type at runtime, in the case that the code calling your FancyThing decided to choose the types you’re using. In my employer’s codebase I’ve seen lists and arrays of interface{} where the it’s expected that code using FancyThing will check the types before use.

                                                                  Go lang takes the Samurai Principle too far for my tastes, the cultural approach to runtime errors (the way I understand it) is that the program should immediately die. To me this implies that runtime errors should not be allowed outside of truly exceptional circumstances where the program cannot possibly continue. My take on that is, “don’t do runtime casting of any sort” so that kinda kills the idea of using the empty interface.

                                                                  I could easily be wrong, I’m certainly not an expert on idiomatic use of Go, though I have spent the last year or two working on a 50k line codebase for my employer. I would appreciate input/feedback from anyone with more understanding of idiomatic use of “die for any error” and “runtime casting of empty interface”.

                                                                  1. 3

                                                                    die for any error

                                                                    Huh? I remember that there’s a lot of passing errors around. But of course in an obnoxious explicit fashion:

                                                                    something, err := maybeDoSomething(x)
                                                                    if err != nil {
                                                                      return nil, err
                                                                    }
                                                                    

                                                                    And every call looks like this. So much simpler than Result/Either :D

                                                                    1. 0

                                                                      For many cases, you can do this, though:

                                                                      if err := x.doSomething(); err != nil {
                                                                          return fmt.Errorf("error when calling x.doSomething: %v", err)
                                                                      }
                                                                      
                                                                      1. 5

                                                                        OK, so it’s slightly more compact… that doesn’t fix the underlying problem though.

                                                                        1. 3

                                                                          That looks really side-effecty, as it doesn’t capture a return value :-) I personally find that even when my program is about ‘doing’ rather than computing, I still have a lot of pure functions in my program because I need to manipulate data before I can act on it – how is that in your experience? (Probably different! I expect we have different styles as well as domains!)

                                                                    2. -1

                                                                      Problem: implement a custom container data structure.

                                                                      That’s a problem almost nobody actually has, but ok. You could use code generation, which would give you the typechecks you were looking for. Don’t some “real generics” implementations essentially do this also?

                                                                      1. 6

                                                                        Surprisingly, I had this problem last week, I really needed a suffix (or prefix) tree that would return the count and value of keys that match a particular suffix. I ended up using strings.HasSuffix instead, but it’s going to make future maintainers sad when they read that code.

                                                                        1. -6

                                                                          YAGNI

                                                                        2. 4

                                                                          That’s a problem almost nobody actually has, but ok. You could use code generation, which would give you the typechecks you were looking for.

                                                                          Plenty of people have this problem. Perhaps the reason people don’t do it more in Go has more to do with the fact that the type system is too weak to handle even simple algebraic sum types, so you just use e.g. integers to express what should be something else.

                                                                          Don’t some “real generics” implementations essentially do this also?

                                                                          Not really, at least during typechecking.

                                                                      2. 2

                                                                        Forth doesn’t lack generics - it just doesn’t have types…

                                                                        1. 1

                                                                          After a few minutes searching, I found an article that’s much better than anything I could say about generics in Go: https://appliedgo.net/generics/

                                                                          I completely forgot that Go interfaces are pretty much like Java interfaces (what I think of as typeclasses).

                                                                          I will also point out that option 6 in the article I linked is exactly the C++ approach, use code generation to build a type-specific implementation at compile time.

                                                                          I’ve not used reflection in Go, so no opinions here.

                                                                          1. 1

                                                                            I think you mean map & slice.

                                                                            1. 1

                                                                              From what I’ve read, arrays and slices are both generic, but slices are a reference-oriented layer on top of arrays. To me arrays and slices are pretty much different views/parts of the same data structure, what do you think?

                                                                              The slice type is an abstraction built on top of Go’s array type, and so to understand slices we must first understand arrays.

                                                                              That’s from this 2011 blog post: https://blog.golang.org/go-slices-usage-and-internals but it’s not 2011 anymore.

                                                                              1. 9

                                                                                Slices, arrays, channels, pointers and maps all support some limited form of polymorphic type-safe operations on them.

                                                                                This discussion is a complete pit. I suggest you bow out while you can. Hell, this sub-thread’s parent comment is literally calling for the OP to be shamed by our descendants based simply on an opinion expressed about a programming language. The fact that nobody has called @soc out of this yet (ah, someone just did, yay) just shows how much all of us have been numbed to how ridiculous this conversation has gotten. The other side is almost as ridiculous too. Apparently implementing type safe reusable data structures isn’t actually a solution to anything.

                                                                                1. 2

                                                                                  Yes, arrays are generic; it’s that they’re not used much in practice becuase slices are much more convenient. My main point was that you left out maps.

                                                                                  1. 1

                                                                                    Oh, good point! I’ll fix that!

                                                                            2. 18

                                                                              Your patronizing tone isn’t really contributing to the discussion.

                                                                            1. 12

                                                                              I disagree with this post. I’m also a professional and my time is valuable too. However, two of the three suggestions they made are taking significant time away from me and my team for evaluating a candidate that potentially can’t even write code to solve a simple task. Part of an interview process is to filter out people before it gets to that point, so we’re not wasting employees time.

                                                                              1. 10

                                                                                I think coding challenges are optimised for candidates who are looking for a job. I’ve been in that boat once, and when you’re actually looking for a job your “valuable time” is of course bet spent trying to get said job (by doing coding challenge or whatever else).

                                                                                Most of the time, though, I’m being recruited. I’m not going to do a coding challenge for a recruiter.

                                                                                1. 1

                                                                                  Taking an entire day to work with them (unpaid) still strikes me as really weird.

                                                                                  1. 1

                                                                                    Think of it as a great way to find out if these are people you would want to work with every day before you actually have to do that.

                                                                                2. 8

                                                                                  I disagree with this post. I’m also a professional and my time is valuable too.

                                                                                  I have the same problem with it as a hiring manager– how do I screen out socially capable but inept developers– and I share the author’s opinion when I’m the candidate– this tells me nothing about why I want to work for you. Each side wants the other to make an unequal commitment so it amounts to a single round game with that candidate. As a candidate with a choice of games, I don’t want to play this one and it signals disregard for/trivialization of the candidate’s investment and work history. For the hiring side, this plays out multiple times and there is investment in posting, screening, reviewing, etc. so regardless of this round my total investment is higher but not visible.

                                                                                  So what have I personally done? When I’m the candidate, I refuse to do the coding challenge and say, like the author, check my repos and talk to my references (unless the problem catches my interest, then I might). I have that luxury. When I’m the employer? Up front I explain how it works and what timeline they can expect as part of a 15-minute phone screen for basic info with someone technical. Then I arrange a round of 45-60 minute calls: a technical call with someone on the team and a social/technical call where I try to get them to talk with me about their work in detail and many of the non-code aspects of their job, habits, tools, designs, etc. They’ll probably have a call with my manager or another peer. Then, if I’m satisfied but not sure, I bring them in or have a video chat and they do a quick coding test. This wastes less of their time, makes my commitment visible, and seems to work but it is not a scalable process.

                                                                                  1. 7

                                                                                    I have a portfolio and some github projects. This is where most of my hiring emails come from. So when a company doesn’t spend the time to check that out, and they want me to implement some trivial thing that doesn’t generate value for them, I don’t have time for them either.

                                                                                    I’ve had companies pay me to be a consultant for a week before giving me an offer, which was a nice way to learn about who they are. On the other hand, sometimes companies give me job offers now before I know anything about them, and I have to pump the brakes and talk to more of them before I feel comfortable going into something long-term.

                                                                                    1. 1

                                                                                      …evaluating a candidate that potentially can’t even write code to solve a simple task.

                                                                                      In the post, they talk about how they have a blog, numerous GitHub repositories, etc. At that point it should be obvious they can code. The interview then should be more about “fit” or whatever, IMHO.

                                                                                      1. 5

                                                                                        They aren’t the only candidate we would interview and in my opinion, it is better to have a consistent process. If every candidate had a similar level of public presence to evaluate then maybe that would be different.

                                                                                        1. 7

                                                                                          So, again IMHO, at that point you’re basically throwing out someone with passion and talent due to bureaucracy. If I come to you with decades of experience/conference talks/published papers/lots of open source software to review/whatever…and you ask me to spend 30 minutes doing trivial work, you’re basically implying that I’m lying to you and/or that your company cares more about process than people.

                                                                                          Again, this is IMHO.

                                                                                          1. 7

                                                                                            I’m saying that you’re not the only person applying for the job and I need to treat everyone the same, so we’re not giving preferential treatment.

                                                                                            1. 3

                                                                                              I know, but…maybe you should give preferential treatment to people who are obviously better candidates. :)

                                                                                              1. 9

                                                                                                Some of the best engineers I know have zero public presence. Some of them are extremely humble and don’t like public flashiness. Some of them have families and maintain a strong work-life balance with non-tech stuff. Never assume those with a strong public presence are giving the world the whole picture. You still want to drill into the parts of their personality that they don’t highlight.

                                                                                                1. 4

                                                                                                  Why does having a public portfolio make someone an obviously better candidate? What makes a candidate obviously better? Arbitrary social metrics? Ability to speak quickly about technical topics? Ability to talk bullshit without it sounding like bullshit?

                                                                                                  How do you know a candidate is obviously better without having them go through the same process and pipeline?

                                                                                                  1. 3

                                                                                                    How do you know a candidate is obviously better without having them go through the same process and pipeline?

                                                                                                    If the code in their GitHub account is as good or better than what would be tested by my coding test, why subject them to that? Ask harder questions, ask questions about the things that the coding test wouldn’t cover (including “soft” things that would judge a good fit), etc.

                                                                                                    Why does having a public portfolio make someone an obviously better candidate?

                                                                                                    Which surgeon would you rather have? The one nobody’s ever heard of, or the one who has published articles on the relevant surgical procedures, who goes to conferences to learn more about surgery, who obviously is passionate enough about medicine that they would study it even if they weren’t getting paid?

                                                                                              2. 8

                                                                                                There are, unfortunately, a lot of liars out there. I won’t say that industry hiring practices are anywhere near ideal, but as an interviewer it was astonishing how many people with great optics were incapable of coding. Someone would speak with great passion about all their projects and yada yada, and id be fairly convinced they could do the job, then I’d ask the most basic question imaginable. Splat.

                                                                                                I guess it helps if you choose to believe the test isn’t meant for you, but for all the other pretenders.

                                                                                                1. 7

                                                                                                  Even more surprising to me is that people who can’t actually code are somehow able to sustain careers as developers. It started making a lot of sense to me why good developers are in such high demand after I had the opportunity to do some interviewing and found that a frustratingly large amount of applicants can’t actually code, even if they look great on paper and are currently employed as developers.

                                                                                                  I think it’s incredibly risky to hire a developer without seeing code that they have written, be it from open source contributions or a coding test if necessary.

                                                                                                  1. 3

                                                                                                    Onsite nerves can kick in. It sure as hell did for me. I hate white boarding and I lockup. Totally brain freeze. That said, if it’s a basic one like writing a loop…well, they somehow lied their way into the onsite. Thing is, a take home coding challenge can weed out those people pretty fast. If they do that and come in and fall flat on their face before the whiteboard I don’t totally discount them. Anyway, there’s no perfect solution. There is always the potential to hire someone that is great at coding interviews and then sucks at real world problems.

                                                                                                    1. 2

                                                                                                      This is exactly my company’s experience. Half of the candidates would just bomb out on the C++ test even though they have studied it at high school/college/university and worked with it at their job for 5-10 years. How?!? Because they were either doing Java, not C++, or they were actually managing a team that did C++ and never had to touch it themselves (Well since leaving school at least).

                                                                                                      1. 1

                                                                                                        What I don’t understand is why this is so hyper-specific to developers. You never hear UI designers talking about processes like this.

                                                                                                        1. 6

                                                                                                          Really? I’ve heard UI designers talk about it a lot.

                                                                                              1. 25

                                                                                                I think the moral here is “you don’t need to do coding tests if they have a good portfolio”, but I have also seen similar posts on this very site complaining about companies that judge you based on your portfolio because not everyone does side projects or work they can share.

                                                                                                Maybe we need to consider that there are multiple classes of applicants that need different interview styles; in particular, the divide here seems to be between “day job” programmers who have no publicly visible work and “enthusiast” programmers who do. It would probably make sense to use a different process for each. (Although I would worry a bit about people who hire software ghost writers. If you think that’s far fetched, you haven’t done interviews.)

                                                                                                1. 11

                                                                                                  It’s more complicated than that, even, because I have a portfolio, but it’s almost completely orthogonal to all my professional experience (the biggest single element of the former being a 3D engine in Rust, and the latter being backend/data processing software mostly in Java). I’m sure it still helps, but it probably shouldn’t—my ability to microoptimize linear algebra and my ability to wrangle large frameworks and macrooptimize data flow don’t really have much to do with each other.

                                                                                                  Ultimately, I think it’s the hiring manager’s job to tailor the process to the candidate. If they have a relevant portfolio, great, look at that. If they have an irrelevant portfolio, that can probably at least tell you whether they’re completely incompetent. If they’ve currently got a job, they’re less likely to put up with an extensive coding test. Etc. There probably are no hard-and-fast rules.

                                                                                                  1. 1

                                                                                                    I would worry a bit about people who hire software ghost writers. If you think that’s far fetched, you haven’t done interviews.

                                                                                                    You can fire someone for lying on their résumé. Not the ideal outcome obviously, but not a permanent dent to the company.

                                                                                                    1. 1

                                                                                                      If you use a take-home to screen people then it is a very good idea to follow it up with a 30 min discussion about the trade-offs made in the code and potential extensions to it, which will be extremely difficult to answer for somebody who did not actually write the code themselves.

                                                                                                  1. 7

                                                                                                    While this is a good read, I do think that the author is misinterpreting Uncle Bob. The original Tools are not the Answer post specifically says that he supports using these tools:

                                                                                                    I think that good software tools make it easier to write good software. However, tools are not the answer to the “Apocalypse”.

                                                                                                    His point, as I understand it, is that more tools cannot solve a lack of discipline because it takes discipline to actually use those tools. And right now most developers don’t even use the simplest tools available to help ensure correctness. If a developer isn’t disciplined enough to write a unit test, why do we think the same developer will be disciplined enough formally prove the correctness of their program?

                                                                                                    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.

                                                                                                    Uncle Bob blames this problem on a lack of discipline. I think that’s partially correct, but also ignores that developers are embedded into dysfunctional contexts that often punish discipline or reward fast completion more than correctness.

                                                                                                    1. 5

                                                                                                      I agreed with him on that point. Discipline is the most important factor. It doesn’t matter what it’s motivation (eg money, principles). The best returns come from a mentality that constantly tries to improve the process of writing solid code or the code itself. Such a mentality naturally seeks out methods such as unit testing, code review, or even formal methods. Without that mentality, they’ll half-ass their QA or just leave it off altogether. This is what we see a lot in both proprietary and FOSS software.

                                                                                                      1. 3

                                                                                                        I think Uncle Bob also ignores that the vast majority of software is not written using best available practices. Cloudbleed could have been prevented by not using C to write a parser.

                                                                                                        1. 1

                                                                                                          I’m not sure how he’s ignoring that? Seems to be the very thing he’s complaining about.

                                                                                                          1. 10

                                                                                                            He pretty explicitly says that in one of his recent posts:

                                                                                                            defects are never the fault of our languages. Defects are the fault of programmers. It is programmers who create defects – not languages.

                                                                                                            1. 3

                                                                                                              Shit, there’s a bug in my Brainfuck code! Oh well, time to sit in the corner and think about what I’ve done…

                                                                                                      1. 3

                                                                                                        Here are some concerns: The syntax can be obscure.

                                                                                                        Nonissue.

                                                                                                        It’s slow. While the speed of a shell script rarely matters, trying to use the shell like a programming language will waste system resources.

                                                                                                        When speed matters, python is not going to be helpful.

                                                                                                        We can often omit crucial features of a script. Checking the status of programs using $? can be accidentally left off, leading to inconsistent behavior.

                                                                                                        Just like all other languages.

                                                                                                        The shell language’s only data structure is the string. There are ways of decomposing strings into words. The expr program can convert strings to numbers to do arithmetic. The date program allows some date manipulations, but the rules can be obscure.

                                                                                                        Not even wrong.

                                                                                                        array=(a b c)
                                                                                                        ((x+=y))
                                                                                                        

                                                                                                        obscure : the second appearance of the word in the sentences I quoted here. Let’s do s/obscure/unknown to the author/.

                                                                                                        Unit testing isn’t easy. There are some packages like Bats that can help with unit testing. A language like Python has a much more robust unit testing capability.

                                                                                                        I totally agree.

                                                                                                        1. 6

                                                                                                          Just like all other languages.

                                                                                                          No, other languages have e.g. types.

                                                                                                          Nonissue.

                                                                                                          Of course syntax can be an issue. Shell scripts that are written by humans should be readable by humans.

                                                                                                          1. 3

                                                                                                            shell scripts are, for the most part readable by humans. Even before I could write a shell script without cribbing off an existing one, I could understand what they were doing 90+% of the time.

                                                                                                            But I would also say that if your job is ops-heavy, you should probably know how to read and write bash. Not because you’ll be writing all your scripts in shell, but because you’re working in a field where a large number of small utilities that you can basically just grab and use are written in shell already.

                                                                                                            I wholeheartedly agree with the author that for larger tools should be written in a higher level language almost all the time, but an ops-person should be mostly fluent with shell syntax, and the shell is more easily read than java, c#, and other languages people use every day.

                                                                                                        1. 3

                                                                                                          The Java/Microsoft mainstream is gaining new traction. Aesthetics also got diluted. Careful engineering is getting diluted. Social networks ubiquity and the easy path of quick cloud deployment is making people less and less patient. Crafting requires patience. People crave Likes, a new generation of vanity metrics arose.

                                                                                                          I certainly wouldn’t classify Ruby as “careful engineering.” 11000-line yacc file? Not exactly screaming “everything was thought out beforehand” to me.

                                                                                                          1. 1

                                                                                                            I feel like I’ve confused Ruby’s grammar before, but I don’t have any examples at hand.

                                                                                                            OTOH, people like, and can usually navigate ambiguous grammars, so as much as I agree with you from a parsing standpoint (there are places where the error state is manually reset…yeah), I don’t know if it is something the user feels the complexity of, despite my expectations that it would.

                                                                                                          1. 4

                                                                                                            I mean, if you’re in Python, yeah. If you’re using a functional language this is seldom the case.

                                                                                                            1. 2

                                                                                                              Yup. My scala functions are rarely more than a few lines.

                                                                                                            1. 0

                                                                                                              We would all save a lot of time if we acknowledged the science and then focused on showing why that science doesn’t make a clear argument for a particular policy direction.

                                                                                                              I think it’s worth noting that the sexists will be arguing in bad faith no matter what. I feel like saying “we should be 100% rigorous” is noble, but I also think it’s dramatically underestimating the depth of the problem, perhaps malignantly.

                                                                                                              Moreover, it would be nice if we could come out and unequivocally say that women are capable of programming, analytical thinking, and that anyone who doesn’t believe this is completely wrong.

                                                                                                              1. 10

                                                                                                                I don’t care much for the reasons given in the article. To me, it’s the fact that I can run it over SSH, and of course the modal editing (note the fact that Emacs has a VI mode, but not the other way around :^) ).

                                                                                                                1. 8

                                                                                                                  I don’t either. But I only use vim over SSH. For me, the refactoring powers of modern IDEs are worth far more than the editing capabilities of vim. And I don’t have to have a finicky and fragile setup. Not to mention how much time it takes. I used to be a very big vim user with a huge init.vim (ok Neovim user, but whatever) but I found myself significant more productive in a jet brains IDE.

                                                                                                                  1. 5

                                                                                                                    It helps that Ideavim (the official vim-keys plugin for Jet Brains’ IDEs) is really quite good (though I’m not a vim power user). I can’t see myself going back to vim for regular coding - I like my IDE features too much, and I actually think people who eschew good IDEs are needlessly hindering their own productivity, or perhaps haven’t really been exposed to the power of (for example) a great debugger.

                                                                                                                    1. 4

                                                                                                                      the refactoring powers of modern IDEs are worth far more than the editing capabilities of vim.

                                                                                                                      Not every language has an IDE, however. Modal editing is worthwhile learning because it’s portable.

                                                                                                                      1. 3

                                                                                                                        Just take good stuff from both worlds. I run Visual Studio with VSVim plugin for example.

                                                                                                                        1. 2

                                                                                                                          I think it varies widely by language. I’m a big Vim fan, but If I’m writing C#, no chance you’re pulling me away from Visual Studio. VsVim is not quite as good as real Vim, but you’ll never beat the IntelliSense auto-completion, realtime syntax and type checking, a real Go To Definition, build and unit test support, TFS source control support, etc.

                                                                                                                          On the other hand, if I’m writing Ruby or Python, I’d rather use real Vim and do anything I can’t do in it on the command line. Most of that other stuff is either not possible or not needed with the more dynamic languages.

                                                                                                                          Haven’t done as much Java personally. I think it’s more usable on the command line than C#, but doing it in IDEA or something instead is such a huge boost for all the same reasons.

                                                                                                                      1. 1

                                                                                                                        Love haskell, but hate it’s use of a million symbols for operators.. sometimes it can be averted by using word based operators, but thats not assured. I guess Idris is somewhat saner thanks to namespaces, but I think I would ultimately find something like a lispy haskell with namespaces to be more ideal.

                                                                                                                        1. 4

                                                                                                                          Don’t use them if you don’t like them

                                                                                                                          Haskell function application is already tuple-less and comma-less, so you can write it like a Lisp all you want, just add the parens. You have full macros too.

                                                                                                                          thisFunction and its arguments can always be rewritten to (thisFunction and its arguments)

                                                                                                                          That nobody does so probably says something, but I am not sure what.

                                                                                                                          1. 1

                                                                                                                            Oh cool, I will. Though I was remarking more on the general state of the haskell ecosystem.

                                                                                                                          2. 2

                                                                                                                            Love haskell, but hate it’s use of a million symbols for operators

                                                                                                                            It’s really a matter of familiarity. To me, 3 + 4 is clearer than add 3 4. And, as bitemyapp pointed out, as long as users like operators for their own use, they’ll keep on being a thing.