Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This question is not at all related to this one When is a function name too long?
Can execution speed suffer because you have a function with a long name that is going to be repeatedly called from numerous places thousands of times? Do optimization flags take care of this in compiled languages so that there is no problem? Then what about interpreted languages like python?
In (typical, static) compiled languages it doesn't matter at all, and has nothing to do with "optimization flags".
In such languages, the function names are strictly something used at compile-time to identify things. They are replaced with actual addresses (or offsets) in the final machine code. No name look-up occurs when you call a function in C.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 21 days ago.
Improve this question
I was having a look at 1.19 MCP, which I downloaded from their GitHub, when I found something strange. In the file net.minecraft.world.damagesource, the class DamageSource contains two variables, among others, that look exactly the same.
These are the declarations:
public static final DamageSource IN_FIRE = (new DamageSource("inFire")).bypassArmor().setIsFire();
public static final DamageSource ON_FIRE = (new DamageSource("onFire")).bypassArmor().setIsFire();
Does anyone know why both variables are very similar? What is the difference between them? Where is one used and where is the other one used?
I tried looking online and trying to follow the implementations of both variables, but so far no good.
Judging from the names, the one might be damage due to the player walking in fire and the other due to the player having caught fire, or in other words, being on fire.
As #Sweeper has pointed out in the comments, the distinction is required, for example, to give precise death messages.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to understand the java 11 (JEP 309) dynamic class-file constants, it looks like an interesting feature.
and I google it, but I didn't find detailed articles (if you know any please share it) I just find this one by Rafael Winterhalter, but I still have some questions :
does this feature will make it possible to extend the types of constants that could be added to the pool (actually the pool could hold primitive and string values- correct me if I'm wrong)
in the article it is said that dynamic constant is generated as a result of invoking a bootstrap method, and that this method need to be referenced from the class’s constant pool, but how to do it (how to reference this method from class’s constant pool??)??.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I would like to read SICP but I don't want to fully learn Scheme. I know Java, C#, and Python all very well, so would it be possible to pick up Scheme quickly while still getting the full value out of the book?
Yes. Just read it, the code is very simple.
(f a b c) means f(a,b,c), and (define (f a b c) ...) means f(a,b,c) { ... }. And, the values, not variables, have types (variables instead are generic pointers to values). That's all. :)
So just by reading the book you'll be able to pick up the Scheme as used in it -- this was the expressed intent of the authors, too.
After reading some, or even before, watch the videos from the 80s. It's great stuff.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i tried to create a calc class which will have methords of mathematical operators which are not in java already..........
now after i created it ....if i wat to use this class functions i will have to make it a super class for my new program but .....if i want my new program to have multiple attributes of diffrent classes .........and simultaneously use calc functions........but i cant..............
why java doesnt have multiple inheritances.......what are its advantages and disadvantages?
tnx in advanced...
Java doesn't support multiple inheritance because of the "diamond problem" and other problems that arise from "increased complexity and ambiguity" as is explained in the wikipedia page on the matter
The creators of Java had a design goal of simplicity. That is why operator overloading with the added complexity of the "copy constructor" was also left out. That is why there is automatic memory management etc etc
most modern languages chose to discard this concept for the same reason.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
We are learning about both of these things in Java class right now. I believe I understand the basic aspects of both, but not sure about how Casting ends up limiting Algorithm Reuse. Our teacher said we need to know this for the test next week. Can anyone explain this?
If you cast you are limiting your algorithm to only work with one Class (or it's children). If you were instead to use an Interface you would be able to accept a greater variety of Objects that themselves implement that Interface. Much more flexible.
Here is a related SO question: Explaining Interfaces to Students
When you use casting in your code, you must know the exact type that you cast to (during the code write phase). Hence your code can't be reused in the future with different types. Always remember to program to interface instead of to specific type.