Apples new 'Swift' language

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

stevenaaus
Posts: 608
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Apples new 'Swift' language

Post by stevenaaus »

Apple have announced a new programming language, Swift, and it's, ready to roll inside a new XCode beta.
Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C
.
Sounds exciting to me :) https://developer.apple.com/swift/

My layman's thoughts - Objective-C always looked good to me, but ... uglier than pure C or C++, and i never had reason to use it. Apple are talking up Swift like it's the bees knees (of course). I guess it will succeed in the iOS ecosystem, but wonder if it will ever make ground in OS X or get ported outside of XCode ?
User avatar
Bloodbane
Posts: 154
Joined: Thu Oct 03, 2013 4:17 pm

Re: Apples new 'Swift' language

Post by Bloodbane »

Has no language integrated parallelization, is slow and works only on iOS and OS X with little prospects of ever working on linux or windows. I'll pass.

Now D on the other hand gets me excited, but it's not new or hip or backed by any big companies so few people care.
Functional programming combines the flexibility and power of abstract mathematics with the intuitive clarity of abstract mathematics.
https://github.com/mAarnos
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Apples new 'Swift' language

Post by zullil »

Bloodbane wrote:Has no language integrated parallelization, is slow and works only on iOS and OS X with little prospects of ever working on linux or windows. I'll pass.

Now D on the other hand gets me excited, but it's not new or hip or backed by any big companies so few people care.
Know nothing yet about Swift, but Go ( http://golang.org/ ) is interesting to me. It too is backed by one of those big companies.
User avatar
SMIRF
Posts: 91
Joined: Wed Mar 26, 2014 4:29 pm
Location: Buettelborn/Hessen/Germany

Re: Apples new 'Swift' language

Post by SMIRF »

After having started to read the related Swift book for its first 250 pages, I am wondering about the motivation whether to make a switch to it. Of course it seems to be clearer and more homogen than Objective-C. But inside Swift it seems no longer possible to combine C or C++ parts within the same source. That would be not a problem, if the Objective-C typical internal message flow in Swift would apply to properties only in well defined circumstances. But I have not yet come as far as to be able to judge that.

There are statements on Swift to be a lot faster executed than Objective-C. I don't know, whether this is propaganda or fact. It would be very appreciated to learn more detailedly on that. Without knowing such details I would not intend to write performant chess routines using Swift. Who does know relevant facts on that? For chess programming I am still preferring C / C++.
kinderchocolate
Posts: 454
Joined: Mon Nov 01, 2010 6:55 am
Full name: Ted Wong

Re: Apples new 'Swift' language

Post by kinderchocolate »

Swift will definitely succeed because it is a better solution than Objective C which in turn is a much better solution than C and C++. Objective C is a good language for writing a high-level user interface, because it encapsulate the intention into the method signature and also it doesn't require a nil check. Unfortunately, the language itself is ancient, for example:

1. No template
2. No static variable
3. No lambda and the blocks is very limited

Apple has given up on Objective C and prefer the newer Swift. Swift allows dynamic scripting without compiling. This is a very significant advantage as running either on a simulator or a device is very slow. The code is concise and better. Objective C will eventually die.

Writing a chess engine with Swift is no different to writing it with Python.
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Apples new 'Swift' language

Post by Tord Romstad »

stevenaaus wrote:I guess it will succeed in the iOS ecosystem, but wonder if it will ever make ground in OS X or get ported outside of XCode ?
It will: At the very least, JetBrains have already promised to add Swift support in AppCode.

I don't understand the comparisions to Go, D and Python in this thread, because it is difficult to think of any use-case where any of those could replace Swift (or vice versa). Swift is an alternative to Objective-C for writing native OS X or iOS apps. Go and D, as far as I know, can't be used for this at all, and although it is in principle possible to write OS X apps in Python by using PyObjC, it seems quite awkward and has never been widely used.

My initial impression of Swift is quite positive: It looks like a great Objective-C replacement. I'm especially pleased to finally have a REPL. The language still looks a little like a work in progress and the standard library is rather embryonic (of course it's always possible to use Foundation or the standard C library for missing functionality, but this is hardly elegant), but even in its current incarnation, it looks quite useable. I'm just about to get started on the long overdue complete redesign of Stockfish for iOS, and I'll certainly use Swift this time. My only regret is that I will have to go back to using XCode (which rivals iTunes as my most hated piece of Apple software) until JetBrains manage to bring decent Swift support to AppCode.
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Apples new 'Swift' language

Post by Tord Romstad »

Bloodbane wrote:Now D on the other hand gets me excited, but it's not new or hip or backed by any big companies so few people care.
D tries too hard to be a better C++ to excite me much. I don't want a better C++, I want a replacement for C++. Rust -- which fortunately is backed by a big company -- looks more promising to me.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Apples new 'Swift' language

Post by mar »

Tord Romstad wrote:D tries too hard to be a better C++ to excite me much. I don't want a better C++, I want a replacement for C++. Rust -- which fortunately is backed by a big company -- looks more promising to me.
D tried to be much simpler than C++ with similar expressive power (which I hope we all would welcome because
I really don't like the path that C++ is taking recently, making it even more bloated).
That was the whole point.
Unfortunately in the meantime it already evolved into something very complicated as well.
Also don't forget that (at least initially, I don't follow it anymore) D was the product of one man which alone deserves a lot of respect if nothing else.
Swift despite the fact that there are some interesting things seems to me as if Apple tried to put the best of many languages into a kettle and cook something better - I say no, thanks.
I'm not sure if defining custom operators with modifyable precedence is a good thing though,
I can imagine where that can lead...
Personally I don't care as long as I'm able to develop in C/C++ on OSX.
As for the comparison of languages, I see nothing wrong comparing AOT-compiled languages.
EDIT: What I would welcome from Apple is not a new programming language, but to be more open and less restrictive (especially towards developers) in general.
Regarding iOS for example, allowing to spawn processes and execute dynamically generated code would be a good start IMHO.
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Apples new 'Swift' language

Post by xmas79 »

kinderchocolate wrote:Writing a chess engine with Swift is no different to writing it with Python.
I would write a chess engine in this language too:

http://en.wikipedia.org/wiki/Brainfuck

but I actually have some problems with the language name, and syntax....
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Apples new 'Swift' language

Post by stegemma »

Anybody try this language? It seems that it has a parallel version:

http://swift-lang.org/main/