News for hackers. Stuff that matters.
Re:Why many developers still prefer Objective-C to Swift by orbitur on Friday October 06, 2017 @09:29PM (#15421715)
I work for a company that writes iOS apps, large and small. When Swift 2 came out, any new projects we started were in Swift. We still maintain several large and small ObjC apps.

If I had my way while were planning out a "big" app, it would be ObjC.

- ObjC isn't going anywhere, and it continues to receive improvements

- Xcode 9 can still barely handle large Swift apps; I consistently lose syntax highlighting and autocompletion

- Equivalently sized ObjC apps clean build in approximately 1/3 of the time

Swift as a language is fine. There were some neat new concepts it forced me to learn, and I look forward to writing it. But the tools make me want to work on anything else.

edit: Also I was really, really looking forward to Swift 4 & Xcode 9. I hoped there would be improvements in build time and less IDE problems, but I see no noticeable change in build time, and Xcode routinely leaves me unable to quickly make changes to Swift code, either because indexing failed and autocomplete is suggesting random shit or because autocomplete isn't there at all. Then I switch tabs and for a moment I'm looking at syntax highlighting until it just... disappears. Maybe changing a line will fix it, maybe it won't. Xcode 9 might actually be worse in this respect.

Re:Why many developers still prefer Objective-C to Swift by bartvk on Saturday October 07, 2017 @03:12AM (#15422681)
Tip to reduce compile times:

1. Use modules.

2. In Xcode, go to your target, go to Build Settings, and at Other Swift Flags, add the following flags: -Xfrontend -warn-long-expression-type-checking=400

This will issue a warning when the Swift compiler takes more than 400ms when deducing the type for a particular expression. If you get no warnings, lower to 300, and if necessary to 200.

Anyone have other tips?

Re:Why many developers still prefer Objective-C to Swift by dep_b on Saturday October 07, 2017 @07:03AM (#15423293)
Type all of your more complex statements and block parameters, especially when you're chaining complex stuff. It's much easier to verify that the types you've stated are correct than to calculate all the possibilities that a type might have.
Re:Why many developers still prefer Objective-C to Swift by steeve on Saturday October 07, 2017 @06:57AM (#15423275)
I'm kind of sad this flag exists to be honest....
Re:Why many developers still prefer Objective-C to Swift by kobeya on Saturday October 07, 2017 @12:29PM (#15424406)
400ms is about a billion clock cycles. If it takes a billion clock cycles to type check an expression, something is very very wrong.
Re:Why many developers still prefer Objective-C to Swift by andrewmcwatters on Saturday October 07, 2017 @10:38AM (#15423929)
1. Sounds pretty sane. 2. is tragic.
Re:Why many developers still prefer Objective-C to Swift by kevan on Friday October 06, 2017 @10:46PM (#15421988)
The safety we get from Swift in our app is worth the problems with the dev tooling, but barely.
Re:Why many developers still prefer Objective-C to Swift by valuearb on Friday October 06, 2017 @10:33PM (#15421943)
Restart XCode 9 every 2 hours. SourceKitService is eating up your available memory.
Re:Why many developers still prefer Objective-C to Swift by iOSGuy on Friday October 06, 2017 @09:55PM (#15421822)
This is my thought exactly. I've written a few open source Swift components to learn the language, but it's just not ready to work on the scale that mobile software is reaching.

Mobile software development isn't about a developer or two building "apps" anymore, it's grown much bigger than that.

Re:Why many developers still prefer Objective-C to Swift by htormey on Friday October 06, 2017 @11:48PM (#15422178)
Is this still the case with Swift 4? Swift had lots of issues as of the 2016 wwdc (language changes breaking third party libraries, barely working tools) however swift 4 seems to be not nearly as bad. I’d be interested in hearing your thoughts.
Re:Why many developers still prefer Objective-C to Swift by zoul on Saturday October 07, 2017 @02:42AM (#15422593)
Swift 4 as a language is marvellous. It’s the tooling that’s still very annoying to work with – autocomplete not working, SourceKit burning CPU time, crashes, that kind of thing.
Re:Why many developers still prefer Objective-C to Swift by AnthonBerg on Saturday October 07, 2017 @07:38AM (#15423380)
I haven’t tried Swift, but I never use XCode and always use Jetbrains IDEs - there is one for Swift: https://www.jetbrains.com/objc/
Re:Why many developers still prefer Objective-C to Swift by AsyncAwait on Saturday October 07, 2017 @08:20AM (#15423467)
AppCode is good, but can't quite keep up with the changes Apple makes on a timely basis, (for obvious reasons). It also doesn't have a great way to work with storyboards and thus is more of a companion than a direct replacement for XCode.
Re:Why many developers still prefer Objective-C to Swift by coldtea on Saturday October 07, 2017 @08:46AM (#15423554)
>but can't quite keep up with the changes Apple makes on a timely basis, (for obvious reasons)

I don't see what the obvious reasons would be. Swift is developed and discussed in the open for one.

Re:Why many developers still prefer Objective-C to Swift by Synaesthesia on Saturday October 07, 2017 @08:53AM (#15423573)
I think not only the language features but the new features of iOS and idevices and Macs, which xcode usually supports on day 1.
Re:Why many developers still prefer Objective-C to Swift by LeoNatan25 on Saturday October 07, 2017 @09:44AM (#15423734)
Huh? Those are features of the SDK. Simulators can be controlled using simctl.

There really is no excuse for an IDE developer not to support the latest swift syntax and runtime from day 1, given how there are nightly and weekly swift toolchain releases.

Re:Why many developers still prefer Objective-C to Swift by AnthonBerg on Saturday October 07, 2017 @09:01AM (#15423600)
Thank you!
Re:Why many developers still prefer Objective-C to Swift by jgalt212 on Saturday October 07, 2017 @10:20AM (#15423863)
> I work for a company that writes iOS apps, large and small.

But aren't most iOS apps just thin clients? and if they are thickish isn't most of the code related to UI?

If the above is true, Swift and its currently un-robust tooling should be the solution for most/all projects.

Re:Why many developers still prefer Objective-C to Swift by Grustaf on Saturday October 07, 2017 @11:36AM (#15424158)
I don't have any statistics on how many iOS apps are just "thin clients" but I wouldn't think it's more than half.
Re:Why many developers still prefer Objective-C to Swift by kobeya on Saturday October 07, 2017 @12:32PM (#15424416)
Very few apps I use are thin clients. Those that are (without an unavoidable need to be) I usually uninstall.
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @03:14AM (#15422687)
This is why I consider IDE-dependence to be a programmer-smell. If you have to have an IDE to function, you're really more of a team liability than an asset. Same goes with the language - if it has to have an IDE or else you get into some sort of hellish mess, then its really not designed as a language to make you productive - more, just to sell tools.
Re:Why many developers still prefer Objective-C to Swift by vertex-four on Saturday October 07, 2017 @03:22AM (#15422720)
Would you consider an engineer who is significantly more productive with CAD software than manual drafting to be a liability? Sure, you want your engineers to know the basics of what they're doing, but why would you choose to throw away that productivity?
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @03:44AM (#15422777)
Its never acceptable as a developer to say "I can't do it, because the IDE is broken" - this is a programmer-smell.

Re: CAD software, I would consider them more productive, but only if they actually knew what the basics were and didn't just depend on the GUI doing all the work. If you can't get underneath the tooling and fix it, then I don't want to work with you, period.

Re:Why many developers still prefer Objective-C to Swift by vertex-four on Saturday October 07, 2017 @04:18AM (#15422876)
No, but it's plenty acceptable to say "I'll be less productive because the IDE is broken". Even the diehard Java enterprise developers I know can jot down code with a pen and paper if they were absolutely forced to - that doesn't make it a good idea to tell them not to use an IDE in their day-to-day job, nor a language without good IDE support.
[dead]
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @07:10AM (#15423314)
If you can't refactor with just search and replace, you don't really know the depths of your project, and yes - I would be uncomfortable working with you.
Re:Why many developers still prefer Objective-C to Swift by orbifold on Saturday October 07, 2017 @07:26AM (#15423354)
That just means you've never worked on a big project, where the component you are responsible for is used by >10 different other components. One very quickly reaches a limit where manual refactoring is an option.
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @08:43AM (#15423544)
Oh, I've worked on plenty of big projects - in fact, your life is probably being protected by my software right now.

Its just that I don't believe in succumbing to the crutch of tools. If the IDE is getting in the way, get the IDE out of the way - too many projects are incapable of doing this.

Re:Why many developers still prefer Objective-C to Swift by coldtea on Saturday October 07, 2017 @08:49AM (#15423558)
>Oh, I've worked on plenty of big projects - in fact, your life is probably being protected by my software right now.

Those two are orthogonal concepts. There is e.g. car or medical embedded software that's tiny in scope compared to a big enterprise project.

Re:Why many developers still prefer Objective-C to Swift by kaftoy on Saturday October 07, 2017 @01:08PM (#15424601)
Just a remark on the topic. Been working in vehicle software business for 12+ years now and renaming variables is almost never done. In fact I don't remember someone ever renaming a system (global) variable. There tens of thousands such variables in a system, plus about the same number of calibratable constants. We have renamed our drivers variables only when we switched to a newer architecture (multicore ready, AUTOSAR compliant).

The entire code base running a modern car goes well within millions of code lines. Our IDE changed in time from Blue River X32 v5 to internally modified Eclipse plugin. The only major use for us are X32 type contractions. [1]

[1]http://tinypic.com/r/20qhq4y/9

Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @09:36AM (#15423703)
Yeah, try taking a train in any one of 38 different countries around the world .. that big enough for you?

No, you really don't need the IDE to make big software.

Re:Why many developers still prefer Objective-C to Swift by coldtea on Saturday October 07, 2017 @09:40AM (#15423716)
You don't need computers to ride trains either.

Programming, as most technologies, is not about what you basically need. We are not cavemen.

It's about what enhances what you can do.

Re:Why many developers still prefer Objective-C to Swift by coldtea on Saturday October 07, 2017 @08:48AM (#15423557)
If you actually really know the "depths of your project" then you haven't worked in any really big project, and yes, I would be uncomfortable working with you.
Re:Why many developers still prefer Objective-C to Swift by AnthonBerg on Saturday October 07, 2017 @07:36AM (#15423377)
Textual search and replace is blind to the syntax and semantics of the programming language, of the software itself. Why should we use stone tools?
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @08:44AM (#15423549)
You, yourself, should not let your control over the project be 'usurped by complexity'. If you can't handle the complexity such that you need an IDE to do refactoring, you should definitely not promote this fact far and wide - its far better to promote the style of thinking where IDE is not a requirement, but rather a luxury.
Re:Why many developers still prefer Objective-C to Swift by AnthonBerg on Saturday October 07, 2017 @09:00AM (#15423598)
I'm sorry, but I fail to see the anything but superstition in the refusal to do search and replace through a language parser.
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @10:19AM (#15423860)
It means there are parts of the project you really don't have an embracive grip over, and that does not make you a great developer. It makes you a weaker one.
Re:Why many developers still prefer Objective-C to Swift by AnthonBerg on Saturday October 07, 2017 @12:00PM (#15424264)
No, it means that I consider there to be a difference between language constructs, variable names, strings, comments, etc. - in other words what a parser does. String/based find-replace muddles these together. An IDE is but a collection of similar tools. I’m not strong if I choose to walk and weak if I choose to use motorised transport.
Re:Why many developers still prefer Objective-C to Swift by fit2rule on Saturday October 07, 2017 @01:11PM (#15424609)
You're weak if, after using motorized transport to get around most of your life, you're suddenly asked to walk - and can't do it.

Look, there's no point arguing about this any further - but I urge you to look at this alternative point of view in your professional career. Without fail, those whose proficiency depends on the features of an IDE are, in my experience, more glib about their work and problem solving, and less likely to actually push to solve common programming problems on their own. Maybe you'll start to notice this too.

Re:Why many developers still prefer Objective-C to Swift by megaman22 on Saturday October 07, 2017 @10:30AM (#15423901)
If you think that search and replace is an appropriate way to refactor, when there are better options, then I'm not sure I'd be comfortable working with you...
Re:Why many developers still prefer Objective-C to Swift by klibertp on Saturday October 07, 2017 @06:11AM (#15423155)
On the other hand, not knowing and not using the tools for your language is also a problem, assuming that such tools are improving productivity (which many of them do). You should be able to get by without them if necessary, but you should also strive to use the most powerful tools you can whenever possible. Powerful tools also have non-trivial learning curves, so you should train to become proficient with them too.

Being tied to a single effective tool is not always bad. If the tool is indeed powerful, the need for other tools may not arise. Emacs and Vim users use their editors to work on a lot of different things, for example, and have enormous libraries of plugins and features at their disposal, ready to use no matter the language.

If someone asked me whether to learn an IDE for a specific language or Emacs, I'd say both. The larger your selection of tools, the better - with more tools the number of things you can do faster/better also increases, which leads to higher productivity.

In other words - don't try to code in Notepad forever and be prepared to spend some time on learning new tools.

Re:Why many developers still prefer Objective-C to Swift by indemnity on Saturday October 07, 2017 @06:28AM (#15423204)
Arguably, using Xcode for Swift is akin to coding in Notepad.

I basically have to have the documentation open in a separate window at all times, because Command-Click hardly works, and syntax highlighting/completion is never long for this world.

At least Notepad doesn't have pretensions to being a programmer tool.

Re:Why many developers still prefer Objective-C to Swift by alexasmyths on Saturday October 07, 2017 @08:36AM (#15423516)
"On the other hand, not knowing and not using the tools for your language is also a problem,"

To be fair - XCode is a problem.

iPhone Apps are not rocket science.

There is no reason for the massive bureaucracy and confusion of XCode - or even Swift.

Not only does Swift try to do too much as a language - dealing with XCode is like dealing with the California DMV.

My god, man the compiler options. Pages and pages of options.

As far as I'm concerned, the biggest failure of the 'Swift' decision, was to be so tied to the old language standard, and to XCode.

The only possible advantage of XCode from a developer perspective is maybe the UI designer, but even then.

Obviously there's a huge investment in Xcode

But ...

Has anyone tried VSCode lately, or Atom? I mean it's possibly to have a 'light' editor and basic compile chain in which we can do powerful things. Or none at all.

I personally loathe using Android Studio or XCode - it feels like working for the government, on a team of 3000 people building a web-site for the local library that never gets into production. Anyhow, I jest.

I think there is rationality in wanting to be able to have a language work without an IDE.

Re:Why many developers still prefer Objective-C to Swift by orbitur on Saturday October 07, 2017 @08:29AM (#15423495)
I obviously know what I'm doing, the IDE isn't going to write the code itself.

But if I can "write" an 80 character line of code by pressing around 10 keys, I think that's pretty useful. If I can write a method, a class, faster than I would by manually typing and referring to docs all the time, why wouldn't I?

And clearly I'm still getting the work done. I'm complaining about the dissonance of trying to type a method name while the autocomplete dialog wants me to finish the name of a random C macro or an image name. It's frustrating and worth complaining about. Syntax highlighting is useful, the reason it exists is to help you differentiate tokens quickly.

Re:Why many developers still prefer Objective-C to Swift by imtringued on Saturday October 07, 2017 @03:19PM (#15425239)
Suppose we have a datatype called "User" and it has an attribute called "username". How do you distinguish between User and username with a text only search for just "user"?

Also nobody is saying that the tool is required to make you productive. The entire point is that it makes you more productive. I consider things like "What file is this datatype defined in?" to be menial work. It's merely a waste of time that requires no skills.