1

In Programming Logic and Design, 8th edition by Joyce Farrell, she states that

When you use the IDE to create and save a program, you occupy much more disk space than when using a plain text editor.

She uses an example of a number doubling program made in C#. When saved with a simple text editor(Notepad to be specific), the program (is said to) only takes up 314 bytes of storage, whereas it takes up over 49,000 bytes when compiled with Microsoft Visual Studio IDE.

The only difference between the two programs is that the one compiled in Visual Studio is shown to have imported three additional things:

using System.Collections.Generic;
using System.Text;
using System.Linq;

The rest of the program for the notepad version:

using System;
public class NumberDoublingProgram
{
    public static void Main()
    {
        int myNumber;
        int myAnswer;
        Console.write("Please enter a number >> ");
        myNumber = Convert.ToInt32(Console.ReadLine());
        myAnswer = myNumber * 2;
        Console.WriteLine(myAnswer);
    }
}

My final question is, is her statement that compiled programs take up more space true for every language/compiler as a blanket statement? Is it acceptable to use this as a generalization for every programming language out there, or is this false information/debunkable?

Thank you for your time.

  • 1
    C# compiled code *does not* include any `using` statements... I suspect you use "compiled" in some meaning that does not match usual "converting textual representation of code to intermediate/executable representation"... The statement in the post may be valid depending on your definition of "compile". – Alexei Levenkov Jan 26 '17 at 05:16
  • Are you talking about the C# file, the project as a whole, or the resulting program? – EJoshuaS - Stand with Ukraine Jan 26 '17 at 08:01
  • @AlexeiLevenkov The code snippet is what was typed into Visual Studio/Notepad, so I guess it was the source code for the program, not the compiled program. I am trying to see if the space on disk varies between the compiled programs, when saved on Visual Studio and on Notepad. I will do some testing today. – roteendamoon Jan 27 '17 at 01:36

2 Answers2

0

Code written with an IDE will compile the same as that written in NotePad. The difference is that the IDE adds files which allow you to better organize your project and may include other features which consume more disk space.

Choose the development environment that best suits your project needs. An IDE can be extremely helpful for a large project. NotePad is a great way to write code for a small program.

user2182349
  • 9,569
  • 3
  • 29
  • 41
0

The size of the resulting program depends on the compiler (as well as its configuration - e.g. release mode vs. debug mode), not whether you created it in an IDE or Notepad.

To answer the second part of your question, things that take one line of code in C#, Java, or C can take several lines of code in the resulting executable (because higher-level languages abstract away some implementation details; for example, there's a fair bit of assembly language that goes on to enter and exit a method, but that's hidden from you when you use C, to the extent that many people don't realize that there even is any overhead to doing a method call). This is why the source code file is often smaller than the resulting executable.

To illustrate this, you can see some good examples of C# and the resulting CIL code here.

A few more answers describing what's in an executable:

Community
  • 1
  • 1