{"id":22927283,"url":"https://github.com/abarrak/why-compiled-languages","last_synced_at":"2025-05-13T01:47:38.322Z","repository":{"id":44684203,"uuid":"441692021","full_name":"abarrak/why-compiled-languages","owner":"abarrak","description":"A simple experiment for compiled/dynamic languages comparision.","archived":false,"fork":false,"pushed_at":"2024-11-15T18:03:08.000Z","size":348,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-13T01:47:32.844Z","etag":null,"topics":["cpp","csharp","go","java","javascript","python","ruby"],"latest_commit_sha":null,"homepage":"https://whycompiledlanguages.com/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abarrak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-25T14:08:32.000Z","updated_at":"2023-03-05T08:20:15.000Z","dependencies_parsed_at":"2022-09-12T08:01:13.591Z","dependency_job_id":null,"html_url":"https://github.com/abarrak/why-compiled-languages","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarrak%2Fwhy-compiled-languages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarrak%2Fwhy-compiled-languages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarrak%2Fwhy-compiled-languages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarrak%2Fwhy-compiled-languages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abarrak","download_url":"https://codeload.github.com/abarrak/why-compiled-languages/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856615,"owners_count":21974576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","csharp","go","java","javascript","python","ruby"],"created_at":"2024-12-14T09:14:07.201Z","updated_at":"2025-05-13T01:47:38.300Z","avatar_url":"https://github.com/abarrak.png","language":"C#","readme":"# Why Compiled Languages?\n\nThis is a very simple experiment to demonstrate the importance of compiled languages over dynamic or interpreted languages when it comes to system programming or high degree of efficiency.\n\n## Experiment\n\nA simple loop operation to sum up the numbers from 1 to 1,000,000,000 (one billion).\n\n## Execution\n\nClone the repo, then open `src/` directory.\n\nC++ run:\n```shell\n$ g++ cplusplus.cpp -o cpp -O3\n$ ./cpp\n```\n\nJava run:\n```shell\n$ javac java.java\n$ java Java\n```\n\nC# run:\n_Note: use `mono` on macOS/linux only._\n```shell\n$ csc csharp.cs\n$ mono csharp.exe\n```\n\nPython run:\n```shell\n$ python python.py\n```\n\nRuby run:\n```shell\n$ ruby ruby.rb\n```\n\nJavascript (node) run:\n```javascript\n$ node javascript.js\n```\n\nGo run:\n```shell\n$ go build go.go\n$ ./go\n```\n\n## Evaluation\n\nTo obtain the time spent on execution, measure the last line of each run with `time` multiple times and get the average.\n\nFor example:\n\n```shell\n$ time java Java\n...\nreal\t0m0.395s\nuser\t0m0.361s\nsys\t0m0.028s\n\n$ /usr/bin/time -l java Java\n...\n22679552  maximum resident set size\n```\n\n## Results\n\nResults breakdown (macOS mid 2015, 2.5 GHz Quad-Core Intel Core i7, 16 GB RAM):\n\n| Language    | Elapsed Time (second) | Memory (MB) |\n| ----------- | --------------------- | ----------- |\n| C++         |       0.015           |     7.49    |\n| Java        |       0.39            |     23      |\n| C#          |       1.172           |    11.88    |\n| Ruby        |       21.77           |    13.45    |\n| Python      |       17.89           |    4.66     |\n| JS (node)   |       0.873           |    22.97    |\n| Go          |       0.284           |    1.56     |\n\nClearly, the way of optimization of this pure calculation logic in compiled versions as we see in static compiled languages outperformed the interperted languages (except `nodeJs`) drastically in terms of speed. Additionally, `Java` and `C#` results show the outstanding optimization made to the compiler and runtime `JVM`/`CLR` to perform nearly identical to the low level languages, for such essential looping computing. \n\nThe two figures below show the comparison between `C++`, `C#`, `Java`, `Ruby`, and `Python` languages in terms of both speed (time) and memory (space).\n\n\u003cimage src=\"https://raw.githubusercontent.com/abarrak/why-compiled-languages/main/output/time.png\" width=\"80%\" /\u003e\n\n\u003cimage src=\"https://raw.githubusercontent.com/abarrak/why-compiled-languages/main/output/space.png\" width=\"80%\" /\u003e\n\n\n## Contribution\n\nAll PRs are welcome for other languages or improvements [on Github](https://github.com/abarrak/why-compiled-languages).\n\n## License\n\nMIT.\n\n## Contributors\n\n- Abdullah Barrak [(@abarrak)](https://github.com/abarrak).\n- Eliot Akira [(@eliot-akira)](https://github.com/eliot-akira).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabarrak%2Fwhy-compiled-languages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabarrak%2Fwhy-compiled-languages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabarrak%2Fwhy-compiled-languages/lists"}