I have a website, it is going to be a web app (it's super secret right now). It works, however my source code is far to long. It has 482,921 lines of raw code, split into 244 different web pages, CGI scripts, Perl scripts, Ruby rails, Flash external files etc. It also contains 1,324,000 characters of code. Every time I run the code, my computer freezes up for about 10 mins. Is there a way to compress the code (Preferably to under 100k lines of code and 500,000 characters)?
I am also programming this very quickly, and I estimate that the source code will reach and mloc by this time next year, and this will kill the end user's computer. So I need for this to be a quick process.
Just another thing: I have already gotten a BSOD from running the code, and I have a lot of HDD space and tons of RAM. I am afraid that most of the people who try my software will simply not be able to use it.
Thanks in advance!
Answer:100k lines and 500k characters is 5 characters/line. I guess that's better than the 3 chars/line you say you have now, but it's still dreadful even if you're getting the character counts from a tool that only counts non-whitespace. If if 1.3M characters is the total of file sizes (that's useful for estimating load and download times) then one character (two in Windows) of each line are newline characters.
That means about a third of your source (482K / 1324K) consists of newlines! The fraction is smaller but still lousy if the character count excludes newlines. One tool you might consider is a source compression program. These are frequently used on HTML and scripts to reduce download times. Such a tool will remove all comments and unneeded whitespace. Some will even rename local variables. (This is more to combat reverse engineering than for performance, but it if reduces file sizes, then why not)
You only use this on the debugged deliverable code, not on your development copy, obviously. Even so, it can cause problems with troubleshooting bugs in deployed code. So, there are consequences to consider. (…like: An obfuscator might make perl code actually *easier* to read. :^) I don't use one, but google for "ruby code compression", "html code compression", etc. Each language needs a different tool.
For your code itself, the primary tool for reducing code size is the brain. Factor common code into functions and methods. Use tables to drive the initial construction of objects.
The CGI (including perl) scripts and Rails code won't affect your users, by the way. Those stay on the server. Treat server-side and client-side optimization as separate issues.
Answer:There's no program that will just simply shorten your code, it needs to be done by hand by people with obviously better programming experience then you.
Answer:Like he said above, but it looks like the fact of the matter is that you just have alot of things in your website. I would try taking out somer of the unecessary things, like flash. You can most likely achieve the same affect that flash would give you with another programming language (try html 5 and just simple html/css)
Answer:What the heck are you programming?!!
As far as I know, there is no way to compress your code.
I don't know what kind of app you're writing, but I believe you have made a mistake in architecture of your software, so that it has become this much large.
And about the resources, again, be sure that there is a mistake in your code that you need that much resource.
I have no idea for a quick solution. All I can say you have to check your code (or at least some critical parts) to find where the problem is.
Maybe a profiler can help…
Answer:244 web pages ????
I corrected one of these once: 3850 "pages", one page for every item in the catalogue!!! How stupid can this be?
It ended up with ONE page and a database…
Obviously, efficiency in coding is not your forté!
You just need to add Joomla and another CMS, a few movies, jsquery and your SERVER will crash!
The problem is that you are using a phletore of pieces of code that all contain masses of totally redundant code, images, folders and so on.
Joomla would takes 26Mb on your server, where you would probably need 200k!!!
You are the coder who uses "already written" pieces of code, without streaming them (or, probably, did not even bother going into them).
It is time for you to start "professionaly"…
Scrap ALL your site.
Start writing using a text editor, in HTML, javascript, php and mysql. Use photoshop for your images, structure your database and your folder's tree.
Re-write the new, following what the old code does, and stream EVERY function: you will see that 90% of them are useless (RoR is very good at it!)
Remove methods from classes that you don't call! (A "pdf" class can be several Mb, but if you use only one method of 100 lines, the rest of the whole class can be removed. (In fact, MANY classes can just be removed: it is like to make a function to call a function that calls a function: write ONE function that does the job and you won't need classes!
(remember: most of the code, to run properly, must be in RAM on the server or user's machine. Windows is a particular good waster of space, using classes everywhere)
I bet your WHOLE site can be re-written, manually, about 50Mb TOTAL.
I just completed a FULL e-commerces, interactive, with plenty of images:
Images: 29Mb, Code: 274kb!!!
… and it is in 3 languages, has an admin and a CMS.
(The largest code I wrote was a clone of Y!A, with 570kb of code…)
Answer:Source code length doesn't matter. You need to look into techniques that load your code when the server starts and keep it in memory. Example: mod_perl for Perl code running in Apache.