TRANSCRIPTEnglish

Go Iterators Are Bad

36m 14s7,644 words1,034 segmentsEnglish

FULL TRANSCRIPT

0:00

look at this why people are angry over

0:02

Go Go's 1.23 iterators by the way I was

0:05

very excited about uh Go's iterators I'm

0:08

very very excited about it and ginger

0:09

bill is Awesome by the way Ginger bill

0:11

is going to be on the stream here

0:11

shortly but I'm very very very excited

0:14

about iterators for those that don't

0:15

know what makes this great is that if

0:18

you're programming some uh some go which

0:21

you know you do from time to time um you

0:23

will be able to do something like this

0:25

if I were to go to uh main.go here we'll

0:28

just pick any of them I will be able to

0:29

have some custom struct and I'll be able

0:31

to go for you know my custom struct and

0:34

do like value or uh K value in range you

0:38

know my struct which is super cool like

0:41

that's a really nice feature we're

0:43

getting good features like go is

0:45

officially becoming a 2016's language

0:47

which is which is which is a good year

0:49

okay it's a good year so I'm very very

0:51

excited I looked at him yesterday it

0:52

looks great to me I'm not sure what the

0:54

problem is yeah I actually want to see

0:55

this problem so I'm actually very

0:56

excited about this by the way I did lose

0:58

my voice at open saw so forgive me hey

1:00

forgive me please it's hard to talk I

1:02

can't scream today we can't get into

1:04

things I want to get into things but I

1:06

can't cuz if I do I'm going to lose my

1:08

voice even more Oh I thought my sound

1:11

was low no no no no yeah Ginger bill is

1:13

very very smart no this is based on but

1:15

completely Rewritten from a Twitter post

1:16

right here okay so we'll open that up

1:18

and look at that tldr it makes go feel

1:20

too functional rather than being an

1:22

unabashed imperative language isn't go a

1:25

fairly functional language to begin with

1:27

you have first class functional support

1:28

or first class functions we'll see we'll

1:30

see I saw a PO let's see let's see I

1:32

recently saw a post on Twitter showing

1:34

the upcoming go iterator design for go

1:36

1.23 August 2024 from what I can gather

1:39

many people seem to dislike this design

1:41

I wanted to give my thoughts on it as a

1:42

language designer so bill by the way

1:44

Ginger bill is a language designer and a

1:45

good one the merge PR for the proposal

1:47

could be found here it has an in-depth

1:49

explanation of the design explaining why

1:51

certain approaches were chosen instead

1:53

so I do recommend reading it if you are

1:55

familiar with go okay here's the uh

1:57

here's the example from the original

1:58

tweet all right so backward H takes in

2:01

an N uh we have this as an array of

2:03

these NES functional it's a that returns

2:06

a function that returns a function that

2:07

takes in an INT and an e and returns a

2:09

bu then you return function yield Funk

2:13

bu 4 I this one and yield it out okay

2:16

this is where cleanup goes okay uh we

2:19

have this we have this and we can range

2:21

backwards on S there you go see we can

2:23

range backwards on S which is pretty

2:24

cool right like this is this is pretty

2:26

cool uh I I I like I immediately agree

2:29

that there's a lot of effing syntax

2:30

there to explain this why yeah curring

2:34

yeah we got some curring going on this

2:35

is a lot of effing syntax right here

2:37

just to say something still easier to

2:39

read than rust potentially potentially

2:43

uh this example is clear enough in what

2:45

it does but the entire design of it is a

2:47

bit crazy to me for the general majority

2:49

uh use case from what I understand it

2:51

appears that the code will be

2:52

transformed into something as the

2:53

following backward s function int L

2:56

string bull format this one return true

3:00

return false would be the equivalent of

3:01

an explicit break okay okay this means

3:04

that g iterators are much closer to what

3:06

some languages have for with the four

3:07

each method yeah dot for each in

3:09

JavaScript and passing a call back to it

3:11

and fun fact this approach is already

3:12

possible and go uh before 1.23 but it

3:15

does not have syntactic sugar to use

3:16

with the four range statement yeah I'll

3:18

try to summarize the rationale for go

3:21

1.23 iterators but it seems that they

3:23

are wanting to minimize a few factors

3:25

make the iterator look SL act like a

3:27

generator from other languages thus the

3:29

yield minimize the need for sharing too

3:31

many stack frames allow for cleanup with

3:33

defer reduce data being stored outside

3:36

the control flow I do like the allowing

3:37

for clean up with the fur I think this

3:39

was pretty nice I at least I like that

3:41

idea as Russ uh Cox uh explains the

3:44

original proposal not regarding push

3:46

versus pole iterator types the vast

3:48

majority of the time push iterators are

3:50

more convenient to implement and to use

3:52

because setup and tear down can be done

3:53

around yield calls rather than having to

3:55

implement those as separate operations

3:58

and expose them to the caller Direct use

4:00

including with Range Loop of a push

4:02

iterator requires giving up sto uh

4:04

storing any data in control flow so

4:06

individual clients May occasionally want

4:08

to pull or want a pull iterator instead

4:12

any such code can trivially call pull

4:14

and defer stop I generally prefer pull

4:16

over push like generally speaking I

4:18

think pull over push is the way to go

4:21

and why I think it's the way to go is

4:22

that you can create really beautiful

4:24

like lazy items which makes it really

4:26

really nice uh as opposed to like kind

4:29

of push it's like you kind of you have

4:30

to create like these buffer zones and

4:32

all that for it and then you kind of

4:34

have to do a lot of um you have to do

4:36

like often copies are involved when you

4:38

do that so like a JavaScript would be a

4:40

push when you do a DOT map it executes

4:42

the entire array across that dot map

4:44

whereas when you do a poll it grabs the

4:46

first value it goes through the map it

4:48

would then go through the iterator or

4:50

the filter and then come out say the for

4:51

each whereas with JavaScript it does the

4:54

map it does the filter and then it does

4:56

the for each which is kind of that's the

4:58

difference between push and pull so I

4:59

generally prefer pull over push I think

5:02

it just makes it nicer in general it it

5:04

makes it it just also makes it really

5:06

easy to understand all right uh Russ Cox

5:08

goes into more detail in the article

5:10

storing data in control flow and about

5:12

why he likes this approach to design

5:13

more complex example do not worry about

5:15

what it actually does I just want to

5:16

show you something of the cleanup needed

5:18

for something like defer okay an example

5:20

from the original PR shows a much more

5:21

complex approach requiring cleanup where

5:23

the values are pulled directly all right

5:25

let's see so we are doing a just a value

5:27

only iterator and the see it's a

5:29

sequence sequence V and we're going to

5:31

return a sequence of two v's uh pair

5:35

returns an iterator over successive

5:36

pairs of values from sequence all right

5:38

we're going to pull stop one two if not

5:41

one two yield this one there we go okay

5:45

I think I get this I know he said not to

5:46

worry but yeah you just take two you

5:48

just create pairs over it okay an

5:49

alternative audo code proposal State

5:51

machine I'm not suggesting go does this

5:53

whatsoever when designing Odin I wanted

5:55

the ability for a user to design their

5:57

own kind of iterators but have them be

6:00

very simple in fact just normal

6:01

procedures I didn't want to add a

6:03

special construct to the language just

6:05

for this this would complicate the

6:06

language too much which is what I wanted

6:08

to minimize with Odin one possible

6:10

pseudo proposal I could give for go

6:12

iterators would look something as the

6:13

following backward an any uh an any

6:16

array function in pool this one return

6:19

function on break in this one if on

6:22

break or I is greater than this one this

6:25

is where cleanup goes else we do this

6:27

one we return it out return it

6:30

oh I think I see what's happening here

6:33

we're just assigning these oh naked

6:34

return yes these are just naked returns

6:36

right do a little naked return on here

6:38

we get uh index uh Elum and okay and

6:41

then just return it I know I hate I I'm

6:43

not a naked return guy Ginger Bill Dirty

6:45

Man Dirty Dirty Man with that one this

6:47

pseudo proposal would operate like this

6:50

yeah okay generally like it uh this is

6:52

from what this this is similar what I do

6:54

in Odin but Odin does not support stack

6:56

frame scope capture closures only non-s

6:59

scope capturing procedure literals

7:01

because go is garbage collected I see

7:03

little need uh to no utilize or to not

7:05

utilize them like this the main

7:07

difference is that Odin does not try to

7:08

unify the idea into one construct I know

7:11

some people will think this approach is

7:12

a lot more complicated it is doing the

7:14

opposite of what Cox prefers with

7:16

storing data in control flow and stores

7:18

the data outside of it but this is

7:20

usually what I want from an iterator

7:22

rather than what go is going to do this

7:24

is the problem it removes the Elegance

7:26

of storing the data in the control flow

7:28

the push pole distinction that Cox

7:30

explains yeah so I assume what he's

7:32

trying to say is that notice that you

7:34

have to store the data here and you use

7:37

that as control flow as opposed to um

7:39

having it right here which is like you

7:41

don't you don't store it outside of the

7:43

function you actually store it right

7:45

here in the ah oh gosh you store right

7:47

here in in the actual this one and then

7:49

you iterate over it and so makes like a

7:51

just a small difference but I I mean

7:53

this is probably a bit closer to what

7:55

rust does rust you typically have a

7:57

struct that is your iterator that

7:59

implements iterator in which contains

8:00

these items and then every time you call

8:02

it it's able to operate over that an

8:04

iterator having a state tracking uh

8:06

where it's at doesn't sound bad yeah see

8:08

NE I I don't think it sounds bad it's

8:10

it's it for me it's very very simple to

8:13

implement that I I know I understand it

8:15

much easier that way at least it's very

8:17

easy to implement in my head uh I'm not

8:19

very let's see I am very much an

8:20

imperative programmer and I like how

8:22

things actually execute rather than

8:23

trying to make uh it elegant looking

8:26

code so the approach I wrote above is

8:28

fundamentally a about thinking with

8:30

regards to execution I don't know what

8:32

NB is NB the type uh class interface

8:35

route would not work and go because this

8:37

would not be or let's see because this

8:38

would not be an orthogonal design

8:40

concept and actually be more confusing

8:41

than necessary this is why I didn't

8:43

originally propose it different

8:44

languages have different requirements as

8:46

to what works with them Go's apparent

8:49

philosophy the approach in go 1.23 takes

8:52

uh or takes seems to go in the face of

8:54

the apparent philosophy of making go for

8:56

the general frankly mediocre programmer

8:59

okay you know like I like go bro can we

9:03

just take a second here hey can we just

9:05

take a second here yo I'm officially a

9:07

mediocre programmer Google let's

9:10

go let's go oh baby oh baby oh baby

9:16

let's

9:16

[Music]

9:21

go Karen get out the

9:24

Champa it is official I am mediocre I

9:28

mean that's a huge upgrade you should

9:31

did you see what Google originally said

9:34

not good it's not looking good but now

9:35

it's looking

9:41

great literally better than Ken Thompson

9:43

inventor of C can't commit to see me

9:47

boom middle of the pack putting down W's

9:50

left and right can I get a pay rise pay

9:52

rise I wish I could be mediocre I know

9:54

one day you're going to be mediocre Shan

9:55

of the dev not there yet you're not

9:57

there yet but one day you will be

9:59

mediocre is that an upgrade from key

10:00

sheater yes yes it is absolutely mid uh

10:04

we're definitely um I'm going to just

10:06

take that and we're going to Tweet this

10:08

this feels like a great things um Ginger

10:11

Bill I'm finally a mid programmer I love

10:13

it I love it oh I'm love I'm so I'm so

10:16

happy right now this is such a good

10:17

article uh it's not elitism by the way

10:20

for those that don't understand go is

10:22

designed so that anybody can be

10:24

successful like you don't have to be

10:26

smart to use go okay and what I mean by

10:29

that is try Zig for a moment and realize

10:33

that there's programming languages in

10:34

which you need to think about everything

10:36

and there's programming languages in

10:38

which you can be very productive in like

10:40

I'm getting good at Zig I'm actually

10:42

getting what I would consider to be

10:43

pretty pretty dang good at Zig but that

10:46

doesn't mean it's easy like I'm building

10:49

things I'm able to do stuff I feel

10:51

pretty fast at it now I know how to make

10:53

interfaces vtables all that kind of

10:55

stuff but I'm not fast like I am with go

10:59

right

10:59

go is just like you don't even have to

11:01

think you just don't you just build it

11:03

and when you don't like something it's

11:04

pretty easy to patch over what you've

11:06

goofed up and then add on top of it and

11:08

when you don't want to do that anymore

11:09

and you want to fix it it's pretty easy

11:11

to fix and refactor and move on grug

11:13

want mid yeah I'm a I'm a real mid I'm a

11:14

mid man I'm a midman go is the fluffer

11:16

language for mediocre DS yeah I like it

11:18

that's why I love Ruby is so fast and

11:20

easy to makes everyone so productive

11:21

yeah I mean I I never discount the

11:24

productivity argument generally speaking

11:26

I think that when people say that you

11:28

use a language in which is really prod

11:30

uh productive I agree but if you say

11:32

that about JavaScript I just disagree

11:35

with you as a person that's probably

11:37

better than you at JavaScript by a by a

11:40

country mile like by a long country mile

11:43

by a New York block it is a very hard

11:46

language to be good at and to write well

11:49

and I know people think that it's easy

11:51

that's what makes it so Insidious

11:53

anyways hello Prime well hey nice look

11:55

at all those little Yar Hearts anyways

11:57

the quote Rob Pike the key point here is

11:59

our programmers are are googlers not

12:01

necess they are not researchers they

12:03

typically fairly young fresh out of

12:05

school probably learned Java maybe some

12:06

C or C++ probably learned python they're

12:08

not capable of understanding a brilliant

12:10

language well okay well I Rob I I really

12:13

always hate these kind of things uh when

12:15

someone says they're not capable I'd say

12:18

the job that they're doing does not

12:20

require right big difference big big

12:23

difference thank you for all the booty

12:24

thank you for all the dumpy baby I know

12:26

it's very elitist a brilliant language

12:28

but we want them to let's see but we

12:30

want to use them to build good software

12:32

so the language that we give them has to

12:34

be easy to understand and easy to adopt

12:36

um yeah I mean go is very easy to

12:38

understand and very easy to adopt it's

12:40

in fact as somebody who only gave go a

12:42

real shot this year like a real shot

12:44

built a really hard program and go I was

12:47

shocked at how how nice the experience

12:49

was because the types are so simple I

12:52

thought I was going to hate it like I

12:54

did I genuinely thought I was going to

12:56

hate it but I'm fine eating kale

12:59

eating a mid language doing a mid

13:01

language because I'm like ah whatever

13:03

it's going to be you know I I want to

13:04

say I want to give it a shot you know

13:06

but now that I've done it I realized the

13:08

beauty in the grug nature of it all see

13:10

is easy to understand now try building

13:12

something complex with it yeah I know

13:13

many people are offended by this comment

13:15

but it's brilliant language design by

13:17

understanding who you are designing the

13:19

language for it is not insulting but

13:21

rather the matter OFA statement as go

13:24

was originally for people who worked at

13:26

Google and similar Industries and funny

13:28

part is that old Google Google 10 years

13:30

ago they like they did they were known

13:31

for hiring pretty smart people you might

13:33

be a better and more capable programmer

13:36

than the average googler but that

13:37

doesn't matter there's a reason people

13:38

love go it's simple opinionated and most

13:41

people can pick it up very quickly yes

13:44

uh however this iterator design seems

13:45

out of character to go especially for

13:47

someone like uh proposer Russ Cox

13:50

assuming that his let's see he was

13:52

actually the original proposer On The Go

13:54

Team it makes go a lot more complicated

13:56

and even more magical too I understand

13:58

how iter system works because I'm

14:00

literally a language design and compile

14:02

implementer it also has the possible

14:04

issue uh to it won't be a well

14:07

performing approach either because of

14:08

the need for closures and callbacks yeah

14:11

I'm very curious about the closure and

14:12

call back thing because that is not a

14:13

very typically not a very good um

14:16

performance I learned go before I

14:18

learned HTM X damn really is it called

14:20

go from Google probably I mean can we be

14:23

real here I know it's called goang but I

14:24

assume it's just Google Google Lang uh

14:27

maybe the argument for its design is

14:29

that the average go programmer is not

14:31

meant to implement iterators but just

14:33

use them and that the majority of

14:34

iterators that people will need will

14:36

already be available in go standard

14:37

library or by thirdparty package itself

14:39

so the onus uh is put on the package

14:41

writer and not the package user fair I

14:44

think that's pretty fair uh I mean I the

14:46

thing I do like about it it it's going

14:47

to unlock a lot of cool behavior and so

14:49

they already put in generics they

14:50

already have this like generic slice

14:52

package and Maps package which is super

14:54

nice and now they have this so I I I am

14:56

happy in the direction of go like I am

14:58

I'm very happy in the direction of go

15:00

and I hope they keep making really good

15:02

direction changes like this I think

15:04

they're just realizing that you H you

15:06

can't make a language so simple that

15:08

people need to rewrite everything every

15:10

time you need to make a language simple

15:13

enough that everything you need to write

15:15

should already be written and provided

15:17

in the standard library right I think

15:19

that's like a pretty good approach and

15:20

that's largely what they've done Lua

15:22

Lu's are very simple language but it's

15:24

actually a really powerful language it's

15:26

really easy to write well uh this is why

15:28

I think a lot of people seem to be angry

15:29

over the design it goes against

15:31

everything go was originally meant to be

15:33

in the eyes of a lot of people and it

15:34

seems like a really complicated mess I

15:36

understand the beauty that it looks like

15:38

a generator with the yield and the

15:39

inline code approach but I do not think

15:41

that is uh necessary in the vein of what

15:43

go is to a lot of people I actually wish

15:45

they would have gone much more the rust

15:47

route honestly have some sort of imp

15:49

like iterator uh function interface that

15:51

you could Implement and then you can

15:53

just range over it right if you provided

15:55

a next and is done or whatever you know

15:57

whatever way you want to do cuz they

15:59

have optionals I I mean personally I

16:01

think that that would have been

16:02

fantastic I mean I know it could have

16:03

collided with other things and maybe you

16:05

had your own iterators that had

16:06

something similar and maybe there that's

16:08

why they're kind of avoiding it is by

16:09

having this really complicated way you

16:11

can do a functional way to do it I just

16:13

I think doing an interface would have

16:14

been so much nicer just like string

16:16

right if you do formatting you can just

16:19

have string and if you implement string

16:21

it just works in the formatting which is

16:23

really really nice go does hide a lot of

16:25

how the magic Works under the scenes

16:26

especially when garbage collection go

16:27

routine select statements and many other

16:29

constructs however I think is a little

16:30

too magical in that it Expos the magic

16:32

to the user a little too much wilst

16:34

looking overly complex for the average

16:36

Co programmer I do think that this like

16:39

generally speaking the yield side of

16:41

things like I honestly don't even know

16:43

what it's doing I'd have to go read

16:45

about how this works because yield

16:47

usually is like a replacement for return

16:50

but it's like now a function but it's

16:52

you have yield Funk this must be the

16:54

name of the function called yield maybe

16:56

you can call it anything I not like I

16:57

assume I've never seen uh uh what's it

16:59

called named functions this way so

17:02

that's what I assume it is is this just

17:04

simply means hey it's time to be done

17:06

maybe I'm not really sure or you yield

17:07

out the value to the loop yeah that must

17:09

be what it is this yields out the value

17:11

out to the loop right the word yield

17:13

kind of tricks like tricks me here this

17:16

is yeah okay okay so this must be the

17:17

one that's doing it okay I see it I see

17:19

it I see it I see it it just feels

17:22

complicated right it yield is the loop

17:24

body basically yeah it just look it it

17:26

just feels complicated for me because my

17:28

brain had to like um at least the

17:30

examples my brain has to stop using

17:32

yield in the word that I or in the way

17:34

I'd normally use the word yield and use

17:36

it different yeah they should have

17:38

called it Yeet or Loop body or Loop

17:40

brain what's that I don't think I have

17:42

one of those you probably don't did you

17:43

ever see that uh this is why it's

17:44

confusing to me yeah that's why I got so

17:46

confused at first now now I understand

17:48

it this makes perfect sense right this

17:50

is literally just the function you're

17:51

just calling the function if that

17:52

function returns false you return false

17:55

which is kind of a generally interesting

17:57

thing I wonder how this works with

17:58

breaking out of you know what I mean

17:59

like can you do something like this uh

18:02

let's go back to the go I wonder if you

18:03

can do something like

18:07

uh do something with like

18:10

outer and break like a break outer

18:13

however that looks you know like just

18:15

sounds confusing right I assume that's

18:18

it it just all works but still it feels

18:20

confusing you know what I mean yeah it

18:22

has a go-to effectively yeah it has a

18:24

go-to cuz you have to break on the

18:25

inside and the outside so okay you can

18:27

okay isn't that a go-to that is oh boys

18:29

that's a go-to hell yeah go-to

18:31

considered amazing and you can screw off

18:34

uh all right here we go maybe the

18:36

argument is for the oh yeah we already

18:38

read

18:39

that uh the other aspect where people

18:41

find it confusing is that funk return uh

18:43

that returns Funk that takes a funk as

18:45

an argument and that the body of the

18:47

four range is transformed into a funk

18:49

and all let's see and all breakes and

18:52

other Escape control flows are converted

18:53

into return false it's just three levels

18:55

of procedural deep which again feels

18:57

like functional language Des rather than

18:59

imperative language design okay no I'm

19:01

not suggesting they replace the iterator

19:03

design uh what I am suggesting but

19:05

rather a generalized iterator approach

19:07

may not have been a good thing go in the

19:10

first place oh really for me at least go

19:13

is an unapologetically imperative

19:15

language with first class CSP like

19:17

constructs it's not trying to be a

19:19

functional like language iterators are

19:20

in the weird place where they do exist

19:22

in imperative languages but they are

19:24

very functionally but but are very

19:26

functionally as a concept iterators can

19:28

be elegant in functional languages but

19:30

in some many unabashed imperative

19:32

languages they always feel weird somehow

19:35

because they are being unified into a

19:36

separate construct rather than

19:38

separating out the parts of it I can buy

19:40

this initialize iterator destroy yeah

19:42

this is a very yes okay actually I I I

19:45

really do like this go relies heavily on

19:47

closures fine it does rely heavily on

19:49

closures but it's still it it is a very

19:51

imperative language typically if you're

19:54

using a lot of closures I would be a bit

19:56

surprised I and what I mean by that is

19:58

that means the only thing I can really

19:59

argue in my head for a lot of closures

20:01

that statement is that you must be doing

20:03

a lot of G Funk make a request that's

20:06

outside the loop and a weight group and

20:07

then or an airor group and then get all

20:09

your responses back and call it a day

20:11

that's at least how I cuz like the thing

20:13

I built with a bunch of bite processing

20:15

and compression and all that there's not

20:17

there's no closures right closures just

20:20

don't really happen in non highly

20:23

parallel SL uh whatever the other word

20:26

is I don't know why I'm blanking on it

20:27

uh concurrent

20:29

uh programming recently I heard about

20:30

Lambda calculus oh gosh oh gosh here it

20:33

goes here we go again here we go again

20:36

what's an imperative language I go a

20:38

then I go B then I go C then I go D then

20:41

I go e right yeah yeah yeah yeah yeah

20:43

yeah yeah yeah yeah let's see aside

20:45

Odin's approach as I alluded sorry my my

20:48

voice is still a little bit lost so

20:50

please forgive me then I go P then I go

20:52

a lot of p PE lot of p PE yeah uh no F

20:55

no effing no effing around here aside

20:57

Odin's approach as I alluded to to

20:58

previously in Odin an iterator uh is

21:01

just a procedural call where the last

21:03

value of the multiple return is just a

21:04

Boolean indicating whether to continue

21:06

or

21:07

not and because Odin does not support

21:09

closures the equivalent go backward

21:11

iterator in Odin is a little uh more

21:13

code to type note before people say that

21:15

looks even more complex can please

21:16

continue reading the article most Odin

21:18

iterators are not like this I would

21:20

never recommend writing such an iterate

21:22

iterator where a trivial for Loop is

21:24

preferred for both the reader and the

21:25

writer all right backward iterator see I

21:28

I like this approach already which is

21:30

this right here I liked the struct I

21:32

this is a very Russ does this too having

21:34

a struct for the iterator I like this

21:36

approach backward get the procedure you

21:39

get the backward iterator you give it a

21:41

slice it gives you backward iterator it

21:43

starts right here see the states stored

21:45

on the struct I see I prefer this by far

21:47

like absolutely there we go this makes

21:49

10 times more sense to me it just does

21:51

if this is greater than this we do this

21:53

else return yeah naked returns I hate it

21:56

I hate it there we go this is beautiful

21:59

to me this actually looks much simpler

22:00

than the go one I know like to me uh if

22:02

we go back up to the Top If I compare

22:04

these two things like I find this I'm

22:07

just going to go like that if we're

22:08

going to be real even though this one is

22:09

much more uh shall we say concise I find

22:13

it to be way simpler to

22:17

understand right like this is much more

22:19

concise you can see it in a small screen

22:21

but the the amount of function that

22:22

you're trying to Funk yourself with is

22:24

very right it's a it's a function that

22:26

returns a function that takes in a

22:28

function that returns booing right

22:30

whereas this one it's just like ah I

22:32

have my struct this is very

22:33

onedimensional I understand ah I can

22:35

make one by just simply doing that I can

22:38

iterate very easily by saying am I

22:40

greater than or equal to zero awesome do

22:42

that else you know return like this is

22:45

this is just extremely simple code

22:47

there's no no one has a question about

22:49

how it works despite me I have no idea

22:50

what any of this like I don't understand

22:53

this syntax at all but this is so simple

22:56

to follow I'm shocked that uh go did not

22:59

do it this way it just feels better to

23:01

me right it just feels it just feels

23:03

better you know uh let's see I'm a funk

23:06

uh playing a funk I'm a funk that's

23:08

pling a funk disguised as another Funk

23:10

oh my gosh oh my gosh oh my gosh dude

23:14

you just you literally just accidentally

23:17

made a great meme we're going for it

23:19

let's go uh what is it Tropic uh

23:22

Thunder uh memes uh generator let's see

23:25

what we got yeah generate that one save

23:28

the image go to Twitter go 1.23 uh uh

23:33

boom MIT license Bam Bam I'm a funk

23:38

playing a funk disguise is another Funk

23:40

dude that is so good that is so good

23:42

thank you thank you for your service

23:43

memes is speed yeah speed speed running

23:46

a meme quick speedrun of a meme pleasure

23:47

to be of a service TS clay you're a

23:49

beautiful man great movie too many funks

23:50

given D just so many so many anyways all

23:53

right let's go back to this I by the way

23:55

I'm shocked that Google didn't do this

23:57

or go didn't do this I I I still am

23:59

shocked I don't like I honestly in my

24:02

head this is actually also by the way

24:04

just to be fair this is also how async

24:06

iterators work in JavaScript because

24:08

it's the only sensible way to make async

24:11

iterators hey Ginger bill I was just

24:12

letting you know Hey look it's the

24:13

writer of the article Ginger I was just

24:15

defending you saying that like this is

24:17

the only sane way to make iterators I

24:20

think I I don't understand why you

24:22

wouldn't require a struct that

24:24

implements an interface and that's that

24:27

right cuz that it that feels very if

24:30

you think about it like go always offers

24:32

ways for you to implement if you want a

24:33

reader it's just a struct that

24:35

implements an interface you want a

24:37

writer it's just a struct that

24:38

implements an interface you want

24:40

something that can be stringified you

24:42

implement the string interface so it's

24:44

like it's shocking that it didn't just

24:46

follow all the other things now the

24:49

difference is the state Machine versus

24:50

story yeah I know and I I I hate this

24:52

argument because a struck State machine

24:55

is the only in my personal opinion is

24:57

the only sensible way to make an

25:00

iterator the this feels very confusing

25:03

to me right this feels this this feels

25:06

confusing just generally speaking

25:09

because I don't want to be a funk that's

25:10

disguised as a funk that is a funk any

25:13

that or I'm a funk that is a funk this

25:15

disguised is a funk it does not Shock me

25:17

why they uh didn't make it an iterator

25:18

because it doesn't actually work because

25:20

the iterator and go would have to be

25:21

extremely generic okay ah yeah okay okay

25:25

okay fair and factual I I can understand

25:29

I can understand that argument for it a

25:31

lot of funking going on yeah all right

25:33

anyways this does not appear to be more

25:34

complicated than the go approach because

25:35

or it this does appear to be a lot more

25:37

complicated I'd actually fully disagree

25:38

this appears to be extremely

25:40

one-dimensional and a baboon such as

25:42

myself a grug brain Dev this makes

25:45

perfect sense I get it this is what I

25:47

would say does not require 200 IQ this

25:50

is what I think requires 200 guy IQ

25:53

honestly I do think it's more

25:55

complicated uh than the go approach

25:56

because it requires you to r a a right a

25:58

lot more code however just use co-pilot

26:01

just use just use copilot boiler plate

26:03

mentioned boiler plate mentioned um

26:05

however it's actually a hell a lot

26:07

simpler to understand comprehend and

26:08

even faster to execute the iterator does

26:10

not call for Loops body rather the body

26:12

calls the iterator I know Cox loves the

26:14

ability to store data and control flow

26:16

and I do agree it is nice but does not

26:18

fit well with Odin uh especially with

26:20

the lack of closures because Odin is a

26:22

manually uh memory managed language an

26:25

iterator is just syntax sugar for the

26:26

following yeah that's Lally all it is

26:28

that's why that's why uh in Zig right

26:31

now when you look at Zig I created for

26:34

for the game I created an FPS iterator

26:36

right I can't just like call hey four

26:39

range on my iterator or on my FPS

26:40

iterator but it does actually work

26:42

really really nicely to be able to have

26:44

something that I can be like hey sleep

26:46

the appropriate amount give me the Delta

26:49

and then the next time it's called

26:51

depending on how long my game Loop took

26:53

it can then sleep for the appropriate

26:56

amount of time it's a very simple kind

26:58

of iterator is type pattern Odin catches

27:00

my eye lately Odin's a very interesting

27:02

language Odin's approach is just

27:04

removing the magic and making it

27:05

extremely clear what's going on

27:06

construction and destruction must be

27:08

handled manually with explicit

27:10

procedures and that iteration is just uh

27:13

a simple procedure which is called each

27:14

Loop all three constructs are handled

27:16

separately rather than managed into one

27:18

confusing thing like go yes yes I do

27:20

agree that uh I also the followup

27:22

agreeing uh is that the cleanup code

27:26

will make it much more confusing looking

27:29

cuz if you have any level of cleanup

27:30

code that's more than one line there's

27:32

just like a lot that goes on right here

27:34

all right Odin does not hide magic Wist

27:36

go approach is actually very magical

27:38

Odin makes you uh handle the closure

27:40

like values manually along with

27:42

construction and destruction of the

27:43

iterator itself Odin's approach also

27:45

trivially trivially allows you to have

27:48

as many multiple return values as you

27:50

wanted to a good example of Odin's core

27:52

encoding CSV package where the reader

27:54

can be treated like an iterator by the

27:56

way fun fact for those that are

27:57

wondering CSV does not have an official

28:02

standard there is a RFC but there is no

28:06

official encoding of a CSV how F how

28:09

effed is that how effed is that CSV is a

28:12

good aful standard yeah I know how like

28:14

screwed is that that there's like a

28:17

thing that people use all the time that

28:18

actually doesn't have a standard have

28:20

you ever used it

28:21

where we've had some csvs produced when

28:24

I was at Netflix dumping data from uh

28:27

our big dat data into records worked

28:30

with like half of the CSV parsers the

28:33

RFC for CSV had an extra comma in it so

28:35

it couldn't be read in

28:37

Excel isn't that just so good isn't it

28:39

just like isn't CSV just such a funny

28:42

funny thing that we deal with it's

28:44

actually the like literally the world's

28:46

worst format and yet there it is drink

28:49

some water PR no I lost my voice

28:51

Microsoft Excel csvs do this for

28:53

non- ancy characters damn dude that's so

28:56

it's just so effed up and coding

28:58

procedure reader string index error more

29:02

bu okay nice aside C++ iterators I will

29:05

try not to get into huge rant about C++

29:07

iterators in this article everything C++

29:09

did for iterators C++ is the only

29:12

language in which asks me would you like

29:14

me to install co-pilot and for me to say

29:17

yes C++ iterators are much more than a

29:19

mere iterators wilst at least Go's

29:21

approach is a mere iterator I completely

29:22

understand why C++ iterators do what

29:24

they do but 99% of the time I just want

29:27

a mere iterator not something that has

29:28

all the AL algebraic properties that I

29:31

that allow it to be utilized in more

29:32

General places dude everything with C++

29:34

iterators felt very hard they feel

29:37

extremely difficult lost your voice at a

29:39

redneck lawnmower trailer pull

29:40

competition I they like unironically a

29:42

redneck lawnmower trailer pull

29:44

competition is exactly something that

29:47

open sauce would have uh for people who

29:49

don't know C++ very well an iterator is

29:51

a custom struct class uh which

29:52

requirements is to have the overload

29:54

operators to make it act like pointers

29:56

historically a C++ iterator would look

29:58

like this ah isn't that just lovely

30:01

don't you love a good oldfashioned begin

30:03

not equal end begin Plus+ ah look at

30:05

that beauty ain't nothing like it you

30:07

got throwing a little const in there a

30:08

little const Auto

30:10

[Music]

30:12

reference dude I hate them uh and would

30:15

be wrapped in a macro before C++ uh 11

30:18

range Loops yeah the big classic thing

30:20

to do is you make apparently you make a

30:22

for each Macro and then you use that to

30:24

do your actual iteration before C++

30:26

arranged a four Loop syntax and auto

30:28

became a thing the biggest issue with

30:30

C++ iterators require you to Define five

30:32

different operations at a minimum the

30:34

following three operation overloads

30:36

equals does not equal Plus+ pointer uh

30:40

along with two Standalone uh procedures

30:42

or bound methods which return in

30:43

iterator value begin and end if I was to

30:46

design a C++ mere iterators it would

30:48

have to be as simple as a struct class

30:50

that calls an iterator next or something

30:52

and that's it yes it does mean that

30:54

other algebraic properties are lost but

30:56

I honestly do not need the ever for any

30:59

problem I am working on when I'm working

31:01

on those kind of problems or those kinds

31:03

of problems they always be either a

31:05

contiguous array or I implement the

31:07

algorithm manually because I want

31:08

guarantee the performance will be good

31:10

for the data structure however there is

31:12

a reason I made my own language Odin

31:14

because I completely disagree with the

31:16

entire C++ philosophy and I want to get

31:18

away from that Madness does anybody know

31:21

what language in uh inspired C++ anybody

31:24

we've had a couple people know it simula

31:27

simula uh what is that nigar right it's

31:30

it's nigar and gosh I can't remember

31:33

anyways simula called it very great

31:35

story by the way how simula was created

31:37

very cool story very very very very cool

31:40

story uh they just it's actually simula

31:44

both was born and died on the fact that

31:46

it was a simulation language trying to

31:47

be a general a general programming

31:49

language it's kind of s it's kind of sad

31:52

hey thank you very much Gucci algo 68

31:54

Supremacy yeah so they they compiled

31:56

down to algo but eventually had the quit

31:58

doing algo due to a stack one thing that

32:00

was really cool about simula is that

32:03

there was no such thing as this idea of

32:05

storing data on the stack and coming up

32:07

doll that's right doll yeah nigar

32:09

niggard and doll and coming up with this

32:11

idea of storing a bunch of stuff on the

32:13

stack was like extremely first off it

32:15

considered distasteful gross but second

32:17

off it just like wasn't really done and

32:20

they like came up with it pretty cool

32:22

it's super cool like a genuinely super

32:24

cool like story uh C++ iterators are a

32:27

hell of a lot more complicated than go

32:28

iterators but they're much more direct

32:30

with the local operation at least with

32:32

go you don't need to construct a type

32:34

with five different properties in

32:36

conclusion I feel like go iterators do

32:37

make sense with the design principles

32:39

but to them uh let's see applied to them

32:42

but seem antithetical to what most

32:44

people view go as being I know go has

32:46

had to get more complex over the years

32:48

especially with the introduction of

32:49

generics which I do think uh are

32:51

actually welld designed with only a few

32:53

syntax quibbles yeah I mean everybody's

32:56

still the problem is is every every body

32:58

wants one thing to really make iterate

33:00

uh uh generics awesome which is Method

33:02

receivers but it does appear that you

33:04

can you can get around some of that

33:06

because I know there's some generic

33:07

libraries in which I don't even

33:09

understand how they work but they they

33:10

do work uh but the introduction of

33:12

iterators of this feels uh of this ilk

33:14

feels wrong I think the short of it is

33:18

that it feels like it goes against the

33:19

apparent philosophy of go that many

33:20

people believe coupled with being very

33:22

functional way of doing things rather

33:23

than imperative and because of those

33:25

reasons I think that is why people don't

33:27

like the iterator stuff even if I

33:29

completely understand the design choices

33:30

made it doesn't feel like what go

33:33

originally was to many people maybe the

33:35

concerns of mind and others are

33:36

overblown and most people will never

33:37

actually Implement them and just use

33:38

them and that them being this over

33:41

complicated to implement second to last

33:43

controversial take maybe go needed to

33:45

gatekeep even more than just tell the

33:48

functional Bros to go away and stop

33:49

asking for such features which make go a

33:51

much more complicated and complex

33:52

language last controversial thing by the

33:54

way I do like this you should this is I

33:57

mean I'm sure Bill I'm sure Ginger bill

33:59

will 100% say this that his language

34:01

likely has uh likely has uh a bunch of

34:05

people asking for things that he has to

34:06

say no to constantly and that there's an

34:08

entire collection of people that want

34:10

Odin to probably look like rust or look

34:14

like go or look like zigg or look like

34:16

Fillin the blank and he has to say no a

34:19

lot I dislike go iterators there I said

34:21

it I I mean I want to dislike him but I

34:24

also want to use them I mean that's

34:25

where my big problem really comes down

34:27

too because I find myself doing dumb

34:29

things now you say no a lot not not

34:31

surprising grug's favorite uh word is no

34:34

yeah what language is fill in the blank

34:36

it's a new language you wouldn't

34:37

understand here's an example of what I

34:38

what I really want uh if you look up

34:40

let's see um there you go I have this

34:42

idea of a virtual box which is just a

34:44

quad tree that you can replace and uh

34:46

replace the underlying buffers for and

34:49

what I had to do is I had to do a um I

34:52

created this whole next idea and I had

34:54

to create like my own iterators so it's

34:56

like it has these bite Ator results

34:58

which has this and then like I had to do

35:00

all these things and when I want to use

35:02

this I have to do things like this I

35:03

have to like range over certain things

35:06

in a very annoying way that I really

35:08

hate because I can't just simply do it

35:11

well right like look at this at the four

35:13

forever get this then I have to do that

35:16

so it's like I want I want that because

35:18

when I get the result and the result is

35:20

done I have to like manually break I

35:22

just want something that I can make a

35:23

struct that I can walk with you know

35:24

what I mean I like that I like the next

35:27

I like done make it easy anyways I don't

35:30

know go iterators feel really clever

35:32

which I think people feel is anti-g

35:34

goang which is another way of saying

35:35

What ginger bill was saying that's

35:37

probably Fair that's probably really

35:38

fair yeah but simultaneously I read

35:40

someone else's code and say I hate this

35:41

yeah I think reading someone else's

35:43

iterator code is going to be in

35:46

intensely more difficult right intensely

35:49

more difficult I I actually really agree

35:51

with that reading you pick careful now

35:54

hey Prime Thor told me uh your deep Dart

35:56

Secret your stash is green screen CGI on

36:00

your face and not real the name is the

36:02

stash is actually real buddy don't don't

36:05

try that don't you Thor's just angry

36:07

because we got a thousand people to sing

36:09

him happy birthday a jet

UNLOCK MORE

Sign up free to access premium features

INTERACTIVE VIEWER

Watch the video with synced subtitles, adjustable overlay, and full playback control.

SIGN UP FREE TO UNLOCK

AI SUMMARY

Get an instant AI-generated summary of the video content, key points, and takeaways.

SIGN UP FREE TO UNLOCK

TRANSLATE

Translate the transcript to 100+ languages with one click. Download in any format.

SIGN UP FREE TO UNLOCK

MIND MAP

Visualize the transcript as an interactive mind map. Understand structure at a glance.

SIGN UP FREE TO UNLOCK

CHAT WITH TRANSCRIPT

Ask questions about the video content. Get answers powered by AI directly from the transcript.

SIGN UP FREE TO UNLOCK

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.