static void wake_up_dreamer(struct dreamer_attr *dattr, int level)
February 22, 2011 8:44 PM   Subscribe

 
Oh, that's very clever. I don't necessarily agree with the programmer's interpretation of the ending, but that's an ingenious way to pay tribute to an excellent film.
posted by OverlappingElvis at 8:55 PM on February 22, 2011


It's 2011, and he's still using #defines rather than const ints?

Yeah, he does need to wake up. const was added to C90 -- the standard previous to the current C99.
posted by orthogonality at 8:56 PM on February 22, 2011 [3 favorites]


....
posted by delmoi at 9:06 PM on February 22, 2011 [6 favorites]


I thought this was going to be BRAAAAAAP played in a different key.
posted by The Winsome Parker Lewis at 9:06 PM on February 22, 2011 [37 favorites]


can someone explain what this looks like? I don't have C installed.
posted by spacediver at 9:07 PM on February 22, 2011


Holy shit. I haven't read code like that since the early '90s. Say what you will about Java, at least most Java apps don't end up looking like kernel code.
posted by GuyZero at 9:08 PM on February 22, 2011 [3 favorites]


I think the idea is to make threads 'sleep' and 'dream' and keep everything synchronized on the computer. In other words it makes the computer behave as if they were the characters in the movie, going through the stages of sleep and so on. Or something like that.
posted by delmoi at 9:09 PM on February 22, 2011


It's 2011, and he's still using #defines rather than const ints?


The only True C is K&R C, 1978 of course.
posted by spasm at 9:09 PM on February 22, 2011 [3 favorites]


Could someone explain the joke for a poor, poor English major?
posted by Rinku at 9:10 PM on February 22, 2011


My Google search for "recursion" keeps asking if I meant "recursion".
posted by twoleftfeet at 9:10 PM on February 22, 2011 [47 favorites]


You want me to download code from the Internet? The only way I'm going to do that is if you ensure me that it includes naked pictures of Marion Cotillard.

Wait, wait, nevermind. Found some already. But WTF, my machine is infected with spyware? No way! OK, fine, I'll buy your malware remover...
posted by Cool Papa Bell at 9:13 PM on February 22, 2011


I think he should have written it in some other language rather than C... most of the code is really support that doesn't help "tell" the story (statically that is, it helps the program print out the right sequence of events when run). As a result when you read the code you don't immediately see the structure of the movie. Maybe some language where you could use operator overloading, types, structures, or objects to make a sort of DSL for the top level where the movie's structure is defined?
posted by destrius at 9:14 PM on February 22, 2011


I for one will go out on a limb and say Ruby is actually less readable than C, scaffolding code be damned.
posted by GuyZero at 9:16 PM on February 22, 2011 [3 favorites]


A. It's safe. Just ran it. B. Even if you don't run it, this is brilliant stuff. It basically simulates the mental state of each dreamer, goes through events and triggers with possible outcomes, and cues it up so the outcome is as the movie. The sneaky bit though, is that it also dickers with x86 opcodes while running so the ultimate incepted 'thought' appears to the computer to have come from the Fischer construct. Sneaky.

Basically, this is a giant programming joke.
posted by CrystalDave at 9:16 PM on February 22, 2011 [5 favorites]


I posted this back in the original Inception thread back in July. But that thread was a beast and this is a great concept, so it's worth FPPing.
posted by painquale at 9:17 PM on February 22, 2011


Everyone seems to think Inception is all crazy convoluted but unless I’m missing something it’s all simple nesting. I mean, I liked the movie but it’s hardly on the level of Primer. Enlighten me?
posted by El Mariachi at 9:19 PM on February 22, 2011 [9 favorites]


Could someone explain the joke for a poor, poor English major?

It's the source code to a computer program that acts out the dream activity in the movie using the logic of the program. It uses the C programming language to set up the structures, conditions & tests for entering & exiting each level of the dream for each character in the movie.
posted by scalefree at 9:21 PM on February 22, 2011


Winception (via)
posted by Rhaomi at 9:27 PM on February 22, 2011 [6 favorites]


The only True C is K&R C

Hallowed be thy namespace.
posted by cortex at 9:30 PM on February 22, 2011 [2 favorites]


Ah, C.
__underscore_underscore__
posted by Civil_Disobedient at 9:30 PM on February 22, 2011


libdispatch version:
Information *yusuf()
{
   return arthur();
}

Motive *arthur()
{
   return eames();
}

Idea *eames()
{
   dispatch_async(limbo, cobb);
   return idea;
}
posted by Mikey-San at 9:31 PM on February 22, 2011


10 PRINT "SLEEP"
20 GOTO 10
posted by blue_beetle at 9:35 PM on February 22, 2011 [4 favorites]


Also, I should totally run the clang static analyzer on this. But I better bring a token in case it goes too deep.
posted by Mikey-San at 9:35 PM on February 22, 2011


i totally meant totem

i should stop looking at this code now
posted by Mikey-San at 9:37 PM on February 22, 2011


Well, see, Primer involves a couple of Canadian guys hanging out in a garage and Inception involves Leonardo Dicaprio shooting people in various fantastic settings. For the record I think Primer is the better film but Inception is fun. It doesn't have to be like a, "This is clearly less intelligent and therefore WORTHLESS!" type equation.
posted by neuromodulator at 9:45 PM on February 22, 2011 [2 favorites]


I for one will go out on a limb and say Ruby is actually less readable than C, scaffolding code be damned.

"In [Ruby]*, everything happens somewhere else."

*Smalltalk
posted by weston at 9:48 PM on February 22, 2011


Could someone explain the joke for a poor, poor English major?

To give you a better idea of what it does, here's what the program outputs (the first part of it anyway):

Dreamer [Fischer], level [1], priority [19], policy [OTHER]
Dreamer [Cobb], level [1], priority [19], policy [OTHER]
Dreamer [Ariadne], level [1], priority [19], policy [OTHER]
Dreamer [Arthur], level [1], priority [19], policy [OTHER]
Dreamer [Eames], level [1], priority [19], policy [OTHER]
Dreamer [Yusuf], level [1], priority [19], policy [OTHER]
Dreamer [Saito], level [1], priority [19], policy [OTHER]
[Fischer] HIJACKED ! Open up my defense projections in my dream to the hijackers!
[Arthur] sees Fischers defense projections at work in the dream at level [1]
[Cobb] sees Fischers defense projections at work in the dream at level [1]
[Yusuf] sees Fischers defense projections at work in the dream at level [1]
[Arthur] follows Cobb. to level 2 to fight Fischers projections
[Eames] sees Fischers defense projections at work in the dream at level [1]
[Saito] sees Fischers defense projections at work in the dream at level [1]
[Ariadne] sees Fischers defense projections at work in the dream at level [1]
[Cobb] taking Fischer to level 2
[Yusuf] starts to fall into the bridge while fighting Fischers projections in level [1]
Dreamer [Arthur], level [2], priority [19], policy [OTHER]
[Eames] faking Browning to manipulate Fischers emotions for the inception at level [1]
posted by scalefree at 9:51 PM on February 22, 2011 [1 favorite]


Also, when it comes to DSLs there are two kinds of people: those smart enough not to name-drop DSLs and those not smart enough to properly use a DSL.

But what if you define a DSL for expressing DSLs?

WE MUST GO DEEPER.
posted by GuyZero at 9:56 PM on February 22, 2011 [3 favorites]




I don't necessarily agree with the programmer's interpretation of the ending

Fork the code.
posted by scalefree at 10:47 PM on February 22, 2011 [10 favorites]


Now someone write one for Primer using nested loops and multithreading.
posted by clarknova at 10:54 PM on February 22, 2011 [1 favorite]


Say what you will about Java, at least most Java apps don't end up looking like kernel code.

Say what you will about C, but at least most kernels don't end up looking like Java apps.

Anyway.
int main()
{
    pthread_t movie;
    register int i;
register? I never see that even in kernel code any more. Compilers generally can take care of register allocation these days.

Insert here similar carping re: overuse of __inline__ and general misuse of assert.
posted by scatter gather at 10:57 PM on February 22, 2011 [1 favorite]


For those of you who don't know git, here's a cheat sheet:

git clone git://github.com/karthick18/inception.git
cd inception
make
./inception


Primarily of interest to C programmers; if you're a layperson, it's pretty unexciting.
posted by Malor at 11:27 PM on February 22, 2011 [3 favorites]


Not nearly as funny as I expected it to be. Not really funny at all, actually. Kind of sad, in a way.
posted by jeffamaphone at 12:10 AM on February 23, 2011


If inception was written in the movie equivalent of Java, it would have been at least a trilogy.
posted by hellslinger at 12:12 AM on February 23, 2011


Sweet Jesus, the guy actually has MIPS assembly in there. Why, god, why?
posted by hellslinger at 12:15 AM on February 23, 2011


Sweet Jesus, the guy actually has MIPS assembly in there. Why, god, why?

I'll say it means he has an SGI laying around.
posted by rhizome at 12:31 AM on February 23, 2011 [1 favorite]


Hmmmm. tl;dr. Also didn't see the movie. And lazy.
posted by tom_r at 12:44 AM on February 23, 2011


Fun fact: despite all the internet memes, no character in Inception ever says "We have to go deeper," or anything close to that.

It's like the "Beam me up, Scotty!" of the 21st century. (And that last link, btw, has about the funniest correction I've ever seen in a news article.)
posted by Rhaomi at 12:51 AM on February 23, 2011 [1 favorite]


which part of the code is where arthur and eames make out a lot? that is the best part.
posted by elizardbits at 3:40 AM on February 23, 2011 [1 favorite]


Not nearly as funny as I expected it to be. Not really funny at all, actually. Kind of sad, in a way.
It's an interesting concept. What's sad about that?
posted by sonic meat machine at 4:13 AM on February 23, 2011


I was expecting Terry Riley.
posted by box at 5:11 AM on February 23, 2011 [6 favorites]


Neeeerrrrddds!
posted by Old'n'Busted at 5:27 AM on February 23, 2011 [2 favorites]


spasm: "It's 2011, and he's still using #defines rather than const ints?


The only True C is K&R C, 1978 of course.
"

You joke, but officially GNU still prefers pre-ANSI K&R style function prototypes (not present in the linked code) and asks that you not require C99 features.
posted by mkb at 5:56 AM on February 23, 2011


You joke, but officially GNU still prefers pre-ANSI K&R style function prototypes

Very special circumstance: they want to be portable to older architectures which lack modern compilers. It's not something to generally emulate.
posted by orthogonality at 6:10 AM on February 23, 2011


Oh Oh! Do LISP next!! I'll get you started:

(((((((((())))))))))
posted by odinsdream at 6:46 AM on February 23, 2011 [5 favorites]


I was having serious trouble compiling. Luckily, delmoi's turbo button helped my machine locate some unresolved symbols.
posted by mistersquid at 6:50 AM on February 23, 2011 [1 favorite]


Neeeerrrrddds!
posted by mikelieman at 7:33 AM on February 23, 2011 [1 favorite]


ohshit! Lewis' calculator case looks a lot like the holster for my Droid!
posted by mikelieman at 7:35 AM on February 23, 2011


He could have at least left a macro flag to allow the possibility that Cobb dreams the whole program...
posted by Popular Ethics at 7:35 AM on February 23, 2011


So you'll be Ritchie & Kernighan
Coding Inception in C
Which defies all earthly conventions
You'll be Coding Inception in C…
posted by zamboni at 11:05 AM on February 23, 2011 [1 favorite]


But what if you define a DSL for expressing DSLs?

You use Scheme?
posted by kenko at 1:52 PM on February 23, 2011


i actually JUST made an Inception themed mix cd.

Nicely done. Makes compiling C all the more enjoyable.
posted by samsara at 1:58 PM on February 23, 2011


Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\obiwanwasabi> inception
'inception' is not recognized as an internal or external command, operable program or batch file.


I'm out.
posted by obiwanwasabi at 3:55 PM on February 23, 2011


Inception is the most hyped up ass sucking movie I have ever seen in my entire existence.

For the love of God, it was like a parody of the Matrix which (for reasons unknown) demanded you take it seriously.

1. Something didn't work out as planned
2. Go to a deeper dream level
3. ???
4. ???
5. Credits.
posted by dougrayrankin at 4:25 PM on February 23, 2011


Oh Oh! Do LISP next!! I'll get you started:

(((((((((())))))))))


odinsdream, the usual Lisp joke would go "Here's the last page of code: ')))))))))))))))))))))))))))))))))))))))))))))))))' etc." because Lisp is a prefix language where the operator has to appear first. e.g. "(dream-about (father-of (friend-of 'odinsdream)))".

However, if you consider Scheme a Lisp, then the operator can be another function call. So "(((((((((((" could be the beginning of a valid Scheme program, one that needs to make 10 function calls in the inner expressions before it even knows what function the top level expression is going to call.
posted by jjwiseman at 5:42 PM on February 23, 2011 [1 favorite]


doug--

The fact that things didn't work out as planned was the best part of Inception -- how commonly in movies does everything actually work out perfectly? All the time.
posted by effugas at 11:48 PM on February 23, 2011


« Older the no in nom   |   North To The Future Newer »


This thread has been archived and is closed to new comments