15

Tech Lead: We need to exclude logged in user from our all users API as we don't want to show user's self card on the frontend with other users.

Me (Backend dev): This should be handled by the frontend and they should exclude it by a condition in their loop:

If (user.id != loggedUser.id)
{
// Add card
}

We also need self user at several other places.

Tech Lead: Create a query param filter for that.

Me: We should keep our APIs as generic as possible.

(Real thing starts)

Tech Lead: Which has more processing power frontend or backend?

Me (confused): Backend

Tech Lead: This will add a break to our loop and Do you know how much processing power it will take because of this condition?

Me (dead): WHAAAA....?

Comments
  • 1
    Troll answer: "So, you mean we should parse the site for the client and should stream the result instead. After all, that is the most time consuming task."
    Google: "What a brilliant idea. It will go well together with our stedia service."
  • 3
    @p100sch He even went on to say this would be a problem on old devices and PCs.

    So, are we living in 1980's?

    And the irony is we are using react for the front end.
  • 1
    🤦‍♂️🤦‍♂️🤦‍♂️
  • 1
    @techcatchers What will be next, force the user to use the IE version. Because backwards compatibility. That would honestly be hilarious.
  • 3
    "yes, practically none"
  • 10
    Your answer was incorrect. Frontend almost always has more processing power.

    Add up all the backend servers and sum up their processing power.

    Now add up all the frontend consuming devices that run your js with all the loops et al and sum up their processing power.

    Now compare them.

    You backend is soooooo far behind the frontend proc power.
  • 1
    @netikras My assumption while saying 'Backend' was the processing power of all servers and a single frontend device.

    Anyway, your answer would have pissed him off even further. Lol
  • 1
    @techcatchers and yet unless your service has under 10 users I believe your whole bkend might add up to less processing power.

    If I alone open up your website it's already a 4GHz i7 hexacore machine. If 10 users like me open it -- do the math. And yes, # of cores has impact on js too, even though it's single-threaded.
  • 6
    Server cpu is expensive, both via limited amount (thousands to tens of thousands of clients per server) and cost. You very literally pay for server cpu (via hardware or time), and increasing the total amount is always expensive.

    By contrast, client cpu is free in cost (they run your code by choice) and almost free in amount. Eventually increases in cpu use will cost UX, but you can always (and often easily) scale this with device and connection specs to mitigate it.

    ------
    tl;dr, the client is your bitch. Make it do all of the boring, unimportant busywork.
  • 3
    @Root

    Bandwidth, both server-server and server-client is the biggest bottleneck though.

    Better to write a good SQL query, than to filter through half a million records in JS.
  • 1
  • 0
    @Root Now that I'm thinking about it.... it's also dependent on the type of website.

    If your customers are paying, and you want to give them an optimal experience, you might go for stuff like server-side rendering, large redis/elastic caches, workers to warm up those caches, etc.

    If you serve something that users are really attracted to regardless of performance, like clickbait articles about popstars and top 10 lists, you probably want to cram in as many JS tracking scripts, ad banners and caroussels as you can, because users are stuck with their brainless browsing addiction anyway 😄
  • 1
    @bittersweet 😮
    I would never!
  • 0
    @Root You passed the test. You are now a Certified Javascript Developer.
  • 1
  • 1
    @Root You passed the second test. You are now a certified and slightly bitter Ruby developer.
  • 1
    @bittersweet It's true, though I'm bitter for very different reasons 😋

    I think I'm mostly bitter because humans are a thing. And not a particularly good thing.
  • 1
    @Root That's why I'm on my 23th refactoring branch.

    *drops EEG wires on floor, wipes bloody scalpel on hoodie*

    git reset --hard

    My basement is starting to get a bit crowded
Add Comment