Saltar al contenido ForoHackers

Swift: start here

Swift
#3069 · · Citar · Denunciar

Swift is a compiled, statically typed language designed to be safe, fast and expressive. It is the main language for apps on Apple's platforms and also runs on servers and other systems. It avoids whole families of errors with optionals and strict initialisation, and mixes value types, protocols and a functional flavour.

Key concepts

  • Optionals: a value that may be absent has its own type, which you must unwrap before use.
  • Value and reference types: structs and enums are copied; classes are shared and reference counted.
  • Protocols and extensions: behaviour described by protocols, added to types with extensions, in preference to deep inheritance.
  • Enums with associated values: data that is one of several shapes, matched exhaustively.
  • Memory management: automatic reference counting, and the cycles it cannot break by itself.
  • Structured concurrency: async functions, tasks and actors that isolate mutable state.

Vocabulary

  • ARC: automatic reference counting, how classes are freed.
  • Closure: an anonymous function that captures values.
  • Property wrapper: a reusable type that adds behaviour to a stored property.
  • Package manager: the tool that builds Swift projects and fetches dependencies.

What to study, in order

  1. Basic syntax, constants and variables, collections, control flow, in a playground or a command-line program.
  2. Optionals, structs versus classes, and enums with pattern matching.
  3. Protocols, extensions and generics; model a small domain.
  4. Closures, error handling with throws, and ARC with weak references.
  5. Async and await, tasks and actors.
  6. Build a small app for your target platform with tests.

Related tags

#ios #macos #mobile-computing #functional-programming

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder