• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Native (C) code vs VM code in the book

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Poor title, so I'll try to explain:

I see the table of contents mentions image processing with C libs. How much of this (what I call native code) approach is in the book? Just a chapter or two?
Seems, of course, like you'd want to stick with I-wont-call-it-Java-so-Oracle-doesnt-sue-me VM based code just to make life easier, but curious about how/why you'd want to dip into C code and how well that works, etc. That's great that there is at least a bit of that in the book!

 
author
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great question. I would first have you look at http://developer.android.com/sdk/ndk/overview.html and read the section “When to Develop in Native Code.“ In general it is best to go to the NDK when you perhaps want to use something in C or C++ that already exists and you cannot either port it to Java because of time, complexity, or licensing issues. For example one of our clients recently had us integrated a C based DRM system from a large company. That company does not allow you to make change to the DRM system and you essentially have to use their compiled code as is (although they allow cross-compiling and give you the source). So in this case there were real legal/business requirements that forced the use of the C code. In some other cases, such as image processing, image detection, or some other CPU intensive task that does not use a huge amount of memory C might make sense. Furthermore since, in those areas, there is such a wealth of C code that is very well written it would be ease to reuse some C projects and thus those would be good candidates as well. In general though you want to stay away from the NDK unless you have a real need for it.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robi;

Doesn't Dalvik have an equivalent to the JSE VM to hotspot or even a more simplistic JIT for those use cases?
 
robi sen
author
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Augusto,

Yes and thats why I emphasize things like reusing code for various reasons. NDK rarely will increase performance. In some rare cases it might.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To answer the question, it looks like there is one chapter on using C and the NDK.
 
andrew ennamorato
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting. Thanks for the info!
 
reply
    Bookmark Topic Watch Topic
  • New Topic