off-topic

tengstrand 2025-11-26T09:35:19.748919Z

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!

👍 1
😲 1
tengstrand 2025-12-01T08:36:26.293229Z

I have documented the algorithm in English https://github.com/tengstrand/tetrisanalyzer/tree/master?tab=readme-ov-file#how-the-algorithm-works @chris358

👀 1
p-himik 2025-11-26T10:40:41.846229Z

> 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.

tengstrand 2025-11-26T11:09:43.352169Z

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.

p-himik 2025-11-26T12:00:20.815789Z

> 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.

borkdude 2025-11-26T13:34:29.042949Z

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.

mauricio.szabo 2025-11-26T16:46:17.532329Z

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"

😬 1
p-himik 2025-11-26T17:12:04.840459Z

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.

Ben Kamphaus 2025-11-28T14:23:59.245859Z

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.

Chris McCormick 2025-11-27T09:54:04.749289Z

@tengstrand Very nice! Tetris is NP-Hard right? Have you written anything about how your algorithm works?

tengstrand 2025-11-27T10:13:46.934759Z

The algorithm is documented https://github.com/tengstrand/tetrisanalyzer/tree/master?tab=readme-ov-file#how-the-algorithm-works.

👀 1
tengstrand 2025-11-27T11:22:43.899399Z

I updated the link, now that I'm back at the computer @chris358.

Chris McCormick 2025-11-27T12:19:16.061119Z

Thanks!

👍 1
tengstrand 2025-11-27T15:57:26.701899Z

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.

kulminaator 2025-11-27T17:06:42.352419Z

For those that had extensive business code with deps the python 2->3 was a horrid experience

kulminaator 2025-11-27T17:06:58.790269Z

Would not recommend