3 ms·
I think that it helps a lot to have a daily practice of using a language for small things. In much that same way that many people do the daily wordle or crossw
by senkora 5mo ago
I think that it helps a lot to have a daily practice of using a language for small things.
In much that same way that many people do the daily wordle or crossword, I do the daily leetcode.
I flip a coin and solve it first in either C++ or Python, then re-write my solution in the other one.
Usually it takes me around 20 minutes to solve it in either language, and 5 minutes to re-solve it in either language.
Recently I decided to start learning emacs lisp. This is an imperative lisp dialect that’s pretty different from scheme, but I think that the particular language doesn’t matter much for this process. I could a bit biased because I do have prior experience with SML and scheme.
I started re-solving the problems a third time in emacs lisp. And I’m still learning but I’ve felt my comfort with the language increase over time, and I expect that if I continue doing this then I will eventually reach parity with C++ and Python.
Currently it takes me about 20 minutes to re-solve a problem in emacs lisp, because I usually have to read documentation and/or look up something new.
- deleted 5mo ago[deleted]
- throwaway27448 5mo agoHow did you arrive at C++ and Python? Yes I'm aware they have many structural and aesthetic differences, but why would you not choose a language with a different paradigm—functional, logical, even procedural, etc?
- senkora 5mo agoGood question. I chose them because they are the languages that I use professionally and would choose for technical interviews. I expect to be asked to solve problems in either language in any given interview. Technical interviews are different enough from day-to-day work that I still find it valuable to practice in them.
- epolanski 5mo agoI hope you really do it more as enjoyment (like people do crosswords) with just a very secondary benefit of technical interviews, because otherwise I can't but find this rat race obsession super sad.
- throwaway27448 4mo agoBrother. Easy interviews are no basis for your own practice.
- Pay08 5mo agoRelatedly, I've noticed the strange infatuation that a lot of C++ programmers have with Python specifically. I have no idea why that is.
- aldanor 5mo agoBoth have `class` keyword
- Pay08 5mo agoSo does JS, yet it's not the scripting language du jour in the C++ world.
- throwaway27448 4mo agoPython has standards
- retrac 5mo ago> I could a bit biased because I do have prior experience with SML You're probably under-weighing this factor. The average programmer looks at SML syntax and cannot make, pardon the expression if you will, heads or tails of it. Indeed, I'd argue the average programmer still considers recursion an advanced topic.
- hibbelig 5mo agoRecursion. Very interesting. My daughter didn’t know much about programming, then started CS. The first semester language was Ocaml and they of course used recursion quite heavily and she’d didn’t know it was supposed to be complicated. The second semester had assembly, C and Java and suddenly it was a problem. I had to remind her that she’s had already done it in the first semester.
- chamomeal 5mo agoSounds like a sick CS department. We had to do Java. The whole first year was just OOP day in and day out. If I’d never seen python I really would have thought all programming is OOP, and probably would’ve dropped it for good
- gucci-on-fleek 5mo ago> If I’d never seen python I really would have thought all programming is OOP But isn't Python object-oriented? I mean, it's arguably more object-oriented than Java, since unlike Java, everything in Python is an object and it supports multiple inheritance. It's totally fair to not like Java, but if you like Python, then I doubt that OOP itself is what made you dislike Java.
- Izkata 5mo agoPython is an object-oriented language in the broader meaning, but object-oriented programming is a particular style that java pushes you into, that python doesn't. It doesn't just mean "everything is an object", it's more like "everything is done in terms of objects that contain data and functions (methods)". Python has objects and could be done in that way, but a more basic imperative style with functional programming elements is more common, where objects are just one component instead of the driving force.
- sillysaurusx 5mo agoWhere do you find a daily leetcode problem? Is there a website somewhere that publishes them?
- senkora 5mo agoIt's a feature of the leetcode.com website. I actually can't find a URL that will directly link to the current day's problem, but you can open https://leetcode.com/problemset/ https://leetcode.com/problemset/ and select the current date in the calendar widget (at the top right on desktop, or by clicking the green calendar floating action button at the bottom right on mobile). You can view the daily problem without logging in or creating an account. Fair warning: today's daily problem is a "hard" difficulty and it is often worth skipping those or peeking at the solution. They can take a while to solve (often at least an hour) and/or rely on unusual tricks or data structures. I haven't solved this one yet so idk exactly what its deal is.
- meken 5mo agoThey are published on the leetcode website. Here's a screenshot showing where to click [1]. LeetCode does have an "unofficial" API to get the problem of the day. Should work for previous days as well. This code worked last I tried [2]. [1] https://github.com/ebanner/daily-coding-challenges#leetcode https://github.com/ebanner/daily-coding-challenges#leetcode [2] https://github.com/ebanner/get-daily-leetcode-problem/blob/main/lambda_funcion.py https://github.com/ebanner/get-daily-leetcode-problem/blob/m...
- meken 5mo agoNice to meet someone else that does the daily leetcode! It is really a nice feature - I wish every online judge website would add it. Bonus - Racket is an accepted language on leetcode ;-)
- arikrahman 5mo agoIt's advantageous in the real world as well with Guile Scheme being used for Guix.
- daemin 5mo agoDo you find yourself programming a solution in the second language in the style of the first? Or are they both similar enough to you that it is effectively the same style of solution?
- senkora 5mo agoI typically do the same algorithm for each solution, but I do try to write it in an idiomatic way to each language. I usually look at the editorial after the first solve to see if I missed any tricks or other approaches, and sometimes I’ll write the second solution differently if there was something interesting that I missed.