Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AxoNeuron

macrumors 65816
Apr 22, 2012
1,251
855
The Left Coast
I have jumped on the Swift band wagon since my initial post in this thread and I have to say it's a pretty great language. I cannot believe how easy it was to move from Obj-C to Swift. I went from zero knowledge to being an expert in a few days. I am still glad I learned Objective-C first though. If you can learn Objective-C, you can really learn anything.
 
  • Like
Reactions: page404 and Mascots

Dookieman

macrumors 6502
Oct 12, 2009
390
67
I have jumped on the Swift band wagon since my initial post in this thread and I have to say it's a pretty great language. I cannot believe how easy it was to move from Obj-C to Swift. I went from zero knowledge to being an expert in a few days. I am still glad I learned Objective-C first though. If you can learn Objective-C, you can really learn anything.
Like I said before in my previous post, I was in the same boat until I actually had use seriously for work. Things worked fine until they didn't.
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
There should be a page of issues with Swift. I can imagine all the hours of head banging trying to find these bugs.

I heard Apple had a number if issues with out non language quality control issues as well. Usually Apple has been very good at fixing things.
 

AxoNeuron

macrumors 65816
Apr 22, 2012
1,251
855
The Left Coast
Like I said before in my previous post, I was in the same boat until I actually had use seriously for work. Things worked fine until they didn't.
It definitely has issues - it's still a new language. But over-all, I think it's pretty good even for rather complex commercial projects as long as you have patience. But yes, some of the Swift bugs do get pretty tiring pretty quickly.
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
We're about due up for a update to Swift. I assume Apple is aware of all these problems, let's see how much effort they put into it. If it's not handled well, the business could reject the language and that could block it's advancement.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
The array slice behavior is a nice optimization (as Swift was started by a compiler designer). It likely returns a reference to a copy-on-write pseudo-object, which can save a lot of memory and unneeded memory copies in many cases (using read-only functions on the sub array).

Also, unlike C, array items are not necessarily stored in memory in contiguous or even ascending index order. Again allowing some compiler optimizations in some interesting cases. Thus an index calculation is more complicated than a subtraction.
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
The array slice behavior is a nice optimization (as Swift was started by a compiler designer). It likely returns a reference to a copy-on-write pseudo-object, which can save a lot of memory and unneeded memory copies in many cases (using read-only functions on the sub array).

Also, unlike C, array items are not necessarily stored in memory in contiguous or even ascending index order. Again allowing some compiler optimizations in some interesting cases. Thus an index calculation is more complicated than a subtraction.

I wonder if that just needs to be explained in the documentation, or maybe it is. IIRC, the runtime treats different data storage methods the same way.
 

Dookieman

macrumors 6502
Oct 12, 2009
390
67
The array slice behavior is a nice optimization (as Swift was started by a compiler designer). It likely returns a reference to a copy-on-write pseudo-object, which can save a lot of memory and unneeded memory copies in many cases (using read-only functions on the sub array).

Also, unlike C, array items are not necessarily stored in memory in contiguous or even ascending index order. Again allowing some compiler optimizations in some interesting cases. Thus an index calculation is more complicated than a subtraction.

You're right, giving the developer an array slice could allow for some optimizations, but 99% of the time, the developer simply wants to assign the objects within the given range to a new array. The problem is that it doesn't work as expected (since most Swift developers are migrating from Objective-C) and their was no clear indication of what to do. Apple should make it default functionality to easily assign new objects to the array. If the developer notices some performance bottlenecks, then let them dive deeper and fiddle with an array slice.

Personally, I feel that this is a symptom of Apple's making though. There are no coding standards for Swift and most developers, including myself, treat Swift like Objective-C, since what else are we suppose to go off of?
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
You're right, giving the developer an array slice could allow for some optimizations, but 99% of the time, the developer simply wants to assign the objects within the given range to a new array. The problem is that it doesn't work as expected (since most Swift developers are migrating from Objective-C) and their was no clear indication of what to do. Apple should make it default functionality to easily assign new objects to the array. If the developer notices some performance bottlenecks, then let them dive deeper and fiddle with an array slice.

Personally, I feel that this is a symptom of Apple's making though. There are no coding standards for Swift and most developers, including myself, treat Swift like Objective-C, since what else are we suppose to go off of?
+1. I found that many programmers have no clue how things really work. Many seem to come with no OOP background and just find a way to get from point A to point B. Seems to be a lot of code sharing without really knowing what's going to behind the code. I've seen this so many times over the years.

This can't be good as apps become more advanced and people have to understand threading and blocking, etc...
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
There are no coding standards for new language and most developers, including myself, treat new language like old language, since what else are we suppose to go off of?

This seems to be a problem mostly with coders who don't want to keep learning new stuff, otherwise all new programming languages, after the era of assembly, Fortran and Cobol (et.al.), would never have gained traction. Exactly the same complaint was made about Objective C when the iOS App store first opened. Every programming language started out with very little to no documentation or coding standards, except maybe 1 manual or man page.
 

Dookieman

macrumors 6502
Oct 12, 2009
390
67
This seems to be a problem mostly with coders who don't want to keep learning new stuff, otherwise all new programming languages, after the era of assembly, Fortran and Cobol (et.al.), would never have gained traction. Exactly the same complaint was made about Objective C when the iOS App store first opened. Every programming language started out with very little to no documentation or coding standards, except maybe 1 manual or man page.
I disagree that it's about people not wanting to learn new things or using old like new. I don't fault anyone for using it like Objective-C, since Swift uses so much of Objective-C from its APIs to it's coding patterns (delegates etc...). Apple dumped a new language on us that was not 100% thought through yet. Obviously it can't be perfect from day 1 but it seems like basic things still aren't there yet.
 

eventailapp

macrumors member
Jan 7, 2016
65
14
I think that what we lack most is a good book which explains how to use Swift, solutions to common problems and so on and so forth.

I can imagine that people are not ready to invest in such effort as the language is still evolving pretty substantially. But I applaud most of the choices Apple made so far. Removal of for(;;) loops and ++/-- operators in the future release will, I imagine help programmers move forward and actually use Swift features rather than write Objective-C in Swift.

In any case, I found that reading up on functional programming in general helps me to understand it better.
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
I think that what we lack most is a good book which explains how to use Swift, solutions to common problems and so on and so forth.

I can imagine that people are not ready to invest in such effort as the language is still evolving pretty substantially. But I applaud most of the choices Apple made so far. Removal of for(;;) loops and ++/-- operators in the future release will, I imagine help programmers move forward and actually use Swift features rather than write Objective-C in Swift.

In any case, I found that reading up on functional programming in general helps me to understand it better.
I just got a book called "Intermediate iOS 9 with Swift" by Simon Ng.

http://www.appcoda.com/intermediate-swift-programming-book/

Looks like it's just what you asked for. I haven't read it yet, but looks interesting.
Code:
1. Preface
2. Building Adaptive User Interfaces
3. Adding Sections and Index list in UITableView
4. Animating Table View Cells
5. Working with JSON
6. How to Integrate Facebook and Twitter Sharing
7. Working with Email and Attachments
8. Sending SMS and MMS Using MessageUI Framework
9. How to Get Direction and Draw Route on Maps
10. Search Nearby Points of Interest Using Local Search
11. Audio Recording and Playback
12. Scan QR Code Using AVFoundation Framework
13. Working with URL Schemes
14. Building a Full Screen Camera
15. Video Capturing and Playback Using AVKit
16. Displaying Banner Ads using iAd
17. Working with Custom Fonts
18. Working with AirDrop and UIActivityViewController
19. Building Grid Layouts with Collection Views
20. Interacting with Collection Views
21. Adaptive Collection Views Using Size Classes and UITraitCollection
22. Building a Today Widget Using App Extensions
23. Building Slide Out Sidebar Menus
24. View Controller Transitions and Animations
25. Building a Slide Down Menu
26. Self Sizing Cells and Dynamic Type
27. XML Parsing and RSS
28. Applying a Blurred Background Using UIVisualEffect
29. Using Touch ID For Authentication
30. Building a Carousel-Like User Interface
31. Working with Parse
32. How to Preload a SQLite Database Using Core Data

As far as the functional programming part goes, I read a blog about that and it was very interesting. Really put a interesting view on function based programming, which was the standard years ago and still used on some small systems where OOP might be too heavy.

Swift might have an advantage in creating global functions to do things that many objects can use, but it might also confuse some that aren't used to OOP. OPP seems to be a sticking point for some.
 

Dookieman

macrumors 6502
Oct 12, 2009
390
67
I just got a book called "Intermediate iOS 9 with Swift" by Simon Ng.

http://www.appcoda.com/intermediate-swift-programming-book/

Looks like it's just what you asked for. I haven't read it yet, but looks interesting.
Code:
1. Preface
2. Building Adaptive User Interfaces
3. Adding Sections and Index list in UITableView
4. Animating Table View Cells
5. Working with JSON
6. How to Integrate Facebook and Twitter Sharing
7. Working with Email and Attachments
8. Sending SMS and MMS Using MessageUI Framework
9. How to Get Direction and Draw Route on Maps
10. Search Nearby Points of Interest Using Local Search
11. Audio Recording and Playback
12. Scan QR Code Using AVFoundation Framework
13. Working with URL Schemes
14. Building a Full Screen Camera
15. Video Capturing and Playback Using AVKit
16. Displaying Banner Ads using iAd
17. Working with Custom Fonts
18. Working with AirDrop and UIActivityViewController
19. Building Grid Layouts with Collection Views
20. Interacting with Collection Views
21. Adaptive Collection Views Using Size Classes and UITraitCollection
22. Building a Today Widget Using App Extensions
23. Building Slide Out Sidebar Menus
24. View Controller Transitions and Animations
25. Building a Slide Down Menu
26. Self Sizing Cells and Dynamic Type
27. XML Parsing and RSS
28. Applying a Blurred Background Using UIVisualEffect
29. Using Touch ID For Authentication
30. Building a Carousel-Like User Interface
31. Working with Parse
32. How to Preload a SQLite Database Using Core Data

As far as the functional programming part goes, I read a blog about that and it was very interesting. Really put a interesting view on function based programming, which was the standard years ago and still used on some small systems where OOP might be too heavy.

Swift might have an advantage in creating global functions to do things that many objects can use, but it might also confuse some that aren't used to OOP. OPP seems to be a sticking point for some.

Have a link to the blog post?
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
Have a link to the blog post?
It was a bit back and IIRC, I was binge watching Swift videos.

Here's a few of the links. One I watched (don't know if its in these links) wrote a full app with functions only (IIRC). I don't remember all the details, but something about global functions made functions visible to all of the app. It was like adding on to the basics of the language. Just like you have NSLog() that you can use anywhere, you could write whatever functions you wanted and use where you wanted.




This last one might have been the better one, I'd have to go thru them again :D



Some of it might have had to do with the overhead of an OOP approach vs a function based approach and the impact on speed. That last link I think covered part of that, but it shouldn't be too hard to run some speed tests and see the performance difference.
[doublepost=1453866685][/doublepost]Looks like someone wrote a book just about functional programming in Swift :D
https://www.objc.io/books/functional-swift/

They've even go an advance Swift book.
https://www.objc.io/books/advanced-swift/

Functions in Swift are first-class values, i.e. functions may be passed as arguments to other functions, and functions may return new functions. This idea may seem strange if you’re used to working with simple types, such as integers, booleans, or structs. In this chapter, we will try to explain why first-class functions are useful and provide our first example of functional programming in action.
This sounds like where I got part of it. It's from the above book.
[doublepost=1453867258][/doublepost]
Objective-C added support for first-class functions with the addition of blocks: you can use functions and closures as parameters and easily define them inline. However, working with them is not nearly as convenient in Objective-C as it is in Swift, even though they’re semantically equivalent.

Maybe this is one of cornerstones of his point. ObjC vs Swift. Swift has 1st class function and blocks, whereas ObjC only had blocks.

Here's a preview, looks like he makes a game with only functions.
https://www.objc.io/books/functional-swift/preview/
 
Last edited:
  • Like
Reactions: page404

bjet767

Suspended
Oct 2, 2010
967
319
One of the issues with all languages is this, as they grow higher in the coding chain lower level access begins to become more difficult. The grabbing of just a few items in an array is just such an example.

As far as inline coding of swift and OC it could be made as simple as some sort of commands like <swift> </swift> to inform preprocessor/compiler that swift coding was next.

But, back in the day, C made us do everything and gave the ability to access machine code and directly to memory locations. Then along came object oriented design and C++. More functionality and less coding.

Personally I don't get the love for Java.

I have found one thing about coding, the logic is always the same, but the calls to accomplish it is where the confusion begins. Also most coders aren't artists and in a visual world its those who can do both who rise to the top.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
One of the issues with all languages is this, as they grow higher in the coding chain lower level access begins to become more difficult. The grabbing of just a few items in an array is just such an example.

Given modern processors (even in the ancient iPhone 5S) low level access might no longer even closely resemble what a coder thinks is happening, given out-of-order and speculative execution, register renaming, multiple levels of data caching each with different latencies, cache snooping, and multiple threads of both preemptive and simultaneous execution. You might think you are "just grabbing" a few bytes, but the optimizer and processor might end up doing a graph of stuff that takes pages to describe, in order not to stall some deep multi-stage pipelines too often.

You are not writing code to run on a 6502 or MC68000 any more. So languages and compilers are trying to evolve to better match feeding current sub-micron GHz hardware.
 
  • Like
Reactions: Mascots

1458279

Suspended
May 1, 2010
1,601
1,521
California
It seems this is the whole battle with languages. They started off with a low level .asm moved to a "high level" like C. They try to strike a balance where the programmer can get more done. When's the last time someone wrote a quick sort routine?

Someone coming into programming and starting with app dev at this point wouldn't know a linked list from a quick sort or a push from a pop on a stack.

Now it seems we're entering into a new mix because threading will become more of an issue as the apps become heavier and the processors are stuck at the speed they are because of heat issues. They add more cores and how many new programmers are going to understand threading?

The business of software development doesn't care about much beyond "give me a product to sell". Many programmers are just looking for a way to get things done.

As far as Java goes, I'm surprised Android and even Windows Phone haven't come up with a true native compiled language. Most see Apple has having a leg up in the performance arena.

Java's further from the chip with only knowledge base as the advantage.
 

bjet767

Suspended
Oct 2, 2010
967
319
The complexity of the GUI/threaded APIs we have today require a simple Object syntax to get the job done.

Access to low level computer functions really don't matter any more. I remember having to write printer functions for the early Windows and it was a real pain. Today both MS and Apple take care of that for the programmer.

But, one of the things all this good stuff and processor speed does is cause the coder to get messy.

In it all the real need is for art minded people to be good coders.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
OOP is a better abstraction these days. Your program no longer tells the computer what to do. Instead, the processors are mostly sleeping to save battery life... or even not melt. So, when they wake up for a bit, the OS calls your app (and maybe a swarm of other processes) to do a few fractions of a tick worth of work. This slice of work can be nicely encapsulated in some objects and messages. Bit-banging and big long procedural code no longer fit this scheme of things as well. So coding paradigms have needed to adapt to this.

As far as Java goes, I'm surprised Android and even Windows Phone haven't come up with a true native compiled language. Most see Apple has having a leg up in the performance arena.

Both Java and C# are garbage collected languages, which doesn't predictably fit in a time slice or a lower level cache footprint. Swift has a big leg up because the language architects seem to actually know something about how current hardware works (and yet not require completely manual memory management).
 
Last edited:

1458279

Suspended
May 1, 2010
1,601
1,521
California
OOP is a better abstraction these days. Your program no longer tells the computer what to do. Instead, the processors are mostly sleeping to save battery life... or even not melt. So, when they wake up for a bit, the OS calls your app (and maybe a swarm of other processes) to do a few fractions of a tick worth of work. This slice of work can be nicely encapsulated in some objects and messages. Bit-banging and big long procedural code no longer fit this scheme of things as well. So coding paradigms have needed to adapt to this.



Both Java and C# are garbage collected languages, which doesn't predictably fit in a time slice or a lower level cache footprint. Swift has a big leg up because the language architects seem to actually know something about how current hardware works (and yet not require completely manual memory management).

I didn't know they were batching up the calls, but now that you mention it that could be a pretty smart idea.

Keeps the processor cool and they can control the response time because they own the OS.
 

Essenar

macrumors 6502a
Oct 24, 2008
553
186
As someone who's fluent in Objective-C and learning Swift, the truth can be simplified to this:
If you want to get a job, NOW, learn Objective-C. Even Google is still hiring iOS Engineers primarily with Objective-C as a framework. And for big companies in general, you have to understand that iOS isn't the only thing they're developing and it'll be a LOT easier for them to import any internal libraries they have that were written in C into multiple projects if they u se Objective-C.
Most private contracting "design studios" are primarily hiring Objective-C because their lead developers and CTO's are cut from an older cloth and a client wouldn't be able to tell the difference between Swift and Objective-C anyway, so stick to what they know.
The only companies that are hiring strictly in Swift, are companies that are newly starting their iOS platform and looking for a lead/senior developer to lead the charge for them. If you are "learning" mobile development, that would probably be the worst job you could apply to and coincidentally a disaster for you to accept. Even a junior level developer with a year of experience would drown in that level of responsibility.

If your goal is to become a developer on your own or be ready for the future, and you plan on publishing your own apps for the next year or so, then learn Swift.

Right now, almost all of the introductory "learn iOS development from scratch" resources are written in Swift. Learning as a beginner in Objective-C requires dating your resources back to iOS 7. And I'll be honest with you, those resources are getting ancient. A lot of changes have taken place and learning from scratch on Objective-C will require you to learn deprecated code, Google for the updated code, but now you have an internal conflict of information because you spent hours reading a chapter about some method that changed completely.

I think that's a waste of energy.

So if you're a beginner, I can simply say, learn Swift because there's more recent beginner learning resources. If you're a seasoned developer in another language looking to add a professional skill to your set so you can apply for more responsibilities or even gun for an iOS position to leave your current language/IDE in, then pick up Objective-C.
[doublepost=1454096516][/doublepost]
My current opinion of Swift is that it is STILL not ready for prime time yet. Some basic 101 things still aren't working properly yet. I was starting to jump on the Swift bandwagon but now I'm hesitant as I got more familiar with the language.

e.g. Want to find the index of an object within an array of structs? Can't do it as is. You need to add the equatable extension to the struct class. I spent hours trying to figure out WHY I can't use the indexOf() method on the array. Maybe they wanted it this way, but there was ZERO indication of what was wrong, it gave some unrelated error that made no sense. This, in my opinion is something that should have been considered in 1.0, people use this all the time. Note: This only happens with pure structs, not a class of NSObject.

e.g. 2 You have an array of 10 items and want grab the items 7-9 (since it starts at 0). In Objective-C you can simply do something like NSArray *newArray = [oldArray subarrayWithinRange:NSRange: blah blah]; Works fine and as expected. In Swift? No. You get something called an ArraySlice which you can't assign to a new array. You have create a new array and typecast it to the ArraySlice before you can't use it as expected. Now maybe this done on purpose to give the dev TOTAL control but I doubt it. Most developers just want to grab objects 7-9 and create a new array. Again, the error was not obvious and took a lot of tinkering to finally figure out. Should have been 1.0 release.

This is basic 101 stuff Apple. You are trying to convince developers that Swift is the greatest thing and to drop Objective-C but Objective-C and other languages work as expected.

I only have one issue with this:
A lot of documentation and tutorials nowadays don't give a flying beagle about Objective-C. This is heart breaking for me because learning new methods and implementations as a junior developer is getting to a point where Google doesn't yield me any relevant information.

This is even worse for beginners.

I can't think of a specific example, but there's a lot of iOS 9 stuff that changed dramatically from iOS 8 and more so from iOS 7. When you search for some of those specific changes in implementation, you get a lot of Swift examples and it's very hard to find the Objective-C one. I wish there would be like a "call to arms" for Objective-C current implementations where people can write articles on implementing popular new Swift tutorials in Objective-C. It would help me a LOT and would make it a lot easier to continue to tell people to learn Objective-C as newbies.

For seasoned developers, I recommend Objective-C. Tried and true.

For newbies, telling them to learn Objective-C is sending them down a path that hasn't been maintained or updated as much as Swift in the last year. Even Big Nerd Ranch more or less gave up on Objective-C for their camp and books which really REALLY sucks because their book is the reason I have a job. Even Stephen Kochan gave up on Objective-C.
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
There's yet another problem with the job market. I just saw a job posted that required 8 years of mobile dev experience. Which is interesting because the iPhone is not yet 8 years old :D

The upside of Swift is that they can't ask for 5 years experience in Swift (yet).

Companies tend to ask for about 2 years less than the age of the language (after the language has been around a while). So Swift helps entry level programmers get into the game.

Someone that got into ObjC in the last 2 years might not have a chance in the job market. Those starting Swift now might be the last that'll be able to get on board.

That's one of the myths about programming. Some think "all I have to do is learn the language and the jobs will come to me" But they don't realize it take years to learn and they want years of experience for most jobs.

Either way you look at it, Apple opened up a can of worms with Swift. I can't see many professional game devs passing on Unity for Swift. It's a single platform language that doesn't closely follow any main stream language.

The whole "++" not going to work anymore is a joke. Other languages use it and it's a standard, if someone can't use it properly, they shouldn't program. What value would they have in any other language, and what value is there in a programmer that only knows one language that only works on one platform?

If you can't handle X++ or ++X, why program at all?
 
  • Like
Reactions: PizzaBoxStyle

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
There's yet another problem with the job market. I just saw a job posted that required 8 years of mobile dev experience. Which is interesting because the iPhone is not yet 8 years old ...

1. You could develop mobile web apps for the original iPhone 2G 8+ years ago.

2. But some of us started doing mobile software development with PalmOS (or even PocketPC/WinMob, Brew, or Symbian). C code and 68000 asm using Metrowerks CodeWarrior on Mac OS 9. That's 11+ years more then you newbies for the resume. :)

3. And Apple Newton developers have even that beat. Integer Basic to NewtonScript to Swift anyone?
 

1458279

Suspended
May 1, 2010
1,601
1,521
California
1. You could develop mobile web apps for the original iPhone 2G 8+ years ago.

2. But some of us started doing mobile software development with PalmOS (or even PocketPC/WinMob, Brew, or Symbian). C code and 68000 asm using Metrowerks CodeWarrior on Mac OS 9. That's 11+ years more then you newbies for the resume. :)

3. And Apple Newton developers have even that beat. Integer Basic to NewtonScript to Swift anyone?
Ok, :D
I know past programming work helps to prove you understand programming, but the job poster probably has no clue about the skills needed.

Actually the number of years is meaning less once you get past a few years. I've seen people program for many years and still have no clue. Headhunters as known for being clueless.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.