Anyone?
Oh right, just putting it onto the screen is the c command println (I thought it was without c).
Why they couldn't just use print like Python is anyones guess.
The declaration and initialization was something like
var announcement = "Hello, world"
Apparantly the variable knows it's an integer because an integer is being assigned to it. No semi colon, no *, no @
Why does this remember me of visual basic a decade ago?
Oh right, just putting it onto the screen is the c command println (I thought it was without c).
Sorry to be picky, but "Hello, world" is a string![]()
Of course, I was just mad when writing it“println is a global function that prints a value, followed by a line break, to an appropriate output. If you are working in Xcode, for example, println prints its output in Xcode’s “console” pane. (A second function, print, performs the same task without appending a line break to the end of the value to be printed.)”
Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/fi/jEUH0.l
----------
Sorry to be picky, but "Hello, world" is a string![]()
my apologies, I didn't get to the swift book yet. I've corrected the other mistakes, I feel stupid today.Not only that, but you should use "let", not "var". Goddamnit, this language was only revealed a few hours ago, and one of the first things they tell you is that you should be using constants as much as possible, and already you people are using variables where you should use constants. I've struggled mightily for the past few years trying to get people to use the "const" keyword in C/C++/Obj-C, but my efforts were in vain. I thought it was because const wasn't added until years after the first version of the language was unveiled. Now I see that it'll take more than it being there from the start for people to use it.
Maybe the syntax needs to be easier. Maybe
announcement "Hello World"
should work the way
let announcement = "Hello World"
does, so that it'll be fewer characters to type and people will somehow think it's better as a result (when really it's better for an entirely unrelated reason... and probably less readable... but at least safer).
Not only that, but you should use "let", not "var". Goddamnit, this language was only revealed a few hours ago, and one of the first things they tell you is that you should be using constants as much as possible, and already you people are using variables where you should use constants. I've struggled mightily for the past few years trying to get people to use the "const" keyword in C/C++/Obj-C, but my efforts were in vain. I thought it was because const wasn't added until years after the first version of the language was unveiled. Now I see that it'll take more than it being there from the start for people to use it.
So far I know, const is used when you want that piece of memory to be const. var str="1234" is the same let str="1234". In memory, both have 5 bytes.
I have figured out how to compile the "hello world" in an xcode project, but how do I compile a single file? Either in xcode or at the command line.
answer is on page 2 of the Swift Programming Language available on iBooks Store..
Xcode 6 isn't available for free? Only who is signed up on developer program is able to access that?![]()
They're making a big deal over safety in this language, too. The more tightly you control your code with stuff like constants the less likely you'll make a mistake.
They're making a big deal over safety in this language, too.
it's very strange, it doesn't forgive you if you don't leave spaces between the variable and equal sign and declaration, as in these examples.
var test = 12 \\ no problem
var test=12 \\ Editor shows an error and the interpreter does nothing.
Tell me you are kidding! I'll rip my eyes out looking for this in a couple thousand lines of code.var test = 12 \\ no problem
var test=12 \\ Editor shows an error and the interpreter does nothing
Tell me you are kidding! I'll rip my eyes out looking for this in a couple thousand lines of code.
Heading off to disprove this right now, so that I can keep my sanity.
Well,this is still beta. I really hope the Editor will automatically fix any spacing issues. Plus, it's not hard to detect, as it points to the line and word where the error is located.
Not only that, but you should use "let", not "var". Goddamnit, this language was only revealed a few hours ago, and one of the first things they tell you is that you should be using constants as much as possible, and already you people are using variables where you should use constants. I've struggled mightily for the past few years trying to get people to use the "const" keyword in C/C++/Obj-C, but my efforts were in vain. I thought it was because const wasn't added until years after the first version of the language was unveiled. Now I see that it'll take more than it being there from the start for people to use it.
...
I've been tilting at the same windmill for years, with the same mostly disappointing results.
Some C-family programmers look at "const" as extra work/extra typing with no benefit. They can always claim the program "works the same without const", so "const" is unnecessary. (Even thought it isn't always true in C++, these folks usually haven't mastered C++ well enough to use those parts.) They find (or claim to find) no value in helping the compiler catch foolish mistakes, and no value in better expressing the code's intent with "const".
Sometimes they just don't know better; a subset of those can be trained to do better.
Sometimes they LIKE making their code as obscure as possible as a twisted form of job security. Avoiding "const" is just one tool in their arsenal. They are usually masters of the entire Book of Foul Code Smells.
Regardless of the cause, this kind of programmer is expensive. They make extra work (cleaning up after them). If they reach critical mass in a project, it's pretty likely to fail. This kind of programmer seems to thrive in the "anything goes" world of C. They usually HATE languages like Swift that are designed to suppress bad habits. They hate compiler warnings and ignore them when possible. They hate type checking. They will hate optionals in Swift, because they will be reminded of all the "it might not exist" bugs they've been leaving in their code for years. Etc., etc., etc.
So I say "Hurrah Swift!". Anything that makes Code Slobs uncomfortable is fine with me.![]()