1. 3

      When using modules (as in this case, see https://github.com/OpenDiablo2/OpenDiablo2/blob/master/go.mod) go wants you to use fully qualified imports all the time. There are some tweaks to avoid that (which help reuse code in both module and non-module environments) using renames in go.mod, but yeah, it’s normal.

      1. 2

        Yes, though they’re not really importing them from Github, but relative to the $GOPATH/src. This is a consequence of how Go originally managed code. I was never a fan.

        Contrary what pgeorgi mentioned, Go modules actually remove the strict need for this, though it makes sense for older projects to keep old style fully-qualified imports as OpenDiablo 2 does so as not to disrupt existing code.

        In newer projects, you could have something like this in your go.mod file:

        module OpenDiablo2
        

        Which would allow you to write imports within your module’s internal source like this instead:

        package d2server
        
        import (
        	"OpenDiablo2/d2game/d2player"
        	"OpenDiablo2/d2networking/d2client/d2clientconnectiontype"
        	"OpenDiablo2/d2networking/d2netpacket"
        )
        

        Which is vastly better. For third-party code you’re pulling in as dependencies, you’d still use fully-qualified imports, however.

        Go modules are far from perfect, but they make life so much easier.

        1. 1

          Which language has the most perfect module/package system according to you?

          1. 1

            I don’t think there is such a thing. Practically every half-decent module system these days is essentially riffing on Wirth’s original work on Modula and its successors.

            Now, packaging (i.e., their distribution, as opposed to the modules/packages themselves) is a whole other issue. Talking about that is a bit of a quagmire, and I don’t think anybody’s really cracked it.

      1. 4

        Why does the code have throws Exception everywhere? It is to allow introducing checked exceptions later? Seems like he is working against the language.

        1. 2

          Java idiom has “limit your use of checked exceptions” from Joshua Bloch’s Effective Java, and many developers have run with it to mean “don’t bother writing the exception signatures in detail”. That’s actually the opposite of his recommendation, but it’s one that’s compatible with the section heading if not the body.

        1. 5

          This article by Dan is good and on the same topic:

          https://overreacted.io/goodbye-clean-code/

          1. 4

            But that article is about some abstract definition of “clean” as opposed to talking about the book.

          1. 15

            Clean code is a really good book. Even if it has some examples that are on the edge, and some examples that you don’t agree on, it doesn’t mean that rest of the examples are bad.

            Most of the things from Clean Code is simply a good idea. I’m not sold on all points, but it’s a damaging reaction to “stop recommend” 1000 hints, just because 20 of them are bad (in the worst case). If everyone would use 25% of the hints that Martin suggested, the world would simply be a better place. Even if people would follow the “bad” advice from this book, it still would be a better situation than people inventing their own strange philosophies for e.g. naming things, that happen to change from variable to variable. From my experience, lots of people don’t even consider most points that Martin has proposed. And if there’s a value to the book, then it might be just to tell you what you should think about. Which is a good outcome I think.

            1. 16

              There are so many books out there, it it really necessary to settle for one that contradicts itself? It is such a red flag.

              1. 5

                Are there so many books on the same topic as Clean Code? I only know Code Complete, and then an incomplete, outdated smattering of language-specific ones including Eloquent Ruby, Effective *, and Smalltalk Best Practice Patterns.

                1. 5

                  How about The Practice of Programming by Kernighan and Pike?

                2. 3

                  I didn’t have an impression that the book contradicts itself.

                  I don’t think the blog post does a good job with argumentation. Author’s rationalization after reading a paragraph is often completely different than mine.

                3. 8

                  These days I write maintainable code because I have been forced to maintain my own code. Martin’s ideas were a great help to get me started on the journey, and I still draw from them periodically. So yes, I think Martin is great learning material, with the huge caveat that experience is the best teacher and Martin’s ideas are not gospel.

                  1. 9

                    I have yet to see maintainable code written by someone who has not spent a few years maintaining code they wrote.

                    This effect mostly seems to kick in around the two year mark; if you change jobs every two years you may have never seen the long term impact your work had on code health.

                  2. 5

                    What specifically is good about it? The specific points that this article makes do strike me as egregiously bad code - and moreover, it seems like the book’s dictums are fairly closely tied to the Java ecosystem and its mandatory object oriented paradigm. If I was writing code in Rust or Haskell, what advice in this book would even be applicable?

                    1. 5

                      Prefer small functions over large ones, prefer consistence when naming things, write tests for your code, prefer to document the app through code/naming conventions instead of comments but remember about adding comments if you need to, remember to maintain the comments as much as the code, think about maintenance aspect when writing code, perfer abstraction over code duplication.

                      There are lots of things in the book that are general. Granted, lots of the things are aimed towards Java. But I think think that lots of things from the book are applicable to e.g. C++. Rust is not an exception (no puns here).

                  1. 17

                    Weird timing (posting the story now as the article is from 2019) with the Perl 7 PR a few days ago. I think like a lot of other programming languages, it will no go away or “die”. The Perl 6/Raku take a clear different path, Perl 7 and 8 coming. The syntax is weird by today standard, yes but is it a problem? I mean we have see the rise of Clojure with a s-expression syntax, functional, etc. making it almost mainstream, why not the idiosyncrasies of Perl?

                    1. 16

                      s-expressions provide regularity. Perl’s idiosyncrasies are truly idiosyncratic. There are a large number of operators that are single punctuation characters. Many of these behave different in different contexts. This makes it so that when looking at other people’s code you are constantly encountering new idioms. So when I’m looking at a legacy code base I’m seeing idioms from 2015, 2010, 2005, 2000 and earlier.

                      1. 5

                        That’s why I like Perl. Once I am old and tired, I will find a job maintaining an obscure tool written in Perl, and I will have job security. ‘Maintainable’ software is an evil ploy from corporations scheming to pit employees against each other.

                        1. 4

                          Obligatory: `perl -e ‘print reverse “dog”’

                          In Vyatta and then VyOS, we’ve had our butts bitten by stuff like this countless times, even with strict and warnings. Strict and warnings only take you that far. Then there’s error handling. Exceptions aren’t there, and monadic approach isn’t really possible because there are no types. Then there’s a GC that hopefully will learn how to break circular references in Perl7, four decades after everyone else.

                          The code we’ve rewritten in Python has much fewer bugs on average, and when there are bugs, it’s much easier to track them down. Of course it’s not just because of the language, we are fixing old design flaws at the same time, but just rewriting the same code word for word would already be an improvement.

                          It’s more like, you can make C safe and reliable by memorizing the MISRA rules and installing an external checker. Or you can switch to Ada or Rust and get a whole bunch of great features in addition to built-in safety checks.

                          1. 2

                            Ha, ha. Be careful what you wish for. While we achieve a work life balance that corporations are incapable of, I’m on the hook for several dozen different collaborations with huge budgets grinding to a halt during outages. Those muons are not going to research themselves.

                            1. 2

                              As a friend is fond of saying: 90% automation, 10% job security

                        1. 12

                          This is tangentially related, but this is the first project in a long time that I’ve seen that uses Darcs, and I’m really happy to see it still getting used! It still feels like it was closer to “how it should be” than either Git or Mercurial.

                          1. 4

                            The author of hikari has also created a video where they talk about how & why they use Darcs: https://hikari.acmelabs.space/videos/hikari-darcs.mp4

                            1. 1

                              Not just a video! They wrote an entire book about Darcs: https://darcsbook.acmelabs.space/

                            2. 2

                              I heard that Darcs has bad performance. Do you think it is unlikely to become an issue for a project of this size?

                              1. 3

                                Hard to know without diving in a bit more. The issue isn’t that Darcs can’t scale as such; it’s that performance degrades exponentially with the number of merge conflicts. If they’re resolving those as they go, they could theoretically scale to a very large repo. But I’ll be blunt I haven’t actually kept up with development terribly well, so I don’t know how much this has (or hasn’t) been meaningfully rectified.

                            1. 10

                              I think he makes an excellent argument for making Zig the introductory language, simple clear semantics and the notation is made to describe allocations / directly interacting with the memory. It doesn’t have a repl though :/

                              Then at some later point make them write a lisp and teach them Haskell then you’ve got a solid base for learning anything. Rust is dismissed by having unique semantics / control structures. JS/TS by too much noise. Maybe ReasonML? Cleaner syntax than OCaml and has mutability…

                              Overall I think his point about academia ‘guiding’ industry by choice of language to teach outweighs everything else. For this reason alone I would pick either a C replacement (Zig) or a Java replacement (which to be fair Scala is, but that is also a leaky abstraction, I would go with Haskell personally).

                              1. 3

                                OCaml has relatively ‘easy’ mutability too: https://dev.realworldocaml.org/imperative-programming.html

                                1. 2

                                  Zig or Nim would be great introductory languages. Nim in particular lets you start higher level (whereas afaik Zig makes you worry about more low-level details up front like allocators), but runs the full gamut of what a systems language can do, supporting pointers, manual memory allocation, and so on.

                                  1. 8

                                    Overall I think starting higher level to learn is better if you want a broad overview.

                                    1. 4

                                      Overall I think starting lower level to learn is better if you want a solid foundation.

                                      1. 2

                                        I do think it’s important to understand the concepts which underpin the abstractions. However, most programming is done in relatively high-level languages. In this situation, I believe it is much more important to write what you mean, rather than trying to express how you think the underlying hardware works.

                                        If you teach someone the higher-level way to do something, then later show them how it might itself be implemented, they’ll probably keep using the high-level way, but will know how to drop down a level on the rare occasion that it becomes necessary. However, if you teach them the low level implementation first, that becomes “normal” for them, and they will keep reimplementing the wheel all over the place. When you show them the higher-level construct later, it could be viewed as an unnecessary curiosity, because the user has become set in their ways.

                                        1. 1

                                          You’ve convinced me that every JavaScript class should start with a few weeks of APL

                                          1. 1

                                            It depends on how long you stay at each layer.

                                      2. 1

                                        Why not start with simplified machine code, then move to assembly, then C, etc.? That’s what my undergrad EE curriculum did in 2005-2009.

                                        Given, I had already had 2 years of Java in highschool CS. But I didn’t learn much of value from that, except for how to do numeral base conversions.

                                        1. 4

                                          I don’t think that assembler is required or helpful when teaching fundamental algorithms and data structures, and at worst it just makes it harder for less experienced students. Ideally, whatever language is used, the student should never have to think “I know how to do it, but I don’t know how to implement it” – not “implement it well”, but just have a working algorithm.

                                          1. 0

                                            If the student doesn’t know assembler, it will be hard to understand the C ABI which is so commonly used in FFI’s to make languages interoperable. So I think you’re contradicting yourself. If you don’t know assembler, you don’t know how to implement everything. And what about boot loaders that the student will be using every day?

                                            Also, history is important. If you know the story of how people used to work before “high-level” C programming became popular, it gives you perspective which is applicable when deciding whether an abstraction is a productivity boost or not. Tony Hoare gave an interesting talk with all sorts of explanations of why null-pointers became popular. You can only understand the world if you understand the history.

                                            1. 4

                                              I’m not saying they should never learn it – just not in introductory CS. I’ve thought people in such courses, and there are far too many who haven’t ever programmed at all or not enough to understand basic concepts such as recursion. Overwhelming them with FFI’s and ABI’s before they can even implement binary search on an array won’t be manageable, either for the students or the coordinators.

                                              1. 1

                                                I really think you should teach things from the fundamentals and move up.

                                                1. 1

                                                  I agree, just my fundamentals are computational thinking familiarity with how computers “think”.

                                              2. 1

                                                If the student doesn’t know assembler, it will be hard to understand the C ABI which is so commonly used in FFI’s to make languages interoperable.

                                                In most languages, you can use the FFI, call C functions from another language and even call the other language’s functions from C, without encountering even a whiff of assembly.

                                                And what about boot loaders that the student will be using every day

                                                Unless they are studying some sort of embedded programming, why would they have anything to do with bootloaders? The subject of the original article is an introductory CS course that would be taken by a broad range of students. Writing your own bootloader probably belongs in a less general course, along with assembly.

                                          2. 1

                                            I always wonder when people say ReasonML has a “cleaner” syntax, what do they mean precisely?

                                            1. 1

                                              It means they like the syntax because it is more familiar, that’s it. For example, it means they prefer f(x, y) to f x y. This kind of superficial differences shouldn’t matter, but in practice, it matters A LOT, in fact having the familiar syntax may be one of the most important thing language needs to have to be popular.

                                              1. 2

                                                Well, that’s what I also think, but I’m curious to hear from people who say that. I haven’t seen Elm fans say “I love that language, if only it had f(x, y), not f x y for example.

                                              2. 0

                                                I guess ‘clean’ == no semicolons xD

                                                Thanks for calling it out.

                                                1. 1

                                                  …but ReasonML has way more semicolons than OCaml?

                                                  1. 1

                                                    I guess I’m full of it, I haven’t programmed in either just read some code and been influenced by facebook marketing, retracted.

                                            1. 10

                                              This was the biggest revelation for me

                                              Do Python learners struggle less than C++ learners? We analyzed student submissions on small coding exercises in CS 1 courses at 20 different universities, 10 courses using Python, and 11 using C++. Each course used either the Python or C++ version of an online textbook from one publisher, each book having 100+ small coding exercises, expected to take 2-5 minutes each. We considered 11 exercises whose Python and C++ versions were nearly identical and that appeared in various chapters. We defined struggle rate for exercises, where struggle means a student spent excessive time or attempts on an exercise. Based on that rate, we found the learning for Python was not eased; in fact, Python students had significantly higher struggle rates than C++ students (26% vs. 13%)

                                              1. 3

                                                It kinda makes sense! The syntax of C++ is insane, but students will never encounter all of it, so it will not hurt them. It’s hard to know how much C++ students are helped by the compiler nudging them with warnings, but it could be a lot!

                                                I know Python has warnings too, but I don’t think there are as many, and I don’t think people use them much.

                                                1. 4

                                                  I wonder what the development environments looked like. Learning with a well-configured IDE is, IMO, an advantage because it literally tells you about many problems as you type. But I think there is a tendency to forgo an IDE with Python because it doesn’t really “need” one.

                                                  Also, I’d be interested in whether they used type hinting with Python. I used to hate writing Python but I’ve had to more recently and found that it’s a lot less annoying if I use type annotations consistently.

                                                  1. 4

                                                    one of the things that bothered me a lot when switching from java to python (and still bothers me a little, today) is that most functions never tell you the type of parameters they expect. will this be a string, or an object of some class?

                                                    so you waste a lot of time in TypeError-s and ValueError-s where as other languages (like java and c++) are explicit on what is expected.

                                                    also, even though I haven’t written java in almost 10 years, i still think that the javadoc is the best format for library documentation. packages-classes/interfaces-methods. you can browse it all, find what you need and discover a lot more.

                                                    python documentation… ugh. it’s an exercise in infinite scrolling and searching in the browser, over and over again.

                                                1. 1

                                                  Wow, this looks like a really neat scripting language! Lots of commits, lots of stars, how come I never heard of this before? Documentation is top notch, I like the minimal design.

                                                  Could this be the language to take Ruby’s place?

                                                  1. 8

                                                    def foo(a, b=[]):

                                                    Yeah, that is such a massive footgun in Python, and I can’t believe that it wasn’t fixed in Python 3. I thought Python was supposed to be “one way to do it”. How can it be that the obvious way in Python is invalidated by super technical distinctions like a difference between memory scope and binding scope?

                                                    I guess I am a radical FP enthusiast, but I see software getting slow not because we have too much immutability, but because leaky abstractions enforce massive overhead (like dockerizing everything).

                                                    So the big problem in software engineering is leaky abstractions! Isn’t it sad if you have to compromise the realistic but unpopular ideal in a CS1 course because of the way the industry turned out?

                                                    1. 4

                                                      I guess I am a radical FP enthusiast, but I see software getting slow not because we have too much immutability, but because leaky abstractions enforce massive overhead (like dockerizing everything).

                                                      I think the reason software is getting slow is because it’s cheaper to buy more/many powerful processors than to pay devs too plug those leaks.

                                                    1. 4

                                                      Why do people use titles that say nothing?

                                                      1. 0

                                                        For the same reason people like ambiguity in art. Makes them feel like they have original insights.

                                                        1. 3

                                                          Given that there have been about a hundred billion people on this planet I think it’s a bit much to expect us to have original insights.

                                                        1. 8

                                                          There is an online Haskell conference https://zfoh.ch/zurihac2020/

                                                          There are workshops and a Discord channel. Talks have already started!

                                                          Featuring Gabriel Gonzalez, Phillip Wadler, Richard Eisenberg, Divesh Otwani, Nicolas Frisby, Rob Rix and many more.

                                                          1. 2

                                                            Would you recommend this for a Haskell curious person, who has no Haskell experience?

                                                            1. 3

                                                              Yes, there is even a beginners course and workshop.

                                                          1. 1

                                                            Why would you prefer the colors that bright? It distracts from the content if too bright. Same reason I prefer grey over block instead of white over black.

                                                            1. 7

                                                              However, webpack can be so much more.

                                                              What if we could take C# code, and transpile it into JavaScript? What if we could take a YAML configuration file, and create a working program just out of configuration? What if we took an image, and automatically made it cropped and greyscaled?

                                                              I think if you start thinking of Webpack as more of a transpiler, not just a bundler, the true power of Webpack can be seen.

                                                              What is this nonsense? Why would Webpack compile C# code? Why should Webpack do everything? I’d prefer if I wouldn’t need webpack at all! And with dynamic imports coming to ECMAScript, and HTTP/2, soon I won’t.

                                                              1. 1

                                                                Compiling C# code to JS or WebAssembly could be great for making C# libraries or programs usable in the browser or in Node without having to reimplement it.

                                                                While it would be great if we had the benefits of Webpack without Webpack (or an equivalent) that’s not going to happen. Even with HTTP2 and dynamic imports, a bundler like Webpack will be necessary to provide the best case performance. (See this post from Kahn Academy.) You’d just use a smarter bundling strategy to produce small feature related bundles that get dynamically imported.