Hacker News new | past | comments | ask | show | jobs | submit login
"Algorithm" is not a four letter word (jamisbuck.org)
443 points by jashkenas on Sept 29, 2011 | hide | past | favorite | 65 comments



I'd like point out something that isn't mentioned in the slides at all. The ideas behind the algorithm are not just games, not just exercises, not just methods of self improvement. I'm reminded of Feynman's story of the wobbling plate. They have very deep implications for how we design programs and how we design programming languages.

The notion of search (logic programming, constraint solving) is a woefully under appreciated topic - I would argue because our programming languages make it very difficult to apply this kind of beautiful knowledge back onto the programming language itself.

What is a type system if not a kind of maze solver? What happens when you apply machine learning like heuristics to a pattern match compiler? What happens if we can apply algorithm rules at the level of the method signature?

Yes learn some algorithms, then question why our programming languages limit how much we can put these great ideas into practice.


"The ideas behind the algorithm are not just games"

Clarifying, sorry.. could you elaborate a bit on what you meant by "games"?


"Stuff that doesn't matter beyond the novelty of screwing around with it"


There's some good stuff here, but a lot of the psychology is ill-founded. Flow, for example, is probably the most effective form of practice, and play often creates flow. Jamis recommends practicing constantly, but it's extremely well established that spacing your practice out gives you more bang for the buck, more improvement per hour of practice. (This is called "massed practice vs. spaced practice", and it's been known since before the dawn of cognitive psychology.)

(There's some pretty good evidence that you can fill the spaces in between your practice sessions by practicing something else — without losing the benefit of spacing.)

The maze generation algorithms, though, are awesome.

My favorite is still this one by Joe Allen:

    /*  jallen@ic.sunysb.edu  */     /* Amazing */     /* Joe Allen 129.49.12.74 */
    int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
    +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
    ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}


I definitely was not recommending constant practice--I agree that doing so will hurt you more than it helps you! I was recommending consistently regular practice.


"play is not exercise" Is this true? ...I have always thought I've learned more "playing" with programming than when programming to produce a specific output... Or perhaps... I've forgotten the last time I've done something hard.


That's a neat generator, but it occasionally generates almost entirely-blocked mazes. The density is impressive, but at that point you might as well just start reading IOCCC entries.


I don't know if he ever submitted it to the IOCCC. It would have been a good entry, though!


I like the visualizations for the maze generation a lot.

I actually used (yet another) maze generation algorithm for an xbox360 game I worked on as a school project. The constraints were slightly different because we wanted cycles and no dead ends.

You put all the cells in a list and take them out at random. If there are 3 or more walls, tear down walls until there are less than 3. When you are done you cannot have any dead ends because a dead end must have three walls. Of course you can have unconnected loops, so you have to go through and tear down walls to connect unconnected segments when you are done.

I don't know what my point is.

Mazes are neat.


Sounds like you did something similar to what I did a few years ago. During lunch I ran a Quake server and every five minutes it would generate a new random level (random layout, goals, weapons, lighting etc). Cycles and no dead ends are one way to improve the quality of the deathmatch levels and a toggle that I added the first day to the generator.


A point P is inside triangle ABC iif the angles add up to 2pi. (APB + BPC + CPA == 2pi)

Thought I'd share too, don't have a point. :) graphics programming / dot product is neat.

Actually, there are some pretty fun graphics algorithms. I could ramble on about some, but don't want to intrude / doubt anyone cares but me, heh.


You've got a 'carer' right here. I'd love to read more on 'traditional' algorithms applied on CG.


Another warning, for photosensitive epileptics: there are rapidly flashing lights in that demo. I have a mild form of it and I started to feel weird, so if you're highly sensitive, you'll want to skip running the maze on the slide labeled "aldous-broder-demo".

Here's a tip for UX people: don't make anything flash more than 2 times per second. Also, "in the United States, websites provided by federal agencies are governed by section 508 of the Rehabilitation Act. The Act says that pages shall be designed to avoid causing the screen to flicker with a frequency greater than 2 Hz and less than 55 Hz." So that's the official recommendation.


How would you recommend visualizing that algorithm?


Visualizing algorithms is unfair, because some people were born without vision and therefore cannot "visualize".


The problem isn't that it is unfair to people who suffer of epilepsy, the problem is that it could be DANGEROUS to people who suffer of epilepsy. Someone who is blind can't be harmed by being unable to see this particular visualization.


If it's so DANGEROUS why isn't there some kind of active display filter available to dampen temporal frequencies between 2 and 55Hz?

That, and--though it wouldn't have helped in this case--the most I heard about epilepsy complaints is on forums with flashy animated GIF images. Why do they browse with GIF animation enabled? Really, if it's such a health hazard, and images posted on a forum can give you dangerous seizures, why would you take a risk and trust on the goodwill of the community and take your chances with the occasional troll?

I don't want to dismiss the problem, not at all, I just wonder about the victim mentality displayed and lack of proactiveness.

Especially the display filter. If it's an actual health hazard, you shouldn't be asking people not to show flashing imagery on their sites, you should be taking action yourself, making sure your computer display is unable to display this imagery. Any kind of modern 3D GFX card should easily be able to detect flashing areas and dampen and/or motion blur them so they're safe, without much processing power needed. You'll be erring on the side of caution of course, so some video content might be degraded (though with a well-designed filter this should be minimal) so you'll want a key-combo to (at your own risk) temporarily disable the filter (with a parental lock for the children, of course).


Yeah, it would be great if everyone who had epilepsy was up to hacking their video card driver to simulate an e-ink display's slow updates. I'm interested to hear what modifications you've made to your own system software to make it suit your preferences.


Except that it's not even that. In firefox there is just a setting that disables animating gifs, if this is something that is affecting a significant number of people at any significant level of danger, then why don't people disable it?

It seems to me that the most likely explanation is that the risk is so minimal that people with epilepsy aren't even willing to give up lolcat gifs for it, though it is possible that people are unable to conceive of a setting existing to disable a largely unnecessary feature in a piece of software.

If it is a significant danger, and people don't realize you can disable it, then that seems to indicate a significant failing of the entire system, from doctors to parents to people taking care of themselves properly. I really want to believe that it isn't the case.


Why the downvotes? Though the comment is snarky, it's simply saying not everything can be made accessible to everyone.

The visualization of maze generation in the presentation is pretty neat, and is meant to demonstrate the running algorithm. The author isn't making it inaccessible on purpose, he can't possibly know about all the accessibility guidelines, and even if he does, there is content which can't meet all the guidelines.


It's probably reasonable for Jamis to put an epilepsy warning on it (particularly since it doesn't run until you click "run"). But I wasn't asking a rhetorical question. I wanted to know if the epileptic poster had a good idea for how to visualize that particular algorithm without flashing lights.


"Play" is boring if it isn't challenging. I completely disagree with the dichotomy presented at the start of this presentation. It seems to imply that improving is painful, and is something you need to force yourself to do.

(Furthermore, I've never found learning about new algorithms to be taxing, and certainly never regarded it as a four-letter word.)


My intent was definitely not to portray learning as painful. Learning is a joyful thing. But it's not something you can acquire by passively staring at the world. You need to exert yourself if you want to do more than gain a passing acquaintance with things.


Yes; but playing is not passively staring at the world, nor does it involve a lack of exertion, nor yet again lack of a "passing acquaintance". The point of play is that you can exert yourself without having much hard work of willing it. A child with a new toy is highly engrossed, focused, and certainly not passive nor satisfied with a "passing acquaintance".

I guess I reacted to the screwed-up faces in particular; they looked like they were in pain.


Our problem here is the overloaded nature of the word "play". I do not disagree that children learn through play. But I'm using the word differently in my presentation: I'm using it to refer to activities that you (as an adult) pursue casually, as a way to relax or enjoy yourself. If you play the guitar very well, for instance, you might take an hour in the evening to just "play", singing along, etc. This serves many purposes, and is definitely valuable, well-spent time, but it does not serve to improve your guitar playing. To accomplish that, you'd need to spend some time working on guitar techniques that you are less accomplished at.

You can see my problem, hopefully. Ambiguity in language has been the downfall of more than one well-intentioned presenter!


You have overloaded play in a very specific way in your response; playing an instrument. I'd have preferred it if you'd chosen something else, because I think it introduces a third meaning for play (specific to instruments) apart from both the focused play like that of a child and something an adult pursues casually (which I doubt should be called play).

My hobby (as well as my only form of transport) is motorbikes. I do it for over an hour every day. I'm definitely getting better at it, because of an iterative process of analysis and experimentation. If I just looked at it as a means of transport, I wouldn't be so eager to stretch myself; I'd be content with getting from A to B in a safe and not very efficient manner.

It's completely different to programming, so in some ways it is relaxing; it's certainly highly enjoyable; but it is also simultaneously energizing and tiring. It uses a completely different part of my brain, and gets the adrenaline going.

I think if guitar-playing was my hobby, I'd be focused on improving and having an iterative experimentation / analysis cycle. But if guitar-playing was something I did to make music, perhaps to entertain other people, then the focus is elsewhere. It would no longer be play; it would merely be doing.

What I'm getting at is that play (my definition of it, at least) necessarily implies stretch goals, doing things that you have room to improve at, because without challenge it's boring. What makes it different from work is intrinsic motivation, and hence the lack of a need for application of will.

But you're right in another respect, this is all coming down to a disagreement over the use of words, rather than a disagreement in concepts etc. The start of the presentation just rubbed me the wrong way, and I've made far too much out of this small thing...


Agreed. Children and young animals play because they learn from it. This is why evolution has programmed them to enjoy it. Play=self-improvement.


Personally I really enjoyed the short slide by slide format a lot. Perhaps it's a short attention span brought on by years in front of a computer, but I struggle with massive walls of text occasionally. At the very least I found it to be a nice changed on top of being an interesting subject.


Ironically, I lost interest in this at some point because of the slide format. With a wall of text, I can figure out how long it is and whether I want to dedicate the time to read it. These cute arrow-key slides were giving me no feedback how many there are and whether it's going to take half an hour to go through them all, so I closed them. Heh.


There's #read/#total in the lower-right corner, fwiw. :)


I didn't notice, but apparently I was right to abandon it!


I was hoping someone had a text version. This form is like a video: I could read all of that in about 30 seconds, probably, versus clicking through for one sentence at a time over 10 minutes. I don't need 40 drawings of smiley faces to understand this.


acquainting yourself with theory is acquainting yourself with new concepts. It gives you building blocks and labels that you can build on, and hang later concepts on. Without the scaffolding that theory gives you, you'll miss many opportunities for insight later.

So very true. The difference between the me one year back and the me now is that I know how and why certain things are the way they are. Understanding is enlightening.

Ultimately, it is that resistance you need to seek out. Look for things that will challenge you consistely (sic). Work at them until the resistance goes away, and then look for something new. That's how you'll grow your craft. That's what will make you better than you are today.

Amen.


I feel I should point out that a lot of people would consider this bad advice.

"It is critical to remember that play is not exercise."

Focusing on what are you're good at (like algorithms for creating mazes), is in fact exercise. You're getting better at what you already consider yourself good at (assuming you don't stagnate - which I think the article is really getting at.)

Should you focus on weaknesses or strengths is a big debate, but strength finder (http://strengths.gallup.com/110440/About-StrengthsFinder-2.a...) seems like a popular camp.


The problem is that you are arguing the analogy. What you are saying neither fits the point or spirit of his slide show.


I am just pointing out that the start of the slideshow is a little unnecessary and potentially off-putting, I quite enjoyed the concise diagrams and animations which followed.

I think those with a CS degree and a good understanding of graph theory should still sit and enjoy it!


I don't think you need a CS degree to enjoy this. I'm a CS student, and I did. :)


For the curious, here's a link to Jamis' repository of Maze visualizations, implemented in CoffeeScript: https://github.com/jamis/csmazes


Pretty. But I would love just a long single page version of it, particularly when it gets to definitions. The page already loads all the content and assets at the start.


Try disabling Javascript, it fallbacks to a single page version; at least it does here with NoScript.


For text only, in console:

    $('body').html($('aside').map(function(x,y){return $('<p>'+y.innerHTML+'</p>')[0];}));


Warning: severe pollution of "history" links in your browser ahead.


I don't understand how this is considered pollution.

How is this different from having a separate page per slide? It seems we have the same result but with a better user experience. Isn't this a feature allowing each slide to be linkable? Why is this considered negative?


Nice presentation, but Chrome 14 was using half a gig of RAM by the end. Seemed to use 4mb per slide.


Worked fine for me on Chromuum.


http://ompldr.org/vYWw2MQ

Looks like this over here.


No apparently history pollution in Opera 11.51 either.


Ctrl+H


Depending on the browser there is no problem, as in some browsers it is completely impossible to navigate to the next slide at all. When exactly did accessibility and standards conformance become unfashionable round here?


The articles on his blog (http://weblog.jamisbuck.org/) give more in-depth explanations for those who dislike the slides.


This site crashes my iPad's browser. iOS 5.0 beta 7. Anyone else?


Wonderful slides! I hope there will be video further on.

I didn't like "It is critical to remember that play is not exercise." and to improve it I would like to add something like "But it's totally fine if your exercise feels like play. If your exercise is fun it's so much easier to do".


I'd like to point out that on the first frame with text on it, the text runs off the screen. So i closed it. I don't even know what the slideshow was about :( firefox 7.0.1 resolution 1280x1024

no text at all in 1024x768


Yep. Scaling doesn't work in firefox. It does work in chrome though.


This is remarkable. The # of ways to solve the same problem is great (ironically, I knew mostly Prim's and Kruskal's algorithms because they are more common), the visualization is great too. I liked the slide format, a bit too long maybe.

Also, since it's a computer science post :) I would have added time complexity, just for sake of completeness.

A big plus to the whole concept of "code kata".

Great stuff.


I think the author did a great job and took quite some time to share his knowledge with us. Pity the average response on HN tends to be a compliment followed by a but.... I guess we feel we are always smarter than the next guy, he just happens to put in the effort :-)

Well done, loved it all the way!


Nice, but my browser (Firefox 6.0.2) hung up for a few moments on the last slide and it took me painfully long to close the tab.


This is a nice presentation! Apart from the excellent content, what did you use to produce the html slides?


The slides presentation was built on top of deck.js (http://imakewebthings.github.com/deck.js/).


Love the presentation! Can someone point me to similar presentations/resources on same topic?


You know what they say...

You have a problem, so you suggest "I'll make an algorithm to solve it!"

...now you have 2 problems.


> This set of potential spanning trees is called a spanning forest.

A spanning forest is a graph, not a set.

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


If you insist on being pedantic, you can compose a set of spanning trees into a spanning forest, which is a graph.


slightly off-topic but an inconvenient of this medium of presentation is that printing fails horribly.


Algorithms for brogrammers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: