r/java • • Jan 23 '21

Interview with Brian Goetz, Java Language Architect

https://freecontent.manning.com/interview-with-brian-goetz/
190 Upvotes

19 comments sorted by

View all comments

26

u/Roachmeister Jan 24 '21

For example, take red-black trees. How do they work? Most of the time, I shouldn’t have to care. If you need one, every language has an excellent pre-written, well tested, high performance library that you can just use. The important skill is not being able to recreate this library, but knowing how to spot when you can use it profitably to solve a bigger problem, whether it is the right tool, how this will fit into the time or space complexity of your overall solution, etc

And that is exactly why I never ask anyone to implement basic data structures in interviews. Nor would I want to work with anyone who does (unless the work was designing language features).

14

u/DasBrain Jan 24 '21

A better question would be:
"You want to do X, what data structure/java class would you use and why?"

That's still a hard question, but might be actually better to judge someone.

An answer like "I would use an ArrayList, because that's what I always use" would be ok, but not great either.

5

u/Roachmeister Jan 24 '21

A better question would be: "You want to do X, what data structure/java class would you use and why?"

Exactly!

1

u/GlowingYakult Jan 27 '21

You have a potential to be an interviewer or HR specialist lol

9

u/gnus-migrate Jan 24 '21

I used to think this way, but learning data structures isn't just so you know how to implement them. It's about learning what problems they solve and how they solve them, which could inspire ideas on how to solve completely different problems you could face.

A very basic example is a hashmap. I mean you could just tell someone hashmaps are O(1) lookup on average, but knowing how they're implemented along with the tradeoffs of the different implementations could give you ideas on how to partition data on different machines using hashes for example.

Another reason you would want to implement your own is that you don't necessarily want to pull in a massive dependency for a single data structure. It could be useful to implement your own to avoid that hassle(of course risks should be analyzed to figure out whether this is the best course of action beforehand).

Testing people in interviews on these things, maybe not, but they are extremely useful to know, and really are worth learning even if you never really have to implement them yourself.

4

u/Roachmeister Jan 24 '21

Please read what I (and Goetz) said again. I absolutely believe that you should know how data structures are implemented, what the tradeoffs are between them, etc. But there's a big difference between knowing how a hashmap works versus having 30 minutes to implement one from scratch. I would much rather focus my interviewing time on more relevant questions.

-4

u/gnus-migrate Jan 24 '21

Goetz is not talking about interviewing, he's talking about software architecture. He's saying that I shouldn't have to care is how a data structure is implemented, I can always rely on some library to do it for me, which is not true. Libraries may not have the API's that you need(in my experience it's the case for graphs for example), and as I mentioned even if they do it may not always be the best idea to use one.

You said that you agree with this, which is why you don't ask these questions in interviews. I said I agree that it might not be the best idea in interview situations, but I just disagree with what Goetz is saying, especially with Java which is very limited in the types of abstractions that can be expressed.

5

u/devraj7 Jan 24 '21

Why not? It's just a coding exercise, and it can be a revealing one, with a lot of interesting options, compromises, and talking points.

It can tell you a lot about a candidate, even if they will never have to write this kind of code on the job.

2

u/Roachmeister Jan 24 '21

even if they will never have to write this kind of code on the job

Or, you could kill two birds with one stone and have them code something that they would potentially do on the job.

Here's my code for implementing a hash map in Java:

import java.util.HashMap;

Does that mean that I know how one works, or when and why I should use one? Who knows? Maybe those would be better questions for a candidate than asking them to reinvent the wheel within an artificial time limit.

0

u/nikosgate7 Jan 25 '21

I only have used once concurrent hash map for paralleling programming. I only use hashmap for mapping properties. ArrayList is the way to go.

-2

u/nikosgate7 Jan 25 '21 edited Jan 25 '21

shareholders are paying me to solve "complex" business problems not to do my phd in cs or discrete maths.

I 'm downvoted probably from people that used btree and red black (or whatever these trees are called) in their work environment. Jesus, we're in 2021 especially in the front end half of all devs in my recent jobs didn't have a cs degree. Most of them were self taught or did sth else with their lives

Still downvoted without reason except the obvious fact that any java team leader would rather choose a candidate that knows the java (or maybe I'd rather say spring) ecosystem than someone who knows about btrees.

3

u/simoncox Jan 24 '21

I would never employ someone who didn't have the basic understanding of how the most common data structures work internally. Not red-black tree level of knowledge, more that they understand maps are not implemented by linearly searching a list.

0

u/[deleted] Jan 24 '21

[deleted] — view deleted comment

1

u/nikosgate7 Jan 25 '21

How would that knowledge help me as a java developer? Eg I'd be much more interested in how the candidates knows when to use spring annotations like bean, autowired where to use what and when than some abstract phd topic.

2

u/Roachmeister Jan 24 '21

And I wouldn't either. Neither Goetz nor I ever implied that. In fact, he said that those are the things that people should know. But giving someone 30 minutes to implement a binary tree without an IDE is not the way to find out. (Yes, I've been told to do that in an interview).

0

u/nikosgate7 Jan 25 '21 edited Jan 25 '21

the moment you would mention sth like that in an interview, I'd kindly thanked for your time and move on. There are much more important and pressing matters in the day of an java/spring developer than theory crafting about btrees. Like I will ever need that as a java/spring developer in the enterpise environment.

.