OT: This Swift thing
Mark Lawrence
breamoreboy at yahoo.co.uk
Thu Jun 5 18:13:00 EDT 2014
On 05/06/2014 22:53, Marko Rauhamaa wrote:
> Mark Lawrence <breamoreboy at yahoo.co.uk>:
>
>> On 05/06/2014 21:07, Alain Ketterlin wrote:
>>> Sturla Molden <sturla.molden at gmail.com> writes:
>>>> On 05/06/14 10:14, Alain Ketterlin wrote:
>>>>> Type safety.
>>>> Perhaps. Python has strong type safety.
>>> Come on.
>>
>> I don't understand that comment, please explain.
>
> I guess what is referred to is static typing. It serves two purposes:
>
> 1. It makes the managers of software development teams believe the
> junior developers in their teams won't be able to do too much damage
> as the compiler at least enforces some rigor in the code. Hence,
> "safety."
>
> 2. It makes it much easier to automatically optimize the code.
>
> Unfortunately, it also has serious downsides:
>
> 3. The code becomes very tedious to type in. You may need hundreds of
> lines of boilerplate code before it actually does anything. It also
> easily makes you lose your focus.
>
> 4. The flow of the code becomes hard to understand because of the
> boilerplate. Ironically, the very straitjacket that seeks to force
> good quality on you prevents you from seeing the forest for the
> trees.
>
> Example:
>
>
> Map<StreetAddress, ZipCode> makeStreetAddressMap(
> List<StreetInfo> infoList) {
> Map<StreetAddress, ZipCode> map =
> new HashMap<StreetAddress, ZipCode>();
> for (StreetInfo info : infoList)
> map.put(info.getStreetAddress(), info.getZipCode());
> return map;
> }
>
> vs
>
> def make_street_address_map(info_list):
> map = {}
> for info in info_list:
> map[info.get_street_address()] = info.get_zip_code()
> return map
>
> or:
>
> def make_street_address_map(info_list):
> return dict((info.get_street_address(), info.get_zip_code())
> for info in info_list)
>
>
> Marko
>
Interesting. We've gone from "Python has strong type safety" to "come
on" to "I guess what is referred to is static typing". I'll simply say
that I understand Python to be strongly, dynamically typed.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
More information about the Python-list
mailing list