📜 ⬆️ ⬇️

How bad should the code be?

Eric Lippert is a Microsoft veteran who has worked for the company for 16 years and is behind the development of VBScript, JScript and C #.

Last week, in the comments to one of the articles, there was a dispute about the role of low-level optimization in programming, and I remembered Eric's related article. It was written at the end of 2003, and although the reality has changed somewhat since then, the principles have remained the same. You can mentally replace ASP and VBScript with PHP, JavaScript, or another scripting language of your choice.

I tried to translate this article in 2005, but the Russian text was clumsy at that time, so this translation is new and not previously published, in accordance with the UFO requirements. In the translation of the blog of Eric Lippert, this text is also not present - probably, it is too old for them.


I already wrote a lot about the speed of scripts, but so far I have not spoken about the fact that I consider many tips on optimizing them to be at least stupid, and even frankly harmful.
')
For example, in seven years at Microsoft, I received dozens of questions similar in nature to this question asked in the late 1990s:
VBScript, Dim , . - ?
! , , n n . n , . , VBScript ? , ! :

№1

— . VBScript , -
Function foo()
    Dim bar
    Execute("bar = 123")

, VBScript . .
, ? , , :
50 . , , . , : VBscript 256 — , , .

— Pentium III 927 , .. 50 ( ).

, , , , — , . , .

, . !

, — . ; , 8- , — .

, , . . , VBScript , :
  1. , ;
    —, ,
  2. , . .

! , . , , , - — , ?

№2


, , 50- . — , . , , , , . . : , . «» «». !

, .

— , , , , , , . VBScript, — . , «VBScript — , » — , .

-, , , . — :

?


— , «» — .

, , « And 1, Mod 2, And, » — VBScript . , , , . , — .

, — , — , «» . , « » — , , , .
  1. .
  2. . ? ? ? ? ?
  3. , .
  4. .

, . , , , PDP-11 — , . , - — , . , — «» .

. , . — , , 200 , . - — 25 / 50 / 20 . , 10- 25 ? 14 / .

— , , . , , , , . , , .

, ; , — , , — , . , , — . — , — . , : .

: , . . . « Dim»: , Dim 50 . — . , . .

Source: https://habr.com/ru/post/166341/


All Articles