Threads for carlosgaldino

  1. 1

    Great post! Love the name too!

    Perhaps it’s for historical reasons or even a dumb question, but why have separate “indirect” level qualifications vice just having a block that either points to data or it points to another pointer? It seems that would allow near infinite “levels.” The only reason against I can think is that you’d need some sort of tag to denote pointer vs data, but that tag could be a single byte or even single bit.

    1. 1

      Thanks! I’m glad you liked it. You’re the first one that got the name reference :)

      Re the blocks, it’s probably like you said, for historical reasons. Both the FFS paper [1] and if you go back to the “UNIX Implementation” [2] talk about triple indirect pointers without discussing using a “tag”.

      [1] https://people.eecs.berkeley.edu/~brewer/cs262/FFS.pdf

      [2] https://users.soe.ucsc.edu/~sbrandt/221/Papers/History/thompson-bstj78.pdf

    1. 1

      Why are the timestamps wrapped in Option<>?

      1. 6

        it’s common to disable atime etc… I can’t count how many bugs I’ve had to deal with over time due to misunderstandings of mtime, ctime, atime etc… Making the ones other than creation time optional is a nice technique for reducing bugs due to representing a type that might not actually be present by some placeholder value that only those who have already been burned enough times might remember to properly handle next time.

        Translating many types of common gotchas into compile-time constraints through types like this is one of the biggest timesaving features of Rust as I use it.

        1. 2

          But as soon as anyone stats it you’re going to have to make up values for them anyway. I’m not aware of any “real” filesystems (*nix ones, anyway) that have any analogous notion (however encoded) of a timestamp that might be missing, and I’m having trouble thinking of a case in which a filesystem-internal operation would be doing anything with the semantic value of a timestamp other than reporting it to a running process (via an API that doesn’t support Option<>), so I still don’t really see the point.

          And just to be clear: I’m not an anti-rust partisan or anything (in fact I’ve been introducing bits of it at my current job) – this particular pattern just seems like additional complexity for no discernible benefit.

          1. 2

            Making the ones other than creation time optional

            Creation time is mostly useless. Hell, Linux didn’t even have an API to read the file creation time until recently.

            Modify time on the other hand is how things like make work.

            1. 7

              It doesn’t matter if it’s useful to you or not. If a file has been created, then it has a creation time. It will not have a modified time until it is modified. The purpose of the Option is to signify when something does not exist, without resorting to error-prone magic values.

              1. 5

                Huh? Creation time is super useful for end users. I often sort Finder windows by creation time, especially of documents I’ve created.

            2. 1

              Disclaimer: not the author.

              created_at is not an option but accessed_at, modified_at, and changed_at are which makes sense in the way that a file may not have been accessed, modified or its properties changed since its creation time. It could also be there for ease of implementation of features like noatime mount option. However, currently code is initializing all of them to the same value when instantiating an Inode so not sure whether that argument holds water.

              1. 1

                Yes, that is exactly the reason. And right now I’m initialising the values to mimic the behaviour from my local machine (APFS).

            1. 1

              so what kind of hash should be used for a merkle tree?

              1. 3

                It doesn’t require a specific hash function. Usually, it’s a cryptographic hash function like SHA-2 but you can choose another function just fine.

              1. 1

                Why would you post the answer to a homework assignment online?

                1. 1

                  The homework from CMU 15-213 is not the same binary used in this series. I’m using the “self-study” from the CS:APP website. If I recall correctly, each CMU student taking 15-213 receives a unique binary as their homework but I have no details about what is the difference between them.

                  Not everyone on the internet is a CMU student so others might benefit from reading the posts and maybe learning a little bit in the process.

                  1. 9

                    “Why we chose X” blog posts are almost always great if you like X and a complete letdown if you don’t like X. In this case, if you like Go then yay, this blog post confirms all your existing beliefs. If you don’t like Go, the reasoning given confirms all your existing beliefs.

                    From a pure logic perspective, I think their argument is weak. They give a list of languages that one can write distributed systems in, now claim that it is a “fact” these are the best options, then claim Go beats the other options for various reasons. This is difficult to distinguish from “here is a list of languages I’m aware of and I like this one the most”.

                    1. 3

                      It’s at least some sort of progress since most of “Why we chose X” I see is about syntax, presence/absence of semicolons, etc.

                    1. 6

                      It would be nice if the blog post said what language this is! I guess it’s probably Swift, but I have no way of knowing.

                      1. 3

                        It’s not Swift, Rust, or Scala. I think it’s pseudocode.

                        I don’t think the idea of ‘nil’ being a subtype of every other type plays well with the idea of representing none-values using an optional type ADT (the author alludes to this a bit).

                        In a language like Swift, the declaration “let myVar : Foo” guarantees that myVar will never contain nil, which ensures at compile time that a variable containing nil will never be improperly dereferenced (unless you do type-system-subverting things like force-unwrapping).

                        If your declaration “Foo myVar” implies myVar can be Foo or nil, then optional types become little more than an opt-in annotation on the parameters or return values of a function/method. You have to figure out what semantics Some(nil) has, and hope your APIs are well-behaved enough to respect that meaning.

                        1. 1

                          I don’t think the idea of ‘nil’ being a subtype of every other type plays well with the idea of representing none-values using an optional type ADT (the author alludes to this a bit).

                          What do you mean? I’m just trying to understand what you said I alluded to in the post.

                          1. 1

                            Mostly this, which I agree with:

                            One way to interpret this is to consider that nil is a subtype of Int and that’s why no error is thrown at compile time. One example of a bad type system that allow this is Java’s where you can return null from a method that its return type is Integer.

                            Some languages, like Scala, have that behavior and the ADT optional.

                            1. 1

                              Yeah, it’s definitely not a good thing. At least the std libs (in Scala) promote the usage of optionals, which is an improvement anyway. Even Java has Optional<T> nowadays.

                              For me the best way is what Rust does (and I’m sure other languages also do) which is just having Option<T>.

                        2. 1

                          I don’t mention because it’s not important for the point of the post and also because it’s not a real language. The syntax is just a mix of Ruby and Rust.

                          1. 4

                            Considering you’re talking about the semantics of something, your post makes no sense without picking a language or at least describing the semantics of your made up lanuage. Your post is nonsense otherwise.

                            1. 1

                              I suggest you to read the post again because you missed the point. There’s no need to know the semantics. The post is clear about nil being a completely different thing from None and why. But I guess I shouldn’t be explaining here, it’s all in the post.

                              1. 2

                                There’s no need to know the semantics.

                                Of course there is, because you don’t say what None or nil are. Python has None with the semantics of your nil (well, not quite but close enough) and OCaml has None with semantics like your None. Which one is the one that you mean? How is the reader supposed to know? The only way to know what you mean is by knowing what you want to explain before reading your post to decipher which semantics you are assigning to None and nil.

                                1. -1

                                  Did you even read the post? I’m pretty sure it says what None and nil are.

                                2. 2

                                  There’s no need to know the semantics

                                  Given that the point of the post is about the semantics of something, I dont' see how you can claim there is no reason to use them.

                                  The post is clear about nil being a completely different thing from None and why.

                                  What you do is show some random code and claim you can interpret it a certain way. Then you show another piece of random code and claim you cannot interpret it that way. I find that less than clear.

                                  Anyways, as someone that has some experience in type systems, I’m telling you that your post is confusing and nonsensical because you have left out important context. Feel free to do what you want with information.

                                  1. 1

                                    Exactly. Let’s just move on. I don’t see this discussion going anywhere. Some people will read stuff and understand and others won’t. It happens everyday with everybody (including me).

                              2. 2

                                The problem is not that we can’t figure out your syntax; the problem is that we can’t figure out your semantics. Your post makes no sense if you’re talking about Python’s None or Scala’s Nil, or indeed if you’re talking about dynamically typed languages at all. It’s like when a five-year-old says “We’re going to Danna’s!” on the assumption that you and indeed everyone in the world share their context that gives meaning to “Danna”. That semantic context is provided by a programming language.

                                1. 1

                                  See my comment above to @apy.

                            1. 1

                              Just noticed that there’s no clojure tag. What’s the policy about tag creation?

                              1. 5

                                Generally we make a new post tagged “meta” and asks that someone make a new tag. However, we’ve discussed making a clojure tag, and so far have decided not to because we already have a lisp tag.

                                The community might have changed its mind since then though, just because at one point in time it made a decision doesn’t mean it will always be that way.

                              1. 1

                                This link leads to a 404. :(

                                1. 1

                                  It is here now: http://www.thoughtworks.com/insights/blog/mockists-are-dead-long-live-classicists

                                  Unfortunately the author made a generalization, using a bad example and most of all, an awful title.

                                  1. 1

                                    Ouch, the article moved…

                                    1. 1

                                      What’s the new link?

                                      1. 3

                                        It still is on Google Cache

                                        1. 1

                                          It looks like it was removed. Odd, it was an interesting article..