TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Designing a programming language to speedrun Advent of Code

243 pointsby polyrandover 1 year ago

12 comments

ghjover 1 year ago
I didn&#x27;t realize who this was by the title, but this is betaveros, the guy who won 1st place in Advent of Code every single year since 2019: <a href="https:&#x2F;&#x2F;clist.by&#x2F;account&#x2F;32289&#x2F;resource&#x2F;adventofcode.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;clist.by&#x2F;account&#x2F;32289&#x2F;resource&#x2F;adventofcode.com&#x2F;</a>
评论 #38264363 未加载
评论 #38265577 未加载
saagarjhaover 1 year ago
I think it’s interesting how similar a lot of this stuff is to what I do, except I’m not very good at Advent of Code and also I decided to hack Python to do this instead of writing my own language. For example:<p>* I couldn’t really make operators first class functions, but I just autoimported operator which has this but in words<p>* I wanted partial application and hated lambda syntax, so I hacked it together with some magic. “_0 + 1” is basically equivalent to lambda x: x + 1<p>* Python really likes to make everything a free function, which messes with the whole left-to-right thing. So I monkey-patched functional methods onto all the collections<p>Together this means that if I have like a comma separated list of numbers in str and I want to, idk, count how many are above five I’d do something like<p><pre><code> str.split(&quot;,&quot;).map(int).filter(_0 &gt; 5).len </code></pre> which matches how my brain things about it far better than how Python would like me to write it. It uses some tricks but it’s not actually that bad of a hack IMO: <a href="https:&#x2F;&#x2F;github.com&#x2F;saagarjha&#x2F;advent-of-code&#x2F;blob&#x2F;main&#x2F;aoc.py">https:&#x2F;&#x2F;github.com&#x2F;saagarjha&#x2F;advent-of-code&#x2F;blob&#x2F;main&#x2F;aoc.py</a>
评论 #38261496 未加载
评论 #38273124 未加载
评论 #38271779 未加载
nemo1618over 1 year ago
&gt; The title is clickbait. I did not design and implement a programming language for the sole or even primary purpose of leaderboarding on Advent of Code.<p>I did: <a href="https:&#x2F;&#x2F;github.com&#x2F;lukechampine&#x2F;slouch">https:&#x2F;&#x2F;github.com&#x2F;lukechampine&#x2F;slouch</a><p>&quot;Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K&quot;<p><pre><code> :load wordlist wordlist.txt words wordlist | filter -:(len == 10 and .8 == &quot;k&quot;) </code></pre> A more interesting example: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=i_zDbInYOpQ">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=i_zDbInYOpQ</a><p>AoC solutions here: <a href="https:&#x2F;&#x2F;github.com&#x2F;lukechampine&#x2F;advent&#x2F;tree&#x2F;master&#x2F;2022">https:&#x2F;&#x2F;github.com&#x2F;lukechampine&#x2F;advent&#x2F;tree&#x2F;master&#x2F;2022</a><p>(The language has builtin commands for fetching inputs and submitting solutions)
评论 #38270777 未加载
评论 #38269156 未加载
评论 #38272101 未加载
评论 #38271610 未加载
hnlmorgover 1 year ago
&gt; Before we move on, I want to point out that “being able to write code from left to right without backtracking” is a completely bonkers thing to optimize a programming language for. This should not be anywhere in the top hundred priorities for any “serious programming language”!<p>There are plenty of serious languages that are written this way. Most noticeably are shell scripting languages but I’ve seen stack based and functional languages that are written like this too.
评论 #38261302 未加载
评论 #38260395 未加载
评论 #38260786 未加载
评论 #38262995 未加载
tuukkahover 1 year ago
One key point I overlooked on first reading:<p>&gt; <i>[--] I wanted access to Haskell’s list monad in a sloppier language.</i><p>&gt; <i>I like static types, but only if they’re sufficiently expressive and supported by good inference, and I like not having to implement any of that stuff even more, so I settled for dynamic typing.</i><p>Then it&#x27;s some of the power of Haskell without any of the safeguards. Plus being able to write &quot;x f y&quot; to mean a function call to f with arguments x and y (whereas in Haskell you&#x27;d write &quot;x `f` y&quot;).
shaftoe444over 1 year ago
Inspired me to have another run at the second half of Crafting Interpreters.
dtx1over 1 year ago
&gt; I solve and write a lot of puzzlehunts, and I wanted a better programming language to use to search word lists for words satisfying unusual constraints, such as, “Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K.”<p>So... Perl?
评论 #38271986 未加载
评论 #38262365 未加载
评论 #38272610 未加载
评论 #38260928 未加载
__mharrison__over 1 year ago
I&#x27;m not a competitive Advent of Coder, but as a corporate trainer, I appreciate it for giving me insights into my coding style. Hopefully, I can use those insights for my students.<p>The last time I did AOC, I tracked every error I made to reflect on my mistakes when coding.<p>I think this year I will do &quot;Advent of AI&quot; and see how far AI tooling can get me.
rohithgillaover 1 year ago
Amazing, the cross inspiration from python and rust is cool. Good work!
Joker_vDover 1 year ago
Why are people so insistent on having unary minus? In my experience, &quot;0-whatever&quot; is just as good as &quot;-whatever&quot; <i>except</i> in a single case where you&#x27;re trying to write an INT_MIN but then again, unary minus doesn&#x27;t help you in this case either — unless you, as e.g. SML does, make the unary minus the <i>lexical</i> part of the number itself. However, SML has to actually use the tilde &quot;~&quot; instead of the minus for the negation because otherwise &quot;1 -2&quot; would be ambiguous.<p>IIRC Elm didn&#x27;t have unary minus for quite some time just fine unless its author decided he <i>really</i> would like to have specifically unary minues but, weirdly, not any other unary operator. So, what&#x27;s the deal with unary minus, why do people want it so much?
lawnover 1 year ago
Such a fantastic and inspiring post, and a very cool language. Kudos!
avindrothover 1 year ago
In terms of speedrunning, couple of friends and I are trying to speedrun AoC using LLMs (sacrilegious i know).<p>It’s been growing a bit; if interested, feel free to shoot me an email to joshcho@stanford.edu<p>Or @eating_entropy on X