4 ms·
Curious as to why CSS Grid chose to start at 1-index rather than zero, and why the end column is one more than the position of the column that actually stops.
by bobthepanda 8y ago
Curious as to why CSS Grid chose to start at 1-index rather than zero, and why the end column is one more than the position of the column that actually stops.
- chrisseaton 8y agoMaybe designers don't have a culture of counting from 0 like programmers do?
- talltimtom 8y agoThere are programmers who don’t count from zero. And even programmers who count from zero but don’t do so consistantly as soon as they implement even the simplest personal indexation.
- ndnxhs 8y agoProgrammers don't count from 0. Its just in many languages it makes sense like in C where an arrays name is actually a pointer to the first element and the index says how many positions to move away from it so foo[0] is the pointer to the first element and then move 0 spaces away. The tradition of starting at 0 just got carried on to everything because having a standard is better than having to memorize what everything uses
- learc83 8y agoThere are good reasons to start counting at 0 beyond convention. Dijkstra wrote a small essay on the topic in 1982 called "Why numbering should start at zero." http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
- pjmlp 8y agoAs someone that started programming in languages that count from 1, I kind of disagree with that essay. Specially when dealing with Algol derived languages, where the indexes can be specified in a flexible way.
- javajosh 8y agoUltimately these are just conventions. There are probably good reasons for them, too. For example having [a,b)* allows easier computation when you have things that abut. E.g. it's [a,b) [b,c) [c,d) rather than [a,b-1] [b,c-1] [c,d-1]. * https://en.wikipedia.org/wiki/Interval_(mathematics)#Including_or_excluding_endpoints https://en.wikipedia.org/wiki/Interval_(mathematics)#Includi...
- Cpoll 8y agoBut it seems to be weirder than that, according to the game (can someone explain this to me?): start:1, end:4 = 1,2,3 (start-inclusive, end-exclusive) start:5, end:2 = 2,3,4 (I guess this means right-exclusive, whether it's 'start' or 'end'?) start:1, end:-2 = 1,2,3,4 (the puzzle text says -1 is the first grid-line from the right, i.e. 5, but that doesn't follow, because now it's right-inclusive) start:-3 = 4 (so -1 is grid count+1, which explains the above?)
- thefifthsetpin 8y agoI'm with you, this feels very weird to me. Usually you get a reasonable relationship between zero- and one-indexed views of the same thing. The relationship is normally that the zero-indexed points 0 and 1 form the start and end bounds of the 1st item. CSS grid numbers columns 1, 2, 3 and also number the the lines around those columns 1,2,3,4. https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout#Grid_lines https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_La... Having grid line 1 come before column 1 makes it feel like the grid lines are substantial and the columns are merely the bounds between grid lines.
- Izkata 8y ago> Having grid line 1 come before column 1 makes it feel like the grid lines are substantial and the columns are merely the bounds between grid lines. Correct. And IIRC the spec doesn't even have columns (they're just referenced to help understanding), just column bounds.
- kristopolous 8y ago
- tzs 8y ago> why the end column is one more than the position of the column that actually stops The positions are, I believe, the positions of the grid lines, not the grid columns.
- bobthepanda 8y agoThat still seems super unintuitive to me, because the whole thing is ‘grid-column-end’, not ‘grid-column-line-end’. Between this and how weird the negative syntax operates, I suspect that I would end up using the start/span syntax the most, but my company requires code that supports IE9, so I will probably only touch this on a regular basis in like five years.
- justintoon 8y agoProbably because all of CSS uses 1-index (ex: :nth-child)
- sjwright 8y agoCorrect answer.
- dylan604 8y agoI really hate products where the in/out points are not the same inclusiveness. There are several video programs I've used in the past that are similar to this where the in-point is inclusive, but the out point is not. If the in/start designates the first thing I want to include, then I would expect the out/end to also designate the last thing I want to include. It's just a mild thing to get over, and visual tools like this make it very easy to realize the end is exclusive. However, it is not always so easy in video tools unless the next frame to your out is an obvious change.
- johnday 8y agoThere's an extra difficulty with something like video software. Consider what the expected outcome would be for "isolate from second 1 to second 10". Then the expected outcome for "isolate from frame 1 to frame 10". What happens with a video at 1fps?
- dylan604 8y agoNow we're getting into definitions of "what is 1 second?", and I always reply "a second is a second, regardless of the divisions". Same when syncing audio to video. Straight audio is just a division of sampling rate, so regardless if you record video at 24,25,30, etc, audio recorded at 48kHz is always the same. It only gets confusing when trying to force sync by embedding timecode into the audio or laying the audio to a video format. Now, you're trying to subdivide the audio into video frames, and that's just going to make framerate conversions difficult. My biggest pet peeve with this is all of the MP4 based capture formats where the audio alignment is within +/- frames. I love frame advancing to the clapper in the clapped position, but the audio pop is frame(s) ahead/behind, and sometimes even sub-frames ahead/behind. It's one of the things I miss the most about FCP7. I could option-click the timeline and slip the audio into alignment with the video. Premiere doesn't allow for this, and I refuse to even install FCPX to investigate. I know just make it the audio department's problem ;-) Wow, I just jerked the wheel so hard far left from the actual topic.