Tagged Questions
4
votes
1answer
252 views
Is it possible to write a code without class methods, globals, and class variables? [closed]
I'm designing my own programming language for fun, and I'm thinking of making it fully Object-oriented (no statics, no globals, no class variables, no class methods), so I need to find a way to ...
18
votes
8answers
2k views
Why is String immutable in Java?
I couldn't understand the reason of it. I always use String class like other developers, but when I modify the value of it, I need to create new instance of String.
What might be the reason of ...
2
votes
6answers
759 views
Why is an interface in Java not allowed to have state? [closed]
There must be a good reason why Java designers didn't allow any state to be defined in interfaces . Can you please throw some light on this aspect of design decision ?
41
votes
10answers
2k views
I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?
My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. ...
5
votes
1answer
249 views
Why can't java generics be in arrays?
Why is it that when I try to make an array of ArrayLists: ArrayList<Integer>[] arr=new ArrayList<Integer>[40]; there is an error and java does not allow this?
Is there a reason related to ...
11
votes
2answers
838 views
Advantages and disadvantages of structuring all code via classes and compiling to classes (like Java)
Edit: my language allows for multiple inheritance, unlike Java.
I've started designing and developing my own programming language for educational, recreational, and potentially useful purposes.
At ...
4
votes
1answer
278 views
Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? [closed]
Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? Every single time I use BigIntegers, and many times I merely think about them, I wonder this.
What reason ...
9
votes
2answers
1k views
Why null pointer instead of class cast?
In Java:
int count = (Integer) null;
throws a java.lang.NullPointerException.
Why doesn't this throw a Class Cast Exception for ease in programmer understanding?
Why was this exception chosen ...
9
votes
5answers
6k views
Why is Python slower than Java but faster than PHP [closed]
I have many times seen various benchmarks that show how a bunch of languages perform on a given task.
Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder ...
10
votes
2answers
577 views
Why does a Java source file bear the name of the public class it contains?
I am a newbie learning Java. In Java every source file must contain a public class and that source file should have the same name as that public class. Moreover, no source file can contain two public ...
43
votes
12answers
4k views
Did the developers of Java consciously abandon RAII?
As a long-time C# programmer, I have recently come to learn more about the advantages of Resource Acquisition Is Initialization (RAII). In particular, I have discovered that the C# idiom:
using (var ...
14
votes
3answers
820 views
Java and .NET: Why different sorting algorithms are used by default?
Just wondering why Java and .NET Framework uses different sorting algorithm by default.
In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says:
In Java, the ...
6
votes
5answers
366 views
Java without implementation inheritance
In a recent video on Java, Joshua Bloch states at 4 minutes 20 seconds into the video:
And then there's inheritance, and that was a marketing necessity. You know, we can argue whether you really ...
5
votes
2answers
357 views
What do you think of an interpreter written in Java?
I am currently working on the implementation of a new programming language, for fun. I realize that most languages never become popular, but I still want the language to have a high-quality ...
15
votes
18answers
2k views
What do you think was a poor design choice in Java?
Java has been one of the most (the most?) popular programming languages till this day, but this also brought controversy as well.
A lot of people now like to bash Java simply because "it's slow", or ...
18
votes
10answers
6k views
What do Java developers think of Scala? [closed]
I've noted that IDE support is nowhere near as good, but the language itself supports functional programming idioms much more cleanly.
5
votes
7answers
434 views
Long Keywords like `function` and `namespace`
In many English-based programming languages like C++ and JavaScript, there exist long keywords like function, namespace, exception (in OCaml languages) and such. Do you think shorter keywords like ...
1
vote
2answers
268 views
Could you blend java and javascript?
As a developer who spends most of my time in either Java or Javascript these days, I have this fantasy about a language that blends the two of them together. I'm always missing something from one or ...