News for hackers. Stuff that matters.
Re:How to seem good at everything: Stop doing stupid shit by Periodic on Thursday August 04, 2011 @07:34PM (#2848267)
I see a lot of people do stupid shit because they don't seem to think it will make a big difference. One mistake isn't a big deal, is it? The problem is that it becomes habit, and then you're making plenty of these, and you think it's okay, but in reality a lot of these mistakes have become normal.

I think the most profound thing about the post was that it showed a striking difference between determined practice and directed practice. Just being determined and putting in the hours will _not_ be sufficient to pass a plateau of learning. Sometimes you need _directed_ learning to push you past that plateau.

Applying that to code, I think this is the difference between just programming a lot and thinking you'll get better, and actually reading texts, reading code and talking to other programmers to see how other people do things better.

For example, you can start using more anonymous functions in your code because all the cool kids are doing it, but unless you really understand how to deal with high-order functions and what a map and fold are, you are just going to be doing stupid shit that doesn't really help your code at all.

Re:How to seem good at everything: Stop doing stupid shit by nostrademons on Friday August 05, 2011 @05:00AM (#2849448)
Simply using map and folds instead of for-loops is just more stupid shit that doesn't really help your code at all. It's not really any shorter or less bug-prone, and it makes your code harder to follow for people who don't understand map & fold.

The real benefit comes from when you understand the concepts behind map and fold. If you realize that fold is nothing but replacing each n-ary constructor of an algebraic data type with an n-ary function, then you recognize that you can do the same thing for data structures besides sequences, like binary trees, graphs, and ASTs. There you're getting some benefit, because there's no built-in language syntax for iterating over those.

  data List a = a : [a] | []
  [1, 2, 3, 4] = (1 : (2 : (3 : (4 : []))))
  foldr :: (a -> b -> b) -> b -> [a] -> b
  foldr (+) 0 [1, 2, 3, 4] = (1 + (2 + (3 + (4 + 0))))
  foldr (*) 1 [1, 2, 3, 4] = (1 * (2 * (3 * (4 * 1))))

  ...by extension ...
  data Tree a = Leaf a | Branch (Tree a) (Tree a)
  foldTree :: (a -> b) -> (b -> b -> b) -> Tree a -> b
  foldTree f g (Leaf x) = f x
  foldTree f g (Branch x y) = g (foldTree f g x) (foldTree (f g y)
Then you recognize that the GoF calls this the Visitor pattern, because certain stupid languages don't have higher-order functions or algebraic data types, and so you need to make the equivalencies between concrete subclass => ADT constructor, Visitor => function, and object state => return value. Suddenly a lot of modularized compiler libraries (eg. LLVM) make a lot more sense.

Then you realize that a map is nothing but a list-fold where the binary operation is constrained to be the composition of some arbitrary function of the element together with a cons operator:

  map :: (a -> b) -> [a] -> [b]
  map f = foldr ((:) . f) []
The cool thing about this formalism is that it makes it explicit that f depends only upon the single element of the sequence, and that the ordering of the resulting list is independent of the actions of f. In other words, map can be parallelized. And that lays the groundwork for MapReduce, which lays the groundwork for massive-scale parallel data processing.
Re:How to seem good at everything: Stop doing stupid shit by Radim on Friday August 05, 2011 @05:51AM (#2849546)
What lays the groundwork any massive-scale parallel data processing is a lot of good engineering, being aware of the common execution scenarios and relations to the environment (incl. HW). Plus tinkering with little devilish "details".

Pretty much the opposite of the (true but trivial) concept that ordering of the result is independent of the map function.

TL;DR What you wrote at the end sounded a bit analogous to saying startups succeed because of their idea, while they succeed for a number of things -- mostly the execution and how much other people like the idea in the real world.

Re:How to seem good at everything: Stop doing stupid shit by nostrademons on Friday August 05, 2011 @06:10AM (#2849585)
Well, any real-world engineering problem is going to have a lot success factors, far more than can be enumerated in a post on an Internet message board.

The general point is that you aren't going to succeed unless you understand those building blocks in enough detail that you can take them apart and put them back together again in new ways. Map & reduce are concepts from functional programming, usually explained in Scheme or Haskell. MapReduce is a C++ framework. To go from one to another, you not only need to understand the nitty-gritty engineering details, but you also need to understand the fundamental computing concepts well enough to translate them into languages and use-cases that they weren't originally intended for.

(Side note: the MapReduce framework actually bears less resemblance to map & reduce than most people think. The "map" phase is a combination map & unfold, because you're not only iterating over the input, but you can output multiple times for a given input element. Think of running a word count over web pages: you have to parse the page and output multiple words per page. And the "reduce" phase is only a reduce within keys: it's really a map between keys, because the output is required to have the same keys as the input to the phase. I've often wished for a separate "re-key" phase, where the values output from the reduce phase could be reshuffled under a different key.)

Re:How to seem good at everything: Stop doing stupid shit by Radim on Friday August 05, 2011 @08:28AM (#2849832)
I don't like the preachy tone but I like the way you disassembled your own argument in the side note there :-)

To avoid misunderstanding, I'm a fan of functional programming too. But the intersection of the MapReduce framework and map&reduce of Scheme and Haskell is mostly in the name and in some core math concepts that are ageless (predate programming and lambda calculus).

Re:How to seem good at everything: Stop doing stupid shit by gwern on Thursday August 04, 2011 @10:11PM (#2848700)
> I think the most profound thing about the post was that it showed a striking difference between determined practice and directed practice. Just being determined and putting in the hours will _not_ be sufficient to pass a plateau of learning. Sometimes you need _directed_ learning to push you past that plateau.

This is exactly right. Ericsson and the related expertise psychology literature calls your directed learning 'deliberate practice'. Have you read the _Cambridge Handbook_ or his 1993 paper http://www.gwern.net/docs/1993-ericsson-deliberatepractice.p... ?

Re:How to seem good at everything: Stop doing stupid shit by joe_the_user on Thursday August 04, 2011 @09:48PM (#2848639)
Applying that to code, I think this is the difference between just programming a lot and thinking you'll get better, and actually reading texts, reading code and talking to other programmers to see how other people do things better.

I don't think this follows from the article. "Not doing stupid shit" in the article's term is getting better at the basics. When you're describing is directed study but I can't see how it is directed at "the basics of programming", which would have to be something not off-by-one, not using objects before their initialized or whatever is "really simple".

The problem of overcoming bad habits is a really tough one.

In a performance-based skill like Chess or music, you can drill simple stuff to make them perfect. It's hard to see a simple equivalent in programming.

I'm also not sure if there is an equivalent to perfection in programming. All the things that slow me down do look "stupid" on some level but they're stupidity of different levels, from design to variable name to the creation of functions to understanding and avoiding syntax errors.

If there is an awareness drill to educate oneself against bad programming habits, I'd love to find it.

Re:How to seem good at everything: Stop doing stupid shit by andrewflnr on Friday August 05, 2011 @12:01AM (#2848918)
Regarding performance tests: maybe just try to write code that works the first time, see how big a chunk of code you can write at once and still have it work the first time. And when it doesn't work, don't just fix it, analyze what happened and learn from it specifically to avoid making similar mistakes in the future. You'll acquire (I'm guessing) a list of things to avoid that eventually become good habits, enabling you to get stuff done faster and concentrate on more important things. I guess it's mainly a matter of avoiding the avoidable mistakes.

Not that I've done this. I should.

Re:How to seem good at everything: Stop doing stupid shit by jacques_chester on Friday August 05, 2011 @01:19AM (#2849037)
You've described, very roughly, the basis of the SEI's "Personal Software Process". Keep records of your errors, study what you do wrong, change your personal process to drive them out, repeat.
Re:How to seem good at everything: Stop doing stupid shit by wisty on Friday August 05, 2011 @06:52AM (#2849671)
Have a look at the Joel test. It's outdated, and might be a little controversial, but it's it list of ways to fix "stupid shit".

I don't have a copy of "Code Complete", but from what I've heard it's a similar deal. XP arguably eliminates a lot of stupid shit, but arguably introduces a lot of stupid shit at the same time (as do many dogmatic processes).

While "best practice" lists are always going to be controversial (in both programming and music, but not chess), they do have a lot of value if you don't overuse them, and take them with a grain of salt.

Re:How to seem good at everything: Stop doing stupid shit by joe_the_user on Friday August 05, 2011 @03:55PM (#2851462)
I think you're also missing idea of "fundamentals" as essential thing that article means by "stupid shit" - fundamentals meaning habits and not just instructions.

Not all "bad stuff" is "stupid shit" in this approach. The "joel test" really doesn't relate.

Just about all Chess players know to avoid hanging pieces - the article described going from there to making that understanding habitual. Essentially, the article, if it was consistent, would be looking for some equivalent to musical scales that a software engineer could do practice before actually programming. It is not a matter of knowing best practices but a way of systematically developing the habits to put them into practice.

It is the difference someone telling you not to make a mistake and going over and over doing things to actually get in the habit of not making mistakes... A person can learn theoretically how to play music in a week and if producing keystrokes at the proper time didn't matter, people wouldn't spend more than a week learning the skill. As it is, a lot more practice is required.

But really, I'm pretty sure there isn't a software equivalent of musical scale because software isn't as specific a skill as reading or performing music. Software involves a large variety of logical skills which most adults already have to some degree. It is so complicated on some levels that mistakes are sort-of inevitable on other levels.

Re:How to seem good at everything: Stop doing stupid shit by r00fus on Friday August 05, 2011 @01:41PM (#2850917)
Totally agreed.

It's very interesting to get ahold of a "best practice" book or an organization's SOP manual just to see what battle-tested advice is given for various situations... you may disagree but they embody wisdom. At the very least you can find out where they're coming from.

Re:How to seem good at everything: Stop doing stupid shit by pmiller2 on Friday August 05, 2011 @01:47PM (#2850953)
The Joel Test isn't really intended for individuals, though. It's more of a "how to fix stupid shit" on an institutional level. I think what people are looking for here are ways to fix stupid shit on an individual level.
Re:How to seem good at everything: Stop doing stupid shit by zumda on Friday August 05, 2011 @03:53AM (#2849337)
I think there is a simple equivalent in programming. A lot of programmers I know can rattle of the benefits of 3 or more frameworks. They can program in half a dozen programing languages. But they couldn't tell you the basics.

They couldn't say what the difference between functional and object-oriented programing is. They couldn't tell you what a good name for a variable is (maybe they have somewhat good variable names, but they don't really know why they are good or bad). They couldn't properly define an architecture for a new project.

There are basics in programing that should be known before all the programing languages, frameworks and what not. And I think from time to time everyone should try to learn more about the basics instead of a new language. From time to time think really hard why this variable should be called that. Why we need a new package for that. Why is a method built the way it is.

Re:How to seem good at everything: Stop doing stupid shit by joelhooks on Friday August 05, 2011 @02:04AM (#2849134)
The concept of code katas approaches this to some extent. http://en.m.wikipedia.org/wiki/Kata_(programming)
Re:How to seem good at everything: Stop doing stupid shit by nickknw on Saturday August 06, 2011 @12:34PM (#2854241)
Programming Praxis[1] is a site that has been constantly updated with these kind of exercises.

[1] - http://programmingpraxis.com/

Re:How to seem good at everything: Stop doing stupid shit by djm on Friday August 05, 2011 @05:28AM (#2849512)
See also the 'design recipe' approach advocated in books like 'how to design programs'.
Re:How to seem good at everything: Stop doing stupid shit by jinfiesto on Friday August 05, 2011 @03:11AM (#2849266)
I work through SICP every year. It seems to ward against bad programming habits on most levels.
Re:How to seem good at everything: Stop doing stupid shit by lutorm on Friday August 05, 2011 @09:24AM (#2849981)
Wow, that's impressive. It seems a new category is needed in the poll at http://news.ycombinator.com/item?id=2846799
Re:How to seem good at everything: Stop doing stupid shit by jinfiesto on Friday August 05, 2011 @01:22PM (#2850836)
Hmm, It seems so on the surface. I'm on my third trip through, and it's going to take me less than a month and a half. It really gets substantially easier once you "grok" it. The first time is AWFUL though. This isn't to say of course that I don't get very much out of subsequent readings. SICP is very deep. It's just after a first reading (and doing all the exercises) you're free to focus on concepts more than "tactics."
Re:How to seem good at everything: Stop doing stupid shit by watmough on Thursday August 04, 2011 @07:58PM (#2848344)
|Sometimes you need _directed_ learning to push you past that plateau.

That and practice. My chess improved noticeable with timed play. Putting a time limit on a game forces you to do 'something', if only to stop losing. In my case, this forced me to eventually develop a strategy and focus my game on actually attacking particular areas of the board. This really improved my game.

Re:How to seem good at everything: Stop doing stupid shit by doctoboggan on Thursday August 04, 2011 @09:40PM (#2848621)
On a side note, I just watched Crockford on Javascript and he said lambda functions are the greatest innovation in computer science. Could you point me toward a resource that will explain why?
Re:How to seem good at everything: Stop doing stupid shit by nandemo on Friday August 05, 2011 @12:21AM (#2848942)
Does he really call it an "innovation"? It would be more precise to say that the lambda function is a essential concept in computer science. Lambda functions -- which is just another name for anonymous functions -- are a basic element of lambda calculus, which is one of the foundations of computer science (predating electronic computers).

In more practical terms, you need lambdas to have closures, currying and higher-order functions in general. Without that you don't have Lisp, ML, Haskell, etc.

http://en.wikipedia.org/wiki/Anonymous_function

Re:How to seem good at everything: Stop doing stupid shit by shadowfox on Thursday August 04, 2011 @09:55PM (#2848653)
I am sure there are better reads. But I found this one a decent back when I read it: http://www.cs.utexas.edu/~shmat/courses/cs345/whyfp.pdf

A lot of what that particular paper talks about is applicable to other languages that have lambda expressions in them.

Some of the examples in it does rely on lazy evaluation though. Laziness is usually encodable in most languages with lambdas. But most aren't lazy by default. Keep that in mind.

Re:How to seem good at everything: Stop doing stupid shit by jemfinch on Thursday August 04, 2011 @09:57PM (#2848657)
Search for (several) "Lambda the ultimate" papers.
Re:How to seem good at everything: Stop doing stupid shit by djm on Friday August 05, 2011 @05:30AM (#2849516)
Re:How to seem good at everything: Stop doing stupid shit by Produce on Friday August 05, 2011 @08:48AM (#2849877)
In regard to what you said about determined and directed practice, it's essentially a case of it being more about the quality, not quantity of time spent on something. I realised this a number of years ago and have been utilising it ever since. Most people tend to keep going down one particular route when they're trying to achieve something and, when they hit a roadblock, they keep pushing forward. This is working harder. The alternative is to go in a completely different direction where, rather counter-intuitively, we have a chance of picking up information/experience which will get rid of the previously encountered road block. This is working smarter. If something seems too difficult, it probably is, and the reason for that is that one is missing key pieces. Doing the same thing will not find these pieces but looking in non-obvious places will (since if it was obvious, it wouldn't be difficult in the first place).

I think that the mechanics behind this consist of what is basically, to borrow a term from comp sci, an impedance mismatch between our internal maps of the world and the shared maps we call physics or math or piano technique. We tend to organise things in a particular way so that we can communicate about them with each other but this shared set of symbols is never the same as an individuals' internal representation. I think that the reason all internal maps are different is because the subject (the human) is an integral part of them. In other words, one's understanding of gravity will have shared symbolism with completely subjective experiences that have nothing to do with gravity. The process of learning is essentially a mapping of one set of symbols to another. More accurately, there seem to be three levels, the experience itself, the internal symbols relating to the experience and the external shared symbols we use to communicate with each other. Based on this, I think that the categorisations in the shared map rarely make sense internally and that, as a layman, following the lines drawn by the categorisations doesn't make sense, hence the roadblocks that people encounter.

To put it another way, the categorisations we have in our shared knowledge are primarily for communication purposes and are, objectively speaking, irrational. Separating math from physics from music does not make sense in real terms since they are different perspectives on the same system. Or, to put it yet another way, the map is not the territory and those who understand that are much more adept at navigating with maps.

Re:How to seem good at everything: Stop doing stupid shit by lepacheco on Friday August 05, 2011 @12:59PM (#2850744)
People do stupid shit because most of the time they don't know "what" is the stupid shit in whatever they are doing. It is hard and only looks easy on hindsight. This is the part were a mentor or good teacher can make a HUGE difference.