Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 4th, 2006, 2:16 AM   #11
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by v0id
C++ got it!
It has operator overloading and multiple inheritance, but not mutable classes.
Arevos is offline   Reply With Quote
Old Aug 4th, 2006, 2:19 AM   #12
v0id
Hobbyist Programmer
 
Join Date: Apr 2006
Posts: 155
Rep Power: 3 v0id is on a distinguished road
Oh, I thought that, thanks.
I'm not that familiar with C++ yet. :o
__________________
-- v0id
v0id is offline   Reply With Quote
Old Aug 4th, 2006, 12:08 PM   #13
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Quote:
Originally Posted by Arevos
I'd say Java's error handling systems were about average, here. It doesn't really boast any advanced error prevention devices, such as the design by contract methodology found in Eiffel, or the NullPointerException prevention syntax found in Nice.

At a snail's pace! Improvements to Java seem glacial compared to most other languages (especially Java's main competitor; C#).
I must be confused about design by contract and NullPointer Exception prevention, because I thought it had both of those.

As for your last comment, I never really thought about that! But choosing C# as a language would not be as wise as choosing .NET as a platform.
Harakim is offline   Reply With Quote
Old Aug 4th, 2006, 1:54 PM   #14
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by Harakim
I must be confused about design by contract and NullPointer Exception prevention, because I thought it had both of those.
Not natively. There are some libraries around that can give Java some design by contract functionality, but it's not built into the language itself.

Eiffel allows developers to define preconditions and postconditions for functions, and class invariants for classes. A precondition validates function input, a postcondition output. A class invariant is a statement that is always true about a class. The idea behind this is that any fault in the program is caught as soon as possible.

The NullPointerException prevention in Nice is also rather interesting. In Java, any reference can be set to null. In Nice, only references with the ? prefix can be set to null:
?String foo = "Test";
String bar = foo;    // compiler error
But we can convert ?String to String with a explicit test:
?String foo = "Test";
if (foo != null) {
    String bar = foo;    // compiles okay
}
Nice also has similar requirements in place to prevent casting errors; objects must be explicitly verified that they have the correct type. Java does not have this error checking capability.

Incidentally, Nice also has pre- and postconditions, though not class invariants.
Arevos is offline   Reply With Quote
Old Aug 4th, 2006, 6:10 PM   #15
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5 lectricpharaoh will become famous soon enough
@Arevos: Semi-OT, but what is a mutable class, and where would it be used? By your comments about Java and C++ lacking this, I assume you mean something beyond a class with mutable members.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is online now   Reply With Quote
Old Aug 5th, 2006, 9:10 PM   #16
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
It does however have a class loader, which I imagine you could use in that respect. I guess that wouldn't be a very good solution in some cases.
Harakim is offline   Reply With Quote
Old Aug 5th, 2006, 9:20 PM   #17
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 6th, 2006, 2:44 AM   #18
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by lectricpharaoh
@Arevos: Semi-OT, but what is a mutable class, and where would it be used? By your comments about Java and C++ lacking this, I assume you mean something beyond a class with mutable members.
By "mutable class", I mean a class where everything that is set at the time the class is created (such as its name, methods and inherited base classes), can be altered at runtime.

For instance:
python Syntax (Toggle Plain Text)
  1. >>> class Foobar:
  2. ... def apply(self):
  3. ... print "Foobar"
  4. ...
  5. >>> Foobar
  6. <class __main__.Foobar at 0xb7e1ee3c>
  7. >>> Foobar.__name__ = "Barfoo"
  8. >>> Foobar
  9. <class __main__.Barfoo at 0xb7e1ee3c>
  10. >>>
  11. >>> Barfoo = Foobar
  12. >>> del Foobar
  13. >>> Barfoo
  14. <class __main__.Barfoo at 0xb7e1ee3c>
  15. >>>
  16. >>> Barfoo().apply()
  17. Foobar
  18. >>>
  19. >>> def apply(self):
  20. ... print "Barfoo"
  21. ...
  22. >>> Barfoo.apply = apply
  23. >>> Barfoo().apply()
  24. Barfoo
Quote:
Originally Posted by Harakim
It does however have a class loader
In order to get similar functionality, you'd not only have to use the class loader, but have to resort to lots of dynamic bytecode generation. Even then, it's such a complicated way of doing things that there becomes little benefit to attempting it in Java.

Mutable classes are really a feature that only dynamically typed languages can have.
Arevos is offline   Reply With Quote
Old Aug 6th, 2006, 11:55 AM   #19
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Mutable classes, methods as objects...I see few compelling reasons.

But multiple inheritance! Someday, hopefully.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC