Feeds

back to article Apple: We'll tailor Swift to be a fast new programming language

Apple stunned the audience at its Worldwide Developers Conference in San Francisco on Monday with a tool few expected: a new programming language for iOS and OS X software called Swift. There already is a programming language called Swift that was developed by the University of Chicago and Argonne National Laboratory for use in …

COMMENTS

This topic is closed for new posts.

Page:

Silver badge

What do you do when your commercial skills become obsolete?

Read quickly, obviously.

Honestly, the new language looks pretty good from the thirty-or-so pages I've read so far but I've yet to get to anything particularly complicated. E.g. if it uses the same runtime as Objective-C — reference counting (automatic or otherwise) rather than garbage collecting — then is it still a programmer's responsibility to avoid retain cycles? That's the main area where I felt the existing runtime (rather than the language) was looking kind of historic.

4
0
Silver badge

Re: What do you do when your commercial skills become obsolete?

You either have the possibility of the in-attentive generating retain cycles or the inexactitude of garbage collection, there is no middle ground that doesn't make decisions you should be aware of and making yourself. Given the choice between the two, ARC, for the serious programmer is, IMHO, the infinitely superior option because you have full and complete control. Plus the memory analysis tools are superb so you can easily identify any accidental retain cycles. The only problem with ARC is that the use case for understanding reference counting is rarely encountered, but when it is, reference counting techniques need to be fully understood. That's OK for me and from the sounds of it, you also, because we were raised with it. But for programmers who have never had to learn the art I feel truly sorry. 99% of the time, they will never need the understanding, but when they do, boy will life be difficult for them.

7
0
Anonymous Coward

Swift looks...

...very much like a strongly typed Python.

9
0
Bronze badge
Meh

Re: Swift looks...

That's interesting, because I very much got the feel of basic Probably because of how variables and constants are declared. It would be a very easy language to port it over to a real computer platform like Windows.

8
23
Bronze badge

Re: Swift looks...

"It would be a very easy language to port it over to a real computer platform like Windows."

And risk getting hounded by Apple lawyers? No thanks. I will stick to languages that are not proprietary and owned by litigious corporations. There are still plenty of good choices.

26
3
Silver badge

Re: Swift looks...

If memory serves... objective-C is part of the gcc so that the core of Objective-C is open source. What is closed source is the libraries.

So if you start with the gcc compiler (Apple/NeXT had to open source those bits under GPL) , use the same open APIs, and write your own libraries from scratch, you can do the same thing.

IANAL so don't take this as legal advice, just that you could do it if you wanted to do it. It doesn't mean Apple won't attempt to sue you anyway...

3
3

Re: Swift looks...

Apple not liking the GPL is why they switched from gcc to rolling their own C++ and Objective C compiler with clang. Swift is not a gcc front end, it's an llvm front end, so they're under no obligation to release the source to any of it.

You could, of course, write your own compiler from scratch that follows the same language spec (I find it doubtful that you can copyright a programming language's syntax) but that's a lot of effort for not much gain, especially since you'd also need to duplicate Cocoa in order to actually port any Swift programs from the Mac (and as Oracle has proved, you can at least make expensive court cases out of that).

6
0
Bronze badge
Windows

Re: Swift looks...

Yes ... front end for Objective-C is included in gcc suite, but it receives very little attention or maintenance and is no longer fully compatible with "reference" implementation which is in LVMM/CLANG.

If one company "owns" a language they usually need only one compiler and will rarely spend the money to help maintain alternative platform(s). Look at Apple, Oracle (Sun before) etc. Microsoft involvement with Xamarin is exception to the rule. Still, if I only knew .NET, the icon above demonstrates what I would look like today (not that I look much better, but at least the clothes are clean most of the time).

2
0
Bronze badge

If one company "owns" a language..

.. it is a very good reason not to use it.

They will, at some point, abandon it or do something else that breaks old code.

Still, it's not as if there isn't a history of some people accepting the mantraps in an Apple walled garden.

12
3
Silver badge

I find it doubtful that you can copyright a programming language's syntax

That's not what Oracle say about Java,

Apple could sell Swift to some evil supervillian years down the road who could claim that they own your independent implementation

2
1

Re: I find it doubtful that you can copyright a programming language's syntax

You're exactly proving my point. Oracle aren't sueing on the grounds that Google copied Java (the language itself), they're claiming Google copied the APIs of Java's standard library (which is why I referenced Oracle when discussing Cocoa).

(And why posit a supervillain? Apple are plenty litigious themselves, at least as much so as Oracle)

4
0
Silver badge

@Joe Re: Swift looks...

And this is why I said ... If memory serves... :-)

Sorry, but I'm dating myself when I look at Objective-C it was from my NeXTStep days. Way back in the early 90's.

To the points raised... when a single company owns, controls and is the only adopter of a language... never bodes well in the long run. Even if its Microsoft or Apple.

3
1
Silver badge

Re: If one company "owns" a language..

> .. it is a very good reason not to use it.

Word, bro! And that word is Dylan. Also developed by apple, then dropped, burning a lot of devs in the process.

BTW dylan was pretty nice dialect of lisp.

4
0

Cross-Platform Looks About as Easy as it Ever Gets

It's definitely not worth MY time to write a Swift compiler, but LLVM is distributed under a very permissive license, and as others note, copyrighting a language seems just a tad unlikely.

Seems that any firm with interest in having Swift on its platform (or, any firm wanting to add a Swift compiler to its existing stock of tools) should have relatively little difficulty. For instance, Google already uses the LLVM framework for much of its work; if they deemed the language to offer actual performance advantages over other languages, or if they wanted to facilitate cross-platform products, why wouldn't they?

Seems interest is the key issue. NIH is strong in this world.

0
0

Re: I find it doubtful that you can copyright a programming language's syntax

Oracle's case against Google was always based on the organization and implementation of the libraries, not the java language itself.

Might be a fine point for a programmer who doesn't care about what is in “the language” and what is in the libraries that make the language useful, but it's key for any organization big enough to actually consider implementing it.

1
0

Re: If one company "owns" a language..

Oh, now you've done it. You're going to get the Delphi users hounding you about why you should indeed use a corporate-controlled language (and pay $1500+ to do it). If you're in luck they'll also tell you that automatic memory management is for stupid people, type inference is "impossible" and that modern language constructs are "fads" added to "look cool" (all things I've been told on their forum).

1
0
JDX
Gold badge

Just what the world needs

Yet another new language. Apple are on thin ice using Objective-C already in my eyes, even MS don't force you to use their own MS-only language (.NET is only one option of many).

Google did Go - which hasn't. MS have gained traction with C# but that's really the stand-out counter-example in terms of a new "next best thing" language that has been adopted into the mainstream.

21
17
Byz

Re: Just what the world needs

I train Objective-C it is currently one of the most used languages due to the app store.

I've had a look at swift and it is similar to Scalar, so it will be straightforward for coders to convert.

It seems to remove all the brackets :)

9
4
Silver badge

Re: Just what the world needs

In what sense does Apple 'force' you to use Objective-C? You can use as much C or C++ code as you like without having to hop any sort of barriers — the three can natively call each other directly, in the same source files. No managed/unmanaged border, no wrapper libraries, straight calls.

Of the two on-the-box options offered by OS X 10.0 and 10.1 — Objective-C and Java — developers picked the former. Not Apple.

As to whether the world needs a new language? It doesn't. But Apple needed one and decided they had to engineer it themselves because (i) they wanted it exactly to fit the existing runtime; and (ii) Apple usually thinks that way anyway.

23
3
Bronze badge

Re: Just what the world needs

.NET is not a language, it is a runtime. There is a pretty low level language MSIL that many excellent c# programmers haven't even heard of which is what your c# or VB.net or whatever compiles into which is if you like the native tongue of the framework which JIT compiles to assembler (usually x86/x64).

But the point is that I can write some fancy component suite in c#** and you could buy it and use it within a VB.net codebase (or j sharp or whatever floats your boat)

** I probably couldn't

10
0
JLV
Bronze badge
Thumb Up

>It seems to remove all the brackets :)

Getting rid of brackets would be great. Last time I tried putting together an iPhone app, Objective Cs syntax made my head swim.

I liked the Objective C <=> IOS API and integration model, very elegant. And I didn't mind Objective C for its C ancestry - coming from Python I actually find plain old C rather elegant, simple and expressive, though I don't use it much.

But I am also slightly dyslexic and just can't wrap my head easily around languages that use brackets and parentheses in exotic ways. Reading and coding Objective C wasn't quite as bad as Lisp, but the bracket syntax just kept on getting in the way so I bailed on my personal project. Yes, could have used C, but almost everything is documented in ObjC and the iOS ObjC actually does a pretty job of looking after a lot of low-level C-ish stuff.

If it seems Swift is here to stay and good enough for purpose, may have another look at iOS/Mac apps. Plus, marrying Python type simplicity with C type speed? Marriage made in heaven.

As far as the world needing another language... look at ObjC's usage level. Huge, and that language was probably pretty minor before the app store made it popular. Swift, if well done, could easily get itself a pretty big mindshare.

I think there is a huge opportunity to develop pedal-to-the-metal compiled languages that take on some the elegant simplicity we have seen in scripting languages and their built-in shortcuts. I.e. something that layers Python/Ruby ideas on C, but eschews C++ 's complexity and Java's obsequiousness. I had been thinking of looking at D at some point, just to step out of my usual scripting language focus, but this may be a good alternative too.

Apologies in advance to all folks who hate Apple on principle. Should be toeing your line, my bad.

11
2

Um, Apple don't force anyone to use Objective-C

You can also use Oxygene (Object Pascal) or Hydrogene (C#) for Cocoa and/or CocoaTouch development. (or .NET or Java / Android for that matter).

www.remobjects.com/elements

4
0
E 2

complexity and obsequiousness

Vs. toadying.

WTH is wrong with brackets?

At least they save me from diverse tab settings.

6
0
Bronze badge
Meh

Re: >It seems to remove all the brackets :)

Frankly, the only reason I see for learning Swift would be if it was a cross-platform tool. As an iPhone-only thing, you would just keep using a C variant.

In it's day, BASIC was the tool of choice. Not because it was powerful, but because it was 1) easy to learn; and 2) it was ubiquitous - it would run on anything with only a little modification.

7
2
Silver badge

Re: Just what the world needs

Go is finding fans all over the place, though mainly in systems, because of its concurrency support. C# is, er, a rehash of Java for the MS runtime.

6
6
Silver badge

Re: complexity and obsequiousness

WTH is wrong with brackets?

The standard answer is that the brackets are there for the compiler not the programmer. People tend to prefer other methods for structuring blocks, but if you like them then good luck to you.

3
1

Re: complexity and obsequiousness

"The standard answer is that the brackets are there for the compiler not the programmer."

Block structuring based on typographical conventions may be convenient for a subset of programmers, but it is even more arbitrary than brackets and braces. In effect, the syntax of space indented languages implies an underlying grid on the page - a hangover from teletypes - whereas bracket syntax continues to work without any kind of underlying grid. It's much more mathematically (and syntactically) satisfying for that reason.

22
0
JDX
Gold badge

Re: Just what the world needs

>>Go is finding fans all over the place, though mainly in systems, because of its concurrency support.

A few users is not a success. Where is Go in real-world use, something like 0.01% of developers? I bet there are more active Haskell developers

>>C# is, er, a rehash of Java for the MS runtime.

Yes, done very well. Who cares if it's a brand new paradigm as long as it works - which it does. It's very unashamedly "a better Java".

10
3
JDX
Gold badge

Re: Just what the world needs

"In what sense does Apple 'force' you to use Objective-C? You can use as much C or C++ code as you like without having to hop any sort of barriers"

How do I call system APIs using native C++? I genuinely thought I couldn't - you end up with C++/OBJ-C files which are normal C++ with lines like:

UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;

How do I do that in pure C++, i.e. set the .cpp file as C++ rather than C++/OBJ-C in XCode? Maybe it's just because all the sample code I saw uses OBJ-C.

4
1
Silver badge

Re: Just what the world needs

Yes C# is one of the few developments to come out of Microsoft having a high degree of intellectual purity and rigour. It was designed by one of the best in the business and is IMO a very, very good language. And I'm saying that as someone who detests most things Microsoft.

14
1
Silver badge

Re: Just what the world needs

And C# is really MS concept of Java, derived from J++

It's not that bad and does have Mono to run it outside .Net

1
4
Anonymous Coward

Re: complexity and obsequiousness

The standard answer is that the brackets are there for the compiler not the programmer. People tend to prefer other methods for structuring blocks, but if you like them then good luck to you.

+1

As someone from the Pascal and then VB camp (and SQL), I still prefer Begins and Ends over harder to see spidery litte { } things. Personal preference I know, but it's easier to see with my eyes.

It's pretty sad in this day and age that languages aren't versatile enough to accept either, with the IDE showing you the ones you prefer. Hardly rocket science, dare I suggest.

4
3
Silver badge

Re: Just what the world needs

A few users is not a success. Where is Go in real-world use, something like 0.01% of developers? I bet there are more active Haskell developers

No idea and no idea how anyone can reliably collect such statistics: what about all the shell and embedded stuff that never appears online?

There probably are more people involved with Haskell than Go, though probably has a lot to do with the fact that it's taught at quite a lot of universities. The most recent Go conference managed to garner some 700 participants and I assume some of the sponsors are using it; we know Google and Canonical are.

0
0
Silver badge

Re: complexity and obsequiousness

It's much more mathematically (and syntactically) satisfying for that reason.

I suspect it depends very much on what you're programming: whether you're essentially programming mathematical functions or doing something else. Which is why we use brackets sparingly when writing. And even then it remains a personal preference.

Indentation is not more arbitrary for structure as it has to be consistent in order to be machine readable.

2
0

Re: complexity and obsequiousness

As someone from the Pascal and then VB camp (and SQL), I still prefer Begins and Ends over harder to see spidery litte { } things. Personal preference I know, but it's easier to see with my eyes.

-------------------------

#define begin {

#define end }

7
3

Re: complexity and obsequiousness

"In effect, the syntax of space indented languages implies an underlying grid on the page - a hangover from teletypes"

Nope. More like a hangover from school where some teachers got you to structure your written notes leaving lines and space, so that logical flow was obvious and so that comments and marking didn't mess things up.

" - whereas bracket syntax continues to work without any kind of underlying grid."

Except that which is applied (differently) by every developer. More in a minute.

"It's much more mathematically (and syntactically) satisfying for that reason.It's much more mathematically (and syntactically) satisfying for that reason."

Perhaps you've never had to maintain or debug code written by 4 different people over the course of a decade and reindent several hundred lines of code because someone, somewhere, changed the logical flow due to a misplaced bracket or inconsistent bracketing style. Personally, I enjoy being able to read, reuse and maintain code I (and others) wrote years ago.

8
1
JDX
Gold badge

Re: complexity and obsequiousness

"Perhaps you've never had to maintain or debug code written by 4 different people over the course of a decade and reindent several hundred lines of code because someone, somewhere, changed the logical flow due to a misplaced bracket or inconsistent bracketing style. Personally, I enjoy being able to read, reuse and maintain code I (and others) wrote years ago."

If only there were incredibly easy ways to automatically impose a standard formatting... or if only it were possible for a lead developer to require people follow a convention.

Messy code serves a purpose, it tells you that the project has probably not been run well and you should be wary.

7
2
Silver badge

Re: >It seems to remove all the brackets :)

Get rid of brackets? Why - it seems like a good thing to do for the lazy but have you ever tried, say, to do a web server page in python? Piece of piss in PHP but Python - any more than a couple of indentations and the meaning is lost. OK you can put in brackets but there's a false fear of them from fairy tales told by bad programmers and most python programmers seem to hide under the sheets when they are around.

2
4
Coffee/keyboard

Re: complexity and obsequiousness

Block structure based on typographical convention has the interesting effect of encouraging you to use the main roads more because of these minor speed bumps, rather than trying to construct very long journeys using seemingly more familiar and understandable but minor and tangled roads and lanes.

For projects requiring more than a couple of hundred lines of code, you should generally be focussed on the source files, packages, modules, classes and objects concepts relating to the problem and solution, not on how you get to do function, loop and branch control done in order to patch together something that just about works but is neither scalable nor maintainable.

3
0
Bronze badge
Angel

Compound statements considered harmfull.

Who cares how a compound statement is formulated, when the problem is that it exists? Compound statements are actually the root all evil in programming, after the banishment of goto.

In Oberon it was done properly: statement lists. No BEGIN or {, except at the star of a procedure. A couple of keywords terminated a statement list, and END was one of them, next to ELSE and possibly UNTIL (forgot whether Oberon has a REPEAT UNTIL).

0
0
Silver badge

Re: Just what the world needs

MS have gained traction with C# but that's really the stand-out counter-example in terms of a new "next best thing" language that has been adopted into the mainstream.

And let's be honest, while C# is a good language, that's also partly down to what came before it being so hideous.

0
1

Re: complexity and obsequiousness

"reindent several hundred lines of code "

This is what we have IDEs for. You set up your formatting conventions, you open the source code, you click on a menu item...everything is now laid out how you like it and you can check the control flow. But if the control flow is hard to follow, chances are some refactoring is needed. Which the IDE makes rather easy, especially if there is a set of coding standards that can be applied. I've cleaned up after enough departed programmers to speak from extensive experience.

Yes I have encountered programmers who regard line numbers as sacred, so don't allow any reformatting. And also programmers who insist on applying every single suggestion Netbeans offers, thus refactoring code without first checking with their superiors that this is OK. But let's face it, anybody who is using line numbers to maintain control of OO code is probably writing the wrong language, and the reckless editor needs to be taken aside and have the basis on which he gets paid (it's going to be a he) explained to him.

1
0
Anonymous Coward

Re: complexity and obsequiousness

... but the code is then impossible to parse as a pattern and requires mental gymnastics to visualise. Indenting has an important place, and it has nothing to do with the TT

2
0

Re: complexity and obsequiousness

Indenting is good for human readability - completely grant you that.

Visible character based block delimiters ensure that the UI element is separated from the syntactical element, but IDEs can then display code using whatever UI structure you prefer. The entire line and indent structure can be removed to represent an entire class as a single line of text, and can then be reconstructed visually at load time by the IDE. Isn't that good?

0
1
Silver badge

Python done right

We had a discussion over this language yesterday and the concensus is that it fixes both the things that are broken in python:

1) Typing.

2) Adding braces. Indenting can be screwed up badly. Braces fix that.

2
0
Silver badge

Re: Just what the world needs (@JDX)

From native C or C++? With the incredibly arbitrary restriction that the feature Apple specifically supplies for this — the ability to make Objective-C calls arbitrarily at any place within C++ code — isn't to be used?

You'd use the C-level entry points to the Objective-C runtime: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html

You're working up to an objc_msgSend, probably, but you can also use class_getMethodImplementation to get the C function pointer for any method on any class. Then you just need to remember to specify the instance of the class as the first parameter, the selector for the method as the second and the other arguments in sequence after that (it's a va_list).

For getting selectors, metaclasses and suchlike you'd use NSClassFromString, NSSelectorFromString and the gang. They take NSStrings as arguments but NSString is toll-free bridged — i.e. the two look the same in memory so just cast the pointer — with CFString, which is a pure-C API. So just use CFString.

0
0
Silver badge

Re: Just what the world needs

"I train Objective-C it is currently one of the most used languages due to the app store."

Perhaps it your world that means its the most used, but back in the real world the apple app store is a piss in a pond compared to all the other programs being written and running in the world that weren't written in Obj-C. Stuff you never get to hear about unless you apply for a job such as internal bank systems, or actuator control units or airport baggage handlers etc etc.

2
0
Silver badge

Re: complexity and obsequiousness

"Perhaps you've never had to maintain or debug code written by 4 different people over the course of a decade and reindent several hundred lines of code because someone, somewhere, changed the logical flow due to a misplaced bracket or inconsistent bracketing style"

Perhaps you've never had to maintain or debug code that was working perfectly but now isn't because someone accidentally deleted a tab on the last line of a block which brought the line into the outer scope. Still perfectly syntatically correct , the code just doesn't work properly and there's no obvious reason why. Try deleting a single bracket in C++ and try compiling and see what happens.

Whitespace defined blocks are an abortion and no sane language designer would ever use them.

8
0

Re: complexity and obsequiousness

"but now isn't because someone accidentally deleted a tab on the last line of a block which brought the line into the outer scope. Still perfectly syntatically correct , the code just doesn't work properly and there's no obvious reason why. Try deleting a single bracket in C++ and try compiling and see what happens."

My experience of multi-dev Python projects is limited, but that's probably why the Python style guide tells you to use spaces not tabs. Cool, didn't get that before- thanks.

0
0

Re: complexity and obsequiousness

This doesn't follow for me at all. It's not about "typographical conventions"; it's about indentation levels. It's about the human eye. Even with brackets or begin...end pairs it's expected to indent properly anyway. Sadly, that's once for the compiler, once for the human. Syntactically significant whitespace lets you employ one means for both. Try reading a block of code with all of the spacing removed. As someone once put it, if you have a "lawyer's eye" you'll eventually be able to parse out what's going on. Now take the same code and leave the spacing but remove the block delimiters (braces or begin...end). Its meaning will still be crystal clear to you. Hence, it's absurd to argue that bracket syntax is in any way more satisfying.

1
0

Page:

This topic is closed for new posts.