Why are C/C++ memory sizes smaller than other languages? [Closed]

Asked 1 years ago, Updated 1 years ago, 97 views

Do you want to improve this question?Update your question, Edit this post to be answered with facts and quotes.

Closed to last year

Last year

When you create a program with C/C++, you often have a smaller memory size for compiled programs than in other languages.

I don't know much about compiler specifications, but sometimes I can manage memory by a few tens of percent more compactly than when I wrote the same code in Java.

Why can C/C++ manage memory more compactly than other languages? Are other languages implicitly adding non-code actions to the program?

c++ c programming-language

2022-09-30 17:44

1 Answers

By the way, I wrote Hello, World in C++ and C# languages.Usually, C and C++ languages are larger.I'd like to know an example of compactness.

C language 10,752 bytes.

#include<stdio.h>
int main() {
    printf("Hello World!\n");
}

C++ language 11,776 bytes.

#include<iostream>
int main() {
    std::cout<<"Hello World!\n";
}

C# Language 4,608 bytes.

using System;
namespace CsHelloWorld{
    US>class Program {
        static void Main (string[]args) {
            Console.WriteLine("Hello, World.");
        }
    }
}


2022-09-30 17:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.