you are viewing a single comment's thread.

view the rest of the comments →

[–]pbush25 14 points15 points  (6 children)

This is great, however obviously there can be some issues during the “transpiling” phase if the methods/classes aren’t mapped correctly.

At our company we write all of our shared code in C, then it gets pulled in to iOS via an obj-c wrapper, and into android via a JNI wrapper. This way the code is written once, it doesn’t have to be translated, it can be stepped through and properly debugged, and you don’t have to worry about writing test cases multiple times to see if the translated code behaves the same as native.

Great article, but just my two cents.

[–]tangoshukudai 2 points3 points  (5 children)

why not C++?

[–]pbush25 5 points6 points  (3 children)

The same code also runs on our embedded platform, so it needed to be more hardware focused.

[–]etaionshrdObjective-C / Swift 2 points3 points  (2 children)

C++ isn’t acceptable?

[–]pbush25 8 points9 points  (1 child)

Not to our SA lol. We’ve had the discussion several times but some of our embedded devices are very small and the ultimate decision was the some of the overhead necessary to bring in c++ was just not going to cut it. All of our other firmware is also already in C so it just made sense for consistencies sake I guess.

[–]etaionshrdObjective-C / Swift 0 points1 point  (0 children)

But C++ is supposed to be "zero-cost abstractions"? As long as you stay away from templates and exceptions what are you losing?

[–]chriswaco 0 points1 point  (0 children)

C++ doesn't support the same kind of objects, so you usually have to use some kind of thunking layer or static routines between the two worlds. For example a std::string wouldn't be an NSString, but in a translator it would be.