Careful About Programming Advice

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 173

  • @pieflies
    @pieflies 9 หลายเดือนก่อน +29

    A similar concept is making sure you understand a bug before fixing it.
    So often I see people implementing a “fix” that is actually fixing the symptom not the cause because they didn’t take the time to fully understand the cause before trying to fix it.
    The project ends up being layers of crap on top of crap u til you can’t work out what code actually needs to be there anymore.

  • @Evilanious
    @Evilanious 9 หลายเดือนก่อน +14

    Secretly, if, for, function calls and all control flow are jumps. I'm glad the jumps are structured into something comprehensible in higher level languages though. The main problem is dogmatism. Using loops and ifs get the job done 99% of the time and are the most readable option 90% of the time. But there are cases where direct jumps or other more unusual options are just as good or better than. Range based loops are neat when they work and they can be done without too much overhead, but making them the default or only option is just silly.

  • @chris-pee
    @chris-pee 9 หลายเดือนก่อน +10

    The "When used incorrectly" makes this even more funny. You could say the same about JS itself, is that a reason to ban JS? (It is)

  • @inDefEE
    @inDefEE 9 หลายเดือนก่อน +33

    I literally just last week had a code review where I asked for a map() to be changed to a forEach() because they were just discarding the result.
    When asked why I said because it’s using additional memory unnecessarily and will cause slowdown as well as confusion as to why map is being used.
    The response I got was essentially “we are doing web development, memory management and performance doesn’t matter”.
    I am at a loss of how to deal with and change that mentality in the industry.

    • @tamaskosa4456
      @tamaskosa4456 9 หลายเดือนก่อน +5

      Ask this counter-question:
      "Why should map be used instead of forEach?"

    • @mudi2000a
      @mudi2000a 9 หลายเดือนก่อน +12

      This mentality is extremely dangerous because it creates code that works at first but later creates strange behavior or performance issues that might be hard to track down.

    • @namcos
      @namcos 9 หลายเดือนก่อน +5

      Except it does matter. Not everyone has the latest super fast phone/computer/tablet etc. Some of those tablets (for a time anyway) were trying to get away with the lowest RAM to qualify as a device for "web surfing" but then add on whatever OS is on the device, chrome, apps you've installed, and on top of that your web app with several fat libraries and you can see why this becomes a potential problem.

    • @TazG2000
      @TazG2000 9 หลายเดือนก่อน +4

      This could be a valid take if both of these are true:
      1. It actually doesn't matter in the given context, i.e. the additional memory is insignificant and does not leak.
      2. It would be considerably more effort to do it the right way.
      So, if some values happen to be copied within a function, but the extra memory will be garbage collected, the function is called infrequently, and refactoring it to be more memory efficient would be extra effort... okay, it's probably fine the way it is.
      But using forEach instead of map _is not hard_ - so this fails #2.
      Basically, absolute rules don't work. We can't rule "never discard results" or "always use map" or anything, whether it's web or app or server development, because it's _always_ context specific.

    • @Ethel173
      @Ethel173 9 หลายเดือนก่อน +2

      "how much money are we losing because customers cant run our software, and how much money do you think we lose because a customer clicked off waiting for something to take 4 seconds to finish"

  • @Mystic998
    @Mystic998 9 หลายเดือนก่อน +43

    Dijkstra's basic point was about how hard it is to follow the state of a variable throughout an iterative process if you let the programmer decide the structure of the loop rather than having some standard iterative flows. Continue in this context would be just fine as it doesn't meaningfully impact that understanding.

    • @brianviktor8212
      @brianviktor8212 9 หลายเดือนก่อน +1

      Yeah, it just makes code harder to understand. I use goto very rarely, almost never... but there was one situation where it was more convenient than alternatives.

    • @foobar8894
      @foobar8894 9 หลายเดือนก่อน +10

      Also, Dijkstra was saying this in a time where people used line number based basic. As in: 10 PRINT "Hello world" - 20 GOTO 10. Before for loops, while loops etc even existed. That type of line number based programming is long gone (in part thanks to Dijkstra). Dijkstra was not wrong, he also wasn't talking about using continue in a loop. He was talking about having structured loops in the first place.

    • @paxcoder
      @paxcoder 9 หลายเดือนก่อน +2

      Not sure about that, early returns, breaks, and even continues interrupt control flow.
      If I'm looking for something specific in a codebase I won't read every function line by line top to bottom. But if I miss a return/break/continue, I can be sent on a wild goose chase.
      Contrast this with conditionals: A properly indented branch tells me at a glance that the part of code I'm looking at depends on some previous condition.

    • @CallousCoder
      @CallousCoder 9 หลายเดือนก่อน +3

      @@paxcoder In Fortran there was this syntax that you could only return once. Just to improve control flow and readability. I thought that achieved quite the opposite.
      And like you said indents really make life easy.
      And also gotos within a subroutine doesn’t make it hard to understand the code. People who find that disorganized probably never wrote assembly. As most of the Fortran devs when this idea of goto must go to came up.

    • @1Caja
      @1Caja 9 หลายเดือนก่อน

      ​@@paxcoderI'd rather have early returns and read the function from top to bottom than deal with the branching nature of nested if clauses in long functions. Especially when it's mutating state outside of them.
      Functions should be short anyway, not clean code short, but as short as it's reasonable given the situation and then it's most of the times only an early return for an assertion. Like:
      if(not validation.success) {
      return/throw whatever
      }
      ... happy path ...
      For my small team and I it's perfectly reasonable and if the situation arises that nested ifs are neccessary or easier to reason about we'd just use them. I haven't read a good arguement why you shouldn't use early returns, and at this point I think it's just preference. 🤷‍♂️
      I've programmed profesionally for 5 years now and changed on many opinions and stances either through good arguments or experience. I am willing to change my mind.

  • @sub-harmonik
    @sub-harmonik 9 หลายเดือนก่อน +8

    1st of all goto isn't harmful.
    2nd of all continue isn't a goto.
    I actually like how java deals with this: just label a block and then you can break out of it, and you can also break out of labelled blocks for iteration. It is exactly the same as goto but the fact that there are labelled brackets around the code that can be jumped out of or continued makes it clear what's happening and what the flow is.

    • @Waine2000
      @Waine2000 9 หลายเดือนก่อน +3

      Both instructions break what Dijkstra calls the "control flow" of the code. So you can't read it as a series of steps top-down anymore.
      That being said, break, continue have the same consequente as goto. But they're "formatted" control flow changes, as for and while loops.
      I don't agree with putting these instructions in the same category as goto, as harmful as goto. But it's important to understand the argument behind it

  • @mikemikemike444
    @mikemikemike444 9 หลายเดือนก่อน +75

    BOOMER LOOPS!

    • @dmitriyrasskazov8858
      @dmitriyrasskazov8858 9 หลายเดือนก่อน +11

      Honestly expected boomer loops to be jumps. I must be old.

    • @gammalgris2497
      @gammalgris2497 9 หลายเดือนก่อน +1

      ​@@dmitriyrasskazov8858
      Depends on which code level you contemplate. Jumps/ Gotos on the lower levels. For on the higher levels.

    • @arafatzahan3697
      @arafatzahan3697 9 หลายเดือนก่อน

      @@dmitriyrasskazov8858missionary loop!

  • @BudgiePanic
    @BudgiePanic 9 หลายเดือนก่อน +30

    "Missionary loops" had me rolling

    • @Haitaish
      @Haitaish 9 หลายเดือนก่อน +2

      The loops were unrolling

    • @serchtul
      @serchtul 9 หลายเดือนก่อน

      this comment is so underrated@@Haitaish

  • @AndrewRusinas
    @AndrewRusinas 9 หลายเดือนก่อน +7

    airbnb style guide is dumb, I am so happy to know that I am not the only one who thinks so

  • @Vitis-n2v
    @Vitis-n2v 9 หลายเดือนก่อน +19

    I get that people don't like goto because it can send you to basically anywhere in the code but a freaking continue is very staightforward and predictable

    • @adambickford8720
      @adambickford8720 9 หลายเดือนก่อน +1

      So isn't goto, until it isn't

    • @reed6514
      @reed6514 9 หลายเดือนก่อน +2

      Personally, i think goto is fine. It's not my first choice most the time, but it's useful occasionally. And i can read code whether it has a goto or not. I don't think people need to be so scared of ... writing code. Every line has implications, whether you use goto or not.

  • @deltapi8859
    @deltapi8859 9 หลายเดือนก่อน +22

    "for loops are faster" in sane project management you would integrate speed/efficiency factors with feature implementation. However sane is not industry standard. Industry standard is to crank out the priority your project organizer breaths down your neck. In this case use map or foreach over for. Because once there is a bug it will never again be addressed, because of the next 10 feature that are breathed down your neck.

  • @astralfoxy1787
    @astralfoxy1787 9 หลายเดือนก่อน +71

    So why we use "functions" if it's GOTO too.
    If that "type" of guys decide what JS is - that's can explain A LOT. LMAO

    • @tanko.reactions176
      @tanko.reactions176 9 หลายเดือนก่อน +2

      because a function returns to its next line.
      goto leads to a situation where variables in the current context/scope have unexpected values, potentially, if not accounted for. and accounting for it is a huge mental burden, lowering maintainability. also its more error prone.

    • @astralfoxy1787
      @astralfoxy1787 9 หลายเดือนก่อน +3

      @@tanko.reactions176 DUDE in assembly you HAVE NOT "SCOPES", its just a TEXT

    • @tanko.reactions176
      @tanko.reactions176 9 หลายเดือนก่อน +4

      @@astralfoxy1787 false.
      you have a frame pointer (ebp or rbp) and therefore, you have "functions".
      you should learn about the call stack (stdcall, for example). you have jumps for loops and if, but they dont count. those are well defined applications of jumps. anything outside of it qualifies as a "goto" which is clearly an anti pattern.
      stop trying to win a fight which has been long lost.

    • @reed6514
      @reed6514 9 หลายเดือนก่อน

      ​@@tanko.reactions176i use actual goto sometimes, and you know what? It works. I'm a programmer, and i can understand code. And i make mistakes, regardless what rules i follow, because I'm a human. And the fix is the same with goto or anything else that's broken: debug & write code.

  • @nomadshiba
    @nomadshiba 9 หลายเดือนก่อน +11

    addicted to prime videos while taking a dump

  • @TalicZealot
    @TalicZealot 9 หลายเดือนก่อน +92

    you know..... Jonathan Blow might have been right about web jobs

    • @nekogami87
      @nekogami87 9 หลายเดือนก่อน

      not sure what he said, but was it something like "95% are overpaid idiots and the other 5% are the ones that do actual interesting stuffs or even just deliver" ? if so, yeah, it's not really a secret.

    • @Malix_Labs
      @Malix_Labs 9 หลายเดือนก่อน +5

      You can attribute most of that to JavaScript, to be really honest

    • @CallousCoder
      @CallousCoder 9 หลายเดือนก่อน +5

      I said in 1996 already that web code was a cancer. If yiu understand http is a markup language means that it’s simply not designed to have interactive interaction.
      To get it to somewhere to that state was just bolting on crap like Java applets and later JavaScript

    • @herrpez
      @herrpez 9 หลายเดือนก่อน +1

      ​@@CallousCoderI've lived the web since the 90s, and I would love to tell you how utterly wrong you are. But you are right, so I won't. 😉

    • @CallousCoder
      @CallousCoder 9 หลายเดือนก่อน

      @@herrpez okay go ahead.
      But to me it’s terrible in every sense of the word.
      Security, speed, complexity, scalability. Oh man cgi-bin in the beginning, what a hell.
      Then Java applets, which was a great idea as running a cross platform vm with capabilities of a think client was okay of an idea, but it was so slow to download and run.
      Then JavaScript, suddenly you used 3 languages your backend language that you had to parse the request headers for post and get 😣JavaScript for frontend and sql for backend. You had to make some clever connection pools separately because it wouldn’t do that properly because a backend module request had to connect to the database and authenticate otherwise ever connection because http wasn’t stateful. Because it wasn’t tasteful you had to use cookies and separate state stores to store state. None of this you ever had to do with regular thick client programs.
      The web is just a heap of technology slapped together to address everyone of the shortcomings of a poor foundation.

  • @Silencer1337
    @Silencer1337 9 หลายเดือนก่อน +11

    I'd like to know how many of us have been there, and moved on. There definitely were times when I wrote contrived code which adhered to uninformed standards just to marvel at how complicated it was while still getting the job done. I think what's going on is that some programmers unconsciously treat programming like a game, instead of as an engineering discipline.

    • @darthbumblebee7310
      @darthbumblebee7310 9 หลายเดือนก่อน +6

      I think part of the problem is many of the so-called clean coding gurus give bad advice that makes its way into coding standards documents.

    • @herrpez
      @herrpez 9 หลายเดือนก่อน +5

      Less a game, more a religion, I would argue. In many cases it's about dogmatic and unquestioning adherence to bad ideas.

  • @HyperFocusMarshmallow
    @HyperFocusMarshmallow 9 หลายเดือนก่อน +2

    So, this is JavaScript of course. I have recently ran across a simple example in rust where an iterator was completely optimized away down to a hard coded constant but the semantically equivalent while loop was not. That clearly relies on the input being know at compile time of course which often is not the case, but I currently don’t fully understand what causes that difference.
    Sometimes rust hardcodes loop results as well so there is some extra difference messing it up.

  • @etiennelemieux472
    @etiennelemieux472 9 หลายเดือนก่อน +1

    Even goto have good uses in c#, for exiting nested loops.

  • @seancooper5007
    @seancooper5007 9 หลายเดือนก่อน +6

    Continue is based

  • @Salantor
    @Salantor 9 หลายเดือนก่อน +4

    Every time I see someone making an array out of a number and then looping over it with .map() to return another array of anything when simple for() loop would suffice I can't help but agree with people seeing JS devs as incompetent. You are using a bulldozer to remove a few bricks, what are you doing? Also: .filter() and .map() instead of .reduce(), because muh readability. Yet another reason to like Golang: one loop for everything, whether you like it or not. Refreshing.

    • @phead2137
      @phead2137 9 หลายเดือนก่อน

      Reduce sucks tbh, it’s much more convenient to just use a loop instead

  • @exception05
    @exception05 9 หลายเดือนก่อน +3

    So if I found some place to rest on Airbnb is it harmful to GOTO?

    • @KatanaDnB
      @KatanaDnB 9 หลายเดือนก่อน

      oh my god what did I just read... 😂😂😂

  • @Junior.Nascimento
    @Junior.Nascimento 9 หลายเดือนก่อน +1

    in the end of the day assembly uses jumps to make flow of the code, we have an branch predict thingy in the CPU's nowdays.
    GOTO holds the mordern world

  • @chudchadanstud
    @chudchadanstud 9 หลายเดือนก่อน +1

    i use contues as gaurd clauses, especially when I'm searching for an item that needs to meet a certain criteria linearly.

    • @anthonyewell3470
      @anthonyewell3470 9 หลายเดือนก่อน

      I searched the issue for a more resonable answer. Someone said that avoiding continue and break may enforce more immutable code and decrease function size. These are points I could understand, but it took some scrolling to get there.

  • @doc8527
    @doc8527 9 หลายเดือนก่อน +4

    Airbnb eslint rule is a plague after maintaining several codebases based on their rules.
    The people who copy/paste the eslint rule has literally 0 idea why they used it. "It was created by Airbnb, big tech company, must be good then". That's the 100% times I got the answer.
    All of their rules might work well for the airbnb codebase, but it's a premature optimization for 99% codebase outside of that, for me it's even an opinionated biased config.

    • @codingjerk
      @codingjerk 9 หลายเดือนก่อน +6

      Disallowing continue is not a premature optimization, it's a premature pessimization

  • @CallousCoder
    @CallousCoder 9 หลายเดือนก่อน +1

    Goto isn’t harmful either. It’s the most useless position to take! And people who defend it hard, don’t understand that gotos are the foundation of branching in any cpu.
    Every loop you program below is using a jump/branch and that’s a goto. But when you use goto just inside a single function, it’s not hard to trace. I agree it’s like break and continue and I have no problem with those either.
    You just don’t want to use goto over functions. This is what creates spaghetti code, because there’s no easy context. And that’s what happened mainly in basic when people didn’t use gosub.
    But frankly I can’t recall when I used goto in a higher level language. But in assembly jmp is my friend and I’m not getting lost in assembly either.

  • @test-rj2vl
    @test-rj2vl 9 หลายเดือนก่อน +1

    At work I also have devs who blindly follow absolutely everything they see in code style guides. Most annoying part is when they demand others to follow them too in code review.

  • @kurt7020
    @kurt7020 9 หลายเดือนก่อน +7

    We must make a copy of all things because functional and immutable are words I've heard.

  • @Lemmy4555
    @Lemmy4555 9 หลายเดือนก่อน

    once i had 2 nested for loops, and i was proud of using continue with label.

  • @Zutraxi
    @Zutraxi 9 หลายเดือนก่อน +1

    Continue and break is not goto? I take offense.
    It is very determined and does the same thing everytime. Goto has to be maintained.
    I use continue and break all the time to optimize the median run time of my loops.

  • @KennethBoneth
    @KennethBoneth 9 หลายเดือนก่อน

    If continue is bad because it’s “GOTO”, why do they like try catch?

  • @MrAlanCristhian
    @MrAlanCristhian 9 หลายเดือนก่อน

    I didn't even listen to what the linter try to warn me.

  • @anakreonmh87
    @anakreonmh87 9 หลายเดือนก่อน +1

    Imagine getting hired in a company where the "senior" devs won't approve your PRs because it has regular loops instead of these "functional" loops (and don't care about the reasons)...

  • @thunderstruck2727
    @thunderstruck2727 9 หลายเดือนก่อน

    Chesterton Fence Principle: Don’t Destroy What You Don’t Understand!

  • @brandonbraner
    @brandonbraner 9 หลายเดือนก่อน

    Yes always ask why, to devs to pms to everyone. If someone can’t tell you why they need to do more homework.

  • @jaysistar2711
    @jaysistar2711 9 หลายเดือนก่อน +1

    No, break and continue are NOT goto! The reason that goto isn't needed is BECAUSE OF break and continue! The use of goto leaves the scope in an arbitrary way, which means defer (Go, Zig, D (called "scope exit")), and destructors (C++, Rust (called "Drop")) don't behave as expected.

  • @user-hk3ej4hk7m
    @user-hk3ej4hk7m 9 หลายเดือนก่อน +1

    forEach doesn't create another array, there's no memory allocation. You could even modify the elements of the same array you're iterating. Some devs are concerned with off by one errors and infinite loops, others are concerned with using JS for what it was not intended to (being fast), both are valid concerns.

    • @stayfree1776
      @stayfree1776 9 หลายเดือนก่อน +1

      that isnt the point. the point is that a forEach will iterate through the entire array, which binds the linear execution time to the current amount of elements in the array. Continue and break can implement early exits in iteration making the linear execution time bound to the matching case, regardless of the size of the array.

    • @user-hk3ej4hk7m
      @user-hk3ej4hk7m 9 หลายเดือนก่อน

      ​@@stayfree1776 for that you can use a for..of loop, which gets rid of the issues I pointed out like infinite loops and off by one errors. Yes, saying that break and continue are bad is dumb, I wasn't defending that idk why you got that idea from my comment.

  • @austinanderson2620
    @austinanderson2620 9 หลายเดือนก่อน

    Yes it come from Dijkstra and was considered bad because goto made it difficult to prove the correctness of an algorithm

  • @deltapi8859
    @deltapi8859 9 หลายเดือนก่อน +1

    "Boomer loops" new term established.

  • @giorgiok8864
    @giorgiok8864 9 หลายเดือนก่อน

    "premature optimisation is the root of all evil" is a misquote from a biblical verse? What?
    Can some give some more info on this ? :D
    Thanks!

    • @MNbenMN
      @MNbenMN 9 หลายเดือนก่อน +2

      1 Timothy 6:10 combined (misquoted by omitting "love of") with "money" replaced by "premature optimization" (Tony Hoare via Donald Knuth) but with the "about 97% of" part being omitted, so indirectly it's a misquote of a misquote of the bible.

    • @giorgiok8864
      @giorgiok8864 9 หลายเดือนก่อน

      @@MNbenMN Thank you!

  • @NoFailer
    @NoFailer 9 หลายเดือนก่อน +1

    My girlfriend said premature optimisation happens to everyone.

  • @MadaraUchihaSecondRikudo
    @MadaraUchihaSecondRikudo 9 หลายเดือนก่อน +3

    If continue and break are GOTO then so is return and throw...

    • @bionic_batman
      @bionic_batman 9 หลายเดือนก่อน +2

      well, to be honest throw is almost as bad as GOTO
      languages that don't have it are much nicer when it comes to error handling

  • @vitalyl1327
    @vitalyl1327 9 หลายเดือนก่อน +3

    Web code monkeys are hilarious, aren't they? It'll be a bit sad when they all are replaced with stochastic parrots, they were quite entertaining.

  • @nerdycatgamer
    @nerdycatgamer 9 หลายเดือนก่อน +2

    so sick of advice just being like 'this thing is bad practice', "continues are bad practice", "goto is bad practice", "LOOPS are bad practice". Nobody actually knows why, they just parrot these things that they heard once and act like they're smarter.
    'GOTO considered harmful' was written before we even had standard control flow like 'for', 'while', 'if else', so a loop would just be 'label: foo(); goto label;', and that this hard to understand when the entire code base is written like that. Djikstra was just advocating for standard control flow, and nowadays 'goto' (and continue/break) are harmful is used where standard control flow could be used instead (looking at all the juniors who write 'while (true) { ... break; }' instead of just putting the break condition as the while condition'
    loops being 'bad practice' in js is just the result of js andy's who don't actually know how to code going 'if you use iterator methods its only one line!! the fewer the lines better!!' and then teaching juniors 'loops are bad practice', and then those juniors taught other juniors and so on.
    'premature optimization is the root of all evil' should be replaced with 'premature abstraction is the root of all evil'. if you can get something done with a boomer 'for (i' loop, do it that way. the end user doesn't see how many lines of code it is. they're not impressed by your 'array.map().reduce().suck().fuck().cum()'.

  • @AnisioLemos
    @AnisioLemos 9 หลายเดือนก่อน +2

    A few hours ago I just stumbled across an article about Chesterton fence, then the first youtube video I watched ThePrimeagen mentions it...
    It's been a recurring thing in my life.
    Maybe I should start a religion... Who's the revealed prophet, you asked me? ThePrimeagen is his name.
    I'm not working and studying too many hours until lack of skill syndrome becomes impostor syndrome.
    I'm completely sane, for now.
    That's what they are saying to me.

    • @inDefEE
      @inDefEE 9 หลายเดือนก่อน

      Just an fyi, it’s because the google algorithm knows what you’re searching and what you’re looking at in chrome. It then uses that info to feed you relevant content on other google entities like youtube.
      It isn’t a coincidence

  • @arafatzahan3697
    @arafatzahan3697 9 หลายเดือนก่อน

    If only he was part of TC69, he'd be taken more seriously.

  • @pudicio
    @pudicio 9 หลายเดือนก่อน

    Love me some boomer speedup loops

  • @adambickford8720
    @adambickford8720 9 หลายเดือนก่อน

    It's not the loops, it's the mutation. Once you get used to using expressions and values, debugging imperative mutating code is vertigo inducing. I want to solve business problems, not play stupid pointer games.

  • @sukapow
    @sukapow 9 หลายเดือนก่อน

    People has been fooling people in tech for long long time

  • @steveoc64
    @steveoc64 9 หลายเดือนก่อน +2

    The only programming advice you should listen to is what Joe Biden says. He is the master of programming.
    He says to Use Rust !

  • @gge6021
    @gge6021 9 หลายเดือนก่อน

    im all in on boomer loops

  • @anasouardini
    @anasouardini 9 หลายเดือนก่อน

    missionary Loop; lessgo

  • @Optimus6128
    @Optimus6128 9 หลายเดือนก่อน

    First they came for the goto..

  • @marcusrehn6915
    @marcusrehn6915 9 หลายเดือนก่อน

    Poor guy never got an answer.

  • @felipedidio4698
    @felipedidio4698 9 หลายเดือนก่อน

    If you look at how I'm using the continue statement, you will start to think they are harmfull xDDDDD
    while (i < argc) {
    if (strcmp(argv[i], "--json") == 0) {
    json_flag = 1;
    i++;
    continue;
    }
    if (strcmp(argv[i], "--debug") == 0) {
    debug_level++;
    i++;
    continue;
    }
    break;
    }

    • @InfiniteQuest86
      @InfiniteQuest86 9 หลายเดือนก่อน +4

      Wtf, continue is the least of the problems with this. No one would ever write it. I mean it most likely never even hits a continue or does anything.

    • @sub-harmonik
      @sub-harmonik 9 หลายเดือนก่อน

      @@InfiniteQuest86 why would it not hit a continue? (assuming i is initialized to 0)

    • @adambickford8720
      @adambickford8720 9 หลายเดือนก่อน

      @@InfiniteQuest86 Bullshit. Its EXACTLY this kind of code that makes me avoid loops.

    • @InfiniteQuest86
      @InfiniteQuest86 9 หลายเดือนก่อน +2

      @@sub-harmonik I mean if i is initialized to 0 it definitely wouldn't hit continue. It would fall through and hit break since the name of the program isn't --json or --debug. But assuming i was correctly initialized to 1, then if you had any other flag before these two, it would fall through and break without going through the rest of the args.

    • @InfiniteQuest86
      @InfiniteQuest86 9 หลายเดือนก่อน +1

      @@adambickford8720 Wtf how do you avoid loops? I probably wrote 100 loops yesterday alone.

  • @noriller
    @noriller 9 หลายเดือนก่อน

    Most people won't need to care about performance for the majority of the loops they would need to make.
    In this case, when you know what you doing and have a case for needing more performance... then go ~to~ for loops!

  • @FirdausAziz
    @FirdausAziz 9 หลายเดือนก่อน

    missionary loops ;-)

  • @micc1211
    @micc1211 9 หลายเดือนก่อน

    Prime got stuck on not using regular loops haha. Its common to consider not using break and continue or more than 1 return as good practice and instead the break conditions should be in the loop condition and if statements organized for operation control. The reasoning is to avoid hidden program flow, especially in a large chunk. It doesn't inherently discourage use of normal loops though. There can be a performance hit to not using continue, break, more than 1 return (but usually in C or other compiled languages this usually isn't the case because they can optimize it back to its continue/break equivalent, not sure about something like JS though)

    • @mudi2000a
      @mudi2000a 9 หลายเดือนก่อน +2

      The avoidance of break continue and multiple returns can not only hit performance but can also lead to unnecessary if statements which make the code much harder to read.

    • @micc1211
      @micc1211 9 หลายเดือนก่อน +1

      @@mudi2000a I've run into multiple times when working on a large loop that having early breakout really took a long time to track down, I even dislike throws for that reason (anything that is not default, well defined program flow), but its mostly personal preference. Both ways have their pros and cons.

    • @asdfqwerty14587
      @asdfqwerty14587 9 หลายเดือนก่อน

      If the break statement is something that happens only at the start or the end of the loop then it should probably be done as part of the loop conditions (even then it might sometimes be more readable as a separate statement - a loop like for(int i =0; i

  • @sixbutton9
    @sixbutton9 9 หลายเดือนก่อน

    careful about about any internet advice.

  • @mathew2214
    @mathew2214 9 หลายเดือนก่อน

    Ban javascript. Websites only need html and css.

  • @anasouardini
    @anasouardini 9 หลายเดือนก่อน

    Agen

  • @ripplecutter233
    @ripplecutter233 9 หลายเดือนก่อน +1

    JavaScript 💀

  • @2an_sound
    @2an_sound 9 หลายเดือนก่อน

    boomer loops

  • @jimboxx7
    @jimboxx7 9 หลายเดือนก่อน +3

    Let me tell you why: 95% of us don't need to write code that iterates over millions of items. 99% of the collections my code has to iterate over contain 20 items at most.

    • @jimboxx7
      @jimboxx7 9 หลายเดือนก่อน +1

      And for that reason, developer time is more important than computer time.

    • @ITR
      @ITR 9 หลายเดือนก่อน +22

      In what scenario does continue slow down your developer time?

    • @Dystisis
      @Dystisis 9 หลายเดือนก่อน

      depends what context you are iterating in

    • @atiedebee1020
      @atiedebee1020 9 หลายเดือนก่อน +1

      And typing 1 second longer for the for loop is just not worth it :/

    • @jimboxx7
      @jimboxx7 9 หลายเดือนก่อน

      @@ITRThe cognitive load of an iterator is smaller than a loop. That is why people recommend using them. Then use map/filter/reduce to transform your data, which makes the code much easier to reason about than a custom for loop with a bunch of temporary variables and if statement and what not.

  • @sid4579
    @sid4579 9 หลายเดือนก่อน +1

    first