255 points · by azhenley · 3y ago · 75 comments
By the time I get the kids in bed at night, I'm often out of steam. Sometimes I try to make some progress on a project, but I usually don't have the willpower to push through a stumbling block. After many many nights of staying up late and losing sleep trying to power through but not actually getting anything working, I finally realized it's better to just go to bed.
But I also feel sad if I go to bed early without making progress on something I'm excited about. So I started tricking myself by telling myself, "Well, you can just think about the project as you fall asleep." That's usually enough to get me in bed early.
And, lo and behold, quite often, I figure something out as I'm drifting off. Then when I wake up the next morning, I can get it implemented while I have my morning coffee. It's a really pleasant routine.
The goal was to see how similar code is, and how little it matters which language you pick.
Obviously it's a constrained problem set (we didn't have to learn all the ins and outs of each language) but it really opened our eyes to the "commonness" of programming, and free'd us from the tyranny of "I program in x".
I think this thinking is a mistake. If you learn languages superficially, you will end up writing the same code just with slightly different syntax. It can take a long time to really understand a language and ecosystem and use its capabilities.
But if those languages are C, APL, Erlang, ML and Lisp then I would expect the lesson would be the design space of languages is much larger than the popular imperative languages would have you believe.
On the other hand, differences will start to show them selves after you spend a while noodling with your script, refactoring it a couple of times and deliberately seeking out opportunities to use language-specific features in the process. This expands the exercise to something more like "a language a week" instead of "a language of day", which is obviously a bit more of a time commitment. But if you want to get value out of a "polyglot" programming exercise like this, I think that's what you really need to do. Otherwise I think you learn lessons that are only correct at surface level.
And Java didn't, until relatively recently (oh god Java 8 was almost 10 years ago), have anonymous functions, which means that you'd be more inclined to express solutions in terms of vulgar loops rather than a map, filter, reduce type operation.
Which is to say, they'd definitely look different.
I think that’s a pretty bad result of the exercise. The point of software isn’t just to do a thing. Good software should properly encode a domain or idea and communicate that to others.
If one took the analogy of driving a nail into wood, there are many tools that can do the job, but only a couple that properly handle the job. Because the goal isn’t to just drive the nail, it’s to do it efficiently and ergonomically and in a way easily communicable.
* Excluding some deliberately opaque languages like brainfuck and malbolge.
Anyone who's tried hammering a Java-shaped solution into an Haskell-shaped language will eventually see the folly.
I interview a lot of programmers and I often get told that one of my questions is just impossible because it’s slightly awkward to express in Java. (It’s only Java folk incidentally, even though it’s roughly equally awkward to express in most of the long list of languages we let candidates use.) By analogy these are folk that would have to sit around waiting for their hammer delivery rather than just make do with a mallet for a few minutes.
I agree with your point though. I remember being asked a question and I blanked with how to model it in Java. Then I switched mid interview to python and it clicked for me.
obligatory reference to Landin "The next 700 programming languages" (1966)
His story of pivoting from PL research to medical research (and being a star in the field) is quite motivating.
I missed blogging too, so I set a New Year’s resolution in January to write at least two blog posts this year. It had been over seven years since my last!
I still hadn’t written one by November, but now I’ve got three for the year.
I’m optimistic I can keep it up now.
[1] https://www.facebook.com/freethinksuperhuman/videos/15306506...
But it’s still very useful and I’m sure he learned a lot and absorbed of some of the new languages’ programming styles. You don’t master idiomatic functional programming from one week of writing Haskell, but it does introduce you to basic concepts like functors, lambdas and embedding computation (IO) in data.
Which isn't to say that you're wrong, but rather that the author is likely well aware of these particular shortcomings of the exercise. But then the exercise wasn't "write perfectly idiomatic code in a different language every day", but just "learn some languages I didn't know before".
From my personal experience of doing AoC in Julia this year, my Julia code started out smelling a lot like Python, but managed to adopt a bit more of the Julian way of doing things as I went along (not done yet though...)
This was the reference I used for TeX programming: https://pgfplots.sourceforge.net/TeX-programming-notes.pdf
100 languages in 100 days...
I likely wouldn't do this personally out of pure laziness but good on you!
In the end I lost the motivation once I only had the “regular” languages left. I was also solving them as quickly as possible (in Ruby) to get on the leaderboard so it was kinda boring to also solve them again later on.
The initial headline of your front page intrigued me because I had noticed in surveying my own institution (the one where I studied, both as an undergraduate and as a postgraduate, and where I now happen to work) that while most of the undergrad courses of study we offer that require mathematics include at least an opportunity to program, Medicine does not. I reasoned at the time that the Medics have to cram such a large amount of other material into their brief time that maybe there's just no room to teach them to write code if they are to sleep (in my country they certainly won't have time to sleep once they're junior doctors)
This year I used Python as my second language (still plan to finish) but with a strong emphasis on TDD and property-based testing since I'm already familiar, but not fluent, with Python.
0: https://www.reddit.com/r/adventofcode/comments/zwi0t4/2022_w...
Curious about this line if op is here.
But, I did once learn how to do template meta-programming:
https://matt.might.net/articles/c++-template-meta-programmin...
Write up on the whiteboard in various languages to echo "Ho Ho Ho", preferably in shorthand, one-liner if possible.
Like python would be
("Ho "*3).strip()Clojure and Rust were on their list of strong languages that they didn't end up needing:
> F#, Ocaml, Rust, Perl, Swift, Clojure, Smalltalk
Forth and APL were on the list of probably impractical languages:
> APL / J, Prolog, Forth, m4, COBOL, Fortran, Ada
For day 1, I ended up using a pretty different method than the Python code, mostly so I could use what I already knew or could quickly figure out, processing it character by character.
I wasn't planning to do more, but I realize the input for day 2 could be executed as Forth code simply by defining the words for what those input command should do, and then executing the input AS Forth, so it was actually a quick and easy one in Forth.
Forth would be a good one though. Both simple and different.
In which case Rust is a powerful tool to bring to AoC late on because you can afford to take a not-so-algorithmically clever approach and Rust's optimiser will save you.
Take day 16. The professor did it in Python, with which they have some experience. My Part II solution is pretty bad, it's a combinatorial explosion resulting from a search of the solution space with both the elephant and myself trying every option. But, I wrote it in Rust, so this bad solution finishes in five minutes. If I'd written this terrible solution in Python it may have taken hours to finish...
Yes, I'm willing to tutor a student to test my claim.
It took me a week from a cold start to get a working mergesort toy example working. By comparison, elixir took me 1.5 hours. 2 to make it multicore.
P.S. I'm somewhat surprised by this community's adoration of AoC and at the same time aversion to Leetcode and/or competitive programming in general. Arguably, many leetcode problems are more interesting (from an algorithmic point of view), are much shorter (although I guess for some, part of the fun of AoC is the elaborate story), and most importantly, have extensive test cases, that require generalized solutions.
The AoC isn't the blog post; the choice of using a different language every day is the blog post. Does that not seem even remotely interesting to you?
> I'm somewhat surprised by this community's adoration of AoC and at the same time aversion to Leetcode and/or competitive programming in general.
AoC is deliberately a game. It's spirited and fun. Leetcode is a by-product of an interviewing system that worked kind-of well at one company once upon a time, and then everybody decided they needed to do the same thing because that company had a Big Name, and now we have a broken interview process that is — in most practical respects — completely useless.
That's not to say some Leetcode problems aren't good or fun problems to work on, but the website itself was purpose-built to help people game a broken interview process (which has, incidentally, only made the process worse).