[Pitch] Eliminate tuples - unify member access syntax

I am almost not sure if this is a joke or not. That is an incredibly complicated looking hieroglyphic to dispatch a bit of code. I do this:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSString* message = [NSString stringWithFormat: @"prepareSeque%@To%@:",(segue.identifier ? segue.identifier : @""), [segue.destinationViewController class]];
    SEL method = NSSelectorFromString(message);
    if([self respondsToSelector:method])
    {
        [self performSelector:method withObject:segue.destinationViewController];
    }
}
// Assume segue identifier was NextStep and we are going to a NextViewController
-(void)prepareSequeNextStepToNextViewController:(NextViewController*)vc
{
    // do specific work in a small focused method instead of buried in a giant ugly switch statement
}

Burying all that logic in a bunch of control statements just obfuscates intent. Now, you may argue my prepareForSegue is a little bit ugly and I would agree with you - but I write that once, stick it on UIViewController as an extension method, and never look at it again, instead going off the naming convention - much like the responder chain works.

I keep hearing the same justifications over and over. "Compiler can't check that", "pattern matching", "powerful enums", "protection from nil", "faster execution", "exhaustively checked switch statements" etc.... I do not value any of that stuff and it all goes out the window once your program beings consuming data from outside. It doesn't make my programs more powerful, more expressive, more robust, or better. It does slow me down a lot trying to satisfy a bunch of constraints that are, frankly, irrelevant to my problem domain and what it does instead is refocus my attention from the problem domain into the implementation domain unnecessarily.

The conventional wisdom is that switch statements are an anti pattern in the presence of OO features. They're brittle and basically they're goto's. Polymorphism is to be preferred. I thought we settled that in the 90s.

It is becoming more and more clear that the ideals of Swift are nothing like the Smalltalk ideals that gave us Cocoa (and Cocoa is a very elegant framework loaded with beautiful design patterns that have served us very well - well enough to let little Apple eat Microsoft's lunch). Swift is a lot closer to the ideals of C++ and ML and they are a terrible fit on top of a Smalltalk inspired framework. Write Swift if you must - but stop screwing up the Apple app scene with it.

Seriously, I'm out. I'd just like to ask the Apple people to stop dumping cruft into the Objective C header files. I don't care about nullable annotations or the fake generics cruft. Objective C is based on Smalltalk. This direction is anathema to the Smalltalk ideals that underly the existing Cocoa system. Nils don't matter and generics are nonsense in a dynamically typed world. I mean, have any of you even used a book on Smalltalk as a doorstop much less read one?

Basically, you're killing the golden goose. Like when WebObjects was ported to Java. It didn't survive the change from dynamic language to more rigid type constrained Java language. It just died.

Cocoa won't either.

I'm signing off this list. Swift is about the opposite of what I need in a programming language. It will not scale to the enterprise any better than C++ did (clue - it didn't - I was there) and the embedded world has already had working Smalltalk implementations all the way down to fpga's (Revisiting Smalltalk-80 blocks: a logic generator for FPGAs | IEEE Conference Publication | IEEE Xplore) for over 20 years so I'm completely unpersuaded by the efficiency arguments or the compiler checked "correctness" arguments. Software is never correct, never done, never perfect. Best to have an environment that can deal with that.

Oh and uh - stop pushing Swift as the future. 9/10 jobs doing iOS now demand Swift. Thanks for that. And by thanks - I mean screw you, Apple. State of iOS development today is a disaster.

Out.

···

On Jan 11, 2017, at 00:04, André Videla <andre.videla@gmail.com> wrote:

func prepareForSegue(segue: UIStoryboardSegue, sender: Any?) {
    Switch (segue.identifier, segue.destination, sender) {
        Case ("Segue"?, let vc as FirstVC, .some(.enumType(let value)) ): // prepare the vc
        ... // other segues
    }
}

I guess you don’t like Swift then after all?

In my humble experience I have been involved in writing iOS apps since 2008 so seen a few changes - I have found it quicker and easier to write in Swift and just get things done better ( compared to Objective C ).

For me - Swift is most welcome, very refreshing and has more clarity than Obj C. It has been nothing but a pleasure to move on from Obj C.

So keep up the great work guys please!!!!!

p.s. I like how easy to use tupules are - if people don’t like them or it’s not their style then just don’t use them huh?

Jamie Lemon

···

On 11 Jan 2017, at 12:01, Freak Show via swift-evolution <swift-evolution@swift.org<mailto:swift-evolution@swift.org>> wrote:

I am almost not sure if this is a joke or not. That is an incredibly complicated looking hieroglyphic to dispatch a bit of code. I do this:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSString* message = [NSString stringWithFormat: @"prepareSeque%@To%@:",(segue.identifier ? segue.identifier : @""), [segue.destinationViewController class]];
    SEL method = NSSelectorFromString(message);
    if([self respondsToSelector:method])
    {
        [self performSelector:method withObject:segue.destinationViewController];
    }
}
// Assume segue identifier was NextStep and we are going to a NextViewController
-(void)prepareSequeNextStepToNextViewController:(NextViewController*)vc
{
    // do specific work in a small focused method instead of buried in a giant ugly switch statement
}

Burying all that logic in a bunch of control statements just obfuscates intent. Now, you may argue my prepareForSegue is a little bit ugly and I would agree with you - but I write that once, stick it on UIViewController as an extension method, and never look at it again, instead going off the naming convention - much like the responder chain works.

I keep hearing the same justifications over and over. "Compiler can't check that", "pattern matching", "powerful enums", "protection from nil", "faster execution", "exhaustively checked switch statements" etc.... I do not value any of that stuff and it all goes out the window once your program beings consuming data from outside. It doesn't make my programs more powerful, more expressive, more robust, or better. It does slow me down a lot trying to satisfy a bunch of constraints that are, frankly, irrelevant to my problem domain and what it does instead is refocus my attention from the problem domain into the implementation domain unnecessarily.

The conventional wisdom is that switch statements are an anti pattern in the presence of OO features. They're brittle and basically they're goto's. Polymorphism is to be preferred. I thought we settled that in the 90s.

It is becoming more and more clear that the ideals of Swift are nothing like the Smalltalk ideals that gave us Cocoa (and Cocoa is a very elegant framework loaded with beautiful design patterns that have served us very well - well enough to let little Apple eat Microsoft's lunch). Swift is a lot closer to the ideals of C++ and ML and they are a terrible fit on top of a Smalltalk inspired framework. Write Swift if you must - but stop screwing up the Apple app scene with it.

Seriously, I'm out. I'd just like to ask the Apple people to stop dumping cruft into the Objective C header files. I don't care about nullable annotations or the fake generics cruft. Objective C is based on Smalltalk. This direction is anathema to the Smalltalk ideals that underly the existing Cocoa system. Nils don't matter and generics are nonsense in a dynamically typed world. I mean, have any of you even used a book on Smalltalk as a doorstop much less read one?

Basically, you're killing the golden goose. Like when WebObjects was ported to Java. It didn't survive the change from dynamic language to more rigid type constrained Java language. It just died.

Cocoa won't either.

I'm signing off this list. Swift is about the opposite of what I need in a programming language. It will not scale to the enterprise any better than C++ did (clue - it didn't - I was there) and the embedded world has already had working Smalltalk implementations all the way down to fpga's (Revisiting Smalltalk-80 blocks: a logic generator for FPGAs | IEEE Conference Publication | IEEE Xplore) for over 20 years so I'm completely unpersuaded by the efficiency arguments or the compiler checked "correctness" arguments. Software is never correct, never done, never perfect. Best to have an environment that can deal with that.

Oh and uh - stop pushing Swift as the future. 9/10 jobs doing iOS now demand Swift. Thanks for that. And by thanks - I mean screw you, Apple. State of iOS development today is a disaster.

Out.

On Jan 11, 2017, at 00:04, André Videla <andre.videla@gmail.com<mailto:andre.videla@gmail.com>> wrote:

func prepareForSegue(segue: UIStoryboardSegue, sender: Any?) {
    Switch (segue.identifier, segue.destination, sender) {
        Case ("Segue"?, let vc as FirstVC, .some(.enumType(let value)) ): // prepare the vc
        ... // other segues
    }
}

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org<mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Pretty sure Array conforms to hashable and ==.

···

On Jan 10, 2017, at 23:43, David Sweeris <davesweeris@mac.com> wrote:

On Jan 11, 2017, at 01:29, David Sweeris via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Jan 11, 2017, at 01:11, Freak Show <freakshow42@mac.com <mailto:freakshow42@mac.com>> wrote:

On Jan 7, 2017, at 23:37, Derrick Ho <wh1pch81n@gmail.com <mailto:wh1pch81n@gmail.com>> wrote:

I think pattern matching is the most compelling reason to keep tuples.

If they were gone, how would we replace the following?

switch (a, b) {
case (value1, value2):
case (value3, value4):
}

I meant to mention this: Smalltalk - Objective C's mother language - has no switch statement (or 'if' or loops either). The language is incredibly malleable because it only does one thing - send messages to objects and all the language constructs are in the library. It would take very little time to add one. Off and on someone does it as an exercise but it never sticks.

Instead, you just use a dictionary of closures. An Objective C equivalent might be:

NSDictionary* switch = @{
  @[@0,@1]: ^{ NSLog(@"zero one"); },
  @[@1,@1]: ^{ NSLog(@"one one"); }
};

NSArray* pair = @[@3, @5];

(switch at:pair ifAbsent:^{})(); //where at:ifAbsent: is added in the Smalltalk style as an extension.

The Smalltalk equivalent (much less ugly because of the lack of @'s) is

switch := {
  #(0 1) -> [ Transcript nextPutAll: 'zero one' ] .
  #(1 1) -> [ Transcript nextPutAll: 'one one' ] .
  #(1 2) -> [ Transcript nextPutAll: 'one two' ] .
} asDictionary.

(switch at: pair ifAbsent:[ ]) value.

So its not like this is some kind of key feature. Switch's vs dictionaries of closures - pretty much the same thing as pattern matching goes. The only thing you have to do is put an object at key that identifies itself as equal to the pattern you will throw at it.

I suspect that's a fair bit slower than a switch statement. I'm not in front of my computer, so I can't prove it, though.

Also, Swift's dictionary requires its keys to conform to `Hashable`, which would mean we'd have to create a formal struct *and* the "==" method for it would have to act as a pattern matched instead of checking equality. I suspect this could break a great many things that depend on "Equatable" meaning what it says.

- Dave Sweeris (again)