
Why I want Swift to be your first language - ra88it
http://www.aaronblock.com/thoughts/2015/8/21/why-i-want-swift-to-be-your-first-language
======
r3bl
Why I don't want Swift to be your first language (from a student's point of
view):

1\. Where am I going to test my applications? Not all students have Apple's
products (I never had any of them). On the other hand, if I use Python, or
Java, or C/C++, I can test my application wherever I want.

2\. As far as I know, Swift will be open source (at least, that's what Apple
said). But Swift is not open source _at the moment_ (please correct me if I'm
wrong).

3\. Swift is a new language. If I type "Swift tutorial" on Google, and I type
"Python tutorial" on Google in a second tab, I'll get much more relevant
results for much more platforms when I type "Python tutorial".

I don't care how good the syntax is. If a programming language is not
currently available on like every platform and if I can't build my application
using whatever I want to use (including a text editor and a compiler), it's
not a good choice for students no matter what you say.

~~~
ra88it
At the end of the article, the author gives several reasons why he won't be
teaching Swift to students yet. He includes each of your points. (With the
assumption that eventually they will be moot.)

~~~
r3bl
Nope.

He lists that there's no Windows IDE, which is far from being able to run the
program everywhere and using whatever I want to use to build it (as I have
said it). I also think that .NET languages (like Visual Basic .NET and C#
.NET) are not a good starting language, even though one of them was my
starting language thanks to my high school and my college (both taught me
Visual Basic .NET for one year). Plus, he states that Swift is open source at
the moment, which, as far as I know, is not true. He didn't mention any of
those three points I made.

EDIT: Replaces .NET with .NET languages.

~~~
Apocryphon
Once it's open source, isn't it logical to conclude that there will be open
source runtimes that run on non-Apple products? Give it a year or so.

~~~
gorena
Not even a year, about a month. Swift for Linux will arrive with the release
of Swift 2.0, which will coincide with the release of Xcode 7, which will
coincide with the release of iOS 9 ... which will coincide with the
announcement of the next iPhone, which should be around late September, as
usual.

~~~
Apocryphon
Hm, do you think it'll only take a month for it to be ported to Windows?

~~~
gorena
I'm not an LLVM expert, but Swift is an LLVM frontend, so once it's open
source, I think it should work for the various backends?

Right now the issue is library support - swiftc can already just spit out LLVM
IR:
[https://github.com/kripken/emscripten/issues/2427](https://github.com/kripken/emscripten/issues/2427)

The stdlib would be included in the open source release.

Linux boxes would fulfill "non-Apple product" though. Unixy programming
languages like Swift and Python have always been weird on Windows.

~~~
dman
Could you elaborate on Python being weird on Windows?

~~~
AstralStorm
Python is a set of packages. On Windows, you're supposed to use a
distribution, such as Anaconda.

Even then, building some of the fancier libraries (with native code) by hand
is bit involved.

In fact, Anaconda works very well on Windows, as long as you don't require
extreme latest versions of modules.

------
ThrustVectoring
The article is missing what I think is the zeroth skill to teach beginning
programmers - a love of hacking on things and getting results.

It's why I think Javascript is the best language to teach beginners. Yes, it's
an ugly language. Yes, it has significant structural problems. Yes, it will
bite you in hilariously difficult to find ways. But that doesn't particularly
matter compared to teaching them that they can futz around with code and get
interesting stuff done.

~~~
mcphage
Processing is also pretty good, for a similar reason.

------
vvanders
Lost me when he mentioned that ARC is better to teach than GC.

I'm the least fan of GC as anyone else but needing to have intro students
worry about cycles seems like the last thing you want to teach first.

~~~
Someone
I don't see him state that. His argument seems to boil down to:

    
    
      1) I want to use a single teaching language.
      2) We need to teach them about memory management.
      3) C style manual memory management is too hard for beginners.
    

If you accept #1 and #2, you can't start with a language with the full 'magic'
of garbage collection, as it would have to be the only language, and you
cannot teach #2 with it.

If, in addition, you accept #3, ARC makes sense to me. You can have your
pupils implement quite a bit of advanced data structures such as trees and
tries before you hit your first cycle, but there are 'real' data structures
that use them, so you won't have to make up some artificial example to find
one. Until that time, you can let your pupils think that the machine reuses
memory as soon as it is no longer referenced.

I think his arguments make some sense, but I am not sure I'm fully behind #1.

------
afandian
The static-void-main-string-args argument is trotted out so often and to me is
the most facetious. Every language has some syntax to learn and with any
learning process it will need to be handwaved away. Basing any kind of
decision on such a trivial thing seems odd to me.

~~~
incepted
Trying to discourage the use of a language because of `public static void
main` is as absurd as trying to sell a language because it lets you write
`println("hello world")`.

Don't believe anybody who uses either of these tactics.

~~~
spinningarrow
Discouraging the use of a language, and discouraging the choice of a certain
language as the first language non-programmers are exposed to are two very
different things.

------
markhahn
The article was a reasonably persuasive argument for why Python should be your
first language. Maybe someone should write "Why I want Swift to be relevant to
non-Appleheads".

~~~
oddevan
Except for the part where he specifically mentioned Swift's ARC as something
to expose Intro students to vs. Python's garbage collection?

~~~
zxcvcxz
Isn't ARC almost exclusive to "Apple languages"? It seems like GC is much more
relevant.

~~~
AlexeyBrin
Not necessarily, C++11 has smart pointers which have reference counting.

------
pmelendez
With the exception of "Named parameters, a life sentence." every argument work
for a Lisp based language as Racket for instance.

~~~
edgyswingset
I'd also argue that a super simple language like Scheme (or stripped-down
Racket) would be pretty close to ideal for a pure intro class.

Introductions should be about learning how to reason about abstractions, and
how to transform problem-solving from what's going on in your head into code.
When you start out with something so rigid like C or Java you really confine a
student's ability to reason about a problem because there's so much syntax to
keep track of.

~~~
coldcode
A Lisp-like language will only help you if you stay in the lisp world. A
C-like will help you with most of the world's current languages in the Tiobe
list.

~~~
pmelendez
That's so not true in my opinion. There is a whole generation that was raised
with Scheme as first language (and SICP ), I am particularly grateful that I
was part of that and today I program (or had programmed) in most of the top
languages in the Tiobe list as you say.

------
kwhitefoot
It doesn't look like a particularly radical change from any other so called
modern curly bracket language to me. It also doesn't seem to have any native
multitasking/multiprogramming features, at least none were mentioned on the
Swift2 summary page. Anyway, what sort of students are we talking about here?
If they are physics or engineering students then they will have to learn
whichever language that the tools they use needs, if they are CS students then
surely the language itself is one of the objects to be studied in which case
there ought to be more than one.

~~~
gress
It doesn't need multitasking/multi programming as a language feature because
these are provided by GCD as a library.

------
wvenable
Swift is inherently tied to the OS X / iOS APIs (just as Objective-C is). It's
a one platform language and will never be (and never intended to be) a general
purpose language for all platforms.

~~~
jayvanguard
Neither are "inherently tied" to OSX or iOS. They may be practically tied due
to who drives them and their competitors lack of incentive to ever invest in
them, but from a pure language point of view they are agnostic.

~~~
wvenable
Almost the entire OSX API is built on the Objective-C object dispatch model.
Swift and Objective-C are built for this model specifically.

It doesn't make sense to run Swift (or Objective-C) without the underlying
platform API. You can do it (and Apple does; iTunes for Windows is built with
such a shim) but it's not practical.

The only reason Swift even exists is that no other language (other than
Objective-C) fit with the object model of the OSX API. So they had to make
their own. As much as other languages don't interface well with OSX is as much
as Swift doesn't interface well with every other platform.

~~~
jayvanguard
You're wrong on all accounts. The Objective-C dispatch model is based on
Smalltalk.

Most OSX apps and services still aren't even written in Objective-C and many
(most actually) platform APIs are still in C.

You can compile Objective-C using the gnu compiler and have been able to for
ages.

Swift is an amalgam of many different programming languages and styles,
including Rust. None of which have anything specific to do with OSX/iOS about
them.

~~~
wvenable
> The Objective-C dispatch model is based on Smalltalk.

I meant the low-level dispatch of methods; the application binary interface
that Objective-C uses to communicate with the APIs that make up almost the
entire OS X GUI API. You can't mix that with the ABI for Windows API or any
Linux toolkit (except GNUStep).

> Most OSX apps and services still aren't even written in Objective-C

Most OS-X apps aren't written in Objective-C? Really? Come on. If it was
written specifically for OS X or iOS then it's almost guaranteed to be in
Objective-C.

> You can compile Objective-C using the gnu compiler and have been able to for
> ages.

Nobody says you can't. But the only real useful thing you can with that is
link to GNUStep.

> Swift is an amalgam of many different programming languages and styles,
> including Rust. None of which have anything specific to do with OSX/iOS
> about them.

At the high-level you are right but on the low-level it's specifically
designed to interface with Objective-C APIs which exist in OSes from only one
manufacturer. You can't separate Swift from that. The fact that it's an
amalgam of OS X specific technology makes it unsuitable for other OSes. It
doesn't really have that much in common with Rust either.

------
PeterisP
At this point of time, being cross-platform (at least the 3 of win,mac,linux)
is a basic 'hygiene factor' for programming languages. I mean, even
experimental niche tools and hobbyist systems are expected to do that and
almost all of them do.

I have access to all kinds of systems, but this is not a consumer item, and it
_should_ work everywhere; a mac-only requirement is just as unacceptably
limiting for general purpose computing as a windows-only requiremet.

------
mwcampbell
Swift isn't actually open-source yet, is it?

Once it is, I think the reasons explained in this article for using Swift as
an introductory language make sense.

~~~
wlesieutre
Maybe after they open source Swift they'll have some free time to work on
Steve Jobs' announcement that FaceTime would be an open video calling
standard.

Swift is not open source. It might be in the future, and if they do follow
through, the release is slated for "later this year." I hope they do, but I
also can't blame anyone who decides to wait and see.

~~~
gress
FaceTime was prevented from being open sourced by a patent troll. Continuing
to repeat misinformation about this in threads like this is not a reflection
on Apple, and is clearly irrelevant to whether Swift will be open sourced.

Pay attention to Chris Lattner and his track record if you want a realistic
view of whether the open source promise is likely to be kept for Swift.

~~~
mikehc
And whose fault is that? I think is both sides. The patent troll for obvious
reasons but also Apple (or Steve Jobs) for announcing something that they
cannot achieve.

That is why people have a hard time believing any Open Source promises made by
Apple. And yes I know they have some open source projects available right now.

~~~
gress
By your logic, anyone who ever runs into trouble with a patent troll should
never be trusted again. Clearly this is absurd.

~~~
mikehc
No, anyone who promises things he cannot fulfill may have his trust in doubt.
It doesn't matter if the problem was internal or external.

What would you think if Apple went to announce next Wednesday that the new
iPhone will have a sapphire screen, but on launch (after a bunch of people
preoder the phone) they announce it's normal glass because a provider couldn't
deliver.

Whose fault would that be, the provider's? Apple's? Both?

------
guelo
The semicolon thing had me scratching my head. Are people teaching Java
without an IDE that shows syntax errors very visibly?

~~~
fernandotakai
hell, i work with python using vim and i can see syntax errors on it. it's
really a basic feature when you are writing code.

also, swift has syntax that can bite new developers just like any other
language.

