[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>people that use for loops instead of foreach when they want

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 51
Thread images: 4

File: butt.png (141KB, 452x434px) Image search: [Google]
butt.png
141KB, 452x434px
>people that use for loops instead of foreach when they want to iterate a list
Why are there people that do this?
>>
>>56824719
Because it's still faster?
>>
>>56824719
Because foreach doesn't exist in C-masterrace-pro-official-Free-Software-language.
>>
>foreach fgt in op
>fgt.getDick().cum()
>error: null pointer: getdick()

There, happy?
>>
>>56824753
Error: op is of type 'object' not 'array'
>>
>there are still people that don't use Parallel.ForEach
>>
>>56824719
Sysadmin here, all I do is ForEach the fuck out of everything. (With PowerShell)
>>
File: 1474859170892.png (119KB, 547x609px)
1474859170892.png
119KB, 547x609px
>>56824719
Hey faggot I was in the last portions of my degree and found out a lot of people couldn't even write for loops. How did they get through the program?

>fag asks for help
>needs to iterate a certain amount of times
>Tell him to try a for loop
>doesn't know how to write it, asks for help
>verbally tell him
>he begins with a single line declaring a counter variable
>next time for blah blah
>mfw


And for that matter, are they writing code for companies now?
>>
foreach is good until you need to do stuff with the iterator, which is why for is still master race.
>>
Is for each not a kind of loop?
>>
>not using std::transform
Top fucking pleb.
>>
>>56825427
stl is slow as fuck.

Top fucking retard.
>>
>>56824719
I seen people manually construct enumerable of the iterator and call .next() on it instead of using foreach..
>>
>>56825257
OP = {fgt, fgt, fgt}
Think gang rape, but OP is too much a fag to not enjoy it
>>
foreach is just syntactic sugar for for loops, using it doesn't make you a better programmer
>>
>not using map
>>
>>56825390
This
>>
>not ipairs()

top zozzle
>>
>>56825464
>For is just syntactic sugar for while loops, using it doesn't make you a better programmer
>>
>>56825464
Kekimus Prime
>>
>>56825390
Yes but using it when you don't makes the code verbose and harder to read.
>>
usually because I need the index counters to do shit with
>>
File: bpc_foreach1.png (42KB, 557x292px) Image search: [Google]
bpc_foreach1.png
42KB, 557x292px
>>56825390
Use a better language scrub
>>
Because they are

1. Using a language without a foreach loop, such as C
2. Wanting to iterate in a special way, such as on every other element, or in reverse
3. Wanting both the index and the element of the array for something else.
>>
>>56825528
>while is just syntactic sugar for goto, using it doesn't make you a better programmer
>>
Because I don't need to make a copy of an instance to loop it
>>
>>56825659
What if none of those things are true?
>>
>>56825894

Then they're a beginner programmer who is not aware of the foreach loop.
>>
>>56825464
>syntactic sugar
Professor Murray, is that you?
>>
>not spinning up a threadpool to operate over the list using a mutex-protected index
>>
>>56825528
I think it does make you a better programmer. It shows your intent, which is important when reading code. This opinion that abstraction is bad, is itself bad.
>>
>>56824719
>People that write manual memory management code when they want to be able to control how and when memory is allocated
Why are there people that do this?
>>
>>56824719
What when i have a data vector and i want to use a virtual function call on each data member, both Base and derived?

Theres an answer for using foreach, i just want to get the reasoning behind it.
>>
File: 1442978097091.jpg (108KB, 500x500px)
1442978097091.jpg
108KB, 500x500px
>function call every iteration
>>
>>56824719
>for loops
just use a while loop you pleb
>>
>>56825630
What exactly am I looking at?
>>
You have to in Java for older libraries, since Java didn't have a for-each loop until Java 5 in 2005.
>>
>>56829501
Unreal engine
>>
>>56824719
>he doesn't use map liberally
>>
>>56825369

Nope. I have no clue what half my graduating class is going to do, because a significant portion.

I shit you not, the company I am working for now had issues finding suitable candidates. The preliminary questions were to define JOINs and how youd use them, what the static keyword means in C#, and to explain overriding vs overloading.

They said most people literally copy and pasted the wikipedia definitions.
>>
>>56825458

Whats the efficiency of that? Wouldnt a for loop generally be quicker?
>>
>>56824746
>its faster
until the very first fucking line of every goddamn loop is run which is list.get(i)
>>
>>56829558
map is generally for transformations, where you would expect to get something back
foreach usually just performs an operation with each element

in functional languages where immutability is a big thing, map would generate and return a new object as a result of it's operations, whereas foreach would be applying some kind of immutable operation against the object, maybe just printing it out.
>>
>>56828447

I have met professional developers who adhere religiously to SOLID principles and reliance on abstraction

I have also met people who got lucky and yet are also professional developers (without degrees) who say SOLID is bumpkiss

who is right?!?!?!?
>>
>>56824719
>retards who use loops and foreach instead of recursion

Fucking brainlets on /g/ when will you dumb shits start learning haskell?
>>
>>56829576
I think they never learned what a foreach loop was and didn't know how to for over non indexed enumerables so they googled the first thing and reinvented the wheel..
>>
>>56828447
Same thing with foreach. We'd all be using gotos and if syntax doesn't matter.
>>
>>56824753
java.lang.outofmem error
The object {OP} has sucked too many dicks
>>
>>56824719
I would point out that pre optimization is a meme. but foreach is slower in pretty much every language, and for loops arnt really any harder in dynamic languages.
>>
>>56831023
It's like 10ns slower but much more readable at a glance
>>
>>56831467
depends on how often you are going to be running the loop. most of the time irl you are right, its negligible
Thread posts: 51
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

If you need a post removed click on it's [Report] button and follow the instruction.
If you like this website please support us by donating with Bitcoin at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties. Posts and uploaded images are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that website. If you need information about a Poster - contact 4chan. This project is not affiliated in any way with 4chan.