Teaching Swift in a university course

Thanks for the feedback everyone. I really appreciate the discussion and the links. I've experimented with remote development in WSL and on our Linux server, but I ran into enough snags that I won't be switching this semester. I am really looking forward to doing so when the tooling and documentation for Swift 5 is out of the alpha or beta stage. It came down to:

  1. My students will want to set up development environments on their own systems and I want that to be easy. This will be the first exposure to Linux and command-line development for many of them.

  2. As I was porting assignments to Swift I found the documentation difficult to follow. For example, I didn't know that the String init(contentsOfFile path: String) constructor required Foundation to be imported, and Xcode didn't give that as a suggestion.

1 Like

hereā€™s a code snippet you can use for reading and writing files to disk. like most linux swift users, i donā€™t recommend using Foundation on Linux,, the implementation is incomplete and the behavior is inconsistent with OSX.

To fix this, [SR-10347] Parity: Remove all uses of NSUnimplemented from swift-corelibs-foundation Ā· Issue #4401 Ā· apple/swift-corelibs-foundation Ā· GitHub exist. As of now, only a few sub-tasks are unresolved.

2 Likes

I think we should start avoiding this type of recommendations. Foundation is now fairly complete on both Linux and Windows.

Snippets like that help creating a fragmented ecosystem (that one in particular does not work on Darwin or Windows). A similar problem can be seen on the Swift Package Manager repo which reimplemented a lot of basic functions instead of relying on Foundation, so porting it now to Windows is a lot more cumbersome than it should be.

11 Likes

I'm curious about your thoughts for your Language Theory course next year. I've been teaching Swift at a high school level for three years and I'm very pleased with the results. The entire pathway (CS-I, CS-II, and CS-III) is taught in Swift.

CS-I provides an introduction to computer science beginning with the basics (Boolean logic, number systems, etc.) We then learn about linux and using bash. The students do some exercises introducing them to emacs, git, and GitHub and then we begin programming in Swift.

While some students remote in to the server using Putty the majority use Google's Chrome SSH extension successfully.

I have been successful using flycheck for syntax highlighting and listing errors and indentation is handled automatically as well. I have not been successful with auto-completion within emacs nor have I succeeded in using integrated debugging.

Are you planning to reconsider Swift for next year's course?

I am definitely interested in using Swift in a course, and I plan on evaluating it again this summer. I'll be looking for more or less the same things (easy setup, good documentation, good tooling). Since I'll only teach the language for a few weeks I think it is important that students have a lot of help from elsewhere.