[Tutor] Slightly OT - Python/Java

Liam Clarke cyresse at gmail.com
Mon Jan 10 23:00:09 CET 2005


On Mon, 10 Jan 2005 01:33:39 +0000, Max Noel <maxnoel_fr at yahoo.fr> wrote:
> 
> > (Also very frustrating is having lists that can be comprised only of
> > one variable type.)
> 
>         First things first: don't use lists/arrays. Use Collections instead
> (classes like ArrayList, HashMap, etc.). They're much more versatile,
> and akin to lists and dictionaries in Python (sometimes even better).
> Iterators over them are supported.
>         And while they can indeed only be comprised of one variable type as
> well, said variable type is Object, from which all classes derive, so
> that's not a problem (you only have to remember to cast as you get()
> something from a Collection).

Hehe, I'm not up to collections yet... working through Learning Java
by O'Reilly.

> > (Why can't a non-static
> > method comparison be called from a static reference? What does that
> > mean anyway?
> 
>         Er... What was your code like? (before and after correcting the error)


it was (off top of head here)

public class dude

{
public static void main(String [] args) {

System.out.print(args[0]);
if (doComp(args[0]));
    {
    System.out.println(" is true");
    }
else
    {
    System.out.println(" is false");
  }

private boolean doComp(String x) {
   int j = new int(x);           #I can't quite remember how I did
this precisely.
   
   if (j==1)
      {
      return True;
      }
   else
      {
       return False;
       }
     }

}


Getting more OT now. 

> > Runtime in Python 17.605 seconds (avg over 10 runs)
> > Runtime in Java     12.302 seoncds (avg over 10 runs)
> 
>         Does runtime in Java include startup? Every time you start a java
> program, it has to load a BIG runtime in memory (roughly 30 megs of
> classes -- that's both Java's curse and blessing).

No - it's just - create a datetime object, run iterations, create new
datetime object and compare.

I have no startup lag really. 


> > So yes - if Jython compiles to Java bytecode, and gives that 5 seconds
> > faster performance, but I write it in Python, and it gives me that 27
> > minutes of not messing about counting my braces, I'm in heaven. ( I
> > actually wrote a Python script to count braces.)
> 
>         Oh Ghost. You didn't actually write a Java program using a regular
> text editor, did you?
>         And of course, it's free (and written in Java). http://www.eclipse.org
>

*sigh* I have no net at home at moment, which is very frustrating when
I want to d/l documentation & editors. For the mo, it's all Notepad.
Ick.

Alan Gauld wrote:
>Actually modern C compilers usually mean that well written C
>can outperform even assembler, to write good assembler is just
>so hard that very few people can outsmart a good comiler...

Good to hear, means I can put off the asm adventure for a looong time.
Of course, that will involve C.... :/

Cheers, 

Liam Clarke
-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only ba sic human duty, to take the consequences.


More information about the Tutor mailing list