[swift-evolution] A mode with no type checking to compete with Python.

Paul Cantrell cantrell at pobox.com
Sun Dec 6 12:42:39 CST 2015


> I think Python's biggest appeal to new programmers is the fact that it has such a great standard library

This is not the case, at least in my teaching experience.

One of the largest hurdles for new programmers, and the one that differentiates beginning languages more than any other, is compiler strictness. This includes both syntax and static type checking.

We easily forget how hard learning syntax is: to see every piece of punctuation as significant, to read code as a parse tree, to think inside the box of the language’s type system. Programmers in their first months easily spend 50% of the time getting their code to compile, usually more like 80%.

The problem with compile-time strictness of any kind is that the compiler won’t do _anything_ until _everything_ compiles. I’ve seen this drive beginners to burnout, even drive them away from CS altogether. (To help calibrate your thinking about just how much we’ve forgotten that we learned: eons and eons ago, when my department taught its intro courses in Pascal and C++, the main first-year hurdle was not dealing with unsafe pointers, but knowing where to put the semicolons. Semicolons!)

When you don’t understand what a failure looks like, it’s tremendously helpful to be able to actually run the code and see the failure happen. Having the language say “this can’t possibly work so I won’t run it” is not helpful to beginners; it’s just bottled frustration. Having the language say “it worked until I got here, at which point this happened” is infinitely more helpful.

The biggest hurdle to a beginning programmer is how _stupid_ programming makes one feel. We experience programmers are all used to this. Beginners are not. Their successes are rarer, the obstacles more daunting. Every stumble feels intensely personal. Anything that makes success more incremental and more self-discoverable helps.

• • •

You might think at this point that I’m arguing in favor of the “no types to compete with Python” mode, but I’d vote against it.

The ideal beginner language has a flexible, forgiving syntax that rewards guessing; the least compile-time type checking possible; and very clear error messages (both compiler and runtime). On all three counts, this sounds very far from Swift today. Better error messages would be good for all of us, but the other two just don’t sound like Swift.

Good beginner languages reward exploration by empirical experimentation. Good professional development languages reward clarity of intent. Those two things are often in tension, and Swift’s core aesthetic clearly lands on the side of the second.

Is making it a good language for new beginners truly a design goal of Swift? I don’t think it should be. It _does_ seem like an excellent design goal to keep the language as simple, approachable, and learnable as it can be within its aesthetic.

Cheers,

Paul

P.S. The Bret Victor article that describes the thinking behind playgrounds has some oustanding ideas on making languages more learnable: http://worrydream.com/#!/LearnableProgramming <http://worrydream.com/#!/LearnableProgramming>

–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
https://innig.net • @inthehands • http://siestaframework.com/


> On Dec 5, 2015, at 6:13 PM, Austin Zheng via swift-evolution <swift-evolution at swift.org> wrote:
> 
> No, I don't. I think Python's biggest appeal to new programmers is the fact that it has such a great standard library, making it really easy to do whatever you want to do without figuring out how to find or add in external dependencies.
> 
> Anyways, mistyped Python code still breaks, it just breaks at runtime instead of compile time. In fact, I'd argue that this is even less beginner friendly, since you might write a function that works with some inputs and then inexplicably breaks with others.
> 
> Austin
> 
>> On Dec 5, 2015, at 4:09 PM, Amir Michail <a.michail at me.com <mailto:a.michail at me.com>> wrote:
>> 
>> 
>>> On Dec 5, 2015, at 7:05 PM, Austin Zheng via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> ml>
>>> I disagree with the idea that a type system is too much of a hurdle for beginner programmers to overcome.
>> 
>> Don’t you think that Python currently provides a better introduction to programming due to its simplicity?
>> 
>>> 
>>> Austin
>>> 
>>>> On Dec 5, 2015, at 4:01 PM, Kevin Lundberg via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>> This is somewhat possible today on Apple platforms with AnyObject. You can call any objc-visible method on AnyObject and it will compile, and the return type will also be AnyObject (I don't recall if the return type is optional as well or not). This doesn't work with value types, but neither does id in objc.
>>>> 
>>>> Having a more complete lax typed mode similar to Python or php I think is of limited usefulness, would add too much complexity to the language, and yield too much uncertainty about any given piece of swift code. 
>>>> 
>>>> --
>>>> Kevin Lundberg
>>>> 
>>>> On Dec 5, 2015, at 6:50 PM, Adrian Kashivskyy via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>>> I can't believe I'm seeing a proposal to remove type safety, one of the fundamental features of Swift...
>>>>> 
>>>>> Regards,
>>>>> Adrian Kashivskyy
>>>>> iOS Developer at Netguru
>>>>> 
>>>>>> Wiadomość napisana przez Amir Michail via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> w dniu 05.12.2015, o godz. 20:51:
>>>>>> 
>>>>>> Python is still easier than Swift for beginning programmers. But maybe such a mode can allow Swift to be used by beginners also? _____________________________________________ swift-evolution mailing list swift-evolution at swift.org <mailto:swift-evolution at swift.org> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> swift-evolution mailing list
>>>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>>> 
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>> 
>>> 
>>> --r‡bžÚḟîẁ
>>> ‰íz{CŠÊhĠ+bḃx§–)Ŷ_______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/ma <https://lists.swift.org/ma>
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151206/7e04d6c0/attachment.html>


More information about the swift-evolution mailing list