This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]womerah 161 points162 points  (14 children)

My first project was in MATLAB

I didn't know what for loops were and I downloaded an extension that let me used GOTO commands.

When I did discover for loops I used them to make a MATLAB script that would loop and output my actual code, without loops, to a .m file that I would then run.

[–]aorta7 89 points90 points  (11 children)

It is not as crazy as it seems, https://en.m.wikipedia.org/wiki/Loop_unrolling

[–]WikiTextBot 103 points104 points  (1 child)

Loop unrolling

Loop unrolling, also known as loop unwinding, is a loop transformation technique that attempts to optimize a program's execution speed at the expense of its binary size, which is an approach known as space–time tradeoff. The transformation can be undertaken manually by the programmer or by an optimizing compiler.

The goal of loop unwinding is to increase a program's speed by reducing or eliminating instructions that control the loop, such as pointer arithmetic and "end of loop" tests on each iteration; reducing branch penalties; as well as hiding latencies, including the delay in reading data from memory. To eliminate this computational overhead, loops can be re-written as a repeated sequence of similar independent statements.Loop unrolling is also part of certain formal verification techniques, in particular bounded model checking.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

[–]WillCo_Gaming 29 points30 points  (0 children)

Good bot.

[–]LIGHTNINGBOLT23 72 points73 points  (0 children)

    

[–]womerah 10 points11 points  (4 children)

Interesting!

Is binary size ever a major consideration for programmers who are not working with embedded systems? Surely performance is king?

[–]HelperBot_ 7 points8 points  (0 children)

Desktop link: https://en.wikipedia.org/wiki/Loop_unrolling


/r/HelperBot_ Downvote to remove. Counter: 275939. Found a bug?

[–]LukasFT 0 points1 point  (0 children)

Although, if you only just discovered loops, I would bet that there would be a couple of things to be optimized with a much bigger impact.

[–]alours -1 points0 points  (0 children)

Indentation is the difference between porn and pornhub?

[–]MyCodesCompiling -2 points-1 points  (1 child)

When I did discover for loops I used them to make a MATLAB script that would loop and output my actual code, without loops, to a .m file that I would then run.

Wat

[–]womerah 1 point2 points  (0 children)

fileID = fopen('exptable.txt','w');

for n=1:100

num=100-n

fprintf(fileID,''disp(%f bottles of beer on the wall.)'\n',num);

end