SVMUG November 16, 2015
Still More on 1Password Metadata (Scroll down to ‘Security Lite)
iPad Pro is Available (Robert has one!!)
Swift Programming for the non-programmer
What is a programmer?
Flexibility, ease of use, portability, and speed
languages before Swift: problems and solutions
What is Swift? How is it different?
Programmers create instructions intended to cause a computer to do some work.
Users are just programmers who believe anything you tell them.
stored instructions: program, playlist, bookmark, app, Macro, script, shortcut, … html, document…
Programmers care about flexibility, ease of use, portability, and speed.
The Facebook web interface makes it very easy to share a post on Facebook,
but you can’t use it to write a program to solve a math problem.
Using Assembly language you can write a program to do anything,
such as posting to Facebook,
but it takes much much more work then using Facebook.
Trade-off: ease of use versus flexibility
Portability is also a concern. Where can I run the program?
Facebook runs everywhere (via web browser).
But assembly language is very specific to the platform.
Speed is also important: how fast is a program after I write it.
— Find the Middle Ground —
Flexible enough yet easy enough
portable enough yet fast enough.
Control Flow: specify the order of execution of program statements
Spaghetti code: a program where the control flow is hard to follow.
With spaghetti code, different parts of your code can be meshed with each other,
so that changing one piece might break some other piece, especially in unexpected ways.
Excel Macros are flexible but not easy to use — makes spaghetti code inevitable.
Furthermore, it is not portable (works only in Excel), and not particularly fast.
— create anything
— easy to create simple elegant code
— portable - everything has a C compiler.
— Speed - very fast
[Sidenote: a compiler takes readable code, e.g. English, and converts it into machine code (or “byte code”).
“The nice thing about C is that you can do everything. The bad thing about C is that you must do everything.”
Solution: object oriented programming: objects encapsulate data with the code that operates on that data.
— code becomes a loose collection of objects.
— the objects are replaceable without great modifications to the rest of the code.
— objects encapsulate code
Objective-C is a strict superset of C.
— perhaps not quite as easy as plain C
— it was designed to portable, but really only used for Apple devices
— fast, but not as fast as pure C
Apple’s Goals for Swift
- open source
- No “silent consent” for unexpected conditions
- Better memory protection
- No selectors.
If Objective-C encounters an unexpected condition, e.g. null pointer, it does nothing, generates no exceptions, no errors.
Swift will deliberately crash the program. This prevents problems later.
Memory Protection: C can wander around in memory, changing stuff that should not be changed.
Swift will enforce array bounds, rigorously check for overflow, and uses no pointers by default.
In C, C++, or Objective-C, it is easy to accidentally modify memory.
Swift does not support selectors. This allows for the creation of private code that other objects are not allowed to call.
Modern: “when Swift was release, everyone said it was just like their favorite language”
— modern nice syntax
— Swift source code is usually shorter than Objective-C source code.
Fast: significantly faster then Objective-C.
Interactive: not a feature of the language, but of the creation tools (Xcode).
— playgrounds execute code automatically.
— — see the results instantly
— — can use Apple frameworks
— — can use image and sound files
— — no need to embed code in complex programs, to see the results.
Open Source: at WWDC 2015, Apple announced that Swift would be made open source by the end of the year.
— it is not the end of the year, yet.
1. Best Swift book for novices is the Apple Swift book. (Currently version 2.1 in iBooks.)
2. How to speed up file sharing between two Macs?
— Use WiFi for the connection.
— AirDrop is also very quick.
3. I am getting restarts in Yosemite. Is this a bad sign? No problems are found in diagnostics. “Your Mac restarted because of a problem.”
— possibly the HD is starting to fail.
— use Disk Utility to read the SMART data on the drive.
— Google kernel restarts - there is an Apple Support Document.
— try EtreCheck
4. How do I view an email in ‘source text’ without opening it?
— you have to open it.
— in the mail list, force touch the mail item or use the menu “view” -> “message” -> “raw”
5. Suggestions of where to start learning programming?
— pick something simple, write it.
— then move on to more complex things.
6. I can calibrate my monitor using the Apple tool. What can I use?
— Use Spyder Pro, X-Rite Pro, etc.
7. New iPhone 6+ — try to transfer my SIM card, but AT&T says I need a new SIM card for new features. What are these features?
— only AT&T knows — ask them at the retail store.
— it might be the WiFi calling, and HQ calling.
Meeting Notes >