General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Lawrence D’Oliveiro
Fireship
comments
Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "Java for the Haters in 100 Seconds" video.
Here’s a trivia question. In C++, you use “new” to create a class instance on the heap; when declaring a class instance on the stack, you don’t use “new”. In Java, all class instances live on the heap. So you would think that “new” would be redundant, and would have been omitted (as in Python). Yet Java still requires “new” for creating class instances; why?
37
One interesting difference in Python’s syntax is the precedence of operators. Java follows C, which means that testing bit masks requires these parentheses: (val & mask) != 0 whereas Python lets you do it without the parentheses: val & mask != 0 You’d think that might cause incompatibility or confusion when trying to move expressions between Python and other languages? Yet lots of people do this all the time, and they don’t even notice the difference.
5
@androdeveloper7261 Correct. But: Why do we need to distinguish? Isn’t the name enough?
5
@androdeveloper7261 No, that’s not the reason. After all, methods can return objects, too.
4
@androdeveloper7261 No, they won’t clash. That’s why “new” is needed: because you can have a class or data field that has the same name as a method, in the same scope .
4
If you look at the size of the language references, Python is about 25% or less the complexity of Java. Yet Python manages to include features that Java does not, like defining your own operator overloads, metaclasses, properties, and import-as. Just compare the conciseness of the Python “select” module with the monstrosity collection of classes and methods that is the whole “Selector” mechanism in Java, and you might see what I mean.
2
@SimonWoodburyForget Note that Python handles this same issue without the “new” keyword. And C++ lets method calls work the same way, regardless of whether the object was created with “new” or not. None of which you address in your so-called explanation. This issue has already been explained further above. Read my posting on that before digging yourself in further.
2
@AyrtonGomesz Java objects are always on the heap.
1
@gmodrules123456789 It’s already been explained: it’s to specify which namespace the name comes from.
1
@SimonWoodburyForget Functions and methods are also objects, with their own memory allocations, in Python. This issue has already been explained, anyway (see above).
1
@philipp1717 It’s to distinguish between the two namespaces, one for method names and one for field/class names, as already explained.
1
Amazing the number of incorrect answers that continue to crop up, even after the correct one has been given.
1