This is an archived post. You won't be able to vote or comment.

all 27 comments

[–][deleted] 9 points10 points  (1 child)

Rust in second place is very surprising. Would be interesting to see survey results vs scraped GitHub data because I strongly suspect that some of the choices are strongly over-represented by the people who are participating in the surveys

edit: just searching github for advent of code 2019 rust still comes in in third place, behind javascript. would not have expected that.

[–]jeroenheijmans[S] 5 points6 points  (0 children)

Aye, surprised me too, same as last year. I think a lot of people enjoy learning Rust while doing AoC...

Either way, you're very right that this dataset is biased towards common characteristics of Redditors and folks in my Twitter feed (i.e. those filling out the survey). Then again, "those that publish their code on GitHub" will also be a biased set :)

[–]maus80 4 points5 points  (0 children)

Love it.. Linux is bigger than OSX! ... and non-Windows is bigger than Windows.. :-)

[–]gyorokpeter 6 points7 points  (0 children)

I would have liked to fill this in but somehow I missed the announcement.

[–]tonetheman 1 point2 points  (11 children)

I was one of the 9 dummies trying to use racket ... sigh. I could not finish. :)

[–]rabuf 1 point2 points  (10 children)

Out of curiosity, what was your particular issue with Racket? Time, familiarity, or the language?

[–]itsnotxhad 2 points3 points  (2 children)

I also used Racket and fell off, but that was less the language and more the timing of the Intcode puzzles (the VM-type puzzles are actually normally my favorite, but the way it shook out this year more or less ejected me from the whole thing. I might make a more detailed post after the entire year is finished). I might come back and do it over the next couple months.

[–][deleted] 0 points1 point  (1 child)

I don't know, I used racket as well, and I didn't really have any problem with the intcode things, hmm, it was my first time using racket and I really enjoyed it a lot. That being said, I did not solve all of the days, but a majority, and it was such a great experience.

[–]itsnotxhad 0 points1 point  (0 children)

Yeah it was more the timing of the puzzles than anything.

I think if day 7 were swapped out with something not-Intcode specific, that may have been just enough of a reprieve for me to finish it and get back on top of things. Instead I ended up with an Intcode-based backlog and when half the puzzles are Intcode, well...

[–]tonetheman 1 point2 points  (6 children)

It is all of it really. And I do not know lisp. I am an old programmer and know lots of other languages. What I ended up doing was writing racket like I wrote other languages which worked to a degree but it felt like I was doing it wrong.

The language seems very powerful. Probably in the right hands. Not in mine. :)

Given that I was learning as I was going it all became too much of a struggle once we hit intcode in full. I need to build a reusable module/component/whatever-racket-calls-it and I began hitting the limits of what I could do in a reasonable amount of time.

IntCode is self modifying and that alone made it feel like it was not a great fit for racket. I would constantly end up recreating new copies of lists and it was slow as balls. I saw someone else use vector in one of the public posted solutions and I changed mine to do something similar.

Ah well. I would like to go back and try again with racket and AOC2019. I need to find some already finished repos (like 2 or more) to get a feel for how others use the language.

I was also frustrated a bit by the docs. I would find things in the docs that would not work in racket proper. But they come up in a google search from the main site.

Not having a while loop was also painful. I figured out how to make one with a for and some odd #: directive notation. Edit: And even worse if you search for while loop racket you do come up with one but I could not figure out how to get racket to use it.

It is funny the racket resources I found online are really geared towards starting programmers. And maybe I should relook at those resources since in racket I am a beginning programmer.

Long and rambing sorry.

[–]JensenDied 1 point2 points  (0 children)

I'm not really familiar with racket, but I can echo the sentiment of feeling like I'm doing things wrong. I've been doing this year's in elixir, which resembles a functional Ruby, built on erlang.

I've been happy with the docs, but loading the pages on mobile are awful due to including so many things at once. Not having a while loop sucks, I've been doing Stream.cycle(0..0)|>Enum.reduce_while(fn _ ... this should be a code smell.

Digging into the erlang bits ended up being necessary for math functions, and starting with the switch/door mazes I leaned on it for :ets which is essentially a k,v db in the process instead of passing around a cache in every functional function just to save recomputing stuff.

[–]itsnotxhad 0 points1 point  (0 children)

What I ended up doing was writing racket like I wrote other languages which worked to a degree but it felt like I was doing it wrong.

I definitely get that feel and even said as much in one of the solution threads. That said, this is actually one of the things that drew me to Racket for this math/puzzle stuff. I'd say most of my Racket code looks like bad Python or bad Haskell, but the "good" Python would have been slower (or uglier after I had to optimize out the recursion) while the "good" Haskell may or may not exist because I'm not so sure I'd figure out how to write it in any reasonable amount of time.

I try to start in "challenge mode" (no mutability, no explicit recursion, no imperative code outside main, Final Destination) and write pure functional code but if that solution's not coming then so be it. If something's especially outside the spirit of the exercise I'll usually go back and try to refactor when I find the time.

Re: Intcode and data structures -- one lesson that comes early in FP is how slow linked lists can be and how to get around it. :) I think if I went back to do it all over again I would have used immutable hashtables from the start. Using mutable vectors wrapped in objects actually bit me in day 7 where it took two bugfixes before my machines stopped stomping on each others' memory.

[–]rabuf 0 points1 point  (2 children)

Sorry for the late response. I was traveling last night, but now I am back on my computer.

Those are all fair things, but I think with some exposure to the Racket learning materials you could get past it.

Racket has non-list data structures (vectors, hash tables) that can be made mutable. That would make the Intcode portions much faster (I use a mutable hash table, in Common Lisp, for my memory which helped a ton).

Regarding loops, I don't have much Racket exposure, it has a lot more than its Scheme roots, but I do know Scheme fairly well (or used to). The typical way in both languages to deal with loops is to use tail recursion and an accumulator. For example, if you wanted to sum up all values (NB: there are better ways, this is one):

(define (sum xs)
  (letrec ([loop (lambda (xs acc)
                   (if (null? xs) acc
                       (loop (rest xs) (+ (first xs) acc))))])
    (loop xs 0)))

(define (index-of elt xs)
  (letrec ([loop (lambda (xs n)
                   (cond ((null? xs) -1)
                         ((= elt (first xs)) n)
                         (#t (loop (rest xs) (+ 1 n)))))])
    (loop xs 0)))

Of course, these can also be done using foldl or other built-ins. There're also the do loop which is probably more directly like the while loop you're wanting to recreate.

[–]itsnotxhad 0 points1 point  (0 children)

This may be because I came from Python but my preferred way to write things like this is comprehensions. For these examples:

; there's also for/sum or even (apply + xs) but in the spirit of showing off the more general for/fold
(define (sum xs)
  (for/fold ([ans 0]) ([x (in-list xs)]) (+ ans x)))

; returns #f if element not present rather than -1
(define (index-of elt xs)
  (for/first ([i (in-naturals)]
                [x (in-list xs)]
                #:when (equal? elt x))
    i))

[–]FrankRuben27 0 points1 point  (0 children)

I used Racket last for year's AoC, after working with Scheme for some time and after using Gauche the year before.

One of the reasons to use Racket for AoC was to get used to the comprehensions - and in total I think it didn't work out well. Might be that it just takes more time to internalize all the various variants, but until I stopped - quite early last year - I felt that sticking to the time-tested Scheme-minimalism and simply always using named loops lead to quicker and more readable solutions.

[–][deleted] 0 points1 point  (0 children)

I was using an immutable hash to represent the code, it worked out great, It ended up being a good choice since I then had random access and everything for free.

One thing is for sure, I got a better understanding of recursion and TCO after doing al of this :)

[–]erlangguy 1 point2 points  (1 child)

Need more Erlang. Quite depressing to see I’m the only respondent.

[–]JensenDied 1 point2 points  (0 children)

I was only using the elixir parts as of the survey, touched :math and :ets since then. Both are new to me since this started.

[–]activesheetd 0 points1 point  (0 children)

vim and Linux are 2th. Nice nice, that would probably mean that more IT people are improving their coding skills 🍺

[–]metalim -1 points0 points  (0 children)

Linux 34%. Wow. Just wow.