<p>Perhaps in the example code that you show them, introduce them to Python 3 Type Hints (PEP 484 -- Type Hints <a href="https://www.python.org/dev/peps/pep-0484/" rel="nofollow noreferrer">https://www.python.org/dev/peps/pep-0484/</a> ). It's a bit of a kludge because the typing is still dynamic, but it at least shows that we care about the arguments and return values.
It looks like this:</p>

<pre><code>def greeting(name: str) -&gt; str:
    return 'Hello ' + name
</code></pre>

CC BY-SA 4.0
2018-10-31T15:10:22.953Z
Thanks for the feedback but that's not really what I'm asking for.
Onorio Catenacci
CC BY-SA 4.0
2018-10-29T22:27:37.173Z
2018-10-29T22:27:37.173Z
Louis B.
<p>If you teach Python's typing system correctly, you should have no problem later. The rule in Python is that names don't have a type associated with them, but all values do. It isn't that "things" change type. They don't. Objects and other values have a well determined type when they are created and that type never changes. Names never have a type to be changed. But any name can be associated with any value. </p>

<p>When you move to a language that requires explicitly applying a type to names (Java, say), then you just need to teach them that names are given types also, as a sort of redundancy so that errors can be caught earlier (compiler v run-time). A name associated with a type can only refer to a value that has that type. </p>

<p>Applying types to names (as well as values) isn't really that big a deal, and the students will be more sophisticated when you get to it. </p>

<p>However, they may not <em>like</em> having to explicitly apply types to names. But that is a different issue. The reason given above will be enough for many of them. </p>

<p>Finding errors early is a big win in programming. If you take that attitude when teaching Python you will stress things like early testing (preferably test-first programming) so that errors show up soonest. </p>

<hr>

<p>For the distinction between a "thing" and a "name applied to a thing" it is often instructive and always fun to return to <a href="https://en.wikipedia.org/wiki/Haddocks&#39;_Eyes" rel="noreferrer">Haddock's Eyes</a>. Lewis Carroll was more interested in mathematics, of course, but the ideas apply equally well to CS. </p>

<hr>

<p>Don't confuse "typing" as <em>hitting keys on a keyboard</em> with "typing" as <em>applying a type to a name or value</em>. It may be that the first version of this was confusing in that regard. Here "typing" means only the latter. </p>

CC BY-SA 4.0
2018-09-22T10:24:45.573Z
I like the distinction of names and values. I had never thought of it like that (I am a Software Engineer / Teacher, and learning to think more like a computer scientist, every day. If you are a computer scientist, then learn to think more like a Software Engineer, both are valuable). However, did you make a small error, I think “having to explicitly type names”, should be “having to explicitly type types”.
ctrl-alt-delor
CC BY-SA 4.0
2018-09-22T11:20:03.217Z
@ctrl-alt-delor. Clearer now. It wasn't an error, but may have been poorly stated.
Buffy
CC BY-SA 4.0
2018-09-21T16:02:33.163Z
2018-09-22T14:31:08.473Z
2018-09-22T14:31:08.473Z
Buffy
<p>Maybe it is a bit overkill, but I'm teaching python and C in parallel to CS beginners. </p>

<p>The languages are syntactically similar enough to lower the burden of learning two languages, but the students understand the "problem" of typing and get a better idea of what is happening in behind in python. </p>

<p>Fun fact: In the beginning, all like Python, because it requires no typing. At week three, all love C because it is clearer. In week 6, we are having two fractions in the course, one loving C, the other loving python (or hating C / python ;-) ). The students preferences are changing quite often during this course and this gives me a lot good teaching opportunities. </p>

CC BY-SA 4.0
2018-10-29T15:37:21.060Z
That's a fascinating approach! Is this your first time using it?  What are the ages of the students?
Ben I.
CC BY-SA 4.0
2018-10-29T15:39:38.433Z
@BenI. I'm doing this for seven years now with good success. This year one colleague of mine switched from java to the same concept because of the good results. 
The students are first semester students in Germany at a university of applied science, many without little to no background in cs and no programming experience (yes, this is Germany in 2018 :-( ).
OBu
CC BY-SA 4.0
2018-10-31T15:11:26.663Z
Wow--you _are_ ambitious :)  Teaching any new developer C seems like a recipe for, well, bad outcomes.  :)  Glad to see that my intuition seems to be quite wrong.
Onorio Catenacci
CC BY-SA 4.0
2018-10-31T17:02:20.147Z
@OnorioCatenacci The good thing about C is, that it uses nearly no magic behind the scenes and you can understand the behaviour once you understood how a computer works. But you have to give the students time to learn, you should not hurry.
OBu
CC BY-SA 4.0
2018-10-29T15:06:39.757Z
2018-10-29T15:06:39.757Z
OBu
<p>Given the prevalence of Python as a first language at many universities I think using Python as a language to teach new software developers is a good approach.  But there's one thing that concerns me.  Eventually these developers will be moving to a statically typed language and I want them to be aware of static typing and what it implies.</p>

<p>Do you think using Python for teaching will be a large hindrance to later instruction or am I just worrying for no good reason?</p>

<p>Would anyone care to recommend other teaching languages I might evaluate as well besides Python?</p>

CC BY-SA 4.0
2018-09-21T22:56:04.777Z
In my experience, the learning curve for from duck typing to (basic) static, declared types is pretty short. Partly because it is enforced by the compiler and partly since you probably introduced at least the int/float/str types in python.
Adam
CC BY-SA 4.0
2018-11-19T16:53:35.397Z
And in the working world I float between Java and PHP.  Gotta admit that at times I miss the  strong typing when working in PHP, and at times I miss the loosey-goosey dynamicness when working in Java.
ivanivan
<python>
Will I Regret Using Python As A Teaching Language When I Later Need to Teach Static Typing?
# Will I Regret Using Python As A Teaching Language When I Later Need to Teach Static Typing?

(Asked by: username_0 on 2018-09-21)

Given the prevalence of Python as a first language at many universities I think using Python as a language to teach new software developers is a good approach. But there's one thing that concerns me. Eventually these developers will be moving to a statically typed language and I want them to be aware of static typing and what it implies.

Do you think using Python for teaching will be a large hindrance to later instruction or am I just worrying for no good reason?

Would anyone care to recommend other teaching languages I might evaluate as well besides Python?

**Tags:** python

> **Comments:**
> **username_1**: In my experience, the learning curve for from duck typing to (basic) static, declared types is pretty short. Partly because it is enforced by the compiler and partly since you probably introduced at least the int/float/str types in python.  
> **username_2**: And in the working world I float between Java and PHP.  Gotta admit that at times I miss the  strong typing when working in PHP, and at times I miss the loosey-goosey dynamicness when working in Java.  

---

## 3 answers

### Answer by username_4 on 2018-09-21. Score: 10 | Accepted answer

If you teach Python's typing system correctly, you should have no problem later. The rule in Python is that names don't have a type associated with them, but all values do. It isn't that "things" change type. They don't. Objects and other values have a well determined type when they are created and that type never changes. Names never have a type to be changed. But any name can be associated with any value.

When you move to a language that requires explicitly applying a type to names (Java, say), then you just need to teach them that names are given types also, as a sort of redundancy so that errors can be caught earlier (compiler v run-time). A name associated with a type can only refer to a value that has that type.

Applying types to names (as well as values) isn't really that big a deal, and the students will be more sophisticated when you get to it.

However, they may not *like* having to explicitly apply types to names. But that is a different issue. The reason given above will be enough for many of them.

Finding errors early is a big win in programming. If you take that attitude when teaching Python you will stress things like early testing (preferably test-first programming) so that errors show up soonest.

---

For the distinction between a "thing" and a "name applied to a thing" it is often instructive and always fun to return to [Haddock's Eyes](https://en.wikipedia.org/wiki/Haddocks'_Eyes). Lewis Carroll was more interested in mathematics, of course, but the ideas apply equally well to CS.

---

Don't confuse "typing" as *hitting keys on a keyboard* with "typing" as *applying a type to a name or value*. It may be that the first version of this was confusing in that regard. Here "typing" means only the latter.

> **Comments:**
> **username_5**: I like the distinction of names and values. I had never thought of it like that (I am a Software Engineer / Teacher, and learning to think more like a computer scientist, every day. If you are a computer scientist, then learn to think more like a Software Engineer, both are valuable). However, did you make a small error, I think “having to explicitly type names”, should be “having to explicitly type types”.  
> **username_4**: @username_5. Clearer now. It wasn't an error, but may have been poorly stated.  

---

### Answer by username_6 on 2018-10-29. Score: 5

Maybe it is a bit overkill, but I'm teaching python and C in parallel to CS beginners.

The languages are syntactically similar enough to lower the burden of learning two languages, but the students understand the "problem" of typing and get a better idea of what is happening in behind in python.

Fun fact: In the beginning, all like Python, because it requires no typing. At week three, all love C because it is clearer. In week 6, we are having two fractions in the course, one loving C, the other loving python (or hating C / python ;-) ). The students preferences are changing quite often during this course and this gives me a lot good teaching opportunities.

> **Comments:**
> **username_7**: That's a fascinating approach! Is this your first time using it?  What are the ages of the students?  
> **username_6**: @BenI. I'm doing this for seven years now with good success. This year one colleague of mine switched from java to the same concept because of the good results.  The students are first semester students in Germany at a university of applied science, many without little to no background in cs and no programming experience (yes, this is Germany in 2018 :-( ).  
> **username_0**: Wow--you _are_ ambitious :)  Teaching any new developer C seems like a recipe for, well, bad outcomes.  :)  Glad to see that my intuition seems to be quite wrong.  
> **username_6**: @OnorioCatenacci The good thing about C is, that it uses nearly no magic behind the scenes and you can understand the behaviour once you understood how a computer works. But you have to give the students time to learn, you should not hurry.  

---

### Answer by username_3 on 2018-10-29. Score: 0

Perhaps in the example code that you show them, introduce them to Python 3 Type Hints (PEP 484 -- Type Hints https://www.python.org/dev/peps/pep-0484/ ). It's a bit of a kludge because the typing is still dynamic, but it at least shows that we care about the arguments and return values.
It looks like this:
def greeting(name: str) -> str:
    return 'Hello ' + name

> **Comments:**
> **username_0**: Thanks for the feedback but that's not really what I'm asking for.  

---

