Programming Language:: Swift
Programming Language:: Swift
Swift:
Swift is a general-purpose, multi-paradigm, compiled programming
language developed by Apple Inc. and the open-source community, first released in
2014. Swift was developed as a replacement for Apple's earlier programming
language Objective-C, as Objective-C had been largely unchanged since the early 1980s
and lacked modern language features. Swift works with Apple's Cocoa and Cocoa Touch
frameworks, and a key aspect of Swift's design was the ability to interoperate with the
huge body of existing Objective-C code developed for Apple products over the previous
decades. It is built with the open source LLVM compiler framework and has been
included in Xcode since version 6, released in 2014. On Apple platforms, it uses the
Objective-C runtime library which allows C, Objective-C, C++ and Swift code to run
within one program. . Swift took language ideas from Objective-C, Rust, Haskell, Ruby,
Python, C#, CLU, and far too many others to list. Swift is an alternative to the Objective-
C language that employs modern programming-language theory concepts and strives to
present a simpler syntax. During its introduction, it was described simply as "Objective-C
without the baggage of C".
By default, Swift does not expose pointers and other unsafe accessors, in contrast to
Objective-C, which uses pointers pervasively to refer to object instances. Also,
Objective-C's use of a Smalltalk-like syntax for making method calls has been replaced
with a dot-notation style and namespace system more familiar to programmers from
other common object-oriented (OO) languages like Java or C#. Swift introduces true
named parameters and retains key Objective-C concepts, including protocols, closures
and categories, often replacing former syntax with cleaner versions and allowing these
concepts to be applied to other language structures, like enumerated types enums.
Unlike Windows, developer knows for which machine the application is being developed
and swift is designed for specifically run on apple mac and developer is specific about
hardware for which he is developing.
Access Control
Swift supports five access control levels for symbols: open, public, internal,
fileprivate, and private. Unlike many object-oriented languages, these access
controls ignore inheritance hierarchies: private indicates that a symbol is
accessible only in the immediate scope, fileprivate indicates it is accessible only
from within the file, internal indicates it is accessible within the containing
module, public indicates it is accessible from any module, and open (only for
classes and their methods) indicates that the class may be subclassed outside of
the module.
AppleScript:
AppleScript is a scripting language created by Apple Inc. that facilitates automated control
over scriptable Mac applications. First introduced in System 7, it is currently included in all
versions of macOS as part of a package of system automation tools. The term "AppleScript"
may refer to the language itself, to an individual script written in the language, or,
informally, to the macOS Open Scripting Architecture that underlies the language.
AppleScript was designed to be used as an accessible end-user scripting language, offering users an
intelligent mechanism to control applications, and to access and modify data and documents. AppleScript
uses Apple events, a set of standardized data formats that the Macintosh operating system uses to send
information to applications, roughly analogous to sending XPath queries over XML-RPC in the world
of web services. Apple events allow a script to work with multiple applications simultaneously, passing
data between them so that complex tasks can be accomplished without human interaction. For example,
an AppleScript to create a simple web gallery might do the following:
Algorithms:
Two major algorithms are used
Round Robin (RR):
The name of the algorithm comes from the round-robin principle known from
other fields, where each person takes an equal share of something in turn. Round-
robin (RR) is one of the algorithms employed by process and network
schedulers in computing. As the term is generally used, time slices (also known as time
quanta) are assigned to each process in equal portions and in circular order, handling all
processes without priority (also known as cyclic executive). Round-robin scheduling is
simple, easy to implement, and starvation-free. Round-robin scheduling can be applied to
other scheduling problems, such as data packet scheduling in computer networks. To
schedule processes fairly, a round-robin scheduler generally employs time-sharing, giving
each job a time slot or quantum (its allowance of CPU time), and interrupting the job if it is
not completed by then. The job is resumed next time a time slot is assigned to that process.
If the process terminates or changes its state to waiting during its attributed time quantum,
the scheduler selects the first process in the ready queue to execute. In the absence of time-
sharing, or if the quanta were large relative to the sizes of the jobs, a process that produced
large jobs would be favoured over other processes.
Round-robin algorithm is a pre-emptive algorithm as the scheduler forces the process out of the
CPU once the time quota expires.
For example, if the time slot is 100 milliseconds, and job1 takes a total time of 250 ms to complete,
the round-robin scheduler will suspend the job after 100 ms and give other jobs their time on the
CPU. Once the other jobs have had their equal share (100 ms each), job1 will get another allocation
of CPU time and the cycle will repeat. This process continues until the job finishes and needs no
more time on the CPU.
To optimize turnaround time algorithms like SJF is needed which require the running
time of processes to schedule them. But the running time of the process is not known in
advance. MFQS runs a process for a time quantum and then it can change its priority (if
it is a long process). Thus it learns from past behavior of the process and then predicts
its future behavior. This way it tries to run shorter process first thus optimizing
turnaround time.