Language-independent vs. language-dependent Most high-level programming languages share common programming constructs and abstractions, such as branching constructs (if, switch), looping constructs (for, while), and encapsulation constructs (structures, objects). Thus, similar optimization techniques can be used across languages. However, certain language features make some optimizations difficult. For instance, pointers in C and C++ make array optimization difficult; see alias analysis. However, languages such as PL/I that also support pointers implement optimizations for arrays. Conversely, some language features make certain optimizations easier. For example, in some languages, functions are not permitted to have side effects. Therefore, if a program makes several calls to the same function with the same arguments, the compiler can infer that the function's result only needs to be computed once. In languages where functions are allowed to have side effects, the compiler can restrict such optimization to functions that it can determine have no side effects.
lAnGuAge-indEPeNDenT vs. lAnGuagE-dEPendEnT moST HigH-leVel proGRaMming LanguAges shAre commoN progRAmmIng coNStrUCts ANd aBsTRaCtiOns, SucH aS branchINg coNsTruCts (if, swiTch), LoopinG CONsTrUcts (fOr, whILe), AnD EnCapsuLation conSTrucTs (structuRes, OBjecTs). tHUs, sImIlAr optiMIzATion tEcHniquES can bE UseD aCRoSs LAnguagEs. HOwever, cErtAIN lanGuage feaTures MaKe SomE oPtimizations diFficult. for iNstAnce, poiNters iN C anD c++ MakE Array optimizaTIOn DiFficUlT; seE alias anaLYsiS. HoweVer, lanGuagES sucH AS pL/i thaT alSo sUPPoRt POiNtErS impleMEnt oPtimizationS FOR aRRayS. ConvErsELY, Some laNgUage fEaTuRes mAke ceRtaIn oPTimIZatioNs EaSier. foR exaMplE, in SOme laNgUAges, functIOns arE nOt permItteD to HavE siDe effeCTs. tHereFore, If A proGram makEs severaL calls To the SAmE FUnctiON WiTh THe same arguMents, The cOMPiler can InfEr tHat The FUncTiOn'S reSulT ONly needs To be computed oNCe. In LaNGuaGes where funCtIOns Are allOweD TO hAvE siDe EffectS, the compIleR CAn rEsTRIct sucH OpTimiZatIoN to fuNcTioNs thAt it Can deteRminE HaVe no sIde eFFEcts.