10 ms·
The code design is also very elegant in its simplicity. You have two static lists of words in the JS code - known words, and a smaller, random pre-shuffled lis
by dvirsky 5y ago
The code design is also very elegant in its simplicity.
You have two static lists of words in the JS code - known words, and a smaller, random pre-shuffled list of words the game will select from.
The selection is done on the client, by date, from the second list - every day at midnight (your local time!) the next word in the pre-shuffled list is selected - no hashing or randomizing or anything. No cookies are involved in making you play one game per day, no server side calls are involved in gameplay at all. And yes, this means that changing your time zone will let you play tomorrow's game, and that you can just view source to know tomorrow's word - it appears right after today's word in the code.
This is so counter to how we usually design software in so many ways, it's just delightful.
- the_af 5y agoI think the full list of words being hardcoded and readily available is not a kind of elegant simplicity, but simply an inelegant compromise to get everything done client-side, which has obvious benefits. It's the one thing I would change about Wordle's implementation.
- neoberg 5y agoWhy tho? Cheating just takes away from the cheater's experience and doesn't affect anyone else. It's pretty much like any physical game. You can play (or cheat) it any way you like even though the game is designed to be played in a certain way.
- the_af 5y agoI agree with your philosophy against cheating, but still, games must implement some sort of anticheat, just like they must implement some sort of game rules. Imagine not implementing blocking walls in Counter Strike, "just don't walk through walls, it would make the game less fun and why would you ruin the experience for yourself like that?". This is a case where not hiding the word list was done because it was easier to implement Wordle this way. Engineering-wise, it's not elegant, it's a cop-out.
- compiler-guy 5y agoWith Wordle, you only play against yourself, so cheating only cheats yourself. So no need for anti cheating. Client side dictionary isn’t a cop out at all. It’s a terrific solution for a single player game that helps keep the code base elegant.
- the_af 5y ago> so cheating only cheats yourself Well, cheating is less important than in Counter Strike, but not entirely unimportant either. Playing Wordle has a social component. I think this solution is neither elegant nor terrific. It's simply completely ignoring the problem and claiming that it doesn't matter anyway. I obviously disagree. PS: when I was a kid, I learned programming on my C64 with BASIC. Like many kids, the first programs I wrote were "guess the thing" kind of games. Usually "guess the number", but occasionally "guess the word". Even back then I understood that hardcoding the word in the program listing was less than ideal, but I just didn't know how to do better. Let's say that 8-year old me would not have been positively impressed if told that Wordle had the "elegant" solution of storing the list of words in its source code.
- Linosaurus 5y agoI think cheating would matter if there was individual words tied to an account. But not when the design says every browser session on the planet gets the same word.
- the_af 5y agoFair enough, but then it's not an "elegant" decision we should be in awe of (as in the title "Wordle is pretty damn smart"). It's just the default of "I decided not to tackle this problem because it's hard and not a priority for my design". This was also what I defaulted to with my C64 BASIC games when I was a kid, "I don't know how to hide this, so I won't".
- 5y ago
- zild3d 5y ago> an inelegant compromise ... It's the one thing I would change about Wordle's implementation What would you change specifically? Adding an API call backed by servers / lambdas? The creator mentioned it costs in the tens of dollars per month to run wordle for 10s of millions of daily players. Having to run servers would not only add a ton of cost, but now be vulnerable to latency spikes, ddos, downtime. Wordle scaled to 10s of millions in a few months, without any latency or downtime. Pretty elegant in my book.
- the_af 5y agoWell yes, an API call or an encrypted/hashed DB of words so at least it's not casually accessible. I understand that the costs might be an issue, but this doesn't make the solution "elegant". This is the kind of code I wrote as an 8-year old in BASIC, like I mentioned elsewhere, and even my young self understood back then it wasn't a satisfying solution, I just didn't know how to hide secret literals. I mean, I enjoy Wordle as much as the next person, but let's not make it into some engineering achievement when it's clearly not one.
- zild3d 5y ago> so at least it's not casually accessible I'd argue that it's not. Puzzles in the newspapers also don't hide secrets, the answers are on the next page or upside down. And for wordle, the vast majority of players don't even know the solutions can be found in the source (because they don't know what that means), and most of the ones who do know that don't look anyway because otherwise what's the point of playing. Having the solutions viewable client side may not be engineering elegance, but in this case I do think it is product elegance. Adding the DB or servers you mentioned would mean costs continue to increase with # of users, which would then create pressure to figure out how to make money off of wordle. Then comes logins, ads, or at the very least donation requests
- the_af 5y ago> which would then create pressure to figure out how to make money off of wordle Oh, you got me there! Definitely wouldn't want that to happen. You make good points. It's true the solution to newspaper crosswords is usually on the same page, upside down.
- mmcnl 5y agoEvery design decision is a compromise. "Inelegant" is simply another word for "I would've done in it a different way".
- dvirsky 5y agoI would have done most of this in a different way, but looking at how this guy solved all those problems made me really stop and think about how I approach problems, and I actually think he did it in a more elegant way that I would have.
- Cthulhu_ 5y ago> This is so counter to how we usually design software in so many ways, it's just delightful. It's letting go of notions of what makes good code. I had a Moment like that doing Pico-8, since you can only fit 40 or so characters on screen, all the tutorials just use dirty, single or two letter variable names, and since everything is small and you learn a few neat tricks about variables (velocity, coordinates, the mod operator), the code can be really compact... and filthy. It's great.
- scambier 5y agoIf you like the code-golfing aspect of it, I suggest you take a look at the #tweetcart hashtag on Twitter, there are some incredible demos in 280 chars or less.
- rrrrrrrrrrrryan 5y agoMaking the whole thing client side also let him scale from a small handful of users to literally millions with basically zero additional work. I hope it inspires future devs to let go of feeling like they absolutely need to beg or require users to create accounts to capture email addresses just so they have a chance at monetizing their thing. Wordle may not have ever caught on if it were preemptively over-engineered: it could've added friction to the onboarding, the site could crash, etc. You can just build a great MVP and let it loose into the world, then see what happens.
- koliber 5y agoThey could have at least thrown in a microservice or two to breathe some air into that fad.
- julianwachholz 5y agoRemoving any friction for new users or players is such a huge deal, more sites should embrace this approach. Similar to how Facebook created ghost users for everyone, why not make this explicit? There are a number of plugins for popular web frameworks that create temporary user accounts for each visitor, allowing them to use the site just like a regular user. This way it's a bit more sophisticated than plain old sessions which allows it to be integrated in existing sites as well. And if the visitor abandons the site their data will just be garbage-collected after a while.
- yen223 5y agoI wish I were smart enough to coin a catchy phrase that means "the moment some software dropped in quality, when they decided to add user accounts", because I see this quite a lot. I'm looking at you, Postman!
- d0gsg0w00f 5y agoYes, I left Postman immediately after rework because I couldn't understand how the hell to use it anymore. Same with Docker Desktop. I tried to use it for personal use a few weeks ago and couldn't figure out how to docker build a container anymore on WSL, then tried on native Windows and it was jabbering on about HyperV prereq and I just uninstalled it and went back to WSL for traditional package management. I think Docker shot themselves in the foot.
- hombre_fatal 5y agoWhen I first discovered Wordle, I immediately looked for a way to keep playing with new random words, something that most clones have implemented. After a few rounds, it just wasn't as fun. What makes it fun to spend 10 minutes on the game is that it's the only round of the day so there's a pay-off to giving it some thought. When you can keep playing new rounds, it's just not rewarding and I would just close the tab when I was stumped. Had I invented Wordle, I would never have thought of just one, shared round per day which is surely one of the critical elements of its success.
- amelius 5y ago> Had I invented Wordle, I would never have thought of just one, shared round per day which is surely one of the critical elements of its success. It's probably the same with Twitter's char limit.
- jrockway 5y ago> I would never have thought of just one, shared round per day which is surely one of the critical elements of its success It's different anyway, but how are people building routines around remembering to visit a certain website once a day? Do they just see the shares on Twitter and remember to go play themselves? Do they bookmark it? I certainly can't build a routine around a novelty like Wordle.
- SketchySeaBeast 5y agoMy wife and I have made it part of our morning routine to play it while we drink our coffee.
- Morizero 5y agoIn some ways it reminds me of Twitter - the innovation was in restricting the content, not in adding more features.
- rrrrrrrrrrrryan 5y agoThe daily bit is clearly modeled off the New York Times daily word puzzles, and it's obvious why the NYT bought it to add it to their collection of daily word games.
- bsimpson 5y agoI forgot to play one day, so at just after midnight, I set my TZ to Hawaii to catch up. After I finished, I set it back to PST. When I went to play the next day's game, it acted like I had already solved the puzzle at midnight. I had to manually edit localStorage to fix my state (or presumably skip a game). This was when it was still hosted on Josh's site, but be weary of changing TZs to get other day's puzzles. The game might get confused.
- suzzer99 5y agoYeah I had the same thing happen. I would jump ahead two hours to play it at night. This morning it kept showing me the same 3-day-old game, no matter what I did. I had to clean out cache, local storage, cookies and everything to finally get it to start playing again.
- pdpi 5y ago> No cookies are involved in making you play one game per day The game does, however, use local storage to keep your score, and progress along today’s puzzle.
- dvirsky 5y agoSure, what I meant is that even if you delete your cookies you'll play the same round.