Is iOS the only platform that's native compiled?

Discussion in 'iOS Programming' started by 1458279, Oct 18, 2014.

  1. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #1
    Years ago I looked into Android and WP.. At that time, Android used Java running in a VM and it didn't even offer JIT compiling. I haven't looked into WP for a long while so I have no clue what they offer, but it's probably C# and their LIM (or whatever they called it) as a part of .net system.

    Q. I understand the ObjC/iOS is a native code compiler and this offers a higher level of performance / security. Does Android / WinPhone offer this or is it just Apple?

    I'm not asking about cross platform tools, just looking for the native stuff.
     
  2. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    Many of the UI and supporting frameworks in Android are indeed Java-based. But it also possible to write some of the logic in Android apps in native C/C++ code if you want. JNI provides a bridge between the Android Java layer and native code. I suppose you could layer your application logic in Android to make the Java layer be very thin and provide most of the core logic in native code. I'd suspect some applications take this approach.

    You could do the same thing with iOS apps. The iOS UI and associated frameworks are in Obj-C. But you could keep the core application logic in C or C++ and interact with the UI via Obj-C layers.

    In this way, application logic could be portable between iOS and Android if you designed your app appropriately. Same C/C++ backend with either a Java/JNI/Android front-end or Obj-C/iOS frontend.
     
  3. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #3
    Since Android 2.2, Android can use the "Dalvik" runtime that does make use of just-in-time compilation. More recently they came out with the Android Runtime that does ahead-of-time compilation, meaning that the bytecode is optimized and compiled during installation, which is efficient.

    It would not be necessary for Apple to use just-in-time or ahead-of-time compilers like Google needs to with Android, since Google has to support thousands of phones it doesn't make itself and Apple makes both the software and the phone. So apps written for the iPhone are compiled before even installation. This is efficient since an iOS device will be getting the most optimized compiled code before it is even installed.

    I am not sure if Google offers any native-code compilation. I don't think it would be a good idea since apps written for android have to support sooooo many different types of devices that it would be more efficient just to compile the bytecode on the device itself.

    mfram obviously knows a lot more about this than I do, and a lot of what I've written here are from old memory so I may be incorrect.
     
  4. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #4
    Thanks!

    Looks like Android has change a bit over the years, because last I dug into it, it wasn't even JIT.

    One more question about security...

    I understand that any app (iOS/Android/WP) can be decompiled/cracked, but as I understand it with iOS you don't get very readable code and it's near worthless to use.

    I remember Android apps getting hacked and Google removed some 50 apps because they were rebadged by someone other than the original programmer.

    Is this still the case, or is Android more secure now?

    I'm not talking about malware, I understand that's a whole different issue.

    Thanks again.
     
  5. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Decompiling and security have nothing to do with each other. OpenSSL is open source, so the source code is readily available (even better than decompiling), but that doesn't make it insecure. Windows is closed source, but that doesn't make it secure. All decompiling will ever do is revert compiled code to source code, so it doesn't have anything to do with security.

    The following is my understanding of how different languages are compiled/decompiled (I'm by no means an authoritative source on the matter and I defer to anyone who says I'm wrong here)

    - Compiled code in most languages removes all of the comments - this is true for all of the languages you mentioned in your post. This means the comments from the original source code can't come back. (Python does not do this... some comments are kept as DocStrings so that you can inspect the code at run time. Other comments are discarded.)

    - In C and C++, all symbol names are removed and replaced with numeric identifiers. In Obj-C and Java, this happens with some variables, but method names are left intact. This helps Obj-C be a dynamic language. Java does it to facilitate Reflection and so that you can write plugins for compiled java applications without needing the source code of the application. So local variable names can't be brought back during decompilation, but public methods and package names can be brought back.

    - All type checking in Java is done prior to compilation - during compilation, types are thrown out. None of the other languages keep types around in the compiled code, either. Based on which publicly available libraries are being called with each variable, it's possible to come up with some of the types during decompilation.

    - Functions and loops and whatnot are replaced with what amounts to GOTOs. What was originally a for loop may become a while loop during decompilation and vice-versa.

    Any code in any language can be decompiled, modified, and recompiled. I wouldn't worry about it, though.
     
  6. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #6
    Thanks!

    I guess I wasn't very clear on the security issue. I heard in the past the an Android app could be stolen very easily. I guessed the process was to decompile and put your name on it, then recompile. Years ago a bunch of apps got pulled by Google because they weren't from the original developers.

    I had a program decompiled before and stolen from me, I didn't even know a program could be decompiled at the time. The contract at the time was pay-at-the-end... I never got paid.

    I'd hate to put in a lot of time into something special and have someone see how it was done or have them slap their name on something that wasn't theirs.

    Sometimes there's a thin line between your app and someone else's app, and that could be the way it handles things. I've done this before where I find a better way of handling something, it can really make a difference when your trying to make a sale.

    This would be for business apps where you are trying to lock in a market and you put effort into finding things that they want and offering that in the app in some way it's not done otherwise.

    Not the kind of thing you'd want other finding out how you do it. Pretty standard in the business world, where a business protects how they do things better than others do.

    I've heard in the past, that one trick is to move special code to a lower level language in order to make the decompiled code harder to read.

    There was a product years ago that would scramble things such that the decompiler wouldn't be able to read it, but that was language/compiler specific.
     
  7. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #7
    Actually, I was also concerned about the speed of the apps on different platforms. There's a lot of companies that already use tablets and it's hard to get them to buy all new equipment just to run yours.
     

Share This Page