Hot answers tagged

11

Because processors have operations specifically for ints, and specifically for floats. The compiler has to know what operation to target. And I mean, even if you had adding for a series of bits, adding 0110 and 0001 have very different meanings if 0001 is treated as a float rather than an int - not to mention actual operations required to calculate it. And ...


8

So why did all those programming languages decided to provide multiple built-in data types Because the built-in types like int, float, byte and char are used in almost all use cases – and it turns out that standards are a convenience for everyone. If everyone used their own variant, writing code that uses libraries with different types, exchanging data ...


8

Let's forget for the moment that processors have specific hardware for manipulating byte sequences of a particular size. Let's forget for the moment that processors have specific hardware for operating on specific interpretations of byte sequences (floating-point registers, SEE registers, etc). What good does this abstraction do from a user perspective? ...


5

I would use a JSP every time. Why? Low-level programming HTML is a slow and error-prone operation. I've done this in C++ on an Arduino board, and I'm glad it was a hobby project.There is no way I could charge commercial rates for the small amount of functionality I produced. A JSP is very close to the HTML it emits, and so is easy to maintain. There are ...


3

An old sage once said: You usually don't create an interface for every class, that would be an afterthought. You create interfaces as a design exercise, then you create classes that implement those interfaces. You have to think that what you are creating is always a foundation upon which someone else can built some bigger. Don't create little programs, ...


3

Interfaces exist (speaking of the interface keyword), so you can define an API for classes, where the implementation does not matter, only the arguments, return types and maybe thrown exceptions. You should treat classes and their public methods exactly the same, whether they implement an interface or not. Once you realize that, you will see even a class ...


3

Why do you want to "mention" anything in the manifest file? What does the documentation of the software you're writing the plugin for say about what it expects in the manifest? Most likely, you can just leave out the Main-Class header or even omit the manifest entirely.


3

There have been languages that, as you suggest, provide only a single datatype and then have operations where the expected encoding of the data is provided as part of the operation, rather than being determined by the type of the variable as it is in most modern languages. The best known of these was probably B, the predecessor of C (in fact, C can be ...


3

When Java encounters this + operator, it compiles the addition to byte code, specifically an iadd instruction. What the computer does when executing this instruction depends on how the virtual machine on which this program is executed was programmed. It might delegate to an ADD opcode from some processor's instruction set. It might consult an internal ...


3

Is 20 Java classes for just making... This is entirely the wrong question. Something is wrong or you wouldn't be asking. It sounds like you're looking for something to blame. Anguishing over the number of classes isn't going to fix it. I've felt this same pain before. You step back and look at everything. It works. You can kinda follow it. But you ...


3

Yes, this is not k only possible but actually quite common. You can create your own byte code and feed it to a ClassLoader instance to turn it into a Class object and then use reflection to create and manipulate it. There's a library called cglib that's commonly used to make it easier, and many frameworks and libraries (eg Spring and Hibernate) use this ...


3

There are two legitimate reasons to DIY that I can think of: It simplifies your life. A custom solution can fit your needs exactly whereas trying to incorporate a 3rd party approach can sometimes be more work than it's worth. Eliminating/Avoiding dependencies. I really think developers in general don't put enough weight into this. There are costs to ...


1

While there are lot of reasons to use Spring (I've never worked with guice so can't comment on it) they aren't always important for any given project, and it's therefore a good idea IMO to at least consider DIY DI for each new project. That said, I end up with more Spring projects than those without. My most common reasons for using Spring are: declarative ...


1

Just a hunch, but are you writing unit tests? Many small classes over a few large ones become more valuable as you test your code more thoroughly and from more levels of mocked out, unit environments or production-like environments. I don't think having a large number of classes in Java is a problem or is unusual, but I am concerned that you feel so ...


1

I think you should export your project as a regular jar file and not as a runnable jar. That way your plugin client just need to know what method to call just like when you use an API. The only difference is that that method will open a Window etc.


1

You are correct that numeric types are just patterns of bits. But processors are optimized for certain operations on certain patterns of bits. For example x86 processors have registers of sizes 8, 16 and 32 bit, arithmetic operators corresponding to these sizes, and memory is addressed in chunks of 8 bits, known as bytes. There is no support for 19-bit ...



Only top voted, non community-wiki answers of a minimum length are eligible