Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. I want to know blank line in code increase the program size or not ?
Qt 6.11 is out! See what's new in the release blog

I want to know blank line in code increase the program size or not ?

Scheduled Pinned Locked Moved Solved C++ Gurus
6 Posts 3 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    I want to know the blank line in code increase the program size or not ?

    I want to know cons of it ?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      a developer of code would know that whitespace has no effect on compiled code size.

      responsible use of white space is for the benefit of the reader. code should be written so that a complete idea can be expressed in a single viweable page of code text, details of algorithms broken out into subroutines (which in c++ can be expanded inline by the compiler), and blank lines before and after to logically separate the ideas.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      5
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        The code you see in your program (source code) is not what the computer uses to run. In C++ the code you write is compiled into special data called machine code. This code is generally unreadable to humans without special tools or knowledge. This special code is as compact as the compiler can make it depending upon which mode the code was compiled too (debug, release, etc). It can actually be bigger than the original source code the programmer wrote due to the libraries and needed startup code.

        // comments have no effect on machine code size
        QString something("the spaces            in here will           effect machine code size");
        
        
        
        // The above blank lines will have no effect on machine code size.
        

        You should take a look at how compiling works to understand this concept better.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          In Javascript used for webpages the size of the source code does matter. As the entire source code the programmer wrote is transmitted to the end user. To help with this JS devs often employ minifiers. Once the browser gets this code it is then compiled and run. So technically the running code is what is actually run by the JVM. So in the case of JS the source code size can matter.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          1
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            Lets not talk about the abomination called javascript. God, I miss the simplicity and lack of commercial coersion that was Mosaic.

            The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

            fcarneyF 1 Reply Last reply
            0
            • Kent-DorfmanK Kent-Dorfman

              Lets not talk about the abomination called javascript. God, I miss the simplicity and lack of commercial coersion that was Mosaic.

              fcarneyF Offline
              fcarneyF Offline
              fcarney
              wrote on last edited by
              #6

              @Kent-Dorfman But I use JS every day with QML. ...

              C++ is a perfectly valid school of magic.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved