8 ms·
Show HN: Simple games ported to Scala 3 – Try them in the browser
Hi everybody, I just ported some 2018-scalajs games to Scala 3, it is amazing that such 8-year old code base required less than an hour to get all the games working in Scala 3.
I encourage you to try Scala.js/Scala3 which work really nice.
- deleted 4y ago[deleted]
- esarbe 4y agoScala/Scala.js is an amazing ecosystem. It simply astounding being able to take code from the frontend and move it to the backend by simply importing it in a different project. Using the same domain validations everywhere is also mind-blowing. Thanks for the effort, these are really cool demos.
- leaflets2 4y agoBut what do you use on the backend? What web framework? That you like and works well with Scala Looking forward to one day having ported all my Scala code to 3 :-)
- threeseed 4y agoFor those interested in Scala.js I would recommend two UI frameworks: a) Slinky - https://slinky.dev https://slinky.dev b) Laminar - https://laminar.dev https://laminar.dev
- cultofmetatron 4y agolaminar - https://laminar.dev/ https://laminar.dev/
- deleted 4y ago[deleted]
- amelius 4y agoWhat platforms do they target?
- AlexITC 4y agoThey target browsers. Slinky is very similar to React while Laminar is more idiomatic Scala.
- billfruit 4y agoIs there anything similar for Clojure.
- Ketan-fullstack 4y agoReagent and Reframe
- halfmatthalfcat 4y agoOr the OG React Scala.js library: https://github.com/japgolly/scalajs-react https://github.com/japgolly/scalajs-react
- thelittlenag 4y agoI've written a fair amount of code using this library. It is, frankly, amazing.
- wbillingsley 4y agoHere's one I made earlier Veautiful - https://www.wbillingsley.com/veautiful/ https://www.wbillingsley.com/veautiful/ Tends to be used for slightly unusual things like - "I want to do lecture notes with a maze game and lunar landar built into the notes" https://theintelligentbook.com/thinkingaboutprogramming/#/decks/state/0 https://theintelligentbook.com/thinkingaboutprogramming/#/de... - "Let's build a simulation of git into the tutorial notes" https://theintelligentbook.com/supercollaborative/#/challenges/gitLocalTutorial/0/0 https://theintelligentbook.com/supercollaborative/#/challeng... or - "What about an automatically self-charting simulation of a MOSFET?) https://theintelligentbook.com/circuitsup/#/mosfets/2/2 https://theintelligentbook.com/circuitsup/#/mosfets/2/2 Any day now, I'll get a chance to improve the documentation of the framework (and give it a proper release rather than using JitPack snapshots all the time).
- AlexITC 4y ago> Veautiful - https://www.wbillingsley.com/veautiful/ https://www.wbillingsley.com/veautiful/ Thanks for sharing, first time I see this project mentioned. > Any day now, I'll get a chance to improve the documentation of the framework (and give it a proper release rather than using JitPack snapshots all the time). It is worth commenting about https://github.com/sbt/sbt-ci-release https://github.com/sbt/sbt-ci-release which makes it simple to auto-publish to maven central.
- hombre_fatal 4y agoThe games on the live demo eat 100% of a CPU and go down to crawling FPS on my Macbook M1 Pro once I start using the keyboard to control them. Wonder what's going on.
- AlexITC 4y agoWeird, I just tried Safari in a Macbook Air M1 and it doesn't eat much CPU, still, the experience is far smoother in Firefox, for some reason, the games get slooow in Safari.
- crispyalmond 4y agoJust tried on Windows with Edge, and I'm experiencing this as well.
- marwis 4y agoWould be nice to see the diff vs Scala 2
- AlexITC 4y agoWell, given that I haven't refactored the code to take full advantage of scala3, the changes are mostly on the build scripts, which is very nice because the old repo likely used scala 2.10 (or 2.11). The only required syntax change was related to https://docs.scala-lang.org/scala3/reference/dropped-features/do-while.html https://docs.scala-lang.org/scala3/reference/dropped-feature... (2 minor occurrences). Original sources at https://github.com/lihaoyi/scala-js-games https://github.com/lihaoyi/scala-js-games
- wbillingsley 4y agoIf you're not using macros, moving from Scala 2 to 3 is pretty easy. I have a bunch of 2d games I use in programmable learning environments. This is the commit that did a lot of the shifting from 3 to 3.0.0-RC1 https://github.com/wbillingsley/lavamaze/commit/0d9aca52e8e8385ba3b49a15a10571ddae28ca0c https://github.com/wbillingsley/lavamaze/commit/0d9aca52e8e8... A lot of it was just trivia like "it's required to put parentheses around lambda function parameters now", and "if the function is declared with an empty arg list () rather than no arg list, you have to call it with an empty arg list rather than no arg list". If I recall, there's a compiler plugin they put out that could automatically make many of those changes, but I found it took little enough time just to do them manually that investigating the plugin wasn't necessary. An example of one of the programmable games in action: https://theintelligentbook.com/thinkingaboutprogramming/#/challenges/lavaMaze/0/0 https://theintelligentbook.com/thinkingaboutprogramming/#/ch...
- AlexITC 4y ago> If I recall, there's a compiler plugin they put out that could automatically make many of those changes Actually, there are compiler options to rewrite the sources to/from scala3, I have tried this in more complex projects and it worked nicely (see https://docs.scala-lang.org/scala3/guides/migration/tooling-migration-mode.html https://docs.scala-lang.org/scala3/guides/migration/tooling-...) This is the link to the plugin you mentioned which is supposed to avoid the manual syntax updates but I haven't had the need to try it, like you said, most of the times the changes are trivial enough (https://docs.scala-lang.org/scala3/guides/migration/scala3-migrate.html https://docs.scala-lang.org/scala3/guides/migration/scala3-m...). > An example of one of the programmable games in action This comes handy to me, looks cool! For one or another reason, I ended up in this page which seems to intend hosting the same app but it doesn't work, just wanted to let you know (https://www.wbillingsley.com/lavamaze https://www.wbillingsley.com/lavamaze) There is a similar nice project which I have been looking into (https://www.kogics.net/kojo https://www.kogics.net/kojo).