News for hackers. Stuff that matters.
Re:Java Was Strongly Influenced by Objective-C by sippndipp on Wednesday December 26, 2012 @09:14PM (#4972007)
So how comes that they missing out all the cool features like "performSelector", "respondsToSelector"? Sure the whole OOP part may comes from Objective-C (SmallTalk to be precise) but the dynamic parts were poorly executed.
Re:Java Was Strongly Influenced by Objective-C by koenigdavidmj on Wednesday December 26, 2012 @09:31PM (#4972066)
Well, they're a lot longer to type, but you can use [1] to get a method (and handle the error to see if it exists) and [2] to call the method on a given object.

1: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class...

2: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/refle...

Re:Java Was Strongly Influenced by Objective-C by aardvark179 on Thursday December 27, 2012 @09:37AM (#4973422)
Java takes its most basic ideas about how OOP is done from the Simula and C++ side, rather from Smalltalk and Objective-C. In that world view you don't ask if something responds to a selector but rather whether it's an instance of a suitable interface. There are still occasions when responsa to/perform is a nice pattern but its often better done with lambdas. Perform also tends to need annoying special casing to optimise.

The exception I'd make to that is meta-programming—especially for ORM libraries—where responds to, perform, and lambdas together produce some lovely patterns to marry a schematic to a dynamically generated object hierarchy.

Re:Java Was Strongly Influenced by Objective-C by malbs on Wednesday December 26, 2012 @09:29PM (#4972058)
Not to mention the fact that they completely ignored class methods.

No, static methods do not count.

Re:Java Was Strongly Influenced by Objective-C by jcampbell1 on Wednesday December 26, 2012 @10:19PM (#4972195)
The only difference I know of is that you can override inherited class methods, but not in Java. Is that really an important feature that you use? I suppose you could use it to do "factory" stuff, without an actual factory class.
Re:Java Was Strongly Influenced by Objective-C by malbs on Wednesday December 26, 2012 @10:22PM (#4972207)
exactly!

Imagine my surprise when I disovered Delphi has class methods too, but they were not copied to C#. I guess most of the time they're not particularly useful, but when you do need to create some factory code, having pure virtual class methods (template methods), is really useful.

Downside w/ Delphi is the metaclasses do not implicitly exist - you have to manually define it, eg TMyObjectClass = class of TMyObject; They should just be implicity, when you define a class, the metaclass is defined too. I guess when they first designed it memory constraints were still a consideration

Re:Java Was Strongly Influenced by Objective-C by i386 on Wednesday December 26, 2012 @10:14PM (#4972176)
Out of curiosity, why do statics not count for class methods?
Re:Java Was Strongly Influenced by Objective-C by hboon on Wednesday December 26, 2012 @10:30PM (#4972234)
They are closer to global functions that are attached to classes and don't support inheritance the same way as instance methods. e.g. if a subclass implements a static function with the same signature as its parent, and you call it with the parent class, it invokes the parent class version instead of the subclass version.

Class-side methods in Smalltalk are inherited, working with classes (as an object) is analogous to how instance-side methods work with instances (also objects). So e.g implementing and using factory methods are simpler in Smalltalk and similar languages.

Edit: grammer and typos.

Re:Java Was Strongly Influenced by Objective-C by malbs on Wednesday December 26, 2012 @10:17PM (#4972186)
class methods are virtual
Re:Java Was Strongly Influenced by Objective-C by stcredzero on Wednesday December 26, 2012 @11:23PM (#4972321)
(SmallTalk to be precise)

Smalltalk to be precise.