Hacker News new | ask | show | jobs
by yura 941 days ago
In my experience it’s not supposed to be that hard, unless you’re working at the cutting edge or on really hard problems. But from what you’ve written it seems like you’re struggling with basic stuff.

Maybe you’re still lacking fundamentals? Seems like your strategy so far has been to grind tutorials and crash courses. They will make you feel like you’re learning a lot in a short time but in the end you’ll still not know what you’re doing, and you’ll keep struggling when facing new problems that are outside of the scope of the tutorial.

Maybe you’re learning from low-quality resources? Yes, the internet is full of free resources but most of them are useless and actually harmful, and some curation is needed. Instead of studying the basics over and over from endless free online tutorial/courses, just learn them once, the right way, from a high-quality resource instead. See: teachyourselfcs.com

3 comments

The author says he struggled with concepts that are “easy” or supposed to be. In my experience of coding since 6th grade and having been in the industry for quite some time, it’s difficult to say something is supposed to be “easy” or “hard”. The author doesn’t give many concrete examples so it’s possible he is just assuming certain things should be super easy… A lot of programmers I meet love to claim they don’t struggle with basics, then I ask them to write be a simple bubble sort or binary search from scratch and 90% cannot do it. They could only do it when they could reference or look it up. Everything thing seems “easy” after you learn it. There’s this romanticized super genius idea everyone thinks they need to live up to but that portrayal is simply fake. No one’s grasps things instantly.. I am a researcher at MIT. I work with arguably some of “smartest” people on the planet, and even they struggle with basic concepts from time to time, as does everyone. There is simply too much information for any single human to know it all, and learn new things instantly. It doesn’t happen…. Most things that should be “simple” or “easy” always end up requiring significant effort because we don’t truly know how to do something until it’s actually down. Forgive my spelling and grammar errors. I am typing on a phone and my hands are just too big to do it quickly.
I don't think writing bubble sort from scratch without mistakes is necessarily a good demonstration of someone's ability to "handle the basics"

Realistically you will never need to write it yourself unless you're coding in some very specific domains

It's at most a signal for whether or not they remember algorithms 101 or some leetcode exercise, but knowing that they do remember isn't really useful to me

> It's at most a signal for whether or not they remember algorithms 101 or some leetcode exercise, but knowing that they do remember isn't really useful to me

For bubble sort? Do you really think anyone should have to remember an algorithm to write a quadratic time sort? All you have to do is "compare and swap" and loop through until you are done, this is way easier than Fizzbuzz.

This is only hard if you have a hard time grasping loops, conditional comparisons or swaps. But if you understand all of those the sort writes itself. And understanding loops, comparisons and swaps is pretty fundamental to anything you do as a software engineer, so I'm not sure how any competent software engineer could struggle with it.

Every technical thing you know is informed by your practice in an area. There's a lot of roles where you don't even have to think about which algorithm is implemented behind your favorite sort method. If you work in a role like that for 10 years, bubble sort becomes "which one was that again"?

Engineering is about solving valuable problems. Solving some of those problems requires obsessive control over (and selection of) specific sorting algorithms, many do not.

Edit: it's also worth bearing in mind that many of the people who discovered these algorithms are famous in part for having thought them up. If data structures and algorithms were so obvious, nobody would know who many of these people were.

Assuming knowledge and understanding of an algorithm but no prior practice with implementing it, one’s way of implementing it does tell about their proficiency in programming.

GPs bubble sort was obviously just an example, effectiveness of the algorithm or wether there’s ever need for implementing it by hand is irrelevant.

> All you have to do is "compare and swap" and loop through until you are done, this is way easier than Fizzbuzz.

I think you have this wrong, Fizzbuzz is actually completely trivial to the point where the problem statement is almost literally (modulo modulo) a description of the algorithm.

Bubble sort is very easy but it's not literally trivial to the same degree as Fizzbuzz!

> Fizzbuzz is actually completely trivial to the point where the problem statement is almost literally (modulo modulo) a description of the algorithm.

Fizzbuzz requires you to read and understand a few lines of requirements. That is much harder than just "order these elements, runtime isn't important", you can easily miss some part of the problem statement or misunderstand it for Fizzbuzz and fail, you shouldn't but it can happen, no such thing for a quadratic sort.

for i = 0 to n { for j = i to n { if n[j] > n[i] { swap(n[i], n[j] }}}
Except that sorts the list in reverse: https://tio.run/##Vc6xDsIwDATQPV9xYyJ5od2Qyo9UGYhIwFXkVlY68P...

(Also a subtle off-by-one error, it should be 0 to |n|-1 and i to |n|-1.)

1 point for having a good reply. 100 points for doing it in code. Well done!
>This is only hard if you have a hard time grasping loops, conditional comparisons or swaps

Or because you don't know the algorithm in question... The problem isn't bubble sort but any generic algorithms test. The examiner wants you to write code but not tell you the specification because it would be shockingly similar to telling you the solution.

When I read a post on HN about inverting a tree I was wondering how exactly you are supposed to invert the child and parent relationship so that children point to parents instead of parents pointing to children. I.e. leaf nodes are now at the root and the root node is where the leaf nodes are supposed to be. Then someone said "He meant reversing the tree" and I'm like "That is not what he said."

> Or because you don't know the algorithm in question

I don't think anyone would care if you did an insertion sort or some other brute force way to sort. Brute force sorting in general is trivial to come up with.

I agree with this.

You'll often see responses like "but many people don't need to write sorting algorithms from scratch in their day to day work, so they're out of practice". But to me this attitude itself is indicative of the issue.

Being able to do this doesn't require sorting algorithms to be well-practiced and fresh in one's mind. It requires a general ability to visualize and reason about simple data manipulations. Which to me is an absolute fundamental for a programmer working in any field.

If the algorithm can be described with a small sketch or a couple of sentences, generally an implementation should just flow for an experienced programmer who has general fluency? For something like bubble sort, the description can be more or less directly translated to code.

The fact that someone even conceives of this as something which needs to me memorized / practiced suggests to me that they might not have that kind of basic working fluency.

The problem is that people need to know the algorithm you're asking them to implement, which biases it towards memorization.

When you tell them how the algorithm works, it feels like you are not testing anything except syntax.

If you let people look it up, it feels like you aren't testing anything except their research skills.

It is difficult to have a test in a vacuum. It would probably be better to have a test with multiple steps.

Exercise 1:

a) Research the topic bubble sort. Explain what bubble sort does and write some notes or pseudo code that will help you implement it. Once you are done, we will disable internet access and close your browser.

b) Write a working bubble sort in COMPANY LANGUAGE.

c) Modify the bubble sort so that it can sort by multiple columns.

The first tests your research skills, the second your syntax skills and the third your ability to deal with changing requirements and implement novel functionality without research.

No need to be so literal. Substitute "bubble sort" for "any simple algorithm involving nested loops/branches/collections" and the result is likely to be the same. Mistakes are common. Partially, that is why unit tests may be useful.
it's not even the most efficient search. I don't think any sort method in a language would use a bubble.
I agree it isn’t but the point I was trying to make is that when you have to do something from scratch, on your own, even if it’s simple, it can be a challenge. My example was poor because I am typing fast sitting in a car parking lot and I hate typing my thoughts on phones.. Forgive me..
I was agreeing with you haha

Companies ask that kind of stuff at interviews lol

Theory: "imposter syndrome" is simply seeing the truth. No one lives up to the social conception. Einstein needed help with mathematics. The realistic perspective is the curiosity of a scientist; the humility of a mortal. Knowing the premises does not automatically imply you know all the consequences... even though it "should".

Bugs have been found in production binary search.

Skipping bubblesort, I think quicksort is easy to implement, if you know Hoare's fp insight (I remembered it, but had to check it was him). Making a version that is both efficient and correct may be harder for me... Similar for Boyer-Moore substring matching (I remembered their names!)

> I think quicksort is easy to implement, if you know Hoare's fp insight

Could you please provide more information on this?

He learnt about recursion in a fp workshop(?), and as a first exercise, tried applying it to sort.

You pick a number in the list, then put lesser numbers into a left-list, and greater into a right-list. Recurse.

It's very slow as intuitive, simple and elegant fp, because it's creating new lists like crazy; but a mutable, in-place version (e.g. in C) is super fast. Maybe the origin of the folklore "learn fp to be a better coder, not to code fp"? I don't think he expected it to be so good; he was just doing him. A very smart man.

This seems like an uninteresting test. Nobody (almost) is implementing sorting algorithms in their day job. We use libraries. It's like asking people who claim to not struggle with driving basics to change their spark plugs and saying "aha, I new you were an idiot".
It seems pretty indicative to me. Bubble sort is a simple idea that I understand conceptually but haven’t written the code for yet. That summarises most of my job. And yet, 30 years in, I still make stupid mistakes all the time.

I think the difference between professional engineers and person writing the blog isn’t necessarily skill. I think it’s how we react when we make mistakes. Maybe the real test of a programmer is watching how calmly they can write their buggy bubble sort, then test it and fix the bugs. Bugs happen. How we roll with the punches is what makes some people great.

Yes but it is basic in the sense that it’s one of the first couple algorithms/data structs mostly everyone has been exposed to. Many knowing what they are and the general principle of how and why they work. That is exactly my point though.. Like what do we consider “basic” exactly? That line becomes blurry in any complex field…
If you don't use something, you forget it. Nobody is writing these algorithms in their job. If you did, it will get flagged in code review, the same way rolling your own crypto does. Which is why I think it's unreasonable to expect people to remember how to implement them off the top of their head.
> I work with arguably some of “smartest” people on the planet, and even they struggle with basic concepts from time to time, as does everyone. There is simply too much information for any single human to know it all, and learn new things instantly.

This. Many programmers, for some reason, act like skill is a complete order; you are either more skilled or less skilled than someone else. In practice you are just familiar with different things, so if somebody doesn't know something that feels trivial to you, it just means he didn't encounter it in the same way.

I have been giving advice to a person, young also (16 years old) and he thinks he can go very far very quickly.

I told him to be patient, to insist, to commit time learning not only typical courses of how to code your website with a database. In fact I gave him advice against doing that first.

I adviced him to learn binary/hex, algorithms, data structures and structured programming as a minimum. Also how a machine works (at least the abstract model): memory addresses, data, pc.ñ, call stack... etc. Interpeters vs compilers, some OS basics (though at first can skip most of this). My advice has been to first learn with Python and later C.

Understand why or when to use functions, certain data structures, etc. Do increasingly difficult but basic exercises.

And specifically, develop a sense and taste, at the end, on how to figure out how to code a solution to a problem he never saw. Cost analysis also helps lots and must be learnt at some point.

This is what happens when you gothrough random courses, exactly:

> Maybe you’re still lacking fundamentals? Seems like your strategy so far has been to grind tutorials and crash courses. They will make you feel like you’re learning a lot in a short time but in the end you’ll still not know what you’re doing, and you’ll keep struggling when facing new problems that are outside of the scope of the tutorial.

That is SO true. You have to start from scratch. I mean it. Because when you see something like s stacktrace that goes from Python to your native library with memory addresses you will understand NOTHING when the time comes.

Programming is a discipline where you need a lot of practice.

Something I have realized with my struggles in learning how to program is that it's as much a philosophy of how we get a computer to solve a problem as it is an experience learning the structure and syntax of a new language. Coming at it from a complete newbie perspective I don't even know what I don't know, so therefore I can't begin to learn what I should. At best, I can memorize how to do basic things but I don't understand the fundamentals of how those things work, or why they were designed that way.

To be honest, I don't have an objective reason to learn much CS as that's not my layer, so I'm butting up against my own ignorance any time I try to advance in something easy. And then my ADHD determines memorizing that information is unnecessary so I struggle to get concepts to sink in.

Recently I discovered Roblox uses Lua so learning that to make silly experiences for my son sounds wonderful. It's goal oriented so I can convince myself it's worth pursuing, and I feel like Lua concepts will help expand my toolkit for the future. But I'm also not starting from a blank IDE page going "geez how do I even know what to start building first..."

You probably don't know how valuable motivation is. I learned that lesson only three years ago. It is so easy to simply do nothing both when you are motivated and not motivated. You don't need to know how write lua if you can inspire your son to build things with it. In the last three years, I have probably had more ideas of things that I want to do than in the two decades before that.

When I was 16, I had software skills but was clueless about what to actually build. Now I know what to do and don't have enough time to do it. The idea of grinding two hours a week just doesn't work for me. I want to do things in bursts. Like working 10 hours on it and then weeks of nothing.

> I don't understand the fundamentals of how those things work, or why they were designed that way

The problem with not understanding things is that when you face a new problem or things crash or go wrong you get totally lost and do not know how to proceed at all.

Another recommendation if you want to learn is that you use a terminal and an editor. Nothing else. You will see things closer to how they work. You will be aware you are launching a script or compiling a file. You will see the output files, you will understand there is a compiled file to be run. You will see if it is native code you run it directly but if it is compiled to bytecode you need a VM, etc.

That is part of the details one must be aware of.

I've been thinking about this a bit lately and I think it's actually less about fundamentals and more of an issue with process. I'm not saying that fundamentals are not essential, but we often don't have the time to learn all aspects of a complex system.

There is definitely a lot of overlap here, but I have a finite amount of time that I can put towards solving problems. I've been thrown into AI over the past 6 months and know none of the fundamentals of this space, but I can still be very productive.

My process now is to know how to pull up docs quickly (in my editor), take advantage of the LSP, use my debugger and learn the systems on the fly. I'm probably not going to take courses in AI, Data Science and other aspects of this discipline as it will only have a marginal affect on my daily activities.

My job is to understand the flow of data, so I need to focus on that and make sure my process, tooling and access to documentation are the best possible to accomplish that.