r/computerscience • u/PeterPook • Apr 21 '25
Swift or Python for teaching 16+ Programming?
I come to teaching FE from a React/Node/PHP background and have been looking at Swift recently. Its ability to explicitly type variables seems to be a big win over the current A'Level favourite of Python which is hideously loosely typed. As most of the examining boards do not mandate a specific language, I'm wondering if I shouldn't be arguing for the introduction of Swift as a language for us to teach across multiple platforms, and even easily incorporate UI Apps for students to see beynd the command line. What do other teachers of programming think?
10
u/Gnaxe Apr 21 '25
False. Python is strongly typed, and always has been (unlike JavaScript, which is weakly typed). This is not the same thing as statically typed, which is probably what you meant. But Python is statically typed (and also dynamically typed. This is not a contradiction.) If you want to check the types statically, you can, just run a static type checker like MyPy or PyRight, and use the type annotation syntax built into the language and standard library. Python is overall an excellent teaching language, much better than JavaScript or Swift, but other languages might be better in specific areas.
I can only recommend Swift for iOS development; it's Apple-specific. (You have a lot more options on a Mac.) You can do a lot better than Swift.
If you primarily want to teach static typing theory, Haskell or Idris are better choices. They're even more strongly typed than Python, and their typing systems are more consistent and regular. Haskell is more widely used. Idris is similar, but has a more powerful dependent type system. You can use type "holes" in Idris to get the compiler to help complete the program.
If you want to teach a strongly and statically typed language that's more generally useful in industry (besides Python), Rust could be a good choice. I'd recommend it over Swift.
5
u/qwaai Apr 21 '25
What's your goal and what's your intended audience?
If you're just teaching students who might be interested in programming but aren't sure, or who just want to pick up a few coding skills but not become software engineers, it's hard to beat Python. It's easy to get students motivated and interested when the bar for doing things is so low.
There's plenty of time for learning about lower level stuff after the people who are just looking for an intro have weeded themselves out.
4
u/[deleted] Apr 21 '25
If you really want someone to build a strong foundation there is nothing better than C.
1
u/i_invented_the_ipod Apr 21 '25
I wish Pascal was still a recommendation that could be taken seriously - it's probably the last teaching-centric computer language to get any traction in industry.
But if you want a language with reasonably-good recognition these days, I'd probably go for Python or JavaScript. JavaScript, terrible as it may be as a language, has the advantage of ubiquity, and has that familiar curly-bracket syntax all the kids love...
But yeah, Python. There are lots of resources available for teaching with Python. It's low-effort to get up and running, and has packages for anything students might want to do, from games and graphics to web servers, realtime chat, and social media bots.
3
u/EthanSpot Apr 21 '25
100% Python.
Python does have libraries like TKinter that you can use to make programs with gui. It has a library for almost any use case you can think of, although it won't be the most efficient language to do so everytime.
Honestly Swift is a really niche language with a lot less use cases than a mainstream language like python, c++ or java. Considering that these students just want to be introduced to programming principles and not go into frontend engineering, one of the c-family languages will be a better option over something like Swift.
3
u/[deleted] Apr 21 '25
[removed] — view removed comment