3

I do not understand why the size of a very simple compiled program is around 8Mb. This does not include the JVM I assume?

Here is a simple Ballerina program

import ballerina/io;

type Score [string, int, int];

public type Person object {
    int age = 0;

    public function allowedToDrink() returns boolean {
        return self.age > 17;
    }

};


public function main() {

    io:println("Hello, World");
    Score result = ["a", 10, 10];



}

which is 316 bytes. When I compile this program the produced jar is around 8Mb.

My questions are?

  1. What can I expect if I add new modules? Will the size grow dramatically?
  2. What does this jar include? Does it include all the standard modules?

BTW I do like the idea of an integration language. Let's hope that more people are willing to pick up Ballerina. It's always a good idea to learn a new language now and then, especially languages with novelties.

Rudolf
  • 107
  • 1
  • 10

1 Answers1

5

The generated jar is so large because it packs all the dependencies that need to run that Ballerina program stand alone as a jar. It does not pack JVM or any code we can find in the JVM. It does pack standard library modules which your program depends on, and their dependencies.

  1. It would not grow drastically when you add new modules. I'm expecting addition of kilobytes (10kb to 100kb)

  2. Ballerina runtime libraries (this takes the large portion of the space) + standard libraries.

Note: Edited the answer to reflect @Sameera's correction.

Dhananjaya
  • 1,510
  • 2
  • 14
  • 19
  • Thank you. That's what I wanted to know and wanted to hear :) – Rudolf Mar 04 '20 at 22:25
  • 2
    I would like to clarify something here. Ballerina compiler does not package all the standard library modules into the executable jar. It packages only the standard library modules that you've imported and their transitive dependencies. – Sameera Jayasoma Mar 06 '20 at 18:04