Scenario
You're in an interview for a job as a developer. You are given a coding exercise to show how you logically attack a problem. You're allowed to use any language of choice.
What language do you go to?
Background
I've always have been fascinated by people who are multilingual and can speak many languages. One question I love to ask is what language do you THINK in? I realize now that while I only speak one language, I can write in multiple...programming languages, that is.
My answer to the above? Java. My first language was PHP and later I worked a lot in Javascript/jQuery until I went to college for Java.
Oddly enough, I still think in Java.
Top comments (29)
I am super surprised by the answers
I think in sets (groupings/state change of data) and graphs (paths of logic)
when i need to pseudocode it will be something in the line of ruby mixed with english expressions as placeholders
I'm kind of confused about this question because I don't think I "think" in any language. When I'm breaking down a problem I'm mentally working with fundamental units of work that need to be done and what data structures I need to represent it, which is different from what the code for it actually looks like. "Perform this function on each element of a collection and save the result" is the same work regardless of whether you write it with a
map
or afor
loop or a list comprehension.For lack of a better way to state it, I might say that I think in English :)
A more practical answer: for interviews I use python, because it's easy to write on a whiteboard and has lots of nice, concise ways of expressing the kinds of data structures and algorithms I usually need to exercise in a coding interview. Lists, dictionaries, tuples, list/generator comprehensions... a standard library that I can guess at functions existing and having a 95% chance of them really existing. I love python for interviews!
I tend to think in the language I’m most comfortable with, and the first one I’ve learnt: Python.
Python tends to be extremely close to pseudo code, and it’s a language that has lots of stuff built in. So it’s a very good choice for coding exercises - I can translate ideas in language constructs very naturally without having to reinvent the wheel! Proof is, most coding challenge solutions written in Python I’ve seen rarely exceed 4 or 5 lines.
C#
Always C#
C# is ❤️
For me, it's Lisp. Lisp taught me how to think through expression evaluation. Its syntax represents the way all languages (compiled or interpreted) represent themselves internally. Whenever I program JavaScript (the language I know best), I think about the AST that my code produces, and that informs my understanding of how the code executes.
This is interesting. I write a lot of Ruby and it's usually my go to if I wanted to represent the logic of a real-world thing. Simple
if-else
statements are pretty easy to represent in Ruby, it has a really basic OOP structure, so overall my mind goes there a lot.But... when doing programming, Ruby doesn't really seem like the one I'd default think about as the language to relate things to because it's so high level, and translating to it kind of seems backwards in my mind. I'd say in this sense it's Java. It's the first language I truly learned in any deep sense (though it never stuck very well and I didn't really like it). So yeah, I'll often relate things back to Java in my mind even though I don't even really know it all that well.
For years I've been thinking in C because:
But to be honest, I've been coding mostly in Ruby for quite some time now and I start thinking in "Ruby logic" also.
It also depends on the problem I'm trying to solve. If the problem is purely OOP, I might even think in Java, since it's the first OOP language I learned (thanks, college...).
I think in a hybrid between Python and JavaScript. I think it's because although I primarily develop in JavaScript, I almost always solve programming challenges in Python because I like its more expressive syntax.
I think in JavaScript/Java/C# syntax with semicolons and curly braces, but simplified function names and such like Python. Getting in the habit of naming with_underscores instead of camelCase. I started with JS and learned a lot of Java in school. Been using Python recently and I love it, but JS is definitely my most common language, as I'm mostly into web dev.
I tend to think generically about how data will flow through my system using mostly
map
,filter
, andreduce
. I wouldn't say it's tied to a particular language, though it usually ends up being F# or Clojure when I write it out.