Coding confession/brag/rfc on something i just wrote



  • code & pre tags are bullshit because they ignore tabs, so screenshot. all the calls used are just composition of framework-provided functions, no needless scruff, really the best and most concise way how i am able to do what i need it to do. please comment on whether and how large a wtf it is, whether the comments make it more or less understandable, anything, nitpick it to bits any way you want if you imagine you came across it or something like it in your codebase.
    0_1497491165790_7e151bdc-fa82-4311-87cd-6a897e4eb518-image.png

    btw there was a general small coding confessions threat that i can't find right now. my confession for there would be "compositing. i'm a compositing and nesting fetishist sometimes."



  • @sh_code
    FYI, in general, the three backticks (`) method for markdown is supported here. You can click the vertical "..." to the right of this post and choose "View raw" to see what I did here.

    Code goes here
    

    It also supports the markdown hinting for specific languages (though it often gets the right language without too much help) so you can do things like:

    SELECT izzion
    FROM dbo.Users
    WHERE UserType = 'Awesome'
    

  • Winner of the 2016 Presidential Election

    @izzion said in Coding confession/brag/rfc on something i just wrote:

    @sh_code
    FYI, in general, the three backticks (`) method for markdown is supported here. You can click the vertical "..." to the right of this post and choose "View raw" to see what I did here.

    Code goes here
    

    It also supports the markdown hinting for specific languages (though it often gets the right language without too much help) so you can do things like:

    SELECT izzion
    FROM dbo.Users
    WHERE UserType = 'Awesome'
    
    Rows returned: 0
    

    🚎


  • Winner of the 2016 Presidential Election

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    code & pre tags are bullshit because they ignore tabs

    Since @izzion didn't make it clear: the three backticks method respects tabs.

    Example
    	of tabbed
    		input
    


  • @Dreikin
    Psh, why should I actually be helpful in my response posts? What is this, Discourse? 🚎


  • Winner of the 2016 Presidential Election

    @izzion said in Coding confession/brag/rfc on something i just wrote:

    What is this, Discourse?

    No,
    0_1497492424444_1qwv12.jpg


  • Winner of the 2016 Presidential Election

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    code & pre tags are bullshit because they ignore tabs, so screenshot. all the calls used are just composition of framework-provided functions, no needless scruff, really the best and most concise way how i am able to do what i need it to do. please comment on whether and how large a wtf it is, whether the comments make it more or less understandable, anything, nitpick it to bits any way you want if you imagine you came across it or something like it in your codebase.
    0_1497491165790_7e151bdc-fa82-4311-87cd-6a897e4eb518-image.png

    btw there was a general small coding confessions threat that i can't find right now. my confession for there would be "compositing. i'm a compositing and nesting fetishist sometimes."

    So, uh, why aren't you doing this in a functional language?



  • @Dreikin said in Coding confession/brag/rfc on something i just wrote:

    So, uh, why aren't you doing this in a functional language?

    C# is a functional language, if you use LINQ. This might actually benefit from LINQ's deferred execution, depending on what you do with the resulting collection.

    Why aren't you using var? Specifically-typing Collider is going to make refactoring more difficult later on. Odds are you don't care if the lookCollector contains Colliders or not, you probably just care that the thing it contains contains a .ClosestPoint() and a .transform. Also your casing is weird, but that might be framework stuff.


  • Winner of the 2016 Presidential Election

    @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    C# is a functional language, if you use LINQ. This might actually benefit from LINQ's deferred execution, depending on what you do with the resulting collection.

    Yes, but I was thinking it would look cleaner in a functional language (like F# in this case) if they always try to code this way*, even given LINQ query syntax.


    *: @sh_code said in Coding confession/brag/rfc on something i just wrote:

    btw there was a general small coding confessions threat that i can't find right now. my confession for there would be "compositing. i'm a compositing and nesting fetishist sometimes."



  • Maybe this is Unity, which doesn't speak F#...


  • Dupa

    Static properties are bad. Someone is gonna hate you for that.

    But before that, I'm gonna hate on you for that.

    Dawg.


    ETA

    I'm the stupid one, I somehow missed your caveat that these are all standard framework classes.

    Move along, nothing to see here. Apart from the fact, that if you put this stuff into variables, you wouldn't have needed comments.



  • @sh_code Without knowing more about the code and just a quick glance, I'd be wondering about why you use the y-component for the Z value, and why you add .5 to it.

    Also, from a quick glance, I'm also wondering if you can't simplify that a bit. I.e., you go viewspace to worldspace, and then back. And both times there's the offset by a half-unity vector. Though that's hard to determine without knowing more about what a Collider is and how ClosestPoint() works. (Again, would need to know more about the Collider in order to be 100% sure, but it almost seems like you want to compute the distance in a certain plane.)

    Regarding the comments. I'd be happier if there was an overarching comment about your what you're going to do at the beginning (i.e., what distance are you actually computing, not how you compute it). The current comments are somewhat meh (but OK), they help in some cases ("center of viewport", since that also depends on your setup), but they also repeat the code in some cases ("point on the collider that is clostest to"). But that's IMO.



  • @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    Specifically-typing Collider is going to make refactoring more difficult later on. Odds are you don't care if the lookCollector contains Colliders or not, you probably just care that the thing it contains contains a .ClosestPoint() and a .transform. Also your casing is weird, but that might be framework stuff.

    only thing that contains .ClosestPoint is a collider which is a superclass for every "ray-castable" component, so odds are I do not care for anything else except colliders. but in general I have aversion against the var keyword, when reading a variable declaration, i like to know what type it is without having to hunt and parse for it in the value assignment.

    also, yes, the casing in unity is weird.



  • @kt_ these static properties are surprisingly useful. having the ability to go Vector3.zero or Vector3.one or Vector3.left/right/up/down instead of new Vector3(x, y, z) feels nice.

    Why Distance and similar operations are as static methods instead of normal ones i have no idea, vectorA.Distance(vectorB) seems better, less wordy, more direct, similarly to Dot, Cross, etc.



  • @cvi said in Coding confession/brag/rfc on something i just wrote:

    Without knowing more about the code and just a quick glance, I'd be wondering about why you use the y-component for the Z value, and why you add .5 to it.

    that would be a good question. the answer is "it was late at night, this snippet went through some corrections after posting (but stayed in principle the same), I'm not entirely sure anymore". i think it was supposed to be correction for y coord to account for character's height (therefore camera is higher than his 0,0 coord), because the viewportToWorld seemed to... not correctly account for local coords, but... the more i think about it now the less sure I am if it was actually the case.

    @cvi said in Coding confession/brag/rfc on something i just wrote:

    And both times there's the offset by a half-unity vector. Though that's hard to determine without knowing more about what a Collider is and how ClosestPoint() works.

    unity's screen space (on some places at least, not sure if all, yes, a bit of framework :wtf: ) is 0,0 from bottom left, the only check i need to do on it is "distance from screen center", so i do distance from 0.5, 0.5 (screen center) to the closest point on the collider...
    ...oh wow. it was really late at night. to be honest, i'm not entirely sure why and how I arrived at this exact form...

    therefore conclusion: this is a confession and that is a horrible piece of code regardless of how cool it looks :-D
    thanks for helping me realize that by forcing me to look at it again when I'm sober



  • @sh_code said in Coding confession/brag/rfc on something i just wrote:

    but in general I have aversion against the var keyword, when reading a variable declaration, i like to know what type it is without having to hunt and parse for it in the value assignment.

    1. if that matters, your program's written stupid. (Unity might be written stupid, I honestly don't know.) C#'s compiler will yell if you do anything really wrong, until then relax and write code.
    2. Your IDE knows the type that'll be assigned if you really need to know, so just mouseover. Unless you're using a crappy IDE, in which case: stop doing that.

    You asked for a code review, there you got one.


  • FoxDev

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    in general I have aversion against the var keyword, when reading a variable declaration, i like to know what type it is without having to hunt and parse for it in the value assignment

    If you're having to hunt and parse the assignment to work out the type, you've done a very bad job of naming it



  • @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    if that matters, your program's written stupid. (Unity might be written stupid, I honestly don't know.) C#'s compiler will yell if you do anything really wrong, until then relax and write code.

    that's how i write code, i imagine puzzle pieces/connector shapes, know which outputs need to go into which input in what shape, write code to transform data from one "connector shape" to the other. that's all that programming is, after all, transforming data, no? how do I transform data in a relaxed state when it's not obvious from one look what i'm transforming into?

    @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    You asked for a code review, there you got one.

    yes, thank you, now I've moved to the discussion section. Not saying you're wrong, just throwing out my aruments seeing what counterones I get.



  • @RaceProUK said in Coding confession/brag/rfc on something i just wrote:

    If you're having to hunt and parse the assignment to work out the type, you've done a very bad job of naming it

    var element;
    var elementWasFound = (myList.First(i => i == "element we're looking for") = element) != null;

    maybe.



  • @sh_code said in Coding confession/brag/rfc on something i just wrote:

    that's how i write code, i imagine puzzle pieces/connector shapes, know which outputs need to go into which input in what shape, write code to transform data from one "connector shape" to the other. that's all that programming is, after all, transforming data, no? how do I transform data in a relaxed state when it's not obvious from one look what i'm transforming into?

    You must embrace the zen of C#. Everything in your code is ethereal, your types float in the mists of vaguery. There are no concrete types until the last possible millisecond when you need them to be concrete, they solidify out of the mists and drop into the mundane world of "output". The compiler is your guide through this world, you can trust it. Those types that are not output stay in the mists until, long after they are no longer needed, they waft peaceably away.

    Your loop cares not for Collider, nor List, it cares perhaps for ICollideable and IEnumerable. Do not sabotage the compiler by trying to second-guess what types it needs, it knows more than you, embrace its wisdom. Concrete types are the mind-killer. Concrete types are the little death that bring total obliteration.



  • @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    Your loop cares not for Collider, nor List, it cares perhaps for ICollideable and IEnunmerable

    incorrect, sadly. unity no likey interfaces, mostly, mainly in the older parts of the codebase, and Colliders, being one of the oldest, don't have any. Two versions ago, the finally made the unified Collider parent class which all colliders now inherit from, before that you had all separate BoxCollider, SphereCollider, MeshCollider, CapsuleCollider, BoxCollider2D, all the other *Collider2D variants, all basically sharing the same interface without... actually sharing anything or even having any interface. so you couldn't even switch out BoxCollider for CapsuleCollider from under your code without everything coming crashing down.
    Then, the godsend of parent Collider which all the flavors of Colliders inherit from was brought upon us :-D

    (i love Unity, but it's got some crazyparts and some stupidparts, in the most unexpected places, as everything.)

    @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    You must embrace the zen of C#. Everything in your code is ethereal, your types float in the mists of vaguery. There are no concrete types until the last possible millisecond when you need them to be concrete, they solidify out of the mists and drop into the mundane world of "output". The compiler is your guide through this world, you can trust it. Those types that are not output stay in the mists until, long after they are no longer needed, they waft peaceably away.

    i kinda like this mindset and at the same time i know it would be suffering for me to adopt it, and c# never seemed to me to be of this mind, with it being the first language where i met <Type Parentheses>... very counterintuitive for me, but will try, maybe


  • FoxDev

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    unity no likey interfaces, mostly, mainly in the older parts of the codebase, and Colliders, being one of the oldest, don't have any. Two versions ago, the finally made the unified Collider parent class which all colliders now inherit from, before that you had all separate BoxCollider, SphereCollider, MeshCollider, CapsuleCollider, BoxCollider2D, all the other *Collider2D variants, all basically sharing the same interface without... actually sharing anything or even having any interface. so you couldn't even switch out BoxCollider for CapsuleCollider from under your code without everything coming crashing down.

    Wait... the designers of Unity seriously sat down and created a whole family of Collider classes, and at no point did any of them think "Now, what do all these Colliders have in common?" until is was too late?



  • @RaceProUK said in Coding confession/brag/rfc on something i just wrote:

    Wait... the designers of Unity seriously sat down and created a whole family of Collider classes, and at no point did any of them think "Now, what do all these Colliders have in common?" until is was too late?

    looking at that piece of code I wrote and how I thought how awesome it was yesterday, anyone making this mistake few times in their lives is pretty understandable to me :-D



  • @RaceProUK they also implemented implicit meaningful conversions from most of the types ToString(), so you don't have to even cast numbers when concatenating, but they neglected to implement Inspector (in-editor view) for Dictionary variables. or for properties, so any parameter you want to set to a script from inside the editor? public variables for you and nothing else! or serializable privates, which i bet i don't have to say is even worse.



  • @sh_code said in Coding confession/brag/rfc on something i just wrote:

    incorrect, sadly. unity no likey interfaces, mostly, mainly in the older parts of the codebase, and Colliders, being one of the oldest, don't have any. Two versions ago, the finally made the unified Collider parent class which all colliders now inherit from, before that you had all separate BoxCollider, SphereCollider, MeshCollider, CapsuleCollider, BoxCollider2D, all the other *Collider2D variants,

    I wouldn't expect game developers to know what the fuck they're doing when writing quality software, but this kind of goes above and beyond.

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    all basically sharing the same interface without... actually sharing anything or even having any interface.

    But the great thing about C# is: "var" still works in that case. Depending on how faithfully they got all the exact method and properly names exactly correct. It's basically duck-typing.

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    (i love Unity, but it's got some crazyparts and some stupidparts, in the most unexpected places, as everything.)

    The Zen of C# is not present in the ancient crappy version of Mono it's using, I understand. What a shame.

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    i kinda like this mindset and at the same time i know it would be suffering for me to adopt it,

    C# isn't really about writing procedural code anymore, is the thing. You tell the compiler about operations it could potentially do, you tell the compiler what outputs it needs to generate, and you let it decide the most efficient way of doing it. There's a good reason the first syntax for LINQ looked an awfully lot like SQL-- the new behavior of C# is actually very similar to SQL in many ways.

    To take your example, since you're using concrete classes throughout, like I said above you've made refactoring more difficult. (If you change Collider for MeshCollider, you'll have to rewrite that code perhaps unnecessarily.) That's a minor benefit.

    But more than that, if you'd used LINQ (and yes, yes, I understand Unity is crap, bear with me), you'd have similar code but none of it would execute until the results were needed. Meaning: if you have 50,000 Collider objects but your player dies after only needing 4 of them, the other 49,996 operations will never happen. It's not just more maintainable code, but you've at the same introduced a major performance optimization.

    It's kind of beautiful when you wrap your head around it.

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    looking at that piece of code I wrote and how I thought how awesome it was yesterday, anyone making this mistake few times in their lives is pretty understandable to me

    There's a difference between "making a mistake" and "shipping it as a finished product to thousands of people for several major versions".



  • @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    C# isn't really about writing procedural code anymore, is the thing. You tell the compiler about operations it could potentially do, you tell the compiler what outputs it needs to generate, and you let it decide the most efficient way of doing it.

    i'm currently realizing this while teaching 14year old to code in it.

    "What's the difference between array and list?"
    "Technically, theoretically, regarding implementation it should be something like this. In practice, almost nobody really has any idea anymore. From usability point of view, list is slightly bigger in memory and slower to work with, but can be resized dynamically."
    "Eh... okay"

    or

    "Why did the destructor ran about 10 frames AFTER i destroyed the object?"
    "...because garbage collector decided that's the right time to actually destroy it. if you really want to destroy it IMMEDIATELY, as you call the function, there's another function for that, DestroyImmediate"
    "Eh... okay"

    ...yes, i know, not the most ideal, teaching someone beginnings of a language along with a whole engine that uses and misuses it in various ways, but still...
    ...things were easier, from this point of view, in the times of QBasic.



  • I would break this into individual statements that you can step through and reason about.

    That's all I have.



  • @sh_code Dude, you shouldn't answer either of those questions. You should be suggesting IEnumerables and absolutely never mention destructors ever. The former rarely means anything, and the latter is almost never correct, to the point where people who helped design the language warn you to just not think about them.


  • I survived the hour long Uno hand

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    "What's the difference between array and list?"
    "Technically, theoretically, regarding implementation it should be something like this. In practice, almost nobody really has any idea anymore. From usability point of view, list is slightly bigger in memory and slower to work with, but can be resized dynamically."
    "Eh... okay"

    You sound like a really shitty teacher, lol. (I say this as a moderately shitty teacher at best)


  • Impossible Mission - B

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    "What's the difference between array and list?"
    "Technically, theoretically, regarding implementation it should be something like this. In practice, almost nobody really has any idea anymore. From usability point of view, list is slightly bigger in memory and slower to work with, but can be resized dynamically."

    ...you were saying?



  • @masonwheeler And talking about speed differences, especially to someone new to the stuff, is kind of silly. Especially since you basically only use IList<> derivatives if you plan to do Adds.



  • @Yamikuronue said in Coding confession/brag/rfc on something i just wrote:

    You sound like a really shitty teacher, lol. (I say this as a moderately shitty teacher at best)

    I've been giving a C++ course at work so that the rest of the team can help with/have a job after the transition, and knowing when to go deeply into detail and when not to is hard. Especially in C++, with all its warts and backwards compatibility, I tend to tell them "this is true 90% of the time, there are ways to go around it but you don't need to know it now". You don't want to lie or say something that isn't accurate, but you also don't want to bog things down with needless detail.


  • kills Dumbledore

    @Kian said in Coding confession/brag/rfc on something i just wrote:

    You don't want to lie or say something that isn't accurate

    Sometimes you do. Maybe with the caveat that it's not necessarily 100% true, but often just ignore the warts entirely until you revisit the topic and get to say "remember what I told you before? That's not entirely true"


  • ♿ (Parody)

    @blakeyrat said in Coding confession/brag/rfc on something i just wrote:

    It's kind of beautiful when you wrap your head around it.

    Careful or someone will show up and start talking about monads.


  • BINNED

    @boomzilla said in Coding confession/brag/rfc on something i just wrote:

    Careful or someone will show up and start talking about monads.

    Possible Laidlaw's Rule inversion?

    edwardkmett: Most monad tutorials are written by people who barely understand monads, if at all, but unfortunately nothing can stop someone from writing a monad tutorial. We've tried, there was blood everywhere.

    And then the murders began.



  • @Yamikuronue said in Coding confession/brag/rfc on something i just wrote:

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    "What's the difference between array and list?"
    "Technically, theoretically, regarding implementation it should be something like this. In practice, almost nobody really has any idea anymore. From usability point of view, list is slightly bigger in memory and slower to work with, but can be resized dynamically."
    "Eh... okay"

    You sound like a really shitty teacher, lol. (I say this as a moderately shitty teacher at best)

    kind of, possibly, maybe, from the point of view people are used to take with teachers?
    i'm shitty in the factography part, but i don't consider teaching (as in, relaying with personalized explanation) these things to be that important.

    first thing I told the boy (and before that his father) was something like: "I'm not going to teach you how to program, because I can't, because nobody can, and if they try they will make you into a codemonkey. But I am going to teach you how to think in order for that process to be compatible with computers and programming, and for it to enable you to solve and learn stuff from programming any time, on your own, for the rest of your life, because that's the only way how to be a programmer. Not necessarily a good one, but a programmer at all. So when we get to the point where you won't need me to learn and find out new stuff about programming, that's the point when our lessons had succeeded."

    So basically that I'm not going to teach him how to program, but I'm going to teach him how to think so he can learn (and keep learning) how to program by himself.

    so i'm not teaching him facts or ready-made already known solutions, i'm even purposely ignoring most of "industry-standard alogithms", at first, and I force him to THINK about the stuff and come up with his own solution, or even multiple ones based on "what if we considered this other feature of the problem as the most important one?", which I then take apart and force him to THINK about how to solve the weaknesses I found in it, and such. I purposefully stay silent when he does stupid mistakes, just so I could spend 5-15 minutes with him reading through the code, looking for the mistake, because I know that the pain and irritation of that effort is what makes the subsequently learned/realized thing stick, instead of giving him answers I usually give questions and force him not to avoid/be afraid of answering them, and such...

    The "factual" answers I give, then, are designed to do several things: explain that "it's complicated and in most cases you don't need to care, but roughly this area of cases is the one when you should care so you should go and learn more about it when you get into that situation", explain that "everything is complicated if it's important enough in the context", and "most of these complexities you can, and even HAVE TO, if you want to stay sane, ignore most of the time".

    ...basically, I'm self-taught, and as such I admit I don't have all the factual info and can't be bothered looking for it if I don't explicitly need it at that moment. but also, as such, I have experienced the value of the parts of learning process which teaching often (incorrectly, IMO) removes.


  • Discourse touched me in a no-no place

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    I have experienced the value of the parts of learning process which teaching often (incorrectly, IMO) removes.

    That'll work as long as the students stay motivated enough and have enough intelligence in the first place. However, the other style of learning can have value too, particularly when it is focusing on providing a higher-level model and explaining how lots of other things fit into it (a lot of algorithms teaching is like this because the deeper model relates to how to work out the cost of an algorithm). Some things work better one way, and some the other.

    Theoretically a student could luck into those higher-level models on their own, but they're usually created by very smart people indeed so it isn't shameful to say “this is a difficult problem that has had some deep analysis applied by others over many years, and they reckon that this is a good way to think about it; here, let me show you an example…”


  • đźš˝ Regular

    @izzion said in Coding confession/brag/rfc on something i just wrote:

    SELECT izzion
    FROM dbo.Users
    WHERE UserType = 'Awesome'
    
    UPDATE dbo.Users SET izzion = NULL WHERE Username = 'Zecc'; 
    

  • Winner of the 2016 Presidential Election

    @Zecc said in Coding confession/brag/rfc on something i just wrote:

    @izzion said in Coding confession/brag/rfc on something i just wrote:

    SELECT izzion
    FROM dbo.Users
    WHERE UserType = 'Awesome'
    
    UPDATE dbo.Users SET boomzilla = true; 
    

    FTFY.



  • @masonwheeler said in Coding confession/brag/rfc on something i just wrote:

    @sh_code said in Coding confession/brag/rfc on something i just wrote:

    "What's the difference between array and list?"
    "Technically, theoretically, regarding implementation it should be something like this. In practice, almost nobody really has any idea anymore. From usability point of view, list is slightly bigger in memory and slower to work with, but can be resized dynamically."

    ...you were saying?

    "Dynamically" means that it's constantly changing sizes to accommodate what you're adding to it, not just when you explicitly tell it to change size.


  • Impossible Mission - B

    @anotherusername said in Coding confession/brag/rfc on something i just wrote:

    "Dynamically" means that it's constantly changing sizes to accommodate what you're adding to it, not just when you explicitly tell it to change size.

    Ok, that's not how I understand the term, but... 🤷♂



  • @masonwheeler "can be resized dynamically" also implies that resizing it dynamically is not prohibitively costly in terms of resources. Reserving a whole new chunk of memory and copying the original array's contents into it is more along the lines of "well, you can do that, but realistically you can't because you really shouldn't, and if that's really what you need then you should probably select a data structure that's more suitable to having dynamic size changes".


  • Impossible Mission - B

    @anotherusername How do you think List<T>'s dynamic resizing is implemented?


  • Discourse touched me in a no-no place

    @masonwheeler The strategy of doubling the underlying array size when required has been shown to make the cost of appending an element amortised constant time; the costs of reallocation are non-trivial, but are borne less and less frequently as the number of elements added rises. It is about as good as this sort of algorithm gets (and gives other common operations better performance than you have available if you use linked lists).



  • @masonwheeler well, it does at least have an add method that automatically (dynamically!) resizes it when needed.


  • Impossible Mission - B

    @anotherusername Yes, and if you care about Add, you definitely want List rather than an array. But the original context said nothing about Add; it said that List can be dynamically resized and arrays can't, which is false.



  • @masonwheeler it said that List can be resized dynamically as you add stuff to them. That is correct. Arrays, by comparison, have to be resized manually when you add stuff to them.


  • Impossible Mission - B

    @anotherusername

    The opposite of "dynamic" is not "manual"; it's "static" (ie. unchanging; the size is fixed from the moment of creation).

    Also, why are you saying "when you add things to them?" Did you miss the bit where I said

    @masonwheeler said in Coding confession/brag/rfc on something i just wrote:

    Yes, and if you care about Add, you definitely want List rather than an array. But the original context said nothing about Add; it said that List can be dynamically resized and arrays can't, which is false.

    ???



  • @masonwheeler that word...

    0_1498248501927_c59079ec-adb0-49b2-9c01-135bc4633bd8-image.png

    means that something changes constantly, i.e. without manual intervention to change it. If you're (constantly) adding things to the list, dynamically sized means that its size will (constantly) change as needed to accommodate the things you're storing. If you have to manually resize it, that's not dynamic resizing. It's manual resizing. You specify a static size for the array, and that size won't change unless you manually resize it.

    @masonwheeler said in Coding confession/brag/rfc on something i just wrote:

    Also, why are you saying "when you add things to them?" Did you miss the bit where I said

    @masonwheeler said in Coding confession/brag/rfc on something i just wrote:

    Yes, and if you care about Add, you definitely want List rather than an array.

    I saw it. It made no sense. "If you care about Add"? You will put things into your list, right? Unless you're adding items to it in some non-linear order, you care about Add, because that's how you will add items to the list.

    It's not like I'm just making this up. "Dynamic array" is a well-defined thing in computing... the thing that makes a "dynamic array" different from a regular array is that a dynamic array includes the code to resize it when necessary, without the programmer having to worry about that.


  • Discourse touched me in a no-no place

    @anotherusername @masonwheeler You two are agreeing violently…