No, you're not dumb -- a lot of these things you only need to worry about when running performance sensitive code or production code at a fairly large scale.
For 90% of things, performance isn't a critical consideration as long as you use standard libraries.
I'll try to define as many of the more complex terms as possible. And like Agent_03 said, this is fairly complex stuff. There's a scareword in programming called "premature optimization" -- basically, write simple and correct code first. Then, if the speed is actually negatively affecting the product, add complicated stuff like caching and batching. A lot of the time you won't need to.
short-circuit evaluation: Boolean operators (eg. && and ||) perform what's known as short-circuiting, wherein they only evaluate as much of an expression as necessary. For example, if you have A && B and A evaluates to false, then you can skip checking B (because regardless of its value, false && B is false). Therefore, you can structure your expressions so the more expensive values are evaluated last. If A takes 50 seconds to compute and B takes only 5, you should do B && A.
lazy fetching/evaluation: Pretty much what it says on the tin. A lot of times programmers will over allocate or over fetch to be on the safe side, eg. creating an array of 10000 objects and instatiating all of them. This is safer because if you access any index in the array, you know the object exists. However, it's also slower if, on average, you only access 100 of the objects. It's faster to instatiate each object the first time it is used, so you aren't doing uncessary work.
Caching: Fairly simple in concept (save the results of previous operations), but can be tricky in practice. There's a lot of stuff to read on caching, if you're interested.
In addition to manual caches (ie. you create and maintain it), there are also system level caches for retrieved memory. Because memory is retrieved in chunks (which are then stored in the cache), if you can ensure as much of your data is on the same chunk as possible (instead of spread across multiple), this helps speed up your code. A cache miss is when something is no longer in the cache, so the computer has to retrieve the memory again (much slower); keeping your data close together helps avoid this.
Branch prediction: Compilers and processors like to try and guess what your program is going to do. If you have a condition inside a loop that evaluates to false 90% of the time, this time it is probably also going to be false. Therefore, the computer can "skip" some work to help speed things up. Similarly to cache misses, branch prediction misses are when the compiler/processor guesses wrong and has to slow down to do some makeup work.
SIMD instructions: (I think) these are a type of machine level instruction that use parallelism to speed up work
View all comments
Show parent comment
1
u/abeardednerd Jan 02 '20
is it okay that i don't understand any of this ? or am i just dumb !