OPERATING SYSTEMSOS Linux

Can Swift Replace Bash (for Scripting)? | @SwiftBird

In iOS and macOS projects, I often deal with some sort of setup or maintenance scripts written in Bash. But because it is so different from Swift—my primary programming language—I don’t feel very confident working with Bash. In this video, I explore scripting in Swift: turns out, it’s a pretty good alternative suitable for most use cases.

You can support me by…
• …buying me a coffee: https://www.buymeacoffee.com/SwiftBird
• …becoming a patron: https://patreon.com/SwiftBird

Links:
• Scripting in Swift basics: https://rderik.com/blog/using-swift-for-scripting/
• FileManager documentation: https://developer.apple.com/documentation/foundation/filemanager
• FileManager basics: https://nshipster.com/filemanager/
• Swift extension for VS Code: https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
• Homebrew on Linux: https://docs.brew.sh/Homebrew-on-Linux

Chapters:
• 0:00 Intro
• 0:56 What’s Wrong with Bash?
• 2:11 Where You Can Use Swift Scripts
• 2:54 Swift vs. Bash for Scripting
• 4:00 Environment Setup
• 6:13 Basic Operations: Printing, Reading Input, Calling Functions, etc.
• 9:14 Calling Other Commands
• 14:23 Reading and Writing Files
• 16:51 Two Forms: Interpreted and Binary
• 19:16 Summary
• 19:35 Outro

The Swift Bird is produced by https://www.youtube.com/yakovmanshin.

#swift #script #softwareengineering

source

by The Swift Bird

linux foundation

5 thoughts on “Can Swift Replace Bash (for Scripting)? | @SwiftBird

  • My problem with Swift and why I won't even try it is because it is basically only for MacOS. Kind of like how C# is only for Windows. Sure, you could run it on other platforms, but it isn't going to be as smooth most of the time.

  • 0:59 "Lets talk about whats wrong with bash" ….*held my breath with antici-…. "To be fair to it, nothings really wrong" …-pation**dramatic exhale*….

  • For anyone who does find they are required to use (or debug) scripts written in 'bash' or plain 'sh', then look up a util called "Shellcheck". It can be very helpful.

  • Nice tutorial on swift scripting. !
    But even with a 27 inch monitor , I have difficulty to see the syntax text.
    Please make the syntax text larger. Many Thanks.

Comments are closed.