Coder Social home page Coder Social logo

rr-2048's Introduction

This is another implementation of the Game 2048 in Reason React. It was my first Reason React project, and is a poor-man's clone of LIU9293's implementation.

Key Observations

  • Reason React is really easy to pickup. I am not much more than a javascript tinkerer, yet I was able to develop this, starting from Reason Scripts within 5-6 hours. The syntax proves very familiar for someone who knows javascript. It's readable and straightforward.
  • It was jawdroppingly powerful
    • Pattern Matching is amazing! I was hooked from the first one I wrote. It allows the programmer to focus on the logic, as the implementation becomes very easy.
    • Encouraged by the toolset, I found myself quickly migrating to more functional-style programming. I avoided loops, and found myself writing recursive code!
    • Tuples are great too. I loved wrapping-together a few variables and treating them as a unit. Although I found the parentheses syntax kinda confusing. There were times when I had 3-4 open or closed parentheses side-by-side for a simple callback function.
    • I loved the typechecking. I haven't programmed with types since the Java era. I can't believe that there was a bullet-proof typesystem that didn't require annotating everything. It just worked. I was floored when the typechecking found errors within my JSX. Wowzers.
  • I did have a number of challenges that took a little while to work-through
    • The ReasonReact Installation Instructions didnt' make clear that Reason-CLI is required for many functions
    • I found the module system a bit confusing. I couldn't figure-out how to create private helper-functions without putting them within the definition of the public function. That ended-up working for this project, however it makes it impossible to share these helper functions wihtin the module, and it made unit testing harder.
    • Jest doesnt' fully support Bucklescript, yet. I worked mostly with linked-lists, but those aren't well supported by Jest. I usually had to convert an list to an array for testing purposes.
    • ReasonML has limited documentation, but OCAML has a ton. For good or for bad, I found myself having to learn the OCAML syntax to get things done. The playground proved invaluable, as I would paste-in OCAML and instantly get out Reason.
    • Similarly, I spent way too much time trying to figure out OCAML type definitions. I'm sure they will become second-nature, but they are not yet.
    • The native OCAML library is pretty limited. I found myself wishing for a number of javascript functions at times
    • Reason / Bucklescript / React is HEAVY. THis very light applicaiton is 58kb gzipped.... My code is a few hundred lines... THat's a lot of library code. I was somewhat surprised to see how much of it was Bucklescript code to handle language features like Linked Lists and Currying.

All-in-all, it's been a very fun experience. And I'm amazed with the power. I'm going to look for opportunities to use it, instead of javascript, going forward.

Todos

  • Fix keyboard bindings.... Right now the user has to click first.
  • Detect game-over
  • Gestures
  • Delay adding new cells after transform for a fraction of a second
  • Retitle the page

rr-2048's People

Contributors

sevenseat avatar

Watchers

Mateusz Pokora avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.