Live data from Hacker News

How do I know if I'm good at programming?

danielslater.net

141–150 of 153 posts

Re: How do I know if I'm good at programming?

#141
post #139

Earlier quoted context omitted.

Take the following code, which I had occasion to write this morning: foreach (var item in items) { if (items.Where(item2 => item.Upc == item2.Upc).Count() != 1) { item.Duplicate = true; } } This is the most readable and straightforward code I could come up with for the task; it's also not particularly efficient, since it does at least twice as many comparisons as necessary (more if there are actually duplicate items)…

Ever heard of these things called "hashes" a.k.a. "dictionaries"? They are magical boxes for elements that are indexed by name. You build such a magical box of seen elements while going through the checking loop and you get the time complexity of O(n) or O(n log(n)) instead of your current O(n^2), so it won't explode when you get more elements passing through the code. Note that this was conceived in just a few minut…

First, a small correction: the if statement in my original code can actually be written as the following, which is what I had in the actual code:

    if (items.Count(item2 => item.Upc == item2.Upc) != 1)
With that correction out of the way, here's the code if I used a HashSet (you suggest 'a. k. a. "dictionaries"' but that is slower and I don't need the other half of the mapping which they would provide):

    var set = new HashSet();
    foreach (var item in items) {
        if (set.Contains(item.Upc)) {
            item.Duplicate = true;
        } else {
            set.Add(item.Upc);
        }
    }
To my eye, this is less readable; in addition to having twice as many lines and an extra variable, it also takes extra work to figure out what it does; whereas my version does exactly what it says: if the UPC appears more than once, it marks the item as a duplicate.

For a final comparison, here's an implementation of the extra loops and manual indexing I suggested:

    for (var i = 0; i 
This isn't significantly longer than the HashSet-based version, but it is even faster to run (I just benchmarked it) and also doesn't use an extra object which takes memory and needs to be managed and garbage-collected later.

In conclusion, while I appreciate your suggestion for a possible alternative implementation, I do not appreciate your impugning of my abilities with the suggestion that "something went wrong with your thought process", and implying that I may not be aware of basic data structures.

Re: How do I know if I'm good at programming?

#142
post #139

Earlier quoted context omitted.

Ever heard of these things called "hashes" a.k.a. "dictionaries"? They are magical boxes for elements that are indexed by name. You build such a magical box of seen elements while going through the checking loop and you get the time complexity of O(n) or O(n log(n)) instead of your current O(n^2), so it won't explode when you get more elements passing through the code. Note that this was conceived in just a few minut…

First, a small correction: the if statement in my original code can actually be written as the following, which is what I had in the actual code: if (items.Count(item2 => item.Upc == item2.Upc) != 1) With that correction out of the way, here's the code if I used a HashSet (you suggest 'a. k. a. "dictionaries"' but that is slower and I don't need the other half of the mapping which they would provide): var set = new H…

Dude, you're leaving O(n^2) landmines in your code and you're now justifying them by linecount and readability (actually more like familiarity with using sets and mappings). You have just proved my intuition about your abilities.

Not to menion that:

> you suggest 'a. k. a. "dictionaries"' but that is slower

In what way you think mappings are different in implementation than sets that makes them slower? They only need to carry one more pointer, and you're already writing in a language quite detached from bare metal.

One more thing, since you decided to "correct" yourself instead of letting the mistake slip: your "working" code is still wrong, unless something very weird happens in the data (but then calling it more readable this way is fundamentally wrong).

Re: How do I know if I'm good at programming?

#143
post #142

Earlier quoted context omitted.

First, a small correction: the if statement in my original code can actually be written as the following, which is what I had in the actual code: if (items.Count(item2 => item.Upc == item2.Upc) != 1) With that correction out of the way, here's the code if I used a HashSet (you suggest 'a. k. a. "dictionaries"' but that is slower and I don't need the other half of the mapping which they would provide): var set = new H…

Dude, you're leaving O(n^2) landmines in your code and you're now justifying them by linecount and readability (actually more like familiarity with using sets and mappings). You have just proved my intuition about your abilities. Not to menion that: > you suggest 'a. k. a. "dictionaries"' but that is slower In what way you think mappings are different in implementation than sets that makes them slower? They only need…

> Dude, you're leaving O(n^2) landmines in your code

O(n^2) I do not dispute. "Landmines," however, I take offense at: my naive implementation can still check 10,000 items in less than three seconds; should this ever become a bottleneck I assure you that I will adjust the implementation accordingly. Considering that hitting this number would require expanding the entire company at least tenfold, and knowing how other portions of the code work, I feel justified in saying that this is likely to be the least of their problems.

> you're now justifying them by linecount and readability (actually more like familiarity with using sets and mappings).

The entire point of this thread was justifying by readability, so yes, I am. I'm well familiar with sets and mappings, I just don't think that they're the best solution for this particular task.

> In what way you think mappings are different in implementation than sets that makes them slower?

I don't know the internal implementation details, but having just benchmarked it I can tell you that Dictionary is roughly 8% slower than HashSet for two otherwise identical implementations of this method.

> You have just proved my intuition about your abilities.

Likewise. From the preceding conversation, I conclude that you are inclined to prematurely optimize at the cost of maintainability and that you tend to look down on and make fun of anyone who you believe knows less about a topic than you, without taking the time to consider their point of view, or even basic politeness. You may not think that this description accurately depicts you; but then I don't think your opinion of me seems to be correct either.

Considering that I have now spent far more time than this code will ever run for arguing the point, I'm going to step away from this discussion now. I feel that I have made my point; increasingly heated argument seems unlikely to affect the outcome of the debate.

Re: How do I know if I'm good at programming?

#144
post #142

Earlier quoted context omitted.

Dude, you're leaving O(n^2) landmines in your code and you're now justifying them by linecount and readability (actually more like familiarity with using sets and mappings). You have just proved my intuition about your abilities. Not to menion that: > you suggest 'a. k. a. "dictionaries"' but that is slower In what way you think mappings are different in implementation than sets that makes them slower? They only need…

> Dude, you're leaving O(n^2) landmines in your code O(n^2) I do not dispute. "Landmines," however, I take offense at: my naive implementation can still check 10,000 items in less than three seconds; should this ever become a bottleneck I assure you that I will adjust the implementation accordingly. Considering that hitting this number would require expanding the entire company at least tenfold, and knowing how other…

> O(n^2) I do not dispute. "Landmines," however, I take offense at: my naive implementation can still check 10,000 items in less than three seconds

If you're satisfied that the loop you presented runs for a time comparable with three seconds for merely 10000 elements, it says plenty enough about your craft.

> [...] I can tell you that Dictionary is roughly 8% slower than HashSet for two otherwise identical implementations of this method.

Ah yes, benchmark comparing non-implementation (abstract class) with an implementation (concrete class).

> From the preceding conversation, I conclude that you are inclined to prematurely optimize at the cost of maintainability

No. I just tend not to leave behind ridiculous algorithms, especially when an acceptably efficient solution is of comparable code complexity.

> [...] You may not think that this description accurately depicts you; but then I don't think your opinion of me seems to be correct either.

Parts of it, yes, they do match. I'm an asshole that laughs openly whenever sees statements that look ridiculous made by somebody who considers themselves an expert (note that it doesn't matter whether they are or are not actually an expert). But then, it's not my code that takes three seconds to walk through ten thousands elements when -- as napkin calculations show -- it should take under a millisecond.

Re: How do I know if I'm good at programming?

#145

There are 2 types of “good” programmers, who both think the other type is useless. The first is the “rockstar” developer type who is great at prototyping, hitting deadlines no matter what and delivering functionality, albeit full of bugs. They will write 80% of the code and will drive the support team up the wall by breaking the build, causing customer issues in production, security holes and basically seriously degr…

While I appreciate you sharing, I have to say that I believe this is extremely non-representative of the industry. I've work on a lot of teams across the years and have seems different people with each of those individual qualities, but have never seen any common split of people into those two combinations. I feel this may be too specific to your personal experience / work history.

I second this, it's a nice story that programmers belong to one of these two categories, but I haven't seen it so black and white in practice.

Re: How do I know if I'm good at programming?

#146
post #91

>Identify the knowledge you lack and seek out the most relevant resource That can be difficult on the Web. When learning electronics searching the Web for help quickly showed how useless it is. There were many explanations but no teaching and often the explanation begun at a level too far past the level of the question asked. My guess is well over 95% of explanations I saw were just people posturing to show off their…

I really want to decipher this statement but I just can't wrap my head around it - > I know 2+2 = 4 but how do you know that how do I learn to know that! Did you miss some punctuation?

Poor analogy on my part I guess I wanted to use an example so simple it would be clear that seeing the result wasn't my goal knowing how to get to the result was what I wanted to know. Telling me the answer to a problem isn't helping me teaching me is helping me. The "give a man a fish he eats for a day but teach a man to fish he eats for life" philosophy.

Re: How do I know if I'm good at programming?

#147
post #34

Earlier quoted context omitted.

I don't know if I agree. I have friends that can smash out amazing code in very little time. Looking through some repositories of programs I like, some of them were prototyped in very little time, but with a surprisingly excellent first revision. I had the pleasure to work with Zed Shaw quite some time ago, and even though his code might not be perfect, he writes a lot better code than the vast majority, in a lot les…

This is interesting to hear. I thought Zed's book on C programming was reasonably good but I lost an awful lot of respect for him with his strange and nearly incomprehensible tirades against Python 3.

LOL. An account with these as the only comments and no submissions? Man this place is so weird. It's like you're at a party, and then some guy can scream at you from across the room while wearing a Richard Nixon mask and everyone goes "Oh yeah that is true." Never questioning why the guy is wearing a mask at a party.

Anyway, I think you need to look up the words "tirade" and "incomprehensible"

Re: How do I know if I'm good at programming?

#148

There are 2 types of “good” programmers, who both think the other type is useless. The first is the “rockstar” developer type who is great at prototyping, hitting deadlines no matter what and delivering functionality, albeit full of bugs. They will write 80% of the code and will drive the support team up the wall by breaking the build, causing customer issues in production, security holes and basically seriously degr…

I don't know if I agree. I have friends that can smash out amazing code in very little time. Looking through some repositories of programs I like, some of them were prototyped in very little time, but with a surprisingly excellent first revision. I had the pleasure to work with Zed Shaw quite some time ago, and even though his code might not be perfect, he writes a lot better code than the vast majority, in a lot les…

Someone linked me here asking me how I can write good quality code so fast so I thought I would come and drop a comment just in case other people read this and fall prey to the "HN must be true" virus.

I have no idea if I write code better or faster than other people. Maybe I do, but I always think that I don't write very good code most of the time so I have to be extra careful. I spent a lot of time writing code very slowly and being extra careful so that I could make sure it's good quality. I guess after focusing on quality for so long I just got faster at it compared to others. But, I'm going to guess that I actually am not much faster than other people.

Re: How do I know if I'm good at programming?

#150
hey guys I was introduced to emrysghosthacker@gmail.com because i really wanted to know what my husband has been up to lately as I seem not to be getting his attention. Emrys was able to hack into my husband’s Facebook, Snapchat, WhatsApp, Instagram and above all gave me full access to his mobile phone and emails without touching the phone. I couldn't help but to introduce him to those who have their spouse cheating on them and want to spy on them. contact emrysghosthacker@gmail.com or wechat at emryshelp he will help you out with any hacking related issues, tell him rhonda referred you..thank me later.you can also contact him-+14088189369
Post reply on HN