Hacker News new | ask | show | jobs
by nopenopenopeno 1608 days ago
>when you only need to write two curly braces to create a “dictionary” (of course behind the scenes this is a hash table) many of the nuances of that data structure are hidden from you. You have no idea that accesses are on average O(1) but worst case are O(n).

Well, that is wrong. Single value accesses are O(1) amortized.

Also, Java is a lower level language but I don’t think simply programming in Java instead teaches you this. Either way, it’s the difference between learning how to write programs and learning computer science.

2 comments

Updated the original comment accordingly.

I suppose that’s also fair. I would say that Java at least makes you aware that there is magic afoot. You have to explicitly write that you’d like to use a HashMap, at which point someone writing or reading the code might wonder “what’s that?” Instead, python hides behind the abstraction of a “dictionary” when it should be in my opinion broadcasted from the high heavens that this is a hash map in disguise.

As far as the remainder of your comment, I agree wholeheartedly. Learn computer science. It makes you a better programmer.

Yeah, that’s true. Calling it a “dictionary” definitely doesn’t help! I would support any and all efforts to stop inventing new words for established constructs. I learned to program with Python and I am confident these things held me back, now that you mention it.
You got me curious there. Do you have any resource recommendation to learn about the cost of different data structures/algos and such?
This is what big O (also little O and little omega) notation is all about. Unfortunately, all the resources I know of teach it as pure mathematics, so they require a firm grasp of mathematical proofs to understand the details and implications.

With that said I highly recommend the classic Introduction to Algorithms (CLRS for short) by Cormen et Al. It is written in clear and straightforward language. And the lectures on MIT OCW by Erik Demaine are outstanding.

By reading and watching the lectures I deeply understood stuff that I had just muddled through previously.

https://en.m.wikipedia.org/wiki/Introduction_to_Algorithms

Introduction to Algorithms is a classic that every serious programmer should read cover to cover.

at my first programming job (now almost 30 years ago), I remember implementing the red-black tree algorithms in C from that book. It is chock full of really useful ideas that will make your systems better.

CLRS is the text, but for a more gentle introduction see Grokking Algorithms.