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...).
Very interesting thread. My mind automatically defaults to the language I first learnt which was C. In interviews I tend to resort back to thinking in C but will tend to use other languages based on the scenario the employers has provided. A lot of the time I've found myself writing Python or Java in a interview, having a C mindset can be a bit weird in some cases as I'll sometimes find myself trying to write C syntax inside of a Python script.
I usually think in a sort of pseudo-code somewhere between Java and Javascript. Mostly just the concept of objects and interactions between specific types, but in a very shorthand Javascript-like syntax. Java was (and still is) my first love, and is the primary way I approach code, but throwing around ideas is much easier with a more dynamic/functional syntax.
So basically Kotlin. I think in Kotlin, my new heartthrob. The more I work in Kotlin, the more I find it to be exactly the way I want to think about Java code.
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.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.
For a job interview coding question, I'd choose Python. It seems to fit my brain best, even though I've used Java more professionally.
If I'm thinking through a problem (and probably writing it down) it's going to be a combination of English, Python (occasionally with Ruby-style blocks), and diagrams with boxes and arrows.
Kind of agree with any non-programming thinking first. Usually, I will start to ask myself "do we need a database for this?", and then build the hole UML around it (if needed). Then I will ask myself "do we need to access those data from multiple UI?", and if yes, I focus on thinking by APIs to tackle the problem. If not, I usually go down to my favorite tool, Laravel, because it is the moment it has something to offer to solve problems like Queues Jobs, Gates, Notifications, ... (basically opiniated tools, but useful tools that make you earn a lot of times, important enough on a project to consider it against another framework because as it is opiniated it will shape a little bit different your database if any was needed). I usually skip the "pseudo-code" step unless I need to explain a job oriented mecanism (if the problem we are trying to solve requires a lot of domain specific knowledge, in this case I do like a lot of you folks, mixed insert-favorite-language-here + pseudo code).
For me it's mainly PHP. As @tux0r said, it really depends on the task and sometimes I would also think about using Python or Javascript.
I don't have much experience in other languages tbh.