Richard Bucker

Go Generics So Long

Posted at — May 9, 2020

I have been a professional programmer since 1982. Back in those days I developed all sorts of apps in assembler, C, pascal, dbase, and a couple of DSLs of my own design. Years later I taught myself C++ and all that it was. stdlib was not much of a thing and I’s be hard pressed to recall whether generics was a thing.

Fast forward a few years and I taught myself java, perl, ruby, python, erlang. All of them lived up to their original promise. The code was clean and easy to understand. Easy to ready so that it could be extended and it worked. I get that oart of this is on me because of my personal coding principles and because once the languages became mainstream and idiomatic with the PEP team I lost faith.

there is a lobby of would be programmers out there who are polluting every domain

I had a contract working for a very popular etailer whose product was based on ruby. They had serious problems scaling their business and most of the problems had to do with the fact that they used generics and class overloading. Their OO model lacked any documentation or “least surprise”. Many times a programmer in a outer class would access a function deep inside the class stack making it impossible to debug without a lot of details.

In fact I’ve experienced this sort of obfuscation more than just a few times. Most programmers have not learned the dangers of long jumps. One OO implementation restricts the parent to accessing it’s descendents only, and grand-children through documented interfaces.

The problem with this sort of language feature is at least 2 parts. [1] you lose OO think [2] if the missing functions are added then the OO call stack is no longer idempotent.

So, what do generics really get you? … that you cannot create for yourself? … to you really benefit by putting that control in the compiler or tools? Again, looking back when I wrote code in C and pascal I knew exactl what the compiler was going to generate. Later when we needed more performance from our languages and java and llvm were proposed we got multi-platform but slow… then came jit and all that self modifying code.

I wonder how fast a turbo pascal or turbo C program would run on today’s hardware

Take another look at Visual Studio… you cannot write a C# program without it. Rather than cleaning up the tools they just stacked tools on top of tools. By comparison my tools chain is a simple editor and compiler. I suppose I should use a linter but my code is simple. Runtime logging is good enough. The code is built based on a contract with the data. If the contract is broken thn the code crashes. This is as intended.