Swift Language ?

Raymond123

Beta member
Messages
2
Location
Canada
I have recently been looking into ways of developing an application as a part of our academic project. I think today's software ecosystems are really diverse. What about doing it with the swift language?
I'm very familiar with Objective-C and C++. But I need a little help starting things off. Does anyone have suggestions on developing an app using swift language? Were there any specific tutorials that you found to be useful ?
 
Swift is for iOS development, which requires XCode and a Mac to compile/run.

My co-workers that do iOS development like Swift a lot, especially over Objective-C. They say it's pretty easy to learn and easy to use.
 
I've recently switched from using Obj-c to Swift, it takes a little getting used to but not too bad. You don't have to be so explicit with swift

e.g. if I wanted to create a string with a variable in it
Code:
NSString *username = "Mike";
NSString *mystring = [NSString stringWithFormat:@"I can put your name here %@",username];

vs

var username = "Mike"
var mystring = "I can put your name here \(username)"

That said, I kind of prefer the obj-c way, it's immediately clear to me what kind of variable is in place and what the command does that I'm using.
 
That said, I kind of prefer the obj-c way, it's immediately clear to me what kind of variable is in place and what the command does that I'm using.

I used to be the same, but I've started heavily using the "var" style in C# for a while now as well. Saves me time from explicitly typing statements/variables out when not needed.
 
Yeah I guess it's a non-issue as long as you comment well, guess time will tell as I keep using it :p

No need to comment if you're being clear in what you're doing :p.

I've adopted a lot of Clean Code practices - avoiding unnecessary comments and instead clarifying what I'm doing with my code itself. Good code doesn't need to be commented if it's done correctly & clearly.

var comes really in handy when using LINQ statements and in order to explicitly type them...would take way longer and unnecessarily complicate the lines. That and when using Parse / Convert methods it's clear what type I'm creating, or when using .ToString() extension method (obviously making a string, so why type out "string").
 
Well I'm no dedicated software developer, but I sure as hell am gonna disagree with you on that one XD

Good code should absolutely still be commented. If there's one thing i've learned over the years, it's that what seems obvious today will most definitely not be obvious 3 years (or even 1 year) down the track. I open up old programs, sometimes in languages I haven't touched in a while, and it's like o_O

I tend to modularize my approach so I can chop/change things if needed without tons of reworking. And on top of each section, I comment briefly what I'm doing with that section in a general sense. If it's part of a large/complicated program, I'll also include what it's doing/enabling in the big picture.
 
Last edited:
Well I'm no dedicated software developer, but I sure as hell am gonna disagree with you on that one XD
maybe that's why you're not a dedicated software dev :p

Good code should absolutely still be commented. If there's one thing i've learned over the years, it's that what seems obvious today will most definitely not be obvious 3 years (or even 1 year) down the track. I open up old programs, sometimes in languages I haven't touched in a while, and it's like o_O

I tend to modularize my approach so I can chop/change things if needed without tons of reworking. And on top of each section, I comment briefly what I'm doing with that section in a general sense. If it's part of a large/complicated program, I'll also include what it's doing/enabling in the big picture.

Honestly all depends on how you architect your program and how you name your methods/functions & variables. If you name your methods/functions and variables clearly enough, they self-document what the code is doing and you don't need to read through unnecessary comments about what exactly the code is doing if you're clear in the first place.

You're talking more about overall documentation, which is fine to do (documenting your methods/functions in regards to what it does, the parameters, and what it returns). I'm talking more about in-line documentation, which should be kept to a minimum if possible (reduces the amount of reading necessary later on down the road when looking through a program).

example:
Code:
<summary>Sums two numbers together.</summary>
<param name="a">First value</param>
<param name="b">Second value</param>
<returns>Sum of two values</returns>
public int Sum(int a, int b)
{
    //sum a and b 
    var c = a + b;
    return c;
}

The XML Summary doc is fine, as that describes what the method is doing, and in the case of Intellisense for VS, will also describe what the method does while you're typing it out and give all the necessary info & meta data that was given in the XML.

The inline "sum a and b" however, is unnecessary (and yet I've seen inline documentation like that). It's clear already what's happening, and thus only clutters up the source and makes it harder to read the actual code.

I know that's a pretty basic example, but it's scalable to larger applications as well - if you break it out well enough into smaller methods that are single-purpose (and reusable!), then the code documents itself.

I didn't agree with Clean Code practices at first, and in the beginning I did indeed add inline comments. But as I gained more experience I saw the benefits of Clean Code and saw exactly how useless those inline comments really were when I architected my application in a proper way.

Basically...if you're adding so much logic in a single function that you require inline comments...you should probably start breaking it up into multiple functions.
 
Thank you for all your suggestions. While searching more on this , I found some benefits of swift programming 3 Benefits Of Using Swift Programming | Cestar College. In which I liked the Swift playgrounds. There is no better way to explore coding than actually writing code. Since Swift Playgrounds requires no coding knowledge, I think it's perfect for students just starting out and makes learning Swift interactive and fun.
I'm planning to start learning swift from Bucky videos.
https://thenewboston.com/videos.php?cat=280
 
Back
Top Bottom