Don’t Compare Java and Objective-C

“My opinion as an android and iOS developer”

I start as an android engineer on my first career and end up on iOS (because i love the MVC architecture), android is incredible open source OS that grow twice faster than iOS and android using Java in development process which mean if you had learn Java for desktop or web you’ll learn faster develop android app.

As we know that Objective-C is one of language from Apple to build app for iDevice or Mac products It is the main programming language used by Apple for the OS X and iOS operating systems, and their respective application programming interfaces (APIs), Cocoa and Cocoa Touch. This statement is totaly different with Java.

Java is intended to let application developers “write once, run anywhere” (WORA) meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.

If we want to compare the performance in language compare Objective-C and Java is not use because we need compare in many cases and in OS Technology Comparing ARC and Dalvik/ART(start from Kitkat API) also hard to do, but if we talk about metrics in iOS altough the memory is very low you can see your app still smoothly animate the button, but in android probably crash because GC(Grabage Collector) is collect you object to release object on memory.

Each programming language that i mention here are have an own patterns. For me Java pattern are more “Geek” than Objective-C start from method name :

private Button stopFuelButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.Layout.activity_main);

stopFuelButton = (Button)findViewById(R.id.fuel_button);

setLimitGas(R.string.caption_fuel, false, stopFuelButton);
}
protected void setLimitGas(String gasName, boolean fuel, View view) {
// Some Logic here ..
} 

i can said that if you aren’t put the JavaDocs on that method probably your team doesn’t know what’s the meaning from those variable. On that sample as we can see method :

protected void setLimitGas(String gasName, boolean fuel, View view)

are not “human friendly” for me. Meanwhile if i wrote sample code on Objective-C :

- (void)setLimitGasWithGasName:(NSString *gasName) isFuel(BOOL isFuel) andView:(UIView *view)

as we can see here Objective-C code are longer than Java but more easy to read. But Objective-C have a weak point. In Java All you need to set method to be public accessible just type :

Public void someMethodName()

but in Objective-C you need to register the method in .h file :

SomeClassName.h
- (void)someMethodName;

and implement on .m file :

- (void)someMethodName { 
//Some Logic here ..
}

this saga not end yet … in variable declaration java have some fancy method :

public static final int MY_SOCKET_TIMEOUT_MS = 30000; // 30 seconds
private static final int SOCKET_PORT = 3000;
private String email; 
// make button not visible to child / parrent class
private Button myButton;

and so many other sample …

In Objective-C private static simply just need declare on interface :

@interface SomeClassName() <UIAlertViewDelegate> {
//place your static variable here
NSMutableArray someMutableArrayName;
}

but Objective-C have other issue ..

for Java engineer if you want to make an object you don’t need to define what is object status on memory, but in objective-C you can assign object status like :

@property (strong, nonatomic) NSString *appName;

strong mean your object will stay still on memory even if memory warning and need to release some object, nonatomic means multiple thread access the variable (dynamic type) for more detail you probably need to see this

actualy there’s still more to compare beetwen Objective-C and Java but some case can’t just tell like this, if you curious about “are you sure with what you doing?” you need to try by your self simply just create an hello world app, or maybe app with simple button and textview where you can try to pass object.

So The Conclusion Are

Java and Objective-C have a different builder, compiler, IDE and platform compability. My advice is please pick one you like if you like readable code you can choose Objective-C but if you like to develop app in more platform Java is not only using by android so you can use Java for build other platform.

Thank you for spend your time read my articles, any feedback please put on Response.