Twenty-five years ago, I wrote a Tetris-playing ‘AI’ in C++, called https://github.com/tengstrand/tetrisanalyzer. Since then, I’ve reimplemented it in several other languages, including Java and Scala, with unfinished versions in Clojure and Python. The Scala version is the most complete, and since I haven't touched Scala in 12 years, I had Cursor update the code to the latest Scala 3 and build tools, so the code can run again!
I have documented the algorithm in English https://github.com/tengstrand/tetrisanalyzer/tree/master?tab=readme-ov-file#how-the-algorithm-works @chris358
> I had Cursor update the code to the latest Scala 3 A perfectly succinct statement of the "Scala problem". :D One cannot just increase the language version, one has to go out of their way to change their code to become compatible.
Well, luckily we have almost none of that in the Clojure community! I'm listening to https://www.youtube.com/watch?v=tmpPueoffVM interview with Martin Odersky, the creator of Scala. It was interesting to hear all the problems they had with Scala 2, with the language, the compiler, and its complexity. The beauty of Clojure is that the core is so small and it can grow while maintaining backward compatibility.
> Well, luckily we have almost none of that in the Clojure community!
For sure.
> The beauty of Clojure is that the core is so small and it can grow while maintaining backward compatibility
I wouldn't call it "so small". :D Apart from clojure.core there are plenty of built-in things, including the spec which is a separate jar.
IMO the beauty is careful language design and an implacable and impeccable attention towards any sort of breakage.
As a counter-example, consider Python 2->3. The "core", in the sense of things that are available without any imports, is quite small. Easily could be smaller than that of Clojure, but I haven't tried checking, especially given that in Python a lot of stuff is at the level of syntax, not functions/macros. But Python also has a lot of things one can import that are a part of the default distribution, including the one that I will always find both funny and endearing - import turtle.
In any case, most if not all breakages in the 2->3 transitions didn't come from the fact that some function had to change in order to accommodate modern usage. They came from treating "purity" and "beauty" above all else (but, apparently, still with some exceptions, like OrderedDict). A lot of things were simply renamed or moved around. Some behavior was changed because it was deemed more correct or desired. Some syntax changed because why not. And Python 3 still sometimes changes syntax or moves things around in a way that breaks things, ugh.
Maybe people should write a ScalaVM so you can write backwards compatible code that transpiles to the Scala du jour. O wait, we already have JVM bytecode.
This is my dystopia fear: a future where nobody will worry about compatibility, documentation, stability, or anything because "the AI will solve for us". Then problems like "I can't upgrade from Node 150 to Node 150.1" will be seen as "the LLM is not smart enough, let's burn three more forests to train a better model"
I'm quite hopeful in this regard. It's a common wisdom that browsers and web standard nowadays are so bloated that writing a new browser (in the "a new web engine" sense) is a fool's errand. And yet people do that. And it will probably be forever like this. A pressure always creates forces that try balance things out. At least, while there's no Earth Government that's utterly totalitarian.
not to mention that during that whole mess, things like PyPy were gaining steam and it wasn’t completely clear whether or not CPython would be the obvious winner outside numerics.
@tengstrand Very nice! Tetris is NP-Hard right? Have you written anything about how your algorithm works?
The algorithm is documented https://github.com/tengstrand/tetrisanalyzer/tree/master?tab=readme-ov-file#how-the-algorithm-works.
I updated the link, now that I'm back at the computer @chris358.
Thanks!
I also had Cursor clean up the C++ version. The C++ implementation processes about 25,000 pieces per second, while the heavily optimized Scala version reaches 76,000 pieces per second on my machine! I also have an older optimized C++ version somewhere that I recall being more than twice as fast as both the Java and Scala versions.
For those that had extensive business code with deps the python 2->3 was a horrid experience
Would not recommend