Live data from Hacker News

Swift Programming Language Evolution

github.com

151–160 of 181 posts

Re: Swift Programming Language Evolution

#151

Earlier quoted context omitted.

For the simple case with a single iterator, yes the C-style for loop isn't as concise. However, there are lots of real-world situations where there is not a single iterator (e.g. looping through 2 arrays). Having to go back to 'while(boolean) { }' loops with initializers outside of the loop and incrementors at strange places inside the loop is much more confusing and error prone.

You can use the zip function to loop through 2 collections. `for (l, r) in zip(c1, c2) {` It is not simply motivated by making code concise, I would say `for num in collection.reverse()` is less error prone and clearer than `for (var i = collection.count; i >= 0; i--) { var num = collection[i] ... }` The reverse collection iterator is computed lazily too, so there is no little perf overhead

Sometimes having those counting variables available is needed. You can use enumerate now but it introduces a lot of noise as now everything is a tuple with a number. It just makes expressing some algorithms messier and less readable although in general for sure "new style" loop is more readable and less bug prone.

Re: Swift Programming Language Evolution

#152

Earlier quoted context omitted.

If there was a common native language between Android/iOS, it would make things easier for sure. But using a third language to solve the existing problem is a rookie error. > 90+% of your mobile code can be shared between Android and iOS This stat depends on how complex your app is, but it usually only applies to gaming. Otherwise it's almost always false. We've already been down this path with the webview craze a fe…

I can see you have no idea what Xamarin is. With Xamarin, you still use UIKit and the native Android UI, the difference is that you program it in C# and thus the non-UI code can be shared seamlessly. Performance is not "very meh" as the UI is completely native and Xamarin compiles the C# to native code ahead-of-time. It has literally nothing to do with WebViews.

I haven't used Xamarin, but I've used a number of other frameworks (some webview based, many not). Some had benefits, but many had a lot of drawbacks.

I could write a long blog post about what a headache it is to support both platforms, but I don't think any of these frameworks solve the real pain points. It's generally a lot of small things which add up. It also takes a lot of team discipline.

Code sharing would be useful, but not massively since the majority of code is in the UI. When the UI is different, a lot of differences start to be needed in the non-UI code as well. Suddenly you are back at square one. Depends on the app though.

Re: Swift Programming Language Evolution

#153

So Swift has been out awhile, what do people think of it? What other language would you compare it to (e.g. C#, C, C++, etc)? What about the libraries are they well laid out?

For me the most exciting thing about Swift is the recent rumour that Google are looking at adopting it as a first class language for Android.

If that happened, you'd finally have an open, fast, expressive, modern language that you could use on the server and on the fronted for iOS and Android. Couple that with Typescript & Aurelia for the web frontend and I'd be in programming nirvana.

Re: Swift Programming Language Evolution

#154

So Swift has been out awhile, what do people think of it? What other language would you compare it to (e.g. C#, C, C++, etc)? What about the libraries are they well laid out?

For me the most exciting thing about Swift is the recent rumour that Google are looking at adopting it as a first class language for Android. If that happened, you'd finally have an open, fast, expressive, modern language that you could use on the server and on the fronted for iOS and Android. Couple that with Typescript & Aurelia for the web frontend and I'd be in programming nirvana.

[deleted]

Re: Swift Programming Language Evolution

#155
Swift is fun. I'm having a great time playing around with it. There are some nuances that take some getting used to, but overall, it's a powerful, fast and fun language to work with.

If you are interested, I have taken on implementing all major design patterns in Swift. I've gone through about 10 of them right now, (7 published on my blog).

If you've never worked with Swift but wish to get a feel for it without going through overly simple tutorials, check them out: https://shirazian.wordpress.com/2016/04/11/design-patterns-i...

Re: Swift Programming Language Evolution

#156
post #12

Are there any plans in place for locking down the syntax? Major release 3 is coming and developers are still being expected to hit a moving target. One of the nice things about C is that K&R era C is just as valid as C written nowadays, but Swift appears to be going in the opposite direction, every major release adding and removing bits of syntax. As someone unfamiliar with the language, it makes me not want to pick…

C got started in 1972, and K&R C dates from 1978 and includes compatibility-breaking changes. You want a young language to change a lot, because you don't really know what it needs until you get it out there and people use it. You want to make necessary changes as early as possible to cause the least pain. Major changes at the two-year mark will be a lot easier than major changes at the five or ten year mark, and wai…

However:

- Almost nobody actually used C prior to 1978.

- Most C compilers have supported both current and previous versions of the C standard via -std flags.

- Other languages with breaking changes, like Java, are similar. Java has always supported specifying the source language level via -src.

Swift is unique in breaking old code completely, without recourse other than semi-functional code rewriting tools.

Re: Swift Programming Language Evolution

#157

Swift is great language and an enormous leap forward in the apple-sphere. I'd like to see a bigger investment in JavaScript everywhere. I'd like to see apple make a push to allow writing 100% javascript apps for iOS and mac. I think it could be a huge differentiator for iOS and Mac development and it would bring to Apple the largest developer base out there.

Starting with OS X Yosemite, you can use JavaScript for writing Mac apps and scripts. https://developer.apple.com/library/mac/releasenotes/Interap...

Re: Swift Programming Language Evolution

#158
post #61

Earlier quoted context omitted.

I get the distinction, but there appears to be a deliberate direction to make Swift more portable. Thus, I was curious if that effort might include something UI related in the future. The interest level would certainly spike up if something were available.

But, that wouldn't make any sense to include UI components in a programming language. And I think the interest level is already "spiked".

Okay. I was under the (perhaps not true) impression that the vast majority of swift apps were iphone apps, with the apple specific UI bindings. Such that one of the first questions on a new platform (Linux, Android, etc) would be "how do I create the UI?".

It sounds like instead, the cross platform appeal is that back end or background services can now be written on non-apple platforms?

Re: Swift Programming Language Evolution

#159
post #157

Swift is great language and an enormous leap forward in the apple-sphere. I'd like to see a bigger investment in JavaScript everywhere. I'd like to see apple make a push to allow writing 100% javascript apps for iOS and mac. I think it could be a huge differentiator for iOS and Mac development and it would bring to Apple the largest developer base out there.

Starting with OS X Yosemite, you can use JavaScript for writing Mac apps and scripts. https://developer.apple.com/library/mac/releasenotes/Interap...

Using JS for automation is a great start. I don't think they have a way to build a JS app that leverages the full capabilities of either Mac or iOS yet.

Re: Swift Programming Language Evolution

#160

Swift is great language and an enormous leap forward in the apple-sphere. I'd like to see a bigger investment in JavaScript everywhere. I'd like to see apple make a push to allow writing 100% javascript apps for iOS and mac. I think it could be a huge differentiator for iOS and Mac development and it would bring to Apple the largest developer base out there.

I will be happy without that "largest developer base" brought to iOS. Anyone whos thinks Javascript it the best language ever deserves to keep programming in it.

The 'best' language is subjective. There are many apps where JavaScript could be one of many 'best' choices and some where it certainly couldn't be. Either way, you don't have the choice today.
Post reply on HN