Currently, most mobile devices are smartphone iPhones and androids. Do you know the upper limit of the size of each app? As of August 2020, the iOS app is 4GB and the android app is 100MB.
Looking at this, there is a big difference ... I wonder if android uses a method to download data later for large-capacity games. I haven't written the heap in detail, but since the terminal has a few GB of memory, it shouldn't be a big problem.
However, what I would like to talk about this time is the future phone (= feature phone) that was active as a mainstay before the birth of smartphones, and the story of DoCoMo's i-appli.
I would like to introduce that the early development method of DoCoMo's i-appli was the result of tearful efforts.
Time goes back to the era of feature phones. I recognize that it was DoCoMo's i-appli that pulled the feature phone app world, but what was the size limit at that time?
The following is the information of the application on the DoJa-1.0 profile that was released at the beginning.
Model | App size (KB) | Heap capacity(KB) |
---|---|---|
FOMA N2001 | 10 | 96 |
FOMA N2002 | 10 | 560 |
FOMA P2101V | 30 | 1100 |
FOMA D2101V | 10 | 128 |
FOMA P2002 | 10 | 560 |
FOMA SH2101V | 30 | 1024 |
FOMA T2101V | 30 | 1105 |
Official page https://www.nttdocomo.co.jp/service/developer/make/content/spec/iappli/#notice05
The minimum app size was 10KB and the heap capacity was 96KB. There is a separate native heap, and it seems that the memory on the terminal side can be used a little, but this capacity in the pure Java part.
The app size is a Jar file that includes bytecode compiled from code and resources such as images. This was limited to 10KB (10240 bytes).
You may only be conscious of it, so let's check how much it is. However, it is difficult to build an i-appli development environment, so we will compare with the android app size as of August 2020.
I think I chose an app that seems to have relatively few functions, but MB units are natural. Since things and times are different, it is not possible to make a general comparison, but I cannot imagine that it will fit within 10KB.
I know that the size of the i-appli is extremely strict, but I wonder how it was made. The only element to scrape is the program.
It's true that you can't do what you want because you'll run out of features if you cut the program, but there's one way to reduce the size without reducing the features. That is to make variable names, class names, and method names smaller.
The code is written in a fairly appropriate way, but for example, it looks like this.
Change before
public class MainFrame {
private static final String TITLE = "Sample app";
private static final String ERROR_MESSAGE = "An error has occurred";
public void showFrame() {
try {
//Some processing
} catch (Exception e) {
showMessage(ERROR_MESSAGE);
}
}
public void showMessage(String message) {
//Message display processing
}
}
After change
public class F {
private static final String A = "Sample app";
private static final String B = "An error has occurred";
public void s() {
try {
//Some processing
} catch (Exception e) {
m(B);
}
}
public void m(String s) {
//Message display processing
}
}
If you reduce the number of characters in the variable name and method name, the number of characters written in the compiled class file will decrease, so you can expect a reduction in size. Anyway, it's an energy saving program.
A program of this size can still be read, but it is obvious that the more you build it, the worse it becomes. How did you clear this problem?
After narrowing down his wisdom, his ancestors decided to use something that the Java language does not. It is a preprocessor often used in C languages.
Specifically, write the following code.
Preprocessor version code
#define _MainFrame F
#define _TITLE A
#define _ERROR_MESSAGE B
#define _showFrame s
#define _showMessage m
public class _MainFrame {
private static final String _TITLE = "Sample app";
private static final String _ERROR_MESSAGE = "An error has occurred";
public void _showFrame() {
try {
//Some processing
} catch (Exception e) {
_showMessage(_ERROR_MESSAGE);
}
}
public void _showMessage(String s) {
//Message display processing
}
}
The syntax below means converting the letter "_MainFrame" to the letter "F".
python
#define _MainFrame F
This part is not Java syntax, so of course it cannot be compiled with a Java compiler. So let's go through the preprocessor. Then, the following code is completed.
public class F {
private final String A = "Sample app";
private final String B = "An error has occurred";
public void s() {
try {
//Some processing
} catch (Exception e) {
m(B);
}
}
public void m(String s) {
//Message display processing
}
}
Now that you can compile it, all you have to do is build normally.
By passing the code with macros in two stages, preprocessor → Java compiler, you can reduce the size while improving readability. I think it was hard because I can't use the IDE.
This article is based on the idea of using a preprocessor that I saw on another site nearly 10 years ago. The site doesn't exist anymore, but I wrote it because I wanted to keep the idea.
Recommended Posts