torkell: (Default)
[personal profile] torkell
Pet peeve #3 about Java: the lack of destructors.

What I would like to happen:
    public Predator()
    {
        System.out.println("Say hello to " + this);
    }
    
    public ~Predator()
    {
        System.out.println("Someone killed " + this);
    }


What I have to do in Java:
    public Predator()
    {
        System.out.println("Say hello to " + this);
    }
    
    public void finalize()
    {
        System.out.println("Someone killed " + this);
    }

and if I'm wearing my lucky rabbit's foot, the moon is blue, and a black cat is following me, then finalize() might just get called when the Predator gets killed. In fact I'm lucky (it seems) if finalize() gets called at all. Hmm. So much for my bright idea for debugging.


In case you're wondering, pet peeves #1 and #2 in Java are the inability to switch() on a String, and the lack of enums in any sane form.

Date: 2005-02-26 11:26 pm (UTC)
From: [identity profile] olego.livejournal.com
http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

And why would you switch on strings to begin with? :-D Actually, I understand the reason for the pet peeve, it's just that last time I needed that functionality, if..else if did the job.

Date: 2005-02-27 03:40 am (UTC)
From: [identity profile] ralesk.livejournal.com

“glorified byte array in C” — that’s what makes me most sick about C after the glorified pointer-fiddling.

Date: 2005-02-27 09:04 am (UTC)
From: [identity profile] olego.livejournal.com
Dude, give it up about the pointers ^_^. When have you ever needed ** (argv doesn't count), let alone ***?

Date: 2005-02-27 03:06 pm (UTC)
From: [identity profile] ralesk.livejournal.com

Needing half the time a pointer and half the time a true variable is my problem really :P

Date: 2005-02-27 04:44 pm (UTC)
From: [identity profile] olego.livejournal.com
Well, what I do is this:

If I have a main function that calls other functions, main has the object and all other functions have the pointer.

If I have no functional main (i.e. a WinMain, with a message loop), then make a global pointer, malloc it before DialogBox(), and free it right after.

:-)

January 2026

S M T W T F S
     123
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 10th, 2026 10:32 am
Powered by Dreamwidth Studios