4 Replies - 455 Views - Last Post: 18 October 2011 - 05:33 AM Rate Topic: -----

#1 Zel2008  Icon User is offline

  • D.I.C Addict

Reputation: 14
  • View blog
  • Posts: 790
  • Joined: 06-January 09

Source code and compiled class files

Posted 17 October 2011 - 12:46 PM

Hi everybody,
I was just compiling my code after a major refactoring, and I noticed that my source code, which takes up 368 KB, takes up more space than my compiled class files, which take up 332 KB. I have 32 source code files and 55 class files, but the class files are still smaller! Obviously, this isn't a problem, but I was just curious, is this a common occurrence? I've never noticed this happening before.
Thanks,
Zel2008

Is This A Good Question/Topic? 0
  • +

Replies To: Source code and compiled class files

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7806
  • View blog
  • Posts: 13,200
  • Joined: 19-March 11

Re: Source code and compiled class files

Posted 17 October 2011 - 12:49 PM

Source files are human-readable, so they're quite verbose. Class files are binary instructions.
Was This Post Helpful? 1
  • +
  • -

#3 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1401
  • View blog
  • Posts: 3,109
  • Joined: 05-April 11

Re: Source code and compiled class files

Posted 17 October 2011 - 12:58 PM

Your java source code is compiled into bytecode, and the JIT (just in time) also may optimize your code. So you cant count on the sizes to be the same
Was This Post Helpful? 1
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Source code and compiled class files

Posted 17 October 2011 - 01:15 PM

Look at the API source code. In many modules there is 10 lines of comments for 1 line of code.
Sure that all the .java are all quite bigger than the generated .class
Was This Post Helpful? 1
  • +
  • -

#5 Zel2008  Icon User is offline

  • D.I.C Addict

Reputation: 14
  • View blog
  • Posts: 790
  • Joined: 06-January 09

Re: Source code and compiled class files

Posted 18 October 2011 - 05:33 AM

Thanks everybody,
Now that you all make your points, that makes a lot of sense. Binary is usually smaller than plain text, isn't it? :) It seems obvious to me now.
Thanks!
Zel2008
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1