Java vs Python for Google/Facebook/Apple

New / Eng
XEqc76

New Eng

PRE
Amazon
XEqc76
Oct 10, 2021 30 Comments

I’ll interview at these places in 1 year or so and I’d like to choose a language to really master: this would mean choosing it for LC, studying it more in depth and trying to get projects/tasks at my current job where I could practice it.

I’m currently decent at both, but expert in none.

I’d pick Java because it’s arguably better for scalable backends but maybe nowadays with all the ML projects Python might be a solid choice too?

In case company preference matters, here’s my preference order: G>F>A

Motivating comments are appreciated :)

140 PARTICIPANTS SELECT ONLY ONE ANSWER
VOTE VIEW RESULT

comments

Want to comment? LOG IN or SIGN UP
TOP 30 Comments
  • Apple
    moolah

    Go to company page Apple

    moolah
    Leetcode is a sports. Choose the one with less typing effort. In this case it means Python.
    Oct 10, 2021 2
    • Definitely agree but no braces in Python is killer for me, I can't follow my own code after a certain point in Python
      Oct 10, 2021
    • New / Eng
      XEqc76

      New Eng

      PRE
      Amazon
      XEqc76
      OP
      Agreed. But I think LC can be also used as an excuse to improve your skills in a language.
      Also the language you interview with (and are better at) might influence in which team you end up or the ramp up time once you join
      Oct 10, 2021
  • Google
    hRcy36

    Go to company page Google

    hRcy36
    I've been interviewing for centuries in python. It saves you a ton of time and puts the focus on solving the problem instead of type safety and verbosity, which you don't need in the less than 100 lines of code you might write. You save non trivial time writing python which can make or break your interview

    I've been writing Java in prod code and wouldn't want to touch python with a 10 foot pole. It's hard to reason about across files and methods. I have been part of multiple python to go/Java migrations and it's not fun. Unfortunately because of the over reliance on ide, I can't write Java from my memory and make syntactic mistakes if not for that. Python is easy to write without an ide, and in fact, ide support is much poorer for python because of lack of typing etc

    Each language has it's purpose. Mixing them up doesn't help.
    Oct 10, 2021 4
    • New / Eng
      XEqc76

      New Eng

      PRE
      Amazon
      XEqc76
      OP
      For heap you can use heapq and just change the sign of the values. For BST you’re right. But I think you never need to implement a balanced BST in interviews. I mean avl/r&b etc
      Oct 10, 2021
    • Google
      hRcy36

      Go to company page Google

      hRcy36
      Agreed that data structures are better supported in Java but I've always asked to be allowed to Google it, which I've needed anyway for both Java and python, in the rare case that such a data structure is needed.
      Oct 10, 2021
  • Google
    👁️♥️🚀

    Go to company page Google

    👁️♥️🚀
    I'd go with Python. The most relevant data types for an interview are easy to declare in Python and you don't have to worry about types. It's a lot easier to type "my_dict = {}" or even "my_dict = defaultdict(int)" rather than "HashMap<int,int> my_dict = new HashMap<>()". Not to mention iterator constructs work effortlessly in Python. You can do "for item in my_list:" and it conveys that you're going through everything in my_list. The corresponding construct in Java is far more verbose.
    Oct 10, 2021 3
    • Google
      👁️♥️🚀

      Go to company page Google

      👁️♥️🚀
      Whichever language you go with, you will have to learn to write it "the Google way." This means everything from style (variable naming conventions, whitespace, header file/import order, etc.) to using Google specific libraries (most of which are really high quality). Whichever language your team uses you will have good resources to learn it.

      I don't think there's a prestige level of knowing specific languages at Google, and a lot of that is due to most Google SWEs being polyglots. Because at the end of the day 95% of everything at Google boils down to throwing data into a protobuf and making a RPC call regardless of the language.

      Career progression is based far more on design ability and ability to launch a product rather than knowing any specific language or technology.
      Oct 10, 2021
    • New / Eng
      XEqc76

      New Eng

      PRE
      Amazon
      XEqc76
      OP
      Thanks a lot for all the info! Highly appreciated :)
      Oct 10, 2021
  • Pinterest / Eng
    rfTs53

    Go to company page Pinterest Eng

    rfTs53
    Always use python. Java is a distant second. Never use fucking javascript which has shit for all standard libraries.

    Basic requirements for languages to use in interviews

    1. Broad support for object literals.

    In python you can write

    char in ['\n', ' '] instead of char == '\n' or char == ' '

    in python you can access the last n elements in an array or string using

    arr[-n::]

    want to create a trie?
    ```
    def create_trie(words):
    trie = {}
    for word in words:
    current = trie
    for ch in word:
    current.setdefault(ch, {})
    current = current[ch]
    current['$'] = word
    ```
    show me how you can do that in fewer lines of code in java

    2. Standard library that includes all basic data structures, set, heap, dictionary, list, deque.
    Oct 10, 2021 1
  • I’d say both. Always best to have at least one compiled and interpreted language under your belt.
    Oct 10, 2021 5
    • I’d recommend focusing on Python for interviewing. I think showing proficiency of programming concepts is more important than demonstrating “deep knowledge” of a language; whatever that means. Coding interviews usually aren’t hard with enough practice. What you should focus on is reasoning through problems not the actual programming language.
      Oct 10, 2021
    • Google
      Tzpgw

      Go to company page Google

      Tzpgw
      That is what you will most likely use. If you are trying to leverage time spent on beyond just LC that is where you should invest.

      That said I agree with others, use the language best for the job viz python
      Oct 10, 2021