Hacker News new | past | comments | ask | show | jobs | submit login

Apologies if the similar wording came across as some sort of personal jibe. I was merely trying to point out that even if the question was a simplification as you said, it was still a poor way to assess a candidate, because it's still getting hung up on a technicality rather than determining whether the candidate understands the underlying issue.



I guess I read too much into your comment. Apologies in my part for overreacting.

As to the technical issue, I don't think this has anything to do with dynamic vs. static typing. It would be theoretically possible to define operator+ in C++ to produce the same behavior as Javascript.


> I don't think this has anything to do with dynamic vs. static typing.

Well, yes and no.

In a sense, the real problem here is the overloaded + operator, which has two quite different meanings, numerical addition and string concatenation, depending on context. This is particularly a problem in a dynamically typed language, though, because you don't know in advance what that context is and therefore which overload will be chosen.

> It would be theoretically possible to define operator+ in C++ to produce the same behavior as Javascript.

In C++, you can't actually change the behaviour in this particular case, because you can only define overloaded operators where at least one operand has a user-defined type.

So in fact, just to make things simple, the C++ answer on most modern computers will be 56. Go figure. :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: