OT: Swift is now open source
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Thu Dec 3 19:18:02 PST 2015
On 12/3/15 9:59 PM, tcak wrote:
> On Thursday, 3 December 2015 at 20:37:04 UTC, Steven Schveighoffer wrote:
>> On 12/3/15 3:16 PM, Meta wrote:
>>> On Thursday, 3 December 2015 at 19:10:04 UTC, Steven Schveighoffer
>>> wrote:
>>>> And the lack of semi-colons has poisoned me from writing syntactically
>>>> valid lines in D :)
>>>
>>> Surprisingly (or not), lack of semicolons is something that I have
>>> sorely missed in D/++/Java/C#/etc. ever since I first tried Ruby.
>>> There's a lot to be said for the little quality of life features in a
>>> language.
>>
>> You may misunderstand -- I prefer semicolons. But having to write
>> swift code for a few weeks, I find now when I write D code I forget
>> them all the time (where usually my proper semi-colon rate is near 100%).
>>
>
> Since you have experience, what is the level of the language? Is it C or
> Javascript level?
It is meant to be a replacement for Objective C. I'd put it more at the
C level, but there are something that are very UNLIKE C. For example,
they do not have any direct instance variables, everything is a
property. There seem to be no low-level types, even 'Int' is a struct.
But I assume the compiler whisks that away.
The type system is static, and everything is done via inference, which
is very nice.
The nullable unwrapping system takes a while to get used to.
> Are you able to define C bindings? Can I do socket programming? Are
> Posix function accessible? How is the speed?
See here:
http://stackoverflow.com/questions/24004732/how-to-call-c-from-swift
You basically need a bridging header that defines what can be called
from swift. I don't know the details of what happens in the compiler for
this.
Speed wise, I can't be sure. I'm sure others here have a better
understanding. All I've used it for so far is UI code on iOS.
Usability-wise, it's much easier to write swift than Objective C.
One thing I would LOVE to see in D from swift is inference of enum names.
In D-speak, it looks like this:
enum Foo
{
Bar,
Baz
}
Foo foo;
switch(foo)
{
case .Bar: // Foo is implied
case .Baz:
}
void fun(Foo);
fun(.Bar); // Foo is implied
I don't think we could have this exact syntax, though.
-Steve
More information about the Digitalmars-d
mailing list