Live data from Hacker News

Swift Programming Language Evolution

github.com

171–180 of 181 posts

Re: Swift Programming Language Evolution

#171

Earlier quoted context omitted.

Actually, all of it is accurate. Since you're spouting off your credentials as the only evidence for why what I wrote is wrong [not sure how that works], here are mine: - programmed in Objective-C for ~30 years - implemented my own pre-processor and runtime (pre NeXT) - programmed in the NeXT ecosystem professionally since 1991 - additionally, worked in Objective-C outside the NeXT/Apple ecosystem for many years - wo…

I'm guessing LeoNatan has an issue with: > it's at best a subtle difference and for most code you won't be able to tell the difference. Which is a pretty dubious claim. I removed a lot of retain/release/autorelease calls when I moved to ARC. Perhaps I'm missing the OP's point...

Can you quantify "a lot"?

My personal frameworks consist of 205584 non-comment, non-whitespace, non-single-bracket lines of code. Of these, 304 contain a retain, 1088 an autorelease, and 957 a release. That's 0.15%, 0.52% and 0.46% of the code respectively, for a grand total of 1.13%.

I'd have a hard time calling around 1% of total code "a lot", especially since the bulk of that is very simple boilerplate and trivial to write, but I guess everyone is different.

Mind you, this is a less-than-optimal code base, dating back to the mid 1990ies, with much more "but I am special" code that does do manual management where it shouldn't. Code I write today, even without ARC, has a significantly lower R/R density, well under 1%.

However, even of that 1%, the bulk is (a) releases in dealloc and (b) autorelease in class-side convenience initializers.

Quite frankly, I really miss convenience initializers in typical ARC code, writing [MPWByteStream streamWithTarget:Stdout] is so much nicer than [[MPWByteStream alloc] initWithTarget:Stdout] that (a) I wish people would write convenience initializers even in ARC mode (my experience is that they don't) and (b) I wrote a little macro that will generate an initializer and its convenience initializer from one specification. It's a bit nasty, so not sure I'll keep with it.

For the releases in dealloc, I once wrote an auto-dealloc that grubbed through the runtime to automatically release all the object instance variables (with an exception list for non-retained ones). It probably would have allowed me to eliminate the bulk of releases, but somehow I just didn't find it all that advantageous, writing those dealloc methods was just not that much of a hassle.

What may be interesting here is that the fact that I had an alternative may have been instrumental to realising it wasn't that big a deal. Things seem a lot worse when you don't have an alternative (or feel you don't have an alternative).

The same applies to ARC itself, at least for me: before ARC was released, it was exactly the solution I had wanted, especially in light of the GC madness. Again it was once I had used it in practice that it really became obvious how insignificant of an issue R/R was.

The only way I can see of getting significantly higher than 1% R/R code is by accessing instance variables directly, either because you are writing accessors by hand (why?) or grabbing at those instance variables without going through their respective accessors (why?!?!?). In both cases: don't do that.

Yet, whenever I mention these straightforward facts (particularly the numbers), people jump at me. Which is interesting in and of itself. My only explanation so far is that people generally write much, much worse code than I can imagine, or that R/R looms much larger in the collective Apple-dev psyche than can be justified by the cold, hard facts of the matter.

My guess is that's it's a little of the former and a lot of the latter. As a case in point, one dev who had jumped at me on a mailing list came back to me a little later in a private mail. He had converted one of his ARC projects back to R/R and was surprised to find what I had written to be 100% true: the R/R portion of the code was tiny and trivial, much less than he'd imagined, and hardly worth noticing, never mind fretting about.

However, the collective paranoia around R/R and the RDF around ARC seems to be big enough that reality doesn't really stand a chance. Which is of course also relevant. Perception matters, and that's why ARC is important.

Re: Swift Programming Language Evolution

#172
post #117
post #108

Earlier quoted context omitted.

There have been 30% stock price drops multiple times during the 13 years of continuous growth. They are clearly not correlated with the actual growth prospects, and if the stock market actually thought that Apple was dropping like a rock as you claim, you would expect to see a far higher discounting. You mention the Mac, which as declined in absolute terms but has continued to grow relative to the declining market. T…

I apologize, as I seem to be failing to convey my message to you. My assertion: Apple is dropping. Be careful about investing in Apple-only techs like Swift. Your argument (I think): Apple is not dropping like a rock. To support your argument, please provide a sources for the following: - The last time Apple stock was down 30% from same day prior year. - iPhone sales are not dropping > 10% (hence 'like a rock') . - M…

Perhaps Swift likes Actionscript? That's where a lot of professional left Actionscript for Scala and some invested and adopted Swift. Who cares about sales drop when it's not your job, when the main goals to get Swift on cross-platforms and IoT. Contents drive sales, you seen Windows and BB, Jolla phones have failed.

It's safe to predict Swift will supported in Android and I still prefer iOS for entertainment whereas I have a bad experience on many Android phones for years including it took years for Samsung and LG to release new ROM.

Re: Swift Programming Language Evolution

#173

A bit too late for wider adoption, isn't it? Are there examples of similar path to openness?

Not so, every years students and millennials are graduated and users are relied heavily on mobile on the move and oversea. Get ready to watch WWDC 2016, the demand is still very much active.

Actionscript did open source, it create lot of unhappiness in the community and poor IDE performance but Swift is a different story, I'm looking forward to have Swift for server as long as the vendors contribution are growing, MS could be keen.

Re: Swift Programming Language Evolution

#174

Earlier quoted context omitted.

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.

Hey, you need to read the parent a bit closer. Nobody's saying that Xamarin uses web views, but clearly there's a comparison to be drawn with the craze a few years back for writing mobile apps using web views. This was advocated as being cross-platform, allowing developers to write the same code and run it on multiple platforms. The downsides are the same in some ways, as the parent enumerated. Xamarin's use of nativ…

Yes, I've read the parent closely. The downsides are still wrong, because they assume that Xamarin is a cross-platform UI toolkit, which is not true. The performance downside is wrong, the newer features downsides is wrong, the front-end code sharing is wrong, the third party libraries is wrong (Xamarin can generate bindings for other frameworks automatically), and the only debatable one is getting locked in a framework.

Re: Swift Programming Language Evolution

#175
post #33
post #21

Earlier quoted context omitted.

Every new language has someone claim it's faster than C. I'll believe it when I see it.

Lots of languages ARE faster than C, including older languages than C, like Fortran and Forth. Being faster than C is not anything special in itself. Most things being equal (typed, optimized, compiled, no runtime etc) C is mostly faster when it does something with a lower overhead than some other language (e.g. a specially written hashmap algorithm targeted to some program vs C++ std map type), not because of its pr…

As someone mentioned below, C can almost be seen as a portable assembly. Given enough time and optimization it will always be as fast as the hardware allows. I guess my point was it is meaningless to say "faster than C" because it always depends on too many factors.

Re: Swift Programming Language Evolution

#176
post #24

Earlier quoted context omitted.

That's rich coming from a C# developer looking at mobile...

You may have missed the announcement where MS bought out Xamarin and is now giving it away for free. You owe it to yourself to at least give it a try while waiting for actual cross-platform Swift. 90+% of your mobile code can be shared between Android and iOS. Not sure if that's something currently possible with Swift or not, but it was worth keeping C# around for our needs. We're more of a "mobile app is something w…

And you must of missed when Apple open sourced Swift and released binaries for Ubuntu 15.10 and Ubuntu 14.04.

Re: Swift Programming Language Evolution

#177
post #12

Earlier quoted context omitted.

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.

Almost nobody actually used Swift prior to mid-2014. Did any 1978 C compilers offer both K&R and prior as options?

IMO the example of Java is a great illustration of why Swift shouldn't be tied to source compatibility too soon. You don't want to be stuck supporting your 1.0 syntax until the end of time, or you'll end up like Java!

Re: Swift Programming Language Evolution

#178

Earlier quoted context omitted.

>I wish I could have been a fly on the wall when they were discussing ARC versus GC. Apple shipped a tracing GC (RC is a form of GC) for a while, but couldn't get it to work reliably or with adequate performance. ARC was a bit of a "Hail Mary" and is problematic in its own right, but certainly better than the GC it replaced. Marcel

> ARC was a bit of a "Hail Mary" and is problematic in its own right I'm just curious with your experience what you are pointing to as problematic. Other than potential extra release calls in tight loops, the main downside I saw was it made the use of C structs way less appealing---at the same time, I wouldn't want to with manually memory managed C structs in GCD blocks.

Problems:

- Lots of extra retains/releases can cause significant and unpredictable performance degradation, and even crashes: http://blog.metaobject.com/2014/06/compiler-writers-gone-wil...

- The language went from fun dynamic, optionally statically typed to strict static typing that restricts exploratory programming: http://blog.metaobject.com/2014/03/cargo-cult-typing-or-obje... http://blog.metaobject.com/2014/05/the-spidy-subset-or-avoid...

- People no longer write class-side convenience initialisers :-((

- The benefits are mostly marginal, and the non-marginal benefits are needlessly bundled with ARC

- The C interaction model of the Objective-C hybrid language was made much more complex, somewhat defeating the purpose of a hybrid language

That's off the top of my head.

Re: Swift Programming Language Evolution

#179

Earlier quoted context omitted.

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.

Almost nobody actually used Swift prior to mid-2014. Did any 1978 C compilers offer both K&R and prior as options? IMO the example of Java is a great illustration of why Swift shouldn't be tied to source compatibility too soon. You don't want to be stuck supporting your 1.0 syntax until the end of time, or you'll end up like Java!

Used everywhere, with decades old libraries that still function fine?

Re: Swift Programming Language Evolution

#180
post #49

Earlier quoted context omitted.

I gotta disagree with this one. Those operators have always been confusing and unnecessary. j = i++ being different from j = ++i alone is enough to convince me it's gotta go.

++i and i++ have their uses. Just because it is confusing to you doesn't mean it is confusing to others. There are things about swift that are confusing to me, but I don't out right say that it has to go. Chalk this one up to shit hacker news says.

Too easy to get errors for array or objects loop outside the boundary that can be confusing for any teams dealing with large scale and when the requirements change frequently.
Post reply on HN