# Revisiting Rock, Paper, Scissors

**URL:** <https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347>\
**Category:** Performance\
**Tags:** type, multidispatch\
**Created:** [April 30, 2021, 9:11pm UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347 "2021-04-30T21:11:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [April 30, 2021, 9:11pm UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347/1 "2021-04-30T21:11:07Z")

</div>

In 2017 @giordano (with 2019 @Mason update) wrote about implementing [Rock, Paper, Scissors](https://giordano.github.io/blog/2017-11-03-rock-paper-scissors/).  
Using v1.7 or v1.6, can we do this any better (more: elegantly, performantly, type-stable, gamelike)?  
Are there new (or better understood) language elements or uses of the language that appertain?

[added for clarification]  
I am a fan of the blog post and have used some of the code in examples over the years.  
I am interested in showcasing at least some the same language features and wondering if there are amended approaches that in some manner would improve the implementations.

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [April 30, 2021, 9:20pm UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347/2 "2021-04-30T21:20:18Z")

</div>

Maybe pattern matching to avoid repeating `play(` in each line.

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [April 30, 2021, 9:22pm UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347/3 "2021-04-30T21:22:01Z")

</div>

The shapes could be an enum.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [April 30, 2021, 9:50pm UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347/4 "2021-04-30T21:50:20Z")

</div>

From the article:

> The main goal of this post is to show how multiple dispatch enables writing generic and extensible code in a few lines.

Rock, paper, and scissors would never be implemented that way if the goal was not to showcase language features. So what you are asking kinda seems to be missing the point, it never was about a good implementation.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [April 30, 2021, 10:07pm UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347/5 "2021-04-30T22:07:39Z")

</div>

I am a fan of the blog post and have used some of the code in examples over the years. I am interested in showcasing at least some the same language features – and wondering if there are alternative approaches to good implementations. [I added a note conveying this to my first post – thank you.]

---

<div class="post-metadata">

**Author:** ![miguelraz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miguelraz/32/631_2.png) [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Post date:** [May 1, 2021, 12:22am UTC](https://discourse.julialang.org/t/revisiting-rock-paper-scissors/60347/6 "2021-05-01T00:22:31Z")

</div>

I still love this post @giordano. It was the first post that made multiple dispatch “click” for me. Thanks again!
