• 0 Posts
  • 15 Comments
Joined 1 year ago
cake
Cake day: July 24th, 2023

help-circle
  • I feel like all the points you raise could be replied by : if you do not like it, no one is forcing you into doing it.

    It is my understanding that people do this for fun - to take the occasion to get into a new language and/or exercise their problem resolution skills.

    Personally, although I love coding (it is a passion), after a whole day of coding I do not feel the energy to partake in a coding event. And during holidays I am busy doing other stuff. So I do not participate in the Advent of Code. But I am still glad that the event exists for people who enjoy it and have the time for it













  • Interesting take. I prefer spaces because each piece of code that I see with tabs has an implicit tabsize you really need to have if you don’t want the code to look ugly - especially if the person has been mixing tabs and spaces - and they usually do. Sometimes unadvertently.

    When you remove all tabs at least everyone is on the same page.

    To the actual problem raised by the article:

    I have ADHD. Two spaces per indent makes it damn near impossible for me to scan code. My brain gets too distracted by the visual noise. Someone who’s visually impaired might bump their font size up really large, and need to scale up or down the amount of space per indent. Someone might just prefer it because…

    I wonder if it could be possible to adjust the “indent number of spaces you see” in code editors. Code editors are able to figure out what are indents and what are not, so in theory it should be possible. Perhaps that would be an idea for a new feature?


  • Then you have to ask yourself, is it worth it to add yet another function that can crash your program if misused just for that 10% in a situation where they might not even matter

    C/C++ already exposes a ton of undefined behaviors: it is part of the language to give full control to the programmer. If you want a language that minimizes the number of undefined behaviors you can get into, C/C++ is not the right candidate anyway. Something like Ada or Rust is much more relevant for that.

    So I would say yes, just as long as it is properly documented.


  • We need to choose something which most closely represents the data.

    Why do you need to do that? You do not have to choose the optimal memory model to code a Tic Tac Toe game.

    A Vec works fine, and is also simple to understand (so it is maintainable).

    If you invent your own complex data structure for the Tic Tac Toe you trade maintainability for… what gain?

    How to build a grid whose orientation does not matter?

    The orientation is how you iterate on your grid. If you iterate from first element to last element on X-axis, you have the “normal” orientation. If you iterate from last to first, you have the Y-symmetrical orientation.

    A 2D array is already a grid whose orientation does not matter. No need to over-complexify this.

    If you want to be picky, you could say that you want a grid with optimal performance. Meaning that your data should be contiguous (ideally, your data should be in the same cache line to prevent cache misses).

    If you start playing with complex data structures with lots of pointer indirections and such, your performance will go down, your code will be more complex to understand, and will (certainly) be bigger in memory. You will lose in both maintainability, performance and size.

    A single vector of 9 elements is enough, really.