Live data from Hacker News

Ask HN: What language do you think in?

news.ycombinator.com

41–50 of 68 posts

Re: Ask HN: What language do you think in?

#41
Probably pseudo-code which resembles whichever language I most recently used to solve a similar problem.

As a really low-level example, previously when I needed to make a comma separated list of items I would do something like this:

$result = ""; $sep = ""; for ($items as $key => $val) { $result .= $sep." ".$val; $sep = ", "; }

of course now I just do join (", ", $items);. all languages I currently use have such a join function or method, and that idea is in my head; the exact syntax is not.

This does result in minor annoyances when I for example solved something in my head with a coroutine, only to realize that I'm at work coding in php, which doesn't have them.

Re: Ask HN: What language do you think in?

#43
Huh. I'm surprised by the responses on this.

I think in "flow". It's hard to describe, but it's not entirely visual -- it isn't like a flow chart in my head. Instead I get an idea of what I want a particular thing to do, and then I "feel" how it gets there, kind of like I'm mentally bouncing through a pinball machine.

I use the same approach for working on engines, circuits, and other complex things.

Re: Ask HN: What language do you think in?

#45
post #6

I think in English. Whenever I'm thinking about a problem, my solutions are immediately described in my head at a high level. This allows me to rapidly iterate over the solution space without having to venture down into the pseudocode or code level until I've found something I'm convinced will actually work.

I think in English, but it looks and sounds similar enough to Python anyway. I find this awfully handy.

Re: Ask HN: What language do you think in?

#46
post #22

Earlier quoted context omitted.

When you say "I think in pseudo-code", what are the semantics of this pseudo-code? 'cause it's actually a bit of a non-answer, when you think about it. Saying 'pseudo code' means that the language you think in has some informality in its syntax - but presumably you still have some fixed understanding of what it does? If it has no fixed syntax and no fixed semantics, then is it actually helpful as a mental model? I wo…

It's perfectly possible to express solutions at a high level without much regard for formal semantics. Knuth's The Art of Computer Programming expresses most of its algorithms in a combination of informal English and ad-hoc pseudocode. It's usually not difficult to translate them into languages with semantics varying from machine code to Haskell.

I didn't say "formal semantics", I said "fixed semantics", as in "something you understand and can apply consistently within a context". Within the context of a single code-fragment, the semantics are not changing. They might change from example to example, but that's perfectly reasonable.

My assertion is that when people say "I think in pseudo-code", they actually mean "an idealised version of language X", where language X is some paradigm or language they understand well.

I just wrote a blog post about this very subject, based on the flood of comments (shameless self-promotion follows):

http://news.ycombinator.org/item?id=802780

Re: Ask HN: What language do you think in?

#47
post #22
post #5

I think in pseudo-code, then figure out what language is best suited for the task.

When you say "I think in pseudo-code", what are the semantics of this pseudo-code? 'cause it's actually a bit of a non-answer, when you think about it. Saying 'pseudo code' means that the language you think in has some informality in its syntax - but presumably you still have some fixed understanding of what it does? If it has no fixed syntax and no fixed semantics, then is it actually helpful as a mental model? I wo…

For example, if someone asked me to do the fizzbuzz test (http://www.codinghorror.com/blog/archives/000781.html), I might think to myself in pseudocode:

  Loop from 1-100:
    if the current number is a multiple of 3, print "fizz"
    if the current number is a multiple of 5, print "buzz"
    otherwise, print the number
    print newline
Then I might turn that into PHP:

  ");
    }
  ?>

Re: Ask HN: What language do you think in?

#48

Am I the only one who doesn't think in any language at all? I just see little flashes and sort of feel ideas. I realize this is a very sucky explanation, but I've never heard it described. When I think about a program it is again a combination of images and feeling how a given algorithm I am designing will work. I only ever think about words when I sit down to write words, and then it is almost like I am transcribing…

In a programming or problem-solving context, this is sounds close to how I work in the very early phases of thinking about a problem.

Re: Ask HN: What language do you think in?

#49
on thinking in code: after doing a rather intense data integration/normalization/clean up project for many hours ending around 5 am or so, i had to take a shower before catching a nap. upon turning on the shower, my tired mind took a minute to organize/process the physical actions required to put myself into the shower - suddenly it wasn't a shower at all, rather, it was an array of droplets i had to somehow JOIN but the query was already running! all of this data was going down the drain - corrupted with no audit trails - but what regex/match would help? there was none... luckily, i snapped out of it and regained the proper level of abstraction conducive to good hygiene. apparently, i only had to step under the water. rest would work itself out with little need for analytic involvement.

after that, with sleep & time to breathe i went back and checked my work from that night because i assumed that a mind so frazzled would be similarly error prone. alas, that mode of thought, while not suited for normal-person-tasks worked well for the project. no bugs (from that night at least) and that single all nighter put the whole thing way ahead of schedule.

Re: Ask HN: What language do you think in?

#50
post #26

Earlier quoted context omitted.

I take a slightly more abstract approach: I first think of the problem from the user's perspective (and their expectations), then I map out a work flow before diving into pseudo-code and wire-frames. Overall, I agree with the parent because before you can dive into coding, you have to think of the problem and solution abstractly. But which language is used for writing out the solution? Whichever is the best tool for…

I still don't think it adequately answers the question. Maybe the question should be rephrased as "What programming paradigm do you think in?"

Yes, perhaps the original question is too open-ended, but without a proper context, all answers will be leaning towards the abstract.

While I may express the solution in Objective-C, PHP or Python, I always think of the solution in terms of logic.

Also, if you have experience in multiple languages (and environments), then you're less likely to be constrained by a single mindset.

Post reply on HN