In C language we can put -o etc to compile a program.
I want to compile java such that it do not do error checking at run
time to increase the efficiency of the code.
As when a/b is done it see diviision by 0 or not.
When assigning array1[55]="dfgdfg"; It checks whether array1[] size is
ok.
int ii="sdfsdf"; Here it checks for Casting etc.
I want that when the program is running it do not waste time in
verifying various things. As my Program is already tested and there is
no error left.
Can I ask the compiler to compile in such a way that it do not look
for errors when runniung and it helps speed up of my Program.
And if it is possible how much fast the program will become when it do
not check for errors at runtime.
I know It is possible in C++ Language but what about Java.
Bye
Sanny
Stefan Ram - 05 Oct 2007 19:10 GMT
>Does Java has compiler options?
http://java.sun.com/javase/6/docs/technotes/guides/javac/index.html
>I want to compile java such that it do not do error checking at run
>time to increase the efficiency of the code.
http://java.sun.com/jsp_utils/PrintPage.jsp?url=http%3A%2F%2Fjava.sun.com%2Fdocs
%2Fhotspot%2FPerformanceFAQ.html
http://java.sun.com/products/hotspot/docs/whitepaper/Java_HotSpot_WP_Final_4_30_
01.html
>When assigning array1[55]="dfgdfg"; It checks whether array1[]
>size is ok.
Hotspot removes such checks, whereever possible.
>I want that when the program is running it do not waste time in
>verifying various things. As my Program is already tested and
>there is no error left.
Of course.
Karl Uppiano - 06 Oct 2007 05:01 GMT
>>Does Java has compiler options?
[snip]
>>I want that when the program is running it do not waste time in
>>verifying various things. As my Program is already tested and
>>there is no error left.
>
> Of course.
You seem incredulous. It is possible. I once almost *completely* debugged
"Hello World".
Stefan Ram - 05 Oct 2007 19:16 GMT
Supersedes: <efficiency-20071005201003@ram.dialup.fu-berlin.de>
>Does Java has compiler options?
http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html
>I want to compile java such that it do not do error checking at run
>time to increase the efficiency of the code.
http://java.sun.com/jsp_utils/PrintPage.jsp?url=http%3A%2F%2Fjava.sun.com%2Fdocs
%2Fhotspot%2FPerformanceFAQ.html
http://java.sun.com/products/hotspot/docs/whitepaper/Java_HotSpot_WP_Final_4_30_
01.html
http://blogs.sun.com/nike/entry/hotspot_internals_q_a
>When assigning array1[55]="dfgdfg"; It checks whether array1[]
>size is ok.
Hotspot removes such checks, whereever possible.
>I want that when the program is running it do not waste time in
>verifying various things. As my Program is already tested and
>there is no error left.
Of course.
Supersedes: <efficiency-20071005201003@ram.dialup.fu-berlin.de>
Stefan Ram - 05 Oct 2007 19:23 GMT
>And if it is possible how much fast the program will become when it do
>not check for errors at runtime.
Have a look at gcj. I believe, one might be able to
disable more checks there:
http://gcc.gnu.org/java/
See also:
http://mindprod.com/jgloss/jet.html
Lew - 05 Oct 2007 21:00 GMT
Sanny writes:
>> And if it is possible how much fast the program will become when it do
>> not check for errors at runtime.
> Have a look at gcj. I believe, one might be able to
> disable more checks there:
>
> http://gcc.gnu.org/java/
Then avoid using it.
> See also:
>
> http://mindprod.com/jgloss/jet.html
Certain checks are defined by the Java Language itself, e.g., array bounds
checking and division by zero. You can't get rid of them without it being not
Java.
As to "how fast" a program will get when you prematurely optimize it without
regard for whether your so-called "optimizations" will help at all, or whether
the code in question is a chokepoint, the answer is, "that depends, but quite
possibly slower than without the 'optimizations'."
>> As when a/b is done it see diviision by 0 or not.
Part of the language. Must happen.
>> When assigning array1[55]="dfgdfg"; It checks whether array1[] size is
>> ok.
Part of the language. Must happen.
>> int ii="sdfsdf"; Here it checks for Casting [sic] etc.
This expression will be rejected at compile time. There is no run-time cost.
>> I want that when the program is running it do [sic] not waste time in
>> verifying various things. As my Program [sic] is already tested and there is
>> no error left.
Presumably you have proven your algorithms with assert statements and other
techniques. Even so, since the types of checks you seem to wish to avoid are
all dependent on run-time values, there is no magic wand that will protect you
against bad data except run-time checks of the data.
As Stefan Ram pointed out, the runtime optimizer will do what it can to
mitigate the cost of the checks.
Have you any evidence that these checks that you are so anxious to avoid
actually affect your runtime performance?

Signature
Lew
Arne Vajhøj - 05 Oct 2007 21:21 GMT
> In C language we can put -o etc to compile a program.
>
[quoted text clipped - 19 lines]
>
> I know It is possible in C++ Language but what about Java.
You can not do that in Java.
All these checks are core Java functionality.
If you want to code in C++ then use C++.
And even though there are formal methods to prove code correct,
then real world apps always has the chance of some circumstances
triggering an exception.
Arne
Joshua Cranmer - 05 Oct 2007 22:02 GMT
> And even though there are formal methods to prove code correct,
> then real world apps always has the chance of some circumstances
> triggering an exception.
There are formal methods, true, but I believe the general case of
proving code correct is equivalent to the Halting problem.

Signature
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Christian - 06 Oct 2007 01:03 GMT
Joshua Cranmer schrieb:
>> And even though there are formal methods to prove code correct,
>> then real world apps always has the chance of some circumstances
>> triggering an exception.
>
> There are formal methods, true, but I believe the general case of
> proving code correct is equivalent to the Halting problem.
Then I will give you the thesis that halting can be proven for any
"nice" program.
And any program you program will be with a high probability of the set
of "nice" programs.
---------------
The problem I see with prooving a program to be correct is that it is
too complicated.. jml might be easy for some people that dream in hoare
triples though I think it still costs too much time compared to setting
up extensive junit tests.
Arne Vajhøj - 06 Oct 2007 02:23 GMT
> The problem I see with prooving a program to be correct is that it is
> too complicated.. jml might be easy for some people that dream in hoare
> triples though I think it still costs too much time compared to setting
> up extensive junit tests.
Which is why we always expect n bugs per KLOC.
Arne
Arne Vajhøj - 06 Oct 2007 02:23 GMT
>> The problem I see with prooving a program to be correct is that it is
>> too complicated.. jml might be easy for some people that dream in hoare
>> triples though I think it still costs too much time compared to setting
>> up extensive junit tests.
>
> Which is why we always expect n bugs per KLOC.
And only NASA can afford to get n < 1.
Arne
Laurent D.A.M. MENTEN - 06 Oct 2007 10:44 GMT
> And only NASA can afford to get n < 1.
And even getting n<1 did not keep them to land a rocket into the sea a
few years ago by mixing nautical and statute miles in their computations.
Arne Vajhøj - 06 Oct 2007 14:44 GMT
>> And only NASA can afford to get n < 1.
>
> And even getting n<1 did not keep them to land a rocket into the sea a
> few years ago by mixing nautical and statute miles in their computations.
It only require one bug in the entire app ...
Arne
Lew - 06 Oct 2007 15:12 GMT
>>> And only NASA can afford to get n < 1.
>>
>> And even getting n<1 did not keep them to land a rocket into the sea a
>> few years ago by mixing nautical and statute miles in their computations.
>
> It only require one bug in the entire app ...
More importantly, in only required one gaping flaw in their development process.
The calculations in nautical miles (or km. or whatever it was) were completely
accurate. The module in question didn't have any bugs.
Likewise the calculations in statute miles also were completely accurate. No
bugs in that module either.
Put the two together and SPLOOSH.
Had the development teams had proper communication, and more importantly,
oversight, then things might've gone better.

Signature
Lew
"On time, on budget, on Mars. Pick two."
- NASA slogan
Laurent D.A.M. MENTEN - 06 Oct 2007 15:55 GMT
That proves one simple thing... there is a lot to do before simply
thinking about having runnable code with no sanity checks.
The last thing I'll ever assume is everything is gonna run without
problems, even if it does by now or for ages I will NEVER assume this is
a stable situation.
Yet the miles problem was not a computer problem, the computer was just
a part of a system, and human was another part of the same system. There
was a bug in the system, whatever part was buggy does not matter.
This is just my point of view...
Thomas Kellerer - 06 Oct 2007 16:20 GMT
Lew wrote on 06.10.2007 16:12:
>>>> And only NASA can afford to get n < 1.
>>>
[quoted text clipped - 17 lines]
> Had the development teams had proper communication, and more
> importantly, oversight, then things might've gone better.
If have heard the rumour that the misunderstanding regarding the units was
casused by the fact that the development lead was asked to document everything
using a PowerPoint presentation. As that presentation became too long certain
aspects were simply removed ("management summary"!) and thus the information
which units were used were lost.
I too have seen companies were important information was "compressed" beyond
recognition just to satisfy some dumb manager - "Can you make a PowerPoint out
of that (50+ pages) manual? I don't have time to read everything".
Thomas
Lew - 06 Oct 2007 19:11 GMT
> I too have seen companies were important information was "compressed"
> beyond recognition just to satisfy some dumb manager - "Can you make a
> PowerPoint out of that (50+ pages) manual? I don't have time to read
> everything".
Such a person would, no doubt, miss the (power) point of
<http://norvig.com/Gettysburg/>

Signature
Lew
bbound@gmail.com - 08 Oct 2007 04:59 GMT
On Oct 6, 11:20 am, Thomas Kellerer <FJIFALSDG...@spammotel.com>
wrote:
> I too have seen companies were important information was "compressed" beyond
> recognition just to satisfy some dumb manager - "Can you make a PowerPoint out
> of that (50+ pages) manual? I don't have time to read everything".
Of course, the engineer that throws out that manual and REPLACES it
with the PP presentation instead of having both is being a bit dumb.
As for SPLOOSH, it's more like BANG when something hits anything, even
water, at those kinds of speeds. ;)
Eric Sosman - 05 Oct 2007 22:25 GMT
Sanny wrote On 10/05/07 14:00,:
> In C language we can put -o etc to compile a program.
>
> I want to compile java such that it do not do error checking at run
> time to increase the efficiency of the code.
>
> As when a/b is done it see diviision by 0 or not.
On many (perhaps most) implementations, this check
is performed by the CPU hardware/firmware as a by-product
of the division opcode. You can turn off the check by
replacing the CPU with a new model of your own design.
> When assigning array1[55]="dfgdfg"; It checks whether array1[] size is
> ok.
The JVM guarantees (or tries to guarantee) a safe
operating environment for all the code it runs, including
itself. In order to make the guarantee, it must defend
against this sort of error. Remember, if *you* can turn
off bounds checking, so can a less responsible programmer
whose code is loaded before yours ...
> int ii="sdfsdf"; Here it checks for Casting etc.
The example won't compile, of course. But you'll
still get run-time checking to catch errors like
Object o = "42.0";
Double d = (Double) o;
Again, the JVM *must* make such checks if it is to be
able to extend its safety guarantees to your code. If it
didn't, that other guy's code could ruin yours.
> I want that when the program is running it do not waste time in
> verifying various things. As my Program is already tested and there is
> no error left.
Donald Knuth offers monetary rewards to people who find
errors in his code or in his books. Are you willing to do
the same? You can offer an extravagantly large sum, since
your code is bug-free and you will never need to pay.
> Can I ask the compiler to compile in such a way that it do not look
> for errors when runniung and it helps speed up of my Program.
No. Some checks (array bounds, for example) are made
internally by the JVM and not by compiler-generated code.
Some (like casts) are initiated by compiler-generated code
and you could omit them by generating your own bytecodes.
You'd have trouble getting the JVM to load the resulting
classes, though: the bytecode verifier wouldn't like them.
> And if it is possible how much fast the program will become when it do
> not check for errors at runtime.
How fast does the wind blow in a vacuum?
> I know It is possible in C++ Language but what about Java.
A lot of things are possible in C++ but not in Java.
You can read about some of them in the CERT advisories.

Signature
Eric.Sosman@sun.com
Mark Thornton - 07 Oct 2007 16:28 GMT
> Donald Knuth offers monetary rewards to people who find
> errors in his code or in his books.
I think that offer expired some years ago.
Eric Sosman - 08 Oct 2007 16:10 GMT
Mark Thornton wrote On 10/07/07 11:28,:
>> Donald Knuth offers monetary rewards to people who find
>>errors in his code or in his books.
>
> I think that offer expired some years ago.
http://www-cs-faculty.stanford.edu/~knuth/address.html
... indicates that he was still writing "original"
checks as of 2002 and writing replacements for those
that couldn't be delivered as of 2006. Also,
http://www-cs-faculty.stanford.edu/~knuth/books.html
... says "you are entitled to a reward" for reporting
bugs; note his use of the present tense.

Signature
Eric.Sosman@sun.com
Roedy Green - 06 Oct 2007 04:30 GMT
>I want to compile java such that it do not do error checking at run
>time to increase the efficiency of the code.
see http://mindprod.com/jgloss/javacexe.html
http://mindprod.com/jgloss/javaexe.html
for the command line options on each. javac.exe does not do the
optimisation, the java.exe run time does.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Roedy Green - 06 Oct 2007 04:32 GMT
>I want to compile java such that it do not do error checking at run
>time to increase the efficiency of the code.
have a look at Jet. It produces code superior to hand generated
assembler. It manages to avoid the Java checks whereever it can prove
they are not necessary.
see http://mindprod.com/jgloss/jet.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com