Why does C++ need a separate header file?

Some people consider header files an advantage: It is claimed that it enables/enforces/allows separation of interface and implementation — but usually, this is not the case. Header files are full of implementation details (for example member variables of a class have to be specified in the header, even though they’re not part of the public … Read more

Why is an array not assignable to Iterable?

Arrays can implement interfaces (Cloneable and java.io.Serializable). So why not Iterable? I guess Iterable forces adding an iterator method, and arrays don’t implement methods. char[] doesn’t even override toString. Anyway, arrays of references should be considered less than ideal – use Lists. As dfa comments, Arrays.asList will do the conversion for you, explicitly. (Having said … Read more

Why are arrays covariant but generics are invariant?

Via wikipedia: Early versions of Java and C# did not include generics (a.k.a. parametric polymorphism). In such a setting, making arrays invariant rules out useful polymorphic programs. For example, consider writing a function to shuffle an array, or a function that tests two arrays for equality using the Object.equals method on the elements. The implementation … Read more

How does “this” keyword work within a function?

Cannibalized from another post of mine, here’s more than you ever wanted to know about this. Before I start, here’s the most important thing to keep in mind about Javascript, and to repeat to yourself when it doesn’t make sense. Javascript does not have classes (ES6 class is syntactic sugar). If something looks like a … Read more

What blocks Ruby, Python to get Javascript V8 speed? [closed]

What blocks Ruby, Python to get Javascript V8 speed? Nothing. Well, okay: money. (And time, people, resources, but if you have money, you can buy those.) V8 has a team of brilliant, highly-specialized, highly-experienced (and thus highly-paid) engineers working on it, that have decades of experience (I’m talking individually – collectively it’s more like centuries) in … Read more

Function overloading by return type?

Contrary to what others are saying, overloading by return type is possible and is done by some modern languages. The usual objection is that in code like int func(); string func(); int main() { func(); } you can’t tell which func() is being called. This can be resolved in a few ways: Have a predictable … Read more

Benefits of prototypal inheritance over classical?

I know that this answer is 3 years late but I really think the current answers do not provide enough information about how prototypal inheritance is better than classical inheritance. First let’s see the most common arguments JavaScript programmers state in defence of prototypal inheritance (I’m taking these arguments from the current pool of answers): … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş