Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror

Comment Re:Yet 'optionals' somehow made it through (Score 1) 339

I can buy that optional chaining (not optionals) encourages lots and lots of redundant null checking. That said, no more than obj-c, which already did redundant null checking on every single message send. Optional chaining effectively is an obj-c compatibility measure, to mimic it's "it's safe to send messages to nil" behaviour.

Optional types rather point out that obj-c's behaviour was weird here, and that you should make your best effort to prove to the compiler that something really isn't null before sending messages to it.

Comment Re:Yet 'optionals' somehow made it through (Score 1) 339

Again, no. It encourages putting the check in exactly one well structured place:

func f(x : Object?) { // We know that the check has not happened yet, x may be null
        guard let y = x else {
                return;
        }

        g(y)
}

func g(x : Object) { // The lack of a ? documents that by this point we expect that the check must of happened. Not only that but it asks the compiler to enforce that it must have happened
        doShitWithX(x)
}

The type system enforces that a) we definitely do check, and b) that the person writing g, or doShitWithX does not need to check, because it's been documented (in a provable way) that the check has already happened by that point.

There's no encouragement of multiple checks at all. Instead, there's encouragement that you make a single check, and then document explicitly where that check is, in a way that the compiler can verify.

Not having optionals, instead encourages you to make multiple checks, as the author of g, or doShitWithX, will feel the need to assert preconditions in their functions, because they have no good way of informing their callers that they should never receive null.

Comment Re:Because ceramics don't get hot? (Score 1) 80

Right, I mean, that's exactly why they use them for heat resistant coatings on vehicles that need to reenter the atmosphere.

Oh wait no, that's because *you're* wrong, and certain ceramics (notably, ones without porosity, and without air or water trapped inside them) are extremely good at resisting heat and heat changes.

Comment Re:Yet 'optionals' somehow made it through (Score 1) 339

Wait, are you suggesting that it should optimise out the checks?

You seem to be missing the important bit of this... You *need* to check for those null pointers. You always did need to check for them before you had optionals making sure that you did. It's flat out a bug to not check. Saying "it's faster to not check" is irrelevant - checking is necessary for program correctness.

Comment Re:Summary insufficient, click through the link. (Score 1) 786

Yes, I did. The author does say a "vocal minority", but that doesn't change the fact that he's implying that software developers have a much higher chance of being "socially underdeveloped" than any other profession. Their entire argument rests on the notion that there's a larger than average proportion of socially underdeveloped people in the open source community.

So yes, yes they really did generalise a large group of people and call them socially underdeveloped.

Comment Re:Yet 'optionals' somehow made it through (Score 1) 339

Why on earth would optionals be considered a bad thing? Not only having the compiler check that you don't ever make a null pointer dereference (probably the single most common type of bug that exists); but also extending that checking to any value that may or may not exist. What possible justification is there to not do that?

Comment Re:Summary insufficient, click through the link. (Score 4, Insightful) 786

Mostly because of the generally non-nice, aggressive, "it's all your fault" way that it was put. The social issue on display here is the article's author generalising a large group of people, and collectively calling them socially underdeveloped. It's unsurprising that that gets a negative response, in much the same way as generalising all women, and calling them crap at technology gets an unsurprisingly negative response.

Slashdot Top Deals

"The fundamental principle of science, the definition almost, is this: the sole test of the validity of any idea is experiment." -- Richard P. Feynman

Working...