comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Using hobby source code in your job ? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a60dfe865a7807c4
* Rules Engines - Best Practices? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a79bfcda56e2b81c
* applet security issues - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/826c15e115e334c0
* Parse Array of Objects - string delimiter java - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f00a610222e5584
* Javac error. - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21513abc37c9cc4
* "static" prefix - to parallel "this" prefix - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157
* NetBeans 4.0 totally blows. What other IDE's are available? - 1 messages, 1 
author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd46bbd76ba757ee
* Valid filenames on operating systems - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/938eed95c48901c5
* Java speed vs. C++. - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29354c898cb3523
* Data Structures for Stateful Inspection - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/425c393c88a4243e
* Generics: how to avoid overloaded methods? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/11b478096ef7c41f
* Creating funny objects - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/275532460061ec7
* Unable to establish a socket connection - Got it! - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3db1070c05ec0b49
* Outputing JSP Code from a database - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3656d14aafe6341d
* String.split() - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3362a3ab6d6ba8ba
* searching strings - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d03e3ab90a0d69cb

==============================================================================
TOPIC: Using hobby source code in your job ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a60dfe865a7807c4
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 12:17 am
From: Jim P  

Nobody wrote:
> "Maarten Wiltink" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>"Nobody" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED]
>>[...]
>>
>>>>1. Do you use your hobby source code in your job ?
>>>
>>>Yes. If I need a specific control that I already have in my library,
>>>I have no intention of re-writing it. That would be f!#$ken stupid
>>>and a waste of my time. I could copy and past just the parts that I
>>>need, but my library is too interwoven for that.
>>
>>The biggest waste is that of company money. They are, after all, paying
>>for my time. If done work redone is what they want, they can have it
>>for all I care.
> 
> 
> You might not care about re-writing stuff, but I do. In my case GUI controls 
> are often tedious to write. Tedious twice is boring.
> 
> 
>>>>This could create problems ?!?
>>>
>>>It can only cause you problems if you start to rock the boat...
>>><and more along this line>
>>
>>This is a pragmatist's viewpoint. An extreme pragmatist. Not everything
>>you will probably get away with is ethical.
> 
> 
> Well, I guess thats where we differ :). I have worked for enough lousy 
> companies (and one decent one) where the sleazy world of "company ethics" 
> has been revealed.  Companies are INHERENTLY unethical. They are scum (p.s., 
> I am 29 and have been programming professionally for 9yrs). Think about it. 
> The average salaried Sr. Software Engineer will get about $90k to $120k per 
> year in the US. How much will your manager make? probably quite a bit more 
> in base + bonuses + stock options -- for doing quite a bit less (shooting 
> the shit in meetings all day). At the average company, the average manager 
> could make 2 to 3 times the money after its all said and done for doing 
> almost nothing except project schedules. How about more Sr. managers? well, 
> by the time you get higher up in the company, people are making 10 times or 
> more what you make, again, for doing very little.
> 
> Sorry, but why should I work my ass off to make them rich? you call it 
> unethical, I call it realistic. If a manager is making $500k a year and I am 
> making $90k to $120k, thats not fair. Yes thats how business works, and 
> thats why I really don't give a shit. I don't go out of my way to help the 
> company.
> 
> And in case you are wondering... my company loves me, but do they show it 
> with money or other compensation? hell no. If my manager is making $500k a 
> year base, "fair" is me making over $300k to $400k, if not more. After all, 
> the manager is making money off MY work. As is the company.
> 
> The amount of stock options is equally out of wack.
> 
> That was slightly off topic, but was to make my point. I could really not 
> give a shit about ethics or the company. If I am not making any money off my 
> work, I'm just a salaried employee, so I  am not going to go out of my way 
> to do extra or put in long hours, etc.
> 
> And as I said before, I hide my opinion around most people, and my company 
> loves me, but I could really not give a shit about helping them since I know 
> I'm not being compensated fairly.
> 
> Yes I am bitter :)
> 
> 
>>A company hiring a programmer is inherently buying access to
>>_knowledge_. As a programmer myself, I see little enough difference
>>between what's in my head and what's on my (home) harddisk. They can
>>have the use, but not the ownership, of both.
>>
>>I have been careful in my last four jobs to have in my contract that
>>anything done on my own time that is not directly related to however
>>the company makes its money, is none of their business. If I write a
>>game on my own time, it's mine. If I have a good idea how to solve a
>>work problem, of course it's theirs. If it makes them _really_ big
>>money, they would of course do well to acknowlege it and motivate me
>>to have more ideas like that.
>>
>>Groetjes,
>>Maarten Wiltink
>>
> 
> 
> Well, here in the US, companies are pretty much in charge. Often, if you 
> rock the boat by asking for stuff in contracts they'll just get someone else 
> wh

So you sit at your desk programming and full of anger at the same time.

Time to understand life - I have designed products that have given the 
companies that I work for Patents, Sold Millions of dollars of product 
because of my innovative ideas.    But that is what I am hired for.
o rolls over.
 >
 >
Remind me to not hire you.

That kind of attitude is a killer and eats at the insides of a person.

and will show in any conversations about rights and ideas.  So you 
limits yourself and value to the company.  Even while getting a good 
wage.  and lots of people are interested in your job.
and that attitude like this will keep you from advancing and making the 
money that you are assuming they are making.

And guess what, You boss is not making that kind of money - in your 
anger you are making guesses about his income and stock options and lots 
of assumptions.

You are only one part of the company and a small part of it.

Jim P.



== 2 of 2 ==
Date: Sun, Dec 5 2004 8:55 am
From: Andrew Thompson  

On Sun, 05 Dec 2004 01:02:20 GMT, Ann wrote:

> "E. Robert Tisdale" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Andrew Koenig wrote:
>>
>>> Unless you're being paid by the hour,
>>> there is no such thing as "your own time".
>>
>> Spoken like a true company man.
>> Who owns you?
> 
> Reminds me of the time the boss called us in for a chat
> about "no overtime pay" and he says:
> Those of you that are hourly, you are not allowed to work overtime.
> Those of you that are staff, you are paid to get a job done.

Why were the staffers' even at the meeting?  Why weren't they
already working (their little fingers to the bone)?

If a member of the staff even required that to be explained, 
it would be in person, one to one, and immediately followed by
"..that's why the company will not be renewing your contract.
Good luck with future positions.".

[ I would have set follow-ups if there was a single group in that 
slew of x-posts that was even slightly relevant.  ]

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: Rules Engines - Best Practices?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a79bfcda56e2b81c
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 12:49 am
From: [EMAIL PROTECTED] (e m madhu babu) 

Try out JESS. (herzberg.ca.sandia.gov/jess/) This is a open source
rule engine for java applications. I tried this. It works great. For
best practices check this site www.ruleML.com This is an initiative to
standardize the business rule engines and interoperability between
them.



== 2 of 2 ==
Date: Sun, Dec 5 2004 11:11 am
From: Patrick May  

[EMAIL PROTECTED] (e m madhu babu) writes:
> Try out JESS. (herzberg.ca.sandia.gov/jess/) This is a open source
> rule engine for java applications. I tried this. It works great.

     I agree, JESS is a very good tool, especially for systems written
in Java.

     JESS is not, however, open source.  There is a no-cost license
available for academic use but commercial users are charged.  From the
JESS FAQ:

     Jess is not licensed under the GPL, the LPGL, the BSD license, or
     any other free software or open source license.

Regards,

Patrick

------------------------------------------------------------------------
S P Engineering, Inc.    | The experts in large scale distributed OO
                         | systems design and implementation.
          [EMAIL PROTECTED]    | (C++, Java, ObjectStore, Oracle, CORBA, UML)




==============================================================================
TOPIC: applet security issues
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/826c15e115e334c0
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 9:14 am
From: Tim Tyler  

"Matthijs Blaas" <<remthis>thijs_blaas <at>hotmaildotcom> wrote or quoted:

> I found that it's possible to replace a cached applet by another one and run 
> that new applet instead of the original one :(

You mean if the attacker has direct access to the machine?
-- 
__________
 |im |yler  http://timtyler.org/  [EMAIL PROTECTED]  Remove lock to reply.



== 2 of 2 ==
Date: Sun, Dec 5 2004 1:43 pm
From: Andrew Thompson  

On Sun, 5 Dec 2004 14:08:39 +0100, Matthijs Blaasthijs_blaas wrote:

>>> 2.) Is there any way of making an unsigned applet instanciate a class 
>>> file
>>> from another jar?
>>
>> Add the Jar of the other class to the archive param and it's classes
>> can be found using getResource(name)
> 
> That's the way Im doing it now. Problem with this method is, that the JVM 
> will wait for all jar's in the archive param to be loaded. 

If you use webstart, you can specify the download of resource
jars as 'lazy' - downloaded when first requested.

>..What I'd like is 
> a compact loader class that display's a loading screen and loads & 
> instanciates the game jars. Unfortunaly Java webstart is not an option for 
> me, I have to stick to crappy JVM 1.1 compatibility...

You can offer the same applet to a 1.1 VM and simply add
the resources to the 'archive' parameter.  While the user
is waiting for the jars to be downloaded, throw up a Dialog 
suggesting they might consider upgrading to the genuine, this
millenium, Sun Java Plug-In.  

>>>...This works ok, but if I want to download the game jar & library jar
>>> from the loader, is there a way I can start the game in an unsigned 
>>> applet?
>>
>> Yes.  So long as you load the classes via URL, and never try
>> to access or use any File object, that will be fine.
> 
> You mean plain class files?

Yes!  My 'Launcher' applet does just that..

> But what if the class I want to instanciate resides in a jar (game jar) and 
> depends on another jar for certain method calls (library jar)? I could 
> download these two jars over an urlconnection, no problem. I also believe 
> the java api offers functionality to look in jar/zip files, but will I be 
> able to instanciate the game mainclass from the gamejar through the loader 
> class? What I thought is that I need an classloader to tell where the game 
> can look for class files it needs (ie: a class it extends from the library 
> jar which I also downloaded). Will it know where to find it when I simply 
> download the two jars? 

..stop, Stop, STOP!
Maybe this will answer some questions for you.
<http://www.physci.org/launcher.jsp>  
That is the launcher applet, each link leads to the 
Launcher applet, ready to open the frame, and the 
source code used for the frame.  Try it.

It is an unsigned applet.  Java 1.1 compatible (though
any of the launched applications may not be).

How is it done?  Let the code do the talking.
<http://www.physci.org/codes/display.jsp?fl=/Launcher.java>

>>> 3.) Is it possible to cache files I download in my applet?
>> The browser will do it automatically in an haphazzard fashion according
>> to the its current settings.  But once you have a Jar'd applet you can
>> install it via JWS and the components (class Jar's or toher resources)
>> will only be updated if they have changed.
> 
> Bummer, JWS sounds like a nice thing, but thats no option for me. 

Stop saying that.  It very much is.

>..Maybe I 
> can do something with the cache option in the URLConnection class...

That will not work between JVM instances, let alone shut-down,
start-up.

>>> I'd greatly appreciate if anyone could help me with any of these 
>>> questions!
>>
>> No worries.
> 
> Thanks again!

ditto.  

Reconsider the entire JWS option, you can offer the applet 
for 1.1 users, and JWS for the rest.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: Parse Array of Objects - string delimiter java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f00a610222e5584
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 11:37 am
From: "Boudewijn Dijkstra"  

"Jim Cheng" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
>
> Pedro is asking fir a String (comma delimitted) including the name, desc, 
> and age.
> So the following does not work.
>> ---------------still not tested ---------------
>> String catlist;
>>
>> for (int j = 0; j < Cat.length; j++)
>> {
>>  if(j!=0) catlist += ",";
>>  catlist += Cat[j].cName;
>> }
>>
>>
>
> try:
>
> String catlist;
>
> for (int j = 0; j < Cat.length; j++)
> {
>  if(j!=0) catlist += ",";
>  catlist += Cat[j].cName +","+ Cat[j].cDesc +","+ cat[j].cAge;
> }

StringBuffer buf = new StringBuffer(cat.length * 30);

buf.append(cat[0].cName).append(',').append(cat[0].cDesc)
  .append(',').append(cat[0].cAge);
for (int j = 1; j < cat.length; j++)
{
  buf.append(',').append(cat[j].cName).append(',')
    .append(cat[j].cDesc).append(',').append(cat[j].cAge);
}

String catlist = buf.toString();






==============================================================================
TOPIC: Javac error.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21513abc37c9cc4
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 2:58 am
From: [EMAIL PROTECTED] (Frank Gerlach) 

Mike Cox <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> I have SUSE 8.2.  I'm trying to compile a program that will be used in
> jakarta tomcat.  I'm getting this error when I try to compile it with javac
> version 1.4.
> 
> java:9: package javax.servlet does not exist
> import javax.servlet.*;
> 
> How do I fix this?
There is probably a jar file containing javax.servlet missing in your
CLASSPATH.



== 2 of 2 ==
Date: Sun, Dec 5 2004 6:30 am
From: "Ryan Stewart"  

"Frank Gerlach" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Mike Cox <[EMAIL PROTECTED]> wrote in message 
> news:<[EMAIL PROTECTED]>...
>> I have SUSE 8.2.  I'm trying to compile a program that will be used in
>> jakarta tomcat.  I'm getting this error when I try to compile it with 
>> javac
>> version 1.4.
>>
>> java:9: package javax.servlet does not exist
>> import javax.servlet.*;
>>
>> How do I fix this?
> There is probably a jar file containing javax.servlet missing in your
> CLASSPATH.

Specifically, servlet.jar or servlet-api.jar. One place you can find it is 
in Tomcat's common/lib folder. 






==============================================================================
TOPIC: "static" prefix - to parallel "this" prefix
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 12:28 pm
From: Tim Tyler  

I've been playing with the Checkstyle "Require this" check.

http://checkstyle.sourceforge.net/config_coding.html#RequireThis

This forces you to distinguish between local variables,
instance variables and static variables in you code -
buy using "this.var" for all instance variables and
"Classname.var" for all static variables.  It (optionally)
does the same for all method calls.

Essentially, I like the effect - but it highlights the need
for a static prefix in Java to match the "this" prefix.

Just as "this." refers to the instance, the static
modifier would refer to the class in which it appears.

Suggested syntax would be "static.var" and "static.method()" -
instead of today's "ClassName.var" and "ClassName.method()".

The rationale is that using the class name all over the place
hinders refactoring and code readability, and violates the
prinicple of specifying each fact in one place.

I believe this change would be a backward-compatible one.

Has this been suggested before?

Does it make sense to you?

Are there any other proposals to deal with the same issue?
-- 
__________
 |im |yler  http://timtyler.org/  [EMAIL PROTECTED]  Remove lock to reply.




==============================================================================
TOPIC: NetBeans 4.0 totally blows. What other IDE's are available?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd46bbd76ba757ee
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 6:39 am
From: "Ryan Stewart"  

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Andrew Thompson <[EMAIL PROTECTED]> wrote:
>> Unfortunately, I don't know of any IDE's that suck,
>> but for a lighterweight editor you might try TextPad.
>> (OK.. it is shareware, but close to free)
>
> I'll chime in here and say I've had good luck with jEdit
> ( http://www.jedit.org ).  There are lots of plug-ins avaialble for
> jEdit which can turn it into a pretty comfortable Java development
> environment.

Please share, then. How do you have it set up exactly? What plug-ins, 
options, etc? A coworker and I have looked at it but couldn't seem to get 
much of anywhere with it. 






==============================================================================
TOPIC: Valid filenames on operating systems
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/938eed95c48901c5
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 12:10 pm
From: "Chris Uppal"  

Bruce Lee wrote:

> Windows doesn't allow filename's containing the following characters:
> \/:*?"<>|
>
> Is this the same on all operating systems?
>
> I'm asking because I'm writing a html parser which needs to find valid
> urls.

You've had lots of answers to your question, but no one (that I've seen) has
pointed out that there is exactly zero connection between what's valid in an
URL and what's valid in a filename (no matter what the OS).

The "path" bit of an URL is only a string of characters (with some encoding),
the interpretations of those characters (once decoded) is /entirely/ up to the
software that, um, interprets it.

    -- chris





== 2 of 2 ==
Date: Sun, Dec 5 2004 2:36 pm
From: "Thomas G. Marshall"  

Chris Uppal coughed up:
> Bruce Lee wrote:
>
>> Windows doesn't allow filename's containing the following characters:
>> \/:*?"<>|
>>
>> Is this the same on all operating systems?
>>
>> I'm asking because I'm writing a html parser which needs to find
>> valid urls.
>
> You've had lots of answers to your question, but no one (that I've
> seen) has pointed out that there is exactly zero connection between
> what's valid in an URL and what's valid in a filename (no matter what
> the OS).
>
> The "path" bit of an URL is only a string of characters (with some
> encoding), the interpretations of those characters (once decoded) is
> /entirely/ up to the software that, um, interprets it.
>
>     -- chris

You're right, but given the context of the question, IMHO, that seemed like
a given.  Regardless of /how/ it was encoded, I think she was trying to
ascertain if the url, (http://C:\mumble) for example or similar, actually
/could/ point to a valid file.  As she was originally pondering, would
screening out "?" be ok for all platforms, for example.

-- 
"I don't want FOP, God dammit!  I'm a DAPPER DAN MAN!"






==============================================================================
TOPIC: Java speed vs. C++.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29354c898cb3523
==============================================================================

== 1 of 3 ==
Date: Sun, Dec 5 2004 12:24 pm
From: "Chris Uppal"  

Mike Cox wrote:

> Would that be a concern when I use Jakarta to run a web application?  Or
> does Jakarta start up and never shut down the engine?

The startup time is only an issue for applications that either need to start
really fast or which only run for a short time (like your example).  For any
reasonably long running program, the startup time is essentially irrelevant
(however irritating while debugging).

One thing to beware of, though, when considering Java in a server environment,
is that the startup time makes Java a very poor choice for writing pure CGI
programs.  (But then I don't think CGI is such a wonderful idea anyway...)

Incidentally, the latest Sun JVM has some tweaks to reduce the minimum startup
time.  I find them quite effective.

    -- chris





== 2 of 3 ==
Date: Sun, Dec 5 2004 2:31 pm
From: "KiLVaiDeN"  


"Mike Cox" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi.  I recently ran a benchmark against two simple programs, one written 
> in
> Java and the other in C++.  The both accomplish the same thing, outputting
> "Hello World" on my screen.  The C++ program took .5 seconds to complete 
> on
> my 400 Mhz PC while the Java program took 6.5 seconds.
>
> I am running the SUSE 8.2 Linux distribution.
>
> Why is Java that much slower than the C++ program?  I read on Slashdot 
> that
> Java was almost as fast as C++.  Here are my programs:
>
> test.cpp
>
> #include <iostream>
> using namespace std;
> int main()
> {
>        cout<<"Hello World";
> }
>
>
> test.java
>
> public class test
> {
>        public static void main(String[] args)
>        {
>                System.out.println("Hello world");
>        }
> }
>
> The reason I ask is because I'm thinking of using Apache and Jakarta to do
> some development. If Java cannot be speeded up, I will be forced to find
> another alternative.

Java takes time to initialise things, like preloading the classes, and lot 
of other things. It's also an interpreted language, and it will be always 
slower than compiled programs, no matter what you do. There is 
native-compilers available if it really is a problem, and through JNI, you 
can run native compiled code, if the need of speed is relevant.

But knowing those things, once running, a Java program, or at least a 
consequent Java program which can be used for benchmarking purposes, can 
compare in speed with C++ ones. The Jvm has had several optimisations that 
made it quite good performance-wise to interpret Java code.

K 





== 3 of 3 ==
Date: Sun, Dec 5 2004 2:32 pm
From: "Scott Lopez"  

Java has a slower startup time because it's compiling the byte code to
native code.  80% of Java code is ready to run, 20% is platform specific
that the JVM must complete compilation for.

During the first run, your seeing Java do this.  As the program runs beyond
the initial launch, you'll notice that Java continues to speed up, this is
because the HotSpot JIT compiler begins inlining code to make it run faster.

I believe the speed of both C++ and Java are close.  Java has a slower
startup time, shouldn't be used for heavy trigonometric calculations and
should not be used in real-time systems (the garbage collector reaks havoc).
If these three issues aren't a concern, then Java is a great choice.

It's interesting to note this arguement never ends, it's religious.  Soooo,
consider this.  Java has significantly more tools available that have well
defined interfaces (JDO, XML parsing, XSLT, JMS), most performance errors
are due to developer coding and Java offers tools such as OptimizeIt, JProbe
and Deep Diagnostics to find these issues.  In my mind, because you have
readily available tools, Java decreases your time to market and because you
have tools that inspect code during operation (profile) you can remove the
performance problems.  Thus Java has faster time-to-market and (in most
cases) better performance.


"KiLVaiDeN" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Mike Cox" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi.  I recently ran a benchmark against two simple programs, one written
> > in
> > Java and the other in C++.  The both accomplish the same thing,
outputting
> > "Hello World" on my screen.  The C++ program took .5 seconds to complete
> > on
> > my 400 Mhz PC while the Java program took 6.5 seconds.
> >
> > I am running the SUSE 8.2 Linux distribution.
> >
> > Why is Java that much slower than the C++ program?  I read on Slashdot
> > that
> > Java was almost as fast as C++.  Here are my programs:
> >
> > test.cpp
> >
> > #include <iostream>
> > using namespace std;
> > int main()
> > {
> >        cout<<"Hello World";
> > }
> >
> >
> > test.java
> >
> > public class test
> > {
> >        public static void main(String[] args)
> >        {
> >                System.out.println("Hello world");
> >        }
> > }
> >
> > The reason I ask is because I'm thinking of using Apache and Jakarta to
do
> > some development. If Java cannot be speeded up, I will be forced to find
> > another alternative.
>
> Java takes time to initialise things, like preloading the classes, and lot
> of other things. It's also an interpreted language, and it will be always
> slower than compiled programs, no matter what you do. There is
> native-compilers available if it really is a problem, and through JNI, you
> can run native compiled code, if the need of speed is relevant.
>
> But knowing those things, once running, a Java program, or at least a
> consequent Java program which can be used for benchmarking purposes, can
> compare in speed with C++ ones. The Jvm has had several optimisations that
> made it quite good performance-wise to interpret Java code.
>
> K
>
>






==============================================================================
TOPIC: Data Structures for Stateful Inspection
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/425c393c88a4243e
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 12:17 pm
From: "Chris Uppal"  

Captain Blammo wrote:

> I'm trying to write a basic stateful packet inspection application using
> JPcap in order to get a bit more familiar with TCP/IP, and was wondering
> if anyone could point me in the direction of the best/most common
> algorithms and data structures for delivering data to the right buffer
> based on source and destination IP and port for an incoming segment.

If you are doing this in order to educate yourself then you'll only be wasting
your time, and potentially confusing yourself, trying to find/use the 'best'
algorithms.

For instance, to find the runtime data associated an IP/port pair I'd create an
object that represented the pair, and use it as an index in a
java.util.HashMap.

If you want to go beyond that and find more space/time efficient lookups, then
that's fine, and it might even teach you something (more) about programming
Java, but it won't be teaching you anything about understanding TCP/IP.

    -- chris






==============================================================================
TOPIC: Generics: how to avoid overloaded methods?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/11b478096ef7c41f
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 11:57 am
From: "Chris Uppal"  

Michael Borgwardt wrote:

> class DataBase{}
> class DataSub extends DataBase{}
>
> class ControllerBase<D extends DataBase>{
> void method(D d);
> }
>
> class ControllerSub<D extends DataSub> extends ControllerBase<D>{
> void method(D d);
> }

Not an attempt to answer your question, Michael.  I just wondered if I was
alone in finding the above sketch almost impossible to "feel" ?

Put another way: is it just that I'm not used to (Java) generics yet, or is the
above genuinely hard to understand (significantly so) ?

    -- chris






==============================================================================
TOPIC: Creating funny objects
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/275532460061ec7
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 5:19 am
From: [EMAIL PROTECTED] (hopkins) 

After reading some of the Java/XML tutorials on the Sun site I was
puzzled by the way in which they create objects:

        // Use an instance of ourselves as the SAX event handler
        DefaultHandler handler = new Echo01();
        // Use the default (non-validating) parser
        SAXParserFactory factory = SAXParserFactory.newInstance();
        try {
            // Set up output stream
            out = new OutputStreamWriter(System.out, "UTF8");

            // Parse the input
            SAXParser saxParser = factory.newSAXParser();
            saxParser.parse( new File(argv[0]), handler);

        } catch (Throwable t) {
            t.printStackTrace();

In particular, why are objects created like this

        SAXParserFactory factory = SAXParserFactory.newInstance();
 ...and
        SAXParser saxParser = factory.newSAXParser();

I have always been taught to creat object in the form

  Person newPerson = new Person();

This way where you seem to call a different method other than the
constructor when the object is created confuses me and I cant really
understand why you'd want to do this. Secondly as the two lines in
question dont seem to have the "new" keyword does this mean they are
not created on the heap and are stack based like in C++?

Thanks in advance!



== 2 of 2 ==
Date: Sun, Dec 5 2004 1:33 pm
From: [EMAIL PROTECTED] (Paul Tomblin) 

In a previous article, [EMAIL PROTECTED] (hopkins) said:
>In particular, why are objects created like this
>
>        SAXParserFactory factory = SAXParserFactory.newInstance();
> ...and
>        SAXParser saxParser = factory.newSAXParser();
>
>I have always been taught to creat object in the form
>
>  Person newPerson = new Person();
>
>This way where you seem to call a different method other than the
>constructor when the object is created confuses me and I cant really
>understand why you'd want to do this. Secondly as the two lines in
>question dont seem to have the "new" keyword does this mean they are
>not created on the heap and are stack based like in C++?

There is a book called "Design Patterns" which explains all this.  You
should get it.

Basically, a "factory" is used so that the programmer can override it to
create a (or more than one different) subclass of SAXParser.  If I have a
class called "fooParser" and another class called "barParser", both of
which are subclasses of SAXParser, I only have to make the factory return
fooParsers or barParsers as the circumstances may merit, instead of
SAXParsers, and all the other code stays the same.  The factory method
"newInstance" would do the appropriate "new fooParser" or "new barParser"
inside it.

For instance, in the application I'm working on right now, I have a class
called "Playlist".  I have subclasses called "AdvertisingPlaylist",
"FeaturePlaylist", "TrailerPlaylist" and "SnipePlaylist".
"FeaturePlaylist" has two subclasses "FilmPlaylist" and
"DigitalFeaturePlaylist".  I have a PlaylistFactory with a method
"newPlaylist(int type)", which does a 
    Playlist n = null;
    switch(type)
    {
      case TYPE_ADVERTISING:
        n = new AdvertisingPlaylist();
        break;
      case TYPE_TRAILER:
        n = new TrailerPlaylist();
        break;
      ...
    }
    return n;

And so where-ever I need a new Playlist, I call on the factory to make it
rather than having that switch statement in each place.

-- 
Paul Tomblin <[EMAIL PROTECTED]> http://xcski.com/blogs/pt/
"You must be smarter than this stick >---- to put a machine on the
Internet."




==============================================================================
TOPIC: Unable to establish a socket connection - Got it!
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3db1070c05ec0b49
==============================================================================

== 1 of 2 ==
Date: Sun, Dec 5 2004 1:43 pm
From: Steve Horsley  


I think I know the answer. Move the initialisation code from 
the constructor to the init() method instead. That should fix
your null exception in getCodeBase(). I get the same exception
if I put the code in the constructor.

I think your next problem will be that your host (from
getCodeBase().getHost() will be "", because you are not loading 
from a web server. (I'm using Firefox on Linux, so I can't be
sure your results will be identical there). 

The security manager only allows the applet to connect to the 
web server that the applet was downloaded from, and in your 
case, the applet wasn't downloaded from a webserver, it came
from the "local" filesystem. So I guess your next step will
be to fire up a web server.

Steve



== 2 of 2 ==
Date: Sun, Dec 5 2004 1:55 pm
From: Andrew Thompson  

On Sun, 05 Dec 2004 13:43:04 +0000, Steve Horsley wrote:

> I think I know the answer. Move the initialisation code from 
> the constructor to the init() method instead. 

Ugggh... (slaps forehead).  Of course!

That's exactly what I did before I first viewed the 
compiled code example in a browser.

>..That should fix
> your null exception in getCodeBase(). I get the same exception
> if I put the code in the constructor.

It would also explain the differences between Steve 
(Rulison's) output and my own.

(snip rest that looks right from here)

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: Outputing JSP Code from a database
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3656d14aafe6341d
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 2:44 pm
From: "KiLVaiDeN"  


"Henry F. Camacho Jr." <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> This might be crazy, but I would like to explore this.
>
> It is my desire to use a servlet to serve up pages from a MySQL
> database.  Of course I would like to be able to use .jsp code that
> would reside in the database.
>
> Question:
>
> How do I output that jsp code that sits in the database from a
> servlet, and have it parsed by the application server?
>
> Thanks,
>
> HFC

You could have a Java application that could write the JSP(or HTML) files 
taken from database. All the structure.

I've done such thing long time ago, not in Java though, to make a website 
"look like" static, by producing the pages in static HTML from the database. 
Therefore the server load was quite acceptable, because nothing was 
interpreted server-side anymore !

But I think what you want to do is something else, and I don't think I have 
the answer for your problematic. If there is some kind of command that would 
interpret JSP code "on the flow" it'd help you I believe, good luck finding 
that information.

K 






==============================================================================
TOPIC: String.split()
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3362a3ab6d6ba8ba
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 2:46 pm
From: "Scott Lopez"  

This worked better for me:

    String rxsl="1}{2}{3}{4}{5}{6}{7}{9}{10}{12}{13}{14}{15}{16";
    //String rsxla[] = rxsl.split("^.*\\}\\{.*$");
    String rsxla[] = rxsl.split("\\}\\{");

    int size = rsxla.length;

    for(int i = 0; i < size; ++i)
    {
      System.out.println(rsxla[i]);
    }


results:
1
2
3
4
5
6
7
9
10
12
13
14
15
16


"Ike" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Can anyone please tell me why the following:
>
>
> String rxsl="1}{2}{3}{4}{5}{6}{7}{9}{10}{12}{13}{14}{15}{17";
>  String rsxla[] = rxsl.split("^.*\\}\\{.*$");
>
> produces rxsla[0]="1}{2}{3}{4}{5}{6}{7}{9}{10}{12}{13}{14}{15}{17";
>
> ???
>
> and not
> rxsla[0]="1";
> rxsla[1]="2";
> ...
> rxsla[13]="17";
>
> clearly I have something (simple and stupid) wrong -- but for the life of
> me, cannot find it here. Thanks, Ike
>
>
>






==============================================================================
TOPIC: searching strings
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d03e3ab90a0d69cb
==============================================================================

== 1 of 1 ==
Date: Sun, Dec 5 2004 6:48 am
From: "Scott Lopez"  

Look into regular expressions.  There are good books on how to do this and
it may greatly simplify your task.

"burchill" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am trying to write a kind of parser program, it is supposed to analyse
> a guitar tab file (just a plain txt file).  It should extract any chord
> names in the tab file by trying match any text in the tab file with any
> text in a list of chords in (another seperate file);
>
> So far I have loaded both files into string variables and am trying to
> search them using the regionMatches string method.
>
> The chords (a list of all chords) file is in this format...
>
> 466644  Absus
> 466644  Absus4
> 466644  G#sus
> 466644  G#sus4
> 545445  A11+
> 545445  A9(#11)
> 545555  A7(#10)
> 545555  A7-10
> 557585  D7sus
> 557585  D7sus4
> and so on...
>
> The numbers aren't important (they represent the fingering to play that
> chord).  My main problem is that as you can see the chord names can vary
> in length (can be anything from 1 character up to 9).
>
> I am trying to write an algoritm that will take each chord name from the
> chord string and then search for it in the tab string.  Each chord name
> starts on the 9th charcter on each line (including spaces as
> chararcters) but they don't all end at the same character on each line.
>
> Is there a way I can create a substring like this...
>
> tab.subSTring(8, end of line);
>
> Can I use the new line \n as a character to search for ?
>
> Any help appreciated.
>
> --
> Eps
>





==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to