Of all the things I've discussed here at Hacker News over the years, this is probably the #1 subject. Most programmers have the opposite problem of you: they have trouble turning their minds on.
I always turn my computer off several hours before bed. The last thing I do every night is review hard copies of code with a red marker. Many nights I dream of my project/code. Sometimes I even jump up in the middle of the night and go to my computer, write down my thoughts, or lately, voice record them.
Sometimes I am incredibly grateful for the "gift" I've received from "outside myself" in the middle of the night. Other times I'm annoyed. For every cool insight, there are many false positives: What was I thinking? But the positives far outweigh the negatives.
I don't know why this works, but I can't imagine accomplishing all I do without it. Many programmers struggle for years to turn this "mind CRON" on. You already have the gift. I suggest you find a way to embrace it and turn your lemons into lemonade. You don't have a problem; you have a gift. Make it count!
My original HN post: https://news.ycombinator.com/item?id=191275
Also #49 here: http://v25media.s3.amazonaws.com/edw519_mod.pdf
Why is that? I loathe writing code on paper, seems like it'd be a serious regression.
I have the exact opposite view. I love writing it my code on paper. It makes me feel like the creative part of the equation while I leave the 'mechanical' computation to the dumb machine. Debugging and understanding difficult code samples is easier too.
I once read that Knuth(?) never used a computer and wrote everything on paper for his sectetary to type.
If you don't need the training wheels and you're not a hacker in a movie, I think you'll discover over time that it is a sweet sweet liberation to be free from the ball and chain of syntax.
Seriously, have you tried this for more than a few minutes? I've been doing it for a year and a half and I've never seen any benefit. You're only "free from the ball and chain of syntax" until you try to run the code, when you realize the syntax is still there, and you're only "free" from being able to clearly see it.
It's just a suggestion. Not everyone will like it or agree to seriously try it. I don't think it would necessarily work well for someone who's forced to use a certain editor or configuration at work, for example (and probably continues to rely on highlighting elsewhere outside of that job, preventing the mode shift from settling in).
But I think a good many developers who haven't considered this might discover as I have that it helps them to be calm and focused on higher problem-solving at the levels that matter to them. It really is liberating to read and write code more broadly as a meaningful language rather than just fitting and stacking bits and pieces together. You might reasonably claim you can just ignore the highlighting at will, but I and others have discovered after making the move (and really giving it time to set in) that we didn't realize how much the highlighting anchored our thinking to syntax.
I've had no more trouble at all preventing or finding bugs without highlighting than I did before. Also, while I've never used one I know that there are syntax-aware editors (or probably plugins for all the usual editors) that will show you broken syntax without drowning your code in syntax color.
As a primarily Python and Haskell writer, I have no idea what you're talking about with this "unchain your mind from syntax" stuff- though I guess that in Python the syntax may be so expressive as to be no cognitive restraint, and in Haskell binding your thoughts with syntactical structure is the point.
In principle I could imagine some languages might exist in which the concerns of developers are so confined to the smallest language bits and pieces -- at the expense of bigger-picture concerns -- that the drag of ever-present syntax cues is less of a drag.
But even from what I've seen of Haskell I can't imagine wanting to have those cues in my face all the time, unless I'm either learning the language or at my wits end trying to locate a (maybe) syntax bug ... in other words, when I'm not really writing or reading code. If anything, its proximity to math might make me more eager to be free of those cues.
I think in just about any significant code-making effort, we'll need to be able to think clearly about the meaning and intent of chapters, pages and paragraphs (and maybe sentences) without hundreds of little tethers constantly reminding us about commas and parentheses and subject-verb agreement.
All I can say really is that I had no idea how much of a drag those syntax cues were until I got used to being without them. Nobody has to do it just because it worked for me (and others). It's just a suggestion.
Frankly though, the dreams you get are the dreams you need to see and experience, whether you like the contents or not. If someone is not dreaming about code but about those other things, those are the deeper stuff related to life that the person needs to deal with.
If you are consistently dreaming about code, the gift is not that you are dreaming about code. The gift is that your daily life is aligned to a deeper sense of purpose and being. Your inner life and outer life is in better alignment than most people's. _That_ is rare.
An aside.
Reading some of the hilarious comments here I am inclined to think they could be compiled into a bestselling nerd comic
That's why I like to play some easy games or read a book 1hr before going to sleep. Sometimes they induce creativity though and are counter-active.
I find that I tend to think about things in my sleep on three occasions:
1 when the activity is new
2.when I am sufficiently stimulated and excited by the material.
3. when I am worried or upset
This 'dream state'used to occur to me in the past when I actively played chess, when I was in school studying for exams and nowadays when I'm struggling with (and mastering) a new concept or paradigm in programming. Recognizing it for what it is - a process of deep archiving and reorganization, I have come to embrace it and even be happy when it occurs, since material I have processed in this way terms to be deeply ingrained in my memory for longer.
One thing I remember that has always amused me is how I would dream about this amazing code. It was so amazing that I would simply have to wake up so I could write it down. But, the few times I could actually wake myself up, as soon as I thought about it (before it quickly faded away) I said to myself, "WTF was that? There's no way that would work!"
I used to have such dreams about EverQuest. So I eventually realized I should play less :P
It's called the Tetris Effect, read: https://en.wikipedia.org/wiki/Tetris_effect
Even though I stopped gaming somewhere during university, I still have dreams about those games every now and then.
OT: Just like other's in this thread, I have dreamed about code as well, with a similar frustration to wake up knowing the beautiful solution was all imaginary :-)
One time I went to sleep after starting a take home code test for a job interview; I woke up a few hours later having some intense dreams about it and ended up knowing exactly what to do. I finished it at 4am. I didn't end up getting the job, but they said during the interview they really liked the code.
The ST had a notoriously slow text output system. The display was a bitmap and there was no hardware acceleration. Somebody called Darek Mihocka came out with 'Quick ST' which made the text display quicker than stock. As a newbie I wanted to beat this, so I learned 68000 assembly and did the usual optimisation - unrolling loops, precomputing bitmaps etc. I got faster than Quick ST but then he had an update which nearly doubled my speed.
I did everything I could to work out what he'd done, including looking at the Motorola reference manuals, nothing came up. I was going crazy. Bear in mind these were the days when there was no middleware, it was you versus the hardware, and if they did it better it's because their code was better.
So I went to bed one night and the 'move.p' opcode came to mind. I woke up and read about it - turns out this opcode took a 16 bit number and split it into 2 8bit codes and placed them 2 bytes apart. This matched the ST interleaved bitmap perfectly - I doubled my speed and beat Darek.
So, yeah, a dream did actually improve my code. I do miss those days where decent code beat driver, middleware and other issues.
Needless to say, she's still laughing at my antics!
This usually only happens the night after a long day working on very mentally challenging problems, it rarely happens after easy days.
Unfortunately I didn't get the job but it was really interesting to experience how my mind operated when a large chunk of my attention was consistently focused on complex topics.
I am convinced that Google interviews are rigged. I got on the phone with an "interviewer" and he sounded like someone strangled his pet in front of him.
I knew I wouldn't get past then because he didn't really seem at all interested in interviewing me.
I wasn't like Homebrew Qualified but I definitely wasn't Fizzbuzz Unqualified.
I dreamt about the homework problem, and realized I had made a mistake. I immediately woke up, grabbed the paper, and made the correction. The whole class burst into laughter, but the professor didn't seem disturbed. Later he told me something like that happens every few years (he's been teaching for 30).
When I was working with Kubernetes intensely, I was moving around abstract "lego blocks" representing concepts. The space was black, 3D, no gravity. (I remember someone coming into the space to visit and I told her I'm still working on it...)
There were times when I was trying to figure out something in the dream and a different mind-thread was hacking code that maps to the plot of the original mind-thread.
I have walked in dream spaces where I took a corner off the happy path and watched the world glitch for a moment and start procedurally generating.
There were dreams about startups, working in an office (I work remotely most of the time).
Lucidity and clarity varies. Sometimes it is very clear, the visuals and the coding concepts I am working with are sharp. Sometimes they are fuzzy. It is occasionally lucid (how aware I am that I am dreaming). That "semi-hypnotic" state seems like it is not high on the lucidity spectrum. That's pretty normal if you are coding in a semi-hypnotic state while coding during the day.
I usually meditate before falling asleep, try to offload things in my day's working memory. It's usually whatever I am binging on, whether it is coding, anime, or even martial arts or whatever. For example, there was a time when I binge watch My Little Ponies and saw the ponies cavorting in the phosphenes. I'm not surprise this happens with code.
It isn't limited to code, when I was a kid I used to wake up dreaming of Tiberium Sun, and Red Alert 2. It's lately been code though.
I first noticed this with PCB layouts - I'd be moving parts and re-routing/prettifying manually for long straights and only 45deg corners.
Also refactoring code, particularly in an aesthetic way as if making the style consistent/readable before doing something with it - shortening lines, aligning data structure entries, whatever.
It happens if I play something like tetris before sleeping or while tired, too.
I used to spend time thinking about code before sleep. The long term effects is the larger problem. Not giving your mind time to do something else will eventually lead to burn out.
Credits to Tim Ferris for this routine.
Different types of code dreams are common too - code nightmares where you get caught in small, infinite loops or are unable to escape oscillation between a small set of bad operations
Or happy code dreams where you float above the system and observe high levels of interaction and execution, watching data flow like water, and execution happen rythmically like beats of music.
I never know which I am going to get but coding is the most pleasant of them, by far. The higher my stress, the more likely it's not fun.
The fact that my current job is to untangle legacy Java code and we actively oppose any "unnecessary" changes hurts me, because I can't not untangle it in my head, working or sleeping. Resting/playing is OK though. That's why it's important.
Of course, we don't have any unit tests, because how else could we employ 2 testers per coder? And we obviously don't have any time for that useless stuff.
I find myself working on it half asleep in my bed. It pretty much always results in finding the solution or at the very least a good lead.
That's where you want to get lucid enough to realise that struggling with the problem isn't a worthwhile pursuit now, and go do something fun instead :)
The clearest memory I have, is when I was 15, debugging some hacky PHP codes for days still unable to find a solution. I dreamed that piece of code and suddenly wake up with a fix, it was a pretty nice feeling.
Also an year ago I started learning Haskell, despite reading a lot of tutorials I wasn't able to understand what a monad is. One day I woke up and find myself understood the concept. I don't remember the content of the dream, but it was a sweet dream and I slept longer than usual.
I am not sure if I have OCD, but I like coding so dreaming code is not an issue for me.
But this happens only in those periods where my day is basically 100% code.
In that dream, I wrote small programs, compiled and executed them. The twist was that the result of the execution was presented to me in the form of physical constructs, composed of square hollow section pipes welded together.
I would then walk around the structure, examine it, and wonder, why a particular part of the structure is welded to the whole structure diagonally, instead of a 90-degree angle. Must be a bug somewhere.
Though I did have this one dream where I was able to open up a virtual console next to anyone I saw and could program them to do whatever I felt like. I could do this with just random objects too, not just people. That'd be an interesting game idea now that I think about it.
It happens less these days. Either because I am more experienced or because development tools have improved; I no longer get stuck like I used.
Somewhat related: I dated a cellist who said she'd read music in her dreams.
I think it's both a blessing and a curse. On one hand, some days I wake up and immediately know how to solve problems, or I'll think of new things to try. I've also had many nights where I come to understand concepts from 'exploring' the whirlpool of vagueness. Solidifying the abstraction helps a lot, I guess.
On the other hand, this phenomenon can be very distracting or distressing at times. I have a terrible memory of trying to have sex and all I could think about was Redis.
Actually terrifying thinking about it again. Made me very wary of live programming XD
Other then that I never dream of code, but sometimes when I am half asleep in bed I start thinking about issues and playing out scenarios I could try to fix something, or implement a new feature.
> The earth represented an "ideal" logical volume of data (life), and the universe was the collective storage LUN. I was using Amazon's Dynamo algorithm to replicate life, with eventual consistency, throughout the universe by watering plants in the garden. Now, Amazon actually uses Requests to perform all internal API control operations for AWS, effectively making my code partially responsible for the operation of the internet itself. See the theme? [...] I was very keen to have the doctors and my family look up the Dynamo whitepaper, to prove the legitimacy of my quest.
1: https://www.kennethreitz.org/essays/mentalhealtherror-an-exc...
One example would be scenario where you can't remember some word, and you decide you can't remember it and stop thinking about it, your brain continues to search for it in the background (subconsciously)... and then the word comes to you like an interrupt.
I had the same thing with studying for exams (I would dream of the lecture notes and when I wake up in the morning I can perfectly recall everything).
There was a study posted at HN where not completing a task at work, leaves your brain working on it even after you leave your office, only to have the solution pop up in the middle of the night.
All of this can be a result of a stress. You need to take a vacation and relax. Recharge your batteries or you'll be feeling drained really soon...
If the answer to most of that is mostly yes, you're doing pretty well.
As someone else mentioned, it's likely the tetris effect. I had a similar feeling while playing the game "triple" town where you want to match three bears items next to each other, I kept seeing items and people in terms of "are they next to each other" while walking around (especially when a bit of alcohol was involved).
Edit: Come to think of it, this 'free shrooms' experience is reason enough to not do CRUD apps :)
Once my life went back to a sane pace, where I could enjoy some personal free time, the problem went away.
Now I have a baby and I dream of diapers.
I've found that watching some boring TV or having a drink (alcohol) before bed helps.
When I struggle with modeling problems, I often solve them in the trance-like state right before falling asleep. These solutions are much more elegant than what I would be capable of while being fully awake.
Almost every time I have a fever, I end up dreaming about code or diagrams. Sometimes even live CSS coding. And yes, it's awful and you can't escape.
When I was studying organic chemistry, I had some pretty cool dreams about aromatic molecules.
Bank finance class gave me an extremely revelatory nightmare about interest rates once.
Dreams about stuff you're learning are almost always constructive though. It's a good thing.
I've experienced the same thing.
I was working on a Minecraft plugin to give the player the ability to access a virtual chest.
I had to dive in the code of Minecraft so deeply that I started dreaming of creeper exploding in my code.
When I'm awake and bored, though, I do think about code a lot, and game mechanics, and such.
It's encouraging too, because my dreams are accurate.
That was the first and last time I dreamt of Java.