Ranch Hand
Posts: 104
 

  • Mark post as helpful 
  • send pies 
  • Quote 
  • Report post to moderator
 
 
How does Codename one compare with React native? Why one should choose one over another?
 
 
Author
Posts: 32
6 

  • Likes 2 
  • Mark post as helpful 
  • send pies 
  • Quote 
  • Report post to moderator
 
 
The tools are pretty different. Here are a few high level differences: 

– Codename One uses Java or Kotlin. React Native uses JavaScript 
– Codename One compiles to native. React Native calls native code from JavaScript 
– Codename One’s development process works in a Java IDE where you use the Codename One simulator. You can then build a native app without the native SDK or hardware. E.g. you can build an iOS app without a Mac. React native uses the native SDK’s for development 
– Codename One is a Write Once Run Anywhere framework with one code for everything. React Native is opposed to that 
– Codename One uses lightweight architecture. React native works with system widgets only 

The last point is core to everything that’s Codename One. It means Codename One draws almost all of the widgets. This allows 100% portability as the code is Java, so what you see in the simulator works on the device. It allows you to just override paint and draw whatever you want. You can control every pixel on the screen… Like Swing or JavaFX. But here’s the cool part… Heavyweight mixing. 

To write an app like Uber you need Google Maps. That’s a native OS widget, it’s implemented as a native widget but the cars on top are Codename One Components that draw on top of it. AFAIK Codename One is the only mobile framework that allows that.

 
 
Greenhorn
Posts: 9
 

  • Mark post as helpful 
  • send pies 
  • Quote 
  • Report post to moderator
 
 
I’m a fan of CodenameOne and have used it for a mobile app that talked to Bluetooth.  I have recently been experimenting using React for creating the same app.  So, here are some additional differences based on my experience: 

 – Since bluetooth is an asynchronous-serialized protocol (You can only request one thing at a time, and you have to wait for the response, but the request is a non-blocking “network like” call), I find the Promise architecture of JavaScript be cleaner than the callback structure of the current CN1 bluetooth library.  Of course, a new library could be created and added to the open source to remedy that (its one my plate) 

 – Your mobile development does not transfer to Web development since one is Java and one is React/JavaScript.  However, there is a nice tool called JavaSweet (JSweet) that will convert your Java into JavaScript.  There are a few quirks, but it works for the most part.  I’ve used it to convert my DB and app model components for the React environment. 

 – CodenameOne based on Java is strongly typed, which I like.  So, for me I had reconfigure my React environment to use TypeScript in order work in a similar fashion with React. 

 – CodenameOne’s image processing is automatic and does the hard part of scalling images for different platforms (so you don’t get stretchy or scruntchy looking images), where as React is a more manual process. 

 
 
Shai Almog
Author
Posts: 32
6 

  • Likes 1 
  • Mark post as helpful 
  • send pies 
  • Quote 
  • Report post to moderator
 
 
Codename One has a JavaScript port that builds a web runnable version of your app seamlessly. The Bluetooth support in Codename One isn’t as great as some other features because it’s a port of a Cordova library. If there was more demand we could have made something more powerful that leverages the advantages of threads etc.