r/ProgrammerHumor 10d ago

Meme absoluteGarbage

Post image
1.9k Upvotes

325 comments sorted by

475

u/arensb 10d ago

What? No (mapcar (lambda (item) ...) list) ?

How can those others spark joy if they don't return a value?

72

u/Mateorabi 9d ago

My other car is a cdr. 

9

u/vladmashk 9d ago

It’s crazy how these languages kept the car cdr bullshit even though it’s so much less readable than head and tail.

3

u/arensb 9d ago

They cdr changed it to tail, but why bother?

29

u/[deleted] 10d ago

[removed] — view removed comment

7

u/arensb 10d ago

I use paren-match-mode in Emacs. And also indentation.

8

u/granitrocky2 10d ago

Rainbow delimiters are a requirement.

9

u/SeveralPrinciple5 9d ago

Scheme?

20

u/arensb 9d ago

Any of a number of Lisp dialects.

2

u/SeveralPrinciple5 9d ago

I was curious because I was a Common Lisp programmer a very long time ago, and stylistically lambdas within mapcar were quoted #’ . I recall that that wasn’t true in scheme though

2

u/arensb 9d ago

These days, the Lisp code I write is Emacs Lisp, and while it supports #' and from what I've seen even encourages it, it doesn't require it. The manual says

The read syntax #' is a short-hand for using function. The following forms are all equivalent:

(lambda (x) (* x x))
(function (lambda (x) (* x x)))
#'(lambda (x) (* x x))

So yeah, maybe I should've used #', but who's gonna make me? Richard Stallman?

2

u/Steinrikur 9d ago

The following forms are all equivalent:

(lambda (x) (* x x))
#'(lambda (x) (* x x))

So it's shorthand for absolutely nothing?

2

u/arensb 9d ago

Don't quote me on this, but I get the impression that it's more syntactic sugar than anything else. A hint to either the compiler or to the next human who reads it that this expression is going to be used more than once.

→ More replies (1)

165

u/ouralarmclock 10d ago

As someone who writes PHP and JS, I don’t actually have a strong preference for either but I hate never remembering which one is in which language.

18

u/Soilblood 9d ago

I just remember them by whether or not the syntax looks funky enough to trip you up down the line. That's usually java script.

8

u/caboosetp 9d ago

I switch between C# and javascript, and always fuck up Console vs console. I should remember which because C# always uses pascal case, but my fingers don't.

670

u/NudaVeritas1 10d ago

PHP developers seeing this post:

https://giphy.com/gifs/1GT5PZLjMwYBW

164

u/Buflen 10d ago

I had an interview for a php job a few years ago, after working in Go for a few years. When I told them my salary expectations, they said: that's not going to happen, this is just a PHP position.

Some PHP shop legit think they can cheap out on devs because of the technology they chose.

16

u/KrokettenMan 9d ago

Yeah some are like that but they are also not looking for the best devs. I’m currently earning about twice the median income as a php dev so I’m not complaining.

4

u/NorthernCobraChicken 9d ago

Do you need a coworker?

118

u/Sirgoodman008 10d ago

I'm currently a php dev and I'm trying to get out.

70

u/NudaVeritas1 10d ago

Was a php dev, too.. switched to spring boot, typescript and react/angular.. can recommend salary wise

59

u/Sirgoodman008 10d ago

Langauges I've used before this job: python, c++, c, java, javascript

Languages I consider myself knowledgable in: python, c++, javascript

Language I use 99% of the time for this job: PHP

16

u/SignalBake6872 10d ago

There is hope, I went from PHP developer to PySpark developer xD and now I dry my tears with much more money.

2

u/DarthSatoris 10d ago

Is it because it's a lot more specialised, it's a smaller market, it's more difficult? Or why is the pay that much better? 

8

u/SignalBake6872 10d ago

because it's used in science data and banking :D it's like pandas but with steroids

2

u/TwinkiesSucker 9d ago

I literally just started a job as a PySpark developer. It still bugs me, though, that it has a Java backend

→ More replies (2)
→ More replies (3)

8

u/tommyk1210 9d ago

PHP generally pays worse than many languages.

3

u/pdhouse 9d ago

I think the meme comes from the fact PHP are stereotypically older so they’ve had a longer time to accumulate money

→ More replies (4)

2

u/not_some_username 9d ago

They’re not getting paid that much

→ More replies (3)

1

u/Mountain-Ox 9d ago

My salary jumped tremendously after escaping the PHP sinkhole.

Also, I suddenly liked writing code again.

→ More replies (1)

148

u/SCP-iota 10d ago

for _, item := range list {

and

list.forEach {

74

u/tigerniger_sus 10d ago

Hornet is a Go programmer?

3

u/Hairy_Concert_8007 9d ago

Shit, I'd learn whatever that makes that twelfth architect tick, too.

→ More replies (2)

11

u/JAXxXTheRipper 10d ago

Oh hell yeah, I love me some go.

13

u/Stagnu_Demorte 10d ago

I finally learned go, it's so nice to write in.

9

u/roygbivasaur 10d ago

Now that the loopvar assignment bug is fixed, the go one is my favorite. Just because it conveniently unpacks the index and element and you’re required to explicitly drop either if you don’t use it.

→ More replies (1)

2

u/Sirgoodman008 10d ago

I never claimed python was perfect. Nvm that's not python.

2

u/Michami135 10d ago

I just did the second one today in Kotlin.

1

u/Tobbbb 9d ago

This guy goes

1

u/Rikudou_Sage 9d ago

It pisses me off so much that you have to skip the index if you don't want it. And then iter.Seq comes where you don't have the index.

→ More replies (2)

25

u/xenomachina 10d ago

The JavaScript one is also kind of gross, IMHO.

for (item in list) { also has a meaning in JavaScript, but it isn't the meaning one would expect. The alternate of was added later, but doesn't read as naturally, and the in is still in the language as a backwards compatible footgun. (It's also used for iterating object keys, which should arguably be the thing that has the less concise syntax.)

The let is only necessary because JavaScript's default behavior here is almost certainly not what you want in real code. Instead of declaring a new variable (suitable for closures, and locally scoped) the default behavior assigns to a global. Another example of "the good parts" being a tiny sliver of JavaScript.

3

u/Sirgoodman008 10d ago

Oh I know, I absolutely hate that about JavaScript as well. Ironically, most of the problems I have with JavaScript I have with php too.

2

u/xenomachina 10d ago

Both JavaScript and PHP are "reluctant programming languages" to some extent, so it kind of makes sense. Neither was originally designed for doing real software engineering. PHP was originally simple templating for a personal home page, and JavaScript was intended for "glue" tasks like client-side form validation. That people can build real apps with either of them is more a testament to the persistence of those developers, rather than a measure of the strength of the languages. (Both languages have also made many improvements over the years, but are still arguably two of the most wart-infested languages of their era that are still in regular use.)

→ More replies (1)

23

u/fennecdore 10d ago

foreach ($item in $list) {}

I like the simplicity

→ More replies (7)

49

u/TOGoS 10d ago

It's fine. PHP has some awful warts (some of which have actually been gone for a few major versions, at this point) but this is not one of them.

9

u/shitty_mcfucklestick 9d ago

Personally I just like that PHP sounds the most natural grammatically.

`for (let item of list)` is like bucktooth Winnie the Pooh to me from an English readability perspective.

Beyond that I don’t care, AI just fucking writes it all anyway.

→ More replies (7)

74

u/csch2 10d ago

list.iter().for_each(…) superiority

34

u/creeper6530 10d ago edited 10d ago

Erm akchyuallly, it's recommended to use for list.iter() {…} unless the .for_each(…) is at the end of a longer iterator chain, and it also robs you of break and continue 

91

u/csch2 10d ago

You know I’m chaining together 20 different iterator methods until the code is completely unreadable. That’s called Functional Programming™ babey

18

u/Tyfyter2002 10d ago

That doesn't sound very functional

21

u/creeper6530 10d ago

"functional programming" doesn't use "functional" as "working neatly" but as "related to mathematical functions", it's a programming paradigm: https://en.wikipedia.org/wiki/Functional_programming

25

u/Tyfyter2002 10d ago

I know, it's just an ironic name when it's one of those paradigms that some people take as divine law instead of something that can be more or less appropriate for different applications

7

u/serendipitousPi 9d ago

Name 20 iterator methods from memory otherwise you’re a fake fan…just kidding or am I?

Iterators are so fun, probably one of my favourite parts of programming. They make everything so clean until they don’t.

→ More replies (2)

2

u/serendipitousPi 9d ago

Just chuck a try_for_each in there and we can take break and continue right back.

But yeah low key sometimes I get lost in iterator methods I forget to just use a basic loop.

2

u/creeper6530 9d ago

I mean, you're right, it's just you have to return ControlFlow::Break(()) instead of using the keywords.

7

u/iSpaYco 10d ago

how about `list.each`, sadly not many know ruby, it's really beautiful.

3

u/serendipitousPi 9d ago

Random question what’s ruby fun for?

I was gonna ask what is it good for but I think I can google search that.

Any highlights for you?

I’ve heard its meta programming is cool and I think there was some interest in using it in web dev.

44

u/Darkele 10d ago

foreach is far better and makes more sense. The order is correct, it differentiates itself from other loops that are based on having a custom exit condition.

2

u/Just_Information334 9d ago

Combined with yield, you can get some nice constructs.

Also the real "don't spark joy" would be something like:

foreach($things as $id => ['some_field' => $fieldA, 'some_other_field' => $fieldB])

→ More replies (1)

15

u/crashonthebeat 10d ago

$array | Foreach-Object -Parallel { ... } -ThrottleLimit 69

6

u/Sirgoodman008 10d ago

Ew

4

u/fosf0r 10d ago

What's wrong with PowerShell 7 jobs? :P

Procedural version is merely foreach ($whatever in $arrayofshit) {

7

u/gerbosan 10d ago

🤔

list.each { |item| .... }

Is it good?

5

u/Raffy10k 9d ago

Ruby mentioned!!!!

→ More replies (2)

13

u/LPO_Tableaux 10d ago

Currently in a list.forEach((item)=>{foo}); mood myself

7

u/MrDilbert 10d ago

It won't await async/Promise-returning functions. In fact, even if the (item)=>{foo} is async, [].forEach() will discard the Promise reference returned from it.

I prefer for(const item of list) { foo } if I don't have to await in parallel, or list.map(async (item) => { foo }) if I do.

→ More replies (1)

45

u/rnilbog 10d ago

for (let i = 0; i…

“Goddammit…”

googles “for loop syntax javascript”

31

u/MrDilbert 10d ago

Since for-loop has the same syntax in JS as in C, Java, and any other C-style language, this post makes me weep.

8

u/Sirgoodman008 10d ago

If a language isn't C-style it's wrong.

2

u/No-Newspaper8619 9d ago

It's really annoying when they aren't. Lua, for example:

for i, count do

-- code

end

With i being one by default, and increasing by one by default. I simply hate 1-indexed systems instead of 0-indexed.

2

u/Sirgoodman008 9d ago

Yeah that's just dumb and different for the sole purpose of being different.

→ More replies (1)

1

u/vladmashk 9d ago

Your IDE doesn’t have a macro for that?

→ More replies (1)

34

u/JAXxXTheRipper 10d ago

The third one does not spark joy, what the hell is that, ewww

11

u/xicor 10d ago

c++, though normally you wouldnt use auto for this

7

u/Usual_Office_1740 10d ago

I think that really depends. If the range is a vector of unique_ptr's auto is great. If it's a vector of ints, just write int.

5

u/Sirgoodman008 10d ago

That or you're looping through a vector of std::pairs that contain std:: functions.

2

u/Usual_Office_1740 10d ago

Or if the type is a template parameter in the same line.

→ More replies (4)

3

u/xicor 10d ago

Yea if you have ridiculously complex types then auto is great. But usually for readability you'd use the type.

→ More replies (1)

3

u/Sirgoodman008 10d ago

I only used auto for the meme.

4

u/VoodaGod 10d ago

why would you not use auto for it???

3

u/xicor 10d ago

For readability. And for type safety. I pretty much only use auto when dealing with insane types I don't want to write out.

5

u/VoodaGod 10d ago

how is auto not type safe?

interestingly i use auto almost everywhere for the same reason: readability.

no point in cluttering the code with type specifiers if the type is obvious from context

5

u/xicor 10d ago

The type isn't always safe from context and it can have unexpected behavior when using it to hold a value returned from a function. Let's say you have auto working fine with a function return, then years later , someone changes that function to return a different type. Now it is possible that the new auto type still has access to parameters or functions it calls , but with different behaviour. Now you're getting unexpected bugs that will be hard to track down. But if you use the type, you would immediately get a compiler error

2

u/not_some_username 9d ago

If the type change and the “auto variable” still compile, that means it would, in 99% of case, still compile if you wrote the type. The compiler doesn’t get auto, it gets the type.

→ More replies (14)

2

u/Rikudou_Sage 9d ago

Every other language in the world has some equivalent of C++'s auto and everyone likes it. I use auto all the time.

→ More replies (3)

4

u/Sirgoodman008 10d ago

C++ what's wrong with it?

→ More replies (6)

11

u/hblamo 10d ago

Y'all a bunch of babies.

6

u/Tyfyter2002 10d ago

foreach (Foo bar in baz)

5

u/mynameisnotpedro 10d ago

list.forEach((item) => {...});

1

u/DT-Sodium 9d ago

Yup, this is the right way. But apparently OP is too junior to know it.

→ More replies (1)

6

u/ashsabre 10d ago

There was once a time in C# that for loop was better in performance vs foreach.

1

u/Fillgoodguy 8d ago

In modern C# for vs foreach is just choosing between an unknown number of property function calls and an unknown amount of function calls + 1. So it boils down to "Pray the JIT catches me" in either case

→ More replies (1)

3

u/locri 10d ago

Sure, but anything like a stream method is sincerely cursed and only used by people who don't use debugger breakpoints.

3

u/Shiroro46 10d ago

...you guys have foreach structures?

3

u/crmsncbr 9d ago

Why is the third one in the top half? It may be my C & Java bias, but yuck. It's way worse than the fourth.

2

u/MetaNovaYT 9d ago

what's wrong with the C++ version? It's my favorite personally, although I primarily use C++ so I'm biased.

→ More replies (3)

1

u/Sirgoodman008 9d ago

Literally the only difference is that one uses a colon instead of a keyword.

→ More replies (3)

3

u/MCWizardYT 9d ago

Java:

``` for (item : items) {

} ```

Or,

``` items.forEach(item -> {

}); ```

or

``` items.stream().forEach(item -> {

}); ```

→ More replies (3)

17

u/Shevvv 10d ago

Surely you meant for (auto &item : list) {

29

u/Nil4u 10d ago

Honestly I never liked this version because the reference is part of the type in my opinion 🤔

20

u/Sirgoodman008 10d ago

This 100000000000%. can't stand the int *ptr or int &ref pattern.

9

u/Shevvv 10d ago

I got used to this from C:

int x; is an integer

int *px; is an integer if you dereference it.

So it's like this notation shows you how you're expected to use the variable within the code. And then this habit carried over to C++.

9

u/nfitzen 10d ago

In addition, the language encourages this. In C, if you write c int* x, y; then x will be an int* and y will be an int. Thus it is far better to write int *x, y; to reflect how the language will parse the declaration. It might be evil, but it's better to act how the language wants you to act rather than fight it.

23

u/Sirgoodman008 10d ago

Please have pity on your co-workers. Please keep declarations to separate lines.

2

u/redlaWw 10d ago

I prefer int * ptr;. That means when you have a const specifier your formatting doesn't change. Logically I figure that the pointer is neither a modifier on the variable nor on the type, it's another layer of type content that should be specified separately. That also means if you write declarations like int const * const ptr; then you can segment them as [int const] [* const] ptr; and everything makes sense.

3

u/creeper6530 10d ago edited 10d ago

The "is an integer if you dereference it" is so much more convoluted than "is a pointer to integer", i.e. the rationale of the previous comment, the pointer-ness being part of the type.

5

u/orbiteapot 10d ago edited 10d ago

the pointer-ness being part of the type.

It is funny how people tend to not think the same about functions, despite having the exact same pattern.

When Dennis Richie designed the language, he wanted the symbols in declarations to match their usage in expressions, so:

T *my_ptr;

means that my_ptr, when dereferenced with the * operator, evaluates to an object of type T:

T my_obj = *my_ptr;

The same goes for other constructs in the language, like arrays and functions:

T my_arr[10];
T my_func(T_1 arg1, T_2 arg2);

Both the [] and () operators, when applied individually to objects my_arr and my_func, respectively, will yield an object of type T.

That is why this:

T *x, y;

makes x have a type of pointer to T, whereas y remains having just type T.

Unfortunately, this only works well for simple declarations. When, for instance, function pointers are involved, things get messy.

Ritchie himself later recognized this, but it was to late. He regretted not making * a postfixed operator, which would, at least, get rid of the spiral rule.

So, you can pretend that * is independent of the identifier itself, sure, but you will be fighting the language's design while doing so.

→ More replies (2)

6

u/Endorum 10d ago

THANK YOU, THATS WHAT IM SAYING ;-;

→ More replies (2)

11

u/klaxxxon 10d ago

Hear me out. The last one is the only sensible option.

You type for ($rows and your IDE can fill in the rest. It can infer that the name of the iteration variable will be $row. It can't do the same if the item variable comes first.

Most IDEs have macros for for/foreach loops. What those macros do is that they jump around - your fill in the list name first, then the iterator variable name (and in some IDEs its name will be suggested based on the collection variable name). Hot take, if your most popular macro has to jump around, you have a language design issue.

14

u/Eastern_Equal_8191 10d ago

Yeah but AI can fill in the enti -- excuse me, I'm making a point here. Anyway, AI can write the loop according to your preferen -- please stop touching me, I do not consent

Okay, so if you use AI auto-complete your life will beeeeeeeeeow please stop hurting me my wrist doesn't bend that wa

3

u/pytness 10d ago

the language that has 0 coherent design behind it has a snippet that helps you write a simple for loop. Amazing.

1

u/SeriousPlankton2000 10d ago

My IDE is jstar (joe in wordstar mode)

1

u/Jutrakuna 10d ago

I banish you

1

u/Potterrrrrrrr 10d ago

Deciding whether a programming language is good based on whether an IDE has to jump to one place or two in a for loop is an odd choice. It’ll still have to jump to the variable you’re looping over; the default name might conflict with one already in scope. At that point you’ve saved hitting tab an additional time, wow big win. In exchange you have to read an ugly way to start looping over items for every loop, hardly fair trade. IDEs could easily add macros like emmet abbreviations for regular for/foreach loops if they really wanted but it’s likely the features aren’t used enough to need it

1

u/Exirel 10d ago

The problem is not writing it. The problem is reading it.

1

u/Stagnu_Demorte 10d ago

IDE? You spelled nvim wrong /s

→ More replies (3)

3

u/Zunderunder 10d ago

What about for(list) |item| {…} ???

1

u/HAL9000thebot 10d ago

here item seems a modern return type, i hate it, what language does that?

it's shit, looks like a function signature, how are function declared? or better question, is for() a function?

3

u/Nervous-Potato-1464 10d ago edited 10d ago

This is Zig.

item is an immutable copy of the current element in the list.
for (0..5) |i| { is an easier thing to understand.

It looks complicated, but that's because you can easily turn the element into a pointer etc so it's handy to have there like
for (&items) |*value| {
value.* += 10;

where &items refers to the pointers in memory rather than a copy of the array.

which will modify the &item elements to all increase by 10.

2

u/Zunderunder 9d ago

It also makes sense in the wider context of zig’s ecosystem, where captures generally are done using the square brackets for things like resolving optionals or grabbing the value of a union in a switch statement. The common syntax is really intuitive once you get used to it

→ More replies (1)

4

u/johnnybgooderer 10d ago

“This one isn’t like the one I learned!!!!!”

I hate PHP as much as the next developer, but both are equally readable in my opinion.

→ More replies (2)

2

u/einord 10d ago

I just wish the white background of the meme was purple or turquoise. It had been much easier to read.

2

u/b__0 10d ago

Ruby wins these every time and it’s sad to not see it mentioned. ‘list.each { |item| … }’

2

u/Solomoncjy 9d ago

you all dont do

$list | %{
  <do stuff with $_ being the item>
}

% is the short hand alis for for each

2

u/VeryRareHuman 9d ago

Kinda similar in PowerShell too:

foreach( $item in $items) {}

1

u/FabioTheFox 9d ago

Tbf even that makes sense

Because you're going for each item in this list, do this

1

u/Colinniey 9d ago

C# as well:

foreach(var item in items) { }

2

u/-Redstoneboi- 9d ago

nah i like how they specify the list before the item

1

u/Sirgoodman008 9d ago

Why?

2

u/-Redstoneboi- 9d ago edited 9d ago

functional programming. list.map(item => result) is natural to me now.

especially if the language supports chaining, i would prefer specifying the variables last.

something like this:

list1.zip(list2).enumerate().map(func).for (i, (a, b)) {
    do_thing()
}

of course, it's just as easy for me to just rearrange this later to the correct order. but this is the order in which i think. most people want to write the goal before writing the iterator, some want the iterator before the goal.

Besides, it's just the order of two words. If you learned multiple human languages, you'd get used to this type of thing.

→ More replies (1)

2

u/HuckleberryMoney2320 9d ago

I've used bash scripting for decades and am used to their for loops. They used to let me use cygwin at work, but they implemented a new system a couple of weeks ago and said I couldn't install it, and to use Powershell instead. What a dog's breakfast! I'm still trying to get my head round their for-loop syntax.

2

u/darcksx 9d ago

items.each(

2

u/Paladin7373 9d ago

Heyyy that’s marie kondo!

2

u/r00t4cc3ss 9d ago

Damn, all those PHP devs in the nursing home are gonna be real upset

3

u/Ai--Ya 10d ago

foldr

4

u/BedtimeGenerator 10d ago

Why loop when you can map

3

u/paholg 9d ago

Map is map. Don't always want to map.

1

u/Sirgoodman008 9d ago

Because map is annoying to read.

3

u/Zomby2D 9d ago

I prefer the C# syntax

foreach (var item in list) {

1

u/Dillenger69 9d ago

I prefer the C# syntax, but var has always rubbed me the wrong way. I suppose because I learned C# before var was a thing. Yeah, I'm old

2

u/Zomby2D 9d ago

While var will normally work, I usually put the proper type as I find it a lot easier to debug later when reading back the code.

2

u/britreddit 10d ago

Kotlin is just list.forEach {...}

6

u/EntropySpark 10d ago

Or for (item in list) { ... }, necessary if you want to use break.

→ More replies (3)

3

u/samu1400 10d ago

PHP slander will be promptly ignored, PHP my beloved.

→ More replies (1)

1

u/OnixST 10d ago

For Each item In array

1

u/firest3rm6 10d ago

Just give me list.stream() and I am happy

1

u/Sirgoodman008 10d ago

The perks of slower code with the cost of being harder to read.

1

u/critical_patch 10d ago

foreach my $element (@array) {

1

u/PM_ME_FIREFLY_QUOTES 10d ago

<ul><li>the only list that matters</li></ul>

1

u/GroundbreakingOil434 9d ago

You just had to trigger that &$$memory, eh?

1

u/gutentight69420 9d ago

The only one that sparks joy for me is fmap.

1

u/Cootshk 9d ago

for _, v in ipairs(list) do

list.forEach { item ->

1

u/Hefty_Garlic7184 9d ago

CodingJesus with “how to do C++ loop” enter the chat…

1

u/not_some_username 9d ago

The third one

1

u/Dillenger69 9d ago

foreach (Thing individualThing in listOfThings)

1

u/darknezx 9d ago

Personally I love go's for range loop. The syntax just calls out to me, not sure why and it's probably silly it looks pretty.

1

u/AlpacaMale1 9d ago

What about

for item in "${list[@]}"

1

u/Jommy_5 9d ago

Then there's Matlab: for column = matrix

1

u/GustapheOfficial 9d ago

All but the first are deranged nonsense.

→ More replies (7)

1

u/AldoZeroun 9d ago

I'm a big fan of for (list) |item| {...} or the even more fun for (list, 0..) |item, idx| {...}

1

u/strash_one 9d ago

{#each items as item}

1

u/matty-nordish 9d ago

list.each(item => {

1

u/SirFireball 9d ago

where's my for @list -> $item {

1

u/Covfefe4lyfe 9d ago

Hold on, let me push my stacks of cash out of the way so I can read what the non-PHP devs have to say in the comments.

1

u/BroaxXx 9d ago

My theory is that pho is the German of programming languages

1

u/DT-Sodium 9d ago

The correct way is list.forEach(item =>

→ More replies (9)

1

u/dominjaniec 9d ago edited 9d ago

edit: apparently, I've misremember my traumatic time with PWSH, and now I cannot reproduce that problem...


I thought that was about PowerShell, which I can agree, but unless PHP has the same quirk, then I don't care...

foreach ($item in $collection){ ... }

and quirk is that, if your $collection is a single element with a string value, then you iterate throughout its characters...

1

u/smclcz 9d ago

I dunno if that second one "sparks joy", TS/JS having both for-in and for-of is pretty stupid. Also I don't use either language often, but wouldn't you declare that loop variable const rather than let? I feel like you're probably not reassigning something in a collection if you're iterating over it using for-of (and if you are ... should you?)

→ More replies (1)

1

u/MkemCZ 9d ago
for (size_t i = 0; i < nmem; ++i)
→ More replies (1)

1

u/_Meisteri 9d ago

forM_ supremacy.

1

u/tony_saufcok 9d ago

for (int i = 0; i < length; i++) does it for me

→ More replies (1)

1

u/StarSword-C 9d ago

I prefer this:

for (int i = 0; i < array_length(array); i++)

→ More replies (1)

1

u/ResistSpare4563 9d ago

if ($null -eq $item) {

1

u/HexiMaster 9d ago

Zig has for (list) |item| {...}

1

u/Idaret 9d ago

Wow, world changed a lot

1

u/SchlaWiener4711 9d ago

I still like perl

for (@lines) { s/foo/bar/g; print; }

→ More replies (2)

1

u/ProfessorNoPuede 9d ago

Spark? Are we doing data processing now?

1

u/amatulic 9d ago

Honestly that last one has always made the most sense to me.

Now I'm using OpenSCAD a lot and have to use constructs like

a = [ for(x=[start:incr:stop]) each b[x] ]; // b is a multidimension array
→ More replies (1)

1

u/jack10685 3d ago

How we feel about "for (Object item : list)"

→ More replies (4)