-2

I have a problem. I am creating website and it is working well. But my boss told me that I shouldn't indent my codes because it can affect memory space because it reads the spaces or every indention in the code? Is this true? If yes can you provide me a reference for that so that I can defend myself. My boss show me some website in Japan that didn't indent their code and He ask me If indention is a program standard. If yes why some of the website in Japan didn't indent their code. It is all align left. I forgot some of the websites He showed me because it is in Japanese.

That's all thanks.

Here's the website that has no indention

http://www.dior.com/couture/home/ja_jp

Jerielle
  • 7,144
  • 29
  • 98
  • 164
  • some programming languages like F# and python are space-sensitive. Otherwise, parsers do not use spaces to build an AST, the abstract representation of your program. – anguyen May 14 '14 at 02:28
  • 1
    Your boss needs to stop worrying about that and make sure the code works. Indented code is for readability in most cases (depending on if the code reads white space or not). If the code works 100% and there are no bugs or errors, you can delete the white space (read here : http://c2.com/cgi/wiki?TabsVersusSpaces) But it makes no difference. – ntgCleaner May 14 '14 at 02:29
  • Wow is it in minified version? :) – Jerielle May 14 '14 at 02:42

1 Answers1

4

For compiled code, it makes no difference whatsoever unless whitespace is significant in the language and means something that impacts memory usage.

Code transmitted over a network (HTML, CSS, JS, XML, etc.) can be made marginally smaller by removing spaces (in addition to compressing the output, which is considered a best practice). But this should never impact coding style and readability!

Whitespace removal can be done automatically when the page is served. This will actually increase the load on the server slightly (CPU, possibly memory), not reduce it. If the bandwidth savings are worthwhile (doubtful, if compression is enabled), it is an acceptable trade.

This answer shows the savings (or lack thereof) achieved by removing whitespace.

But my boss told me that I shouldn't indent my codes because it can affect memory space because it reads the spaces or every indention in the code?

"It" could refer to the web server sending the content or the browser reading the content.

  • Server: must send bytes of data from disk/memory in response to a request. So yes, extra whitespace may take a trivial amount more memory if the data is buffered and/or cached.

  • Browser: the browser can discard whitespace it doesn't need. It may never use any memory at all for those extra bytes of whitespace.

So (to be generous) your boss is right, but he is focused on the wrong thing. The savings (if at all) is measured in bytes and nanoseconds.

  • There are many, many other things that can be optimized first and will yield much more substantial benefits.

  • Hurting developer productivity is expensive. People indent code to make it more readable, and lack of readability equals lost productivity.

Community
  • 1
  • 1
Tim M.
  • 53,671
  • 14
  • 120
  • 163