News for hackers. Stuff that matters.
Re:Introducing Swift by georgewfraser on Monday June 02, 2014 @05:09PM (#7836410)
You appear to be advocating a new:

[ ] functional [X] imperative [X] object-oriented [X] procedural [X] stack-based

[ ] "multi-paradigm" [ ] lazy [ ] eager [X] statically-typed [ ] dynamically-typed

[ ] pure [X] impure [ ] non-hygienic [ ] visual [ ] beginner-friendly

[ ] non-programmer-friendly [ ] completely incomprehensible

programming language. Your language will not work. Here is why it will not work.

You appear to believe that:

[X] Syntax is what makes programming difficult

[ ] Garbage collection is free [ ] Computers have infinite memory

[ ] Nobody really needs:

    [X] concurrency  [ ] a REPL  [ ] debugger support  [ ] IDE support  [ ] I/O

    [X] to interact with code not written in your language
[ ] The entire world speaks 7-bit ASCII

[X] Scaling up to large software projects will be easy

[X] Convincing programmers to adopt a new language will be easy

[X] Convincing programmers to adopt a language-specific IDE will be easy

[ ] Programmers love writing lots of boilerplate

[ ] Specifying behaviors as "undefined" means that programmers won't rely on them

[ ] "Spooky action at a distance" makes programming more fun

Unfortunately, your language (has/lacks):

[ ] comprehensible syntax [ ] semicolons [ ] significant whitespace [ ] macros

[X] implicit type conversion [ ] explicit casting [ ] type inference

[ ] goto [ ] exceptions [ ] closures [X] tail recursion [ ] coroutines

[ ] reflection [X] subtyping [X] multiple inheritance [ ] operator overloading

[X] algebraic datatypes [ ] recursive types [ ] polymorphic types

[X] covariant array typing [ ] monads [ ] dependent types

[ ] infix operators [ ] nested comments [ ] multi-line strings [ ] regexes

[ ] call-by-value [ ] call-by-name [ ] call-by-reference [ ] call-cc

The following philosophical objections apply:

[ ] Programmers should not need to understand category theory to write "Hello, World!"

[ ] Programmers should not develop RSI from writing "Hello, World!"

[ ] The most significant program written in your language is its own compiler

[X] The most significant program written in your language isn't even its own compiler

[X] No language spec

[X] "The implementation is the spec"

   [X] The implementation is closed-source  [ ] covered by patents  [ ] not owned by you
[X] Your type system is unsound [ ] Your language cannot be unambiguously parsed

   [ ] a proof of same is attached

   [ ] invoking this proof crashes the compiler
[X] The name of your language makes it impossible to find on Google

[ ] Interpreted languages will never be as fast as C

[ ] Compiled languages will never be "extensible"

[ ] Writing a compiler that understands English is AI-complete

[ ] Your language relies on an optimization which has never been shown possible

[ ] There are less than 100 programmers on Earth smart enough to use your language

[ ] ____________________________ takes exponential time

[ ] ____________________________ is known to be undecidable

Your implementation has the following flaws:

[ ] CPUs do not work that way

[ ] RAM does not work that way

[ ] VMs do not work that way

[ ] Compilers do not work that way

[ ] Compilers cannot work that way

[ ] Shift-reduce conflicts in parsing seem to be resolved using rand()

[ ] You require the compiler to be present at runtime

[ ] You require the language runtime to be present at compile-time

[ ] Your compiler errors are completely inscrutable

[ ] Dangerous behavior is only a warning

[ ] The compiler crashes if you look at it funny

[ ] The VM crashes if you look at it funny

[ ] You don't seem to understand basic optimization techniques

[ ] You don't seem to understand basic systems programming

[ ] You don't seem to understand pointers

[ ] You don't seem to understand functions

Additionally, your marketing has the following problems:

[X] Unsupported claims of increased productivity

[X] Unsupported claims of greater "ease of use"

[ ] Obviously rigged benchmarks

   [ ] Graphics, simulation, or crypto benchmarks where your code just calls

       handwritten assembly through your FFI

   [ ] String-processing benchmarks where you just call PCRE

   [ ] Matrix-math benchmarks where you just call BLAS
[ ] Noone really believes that your language is faster than:

    [ ] assembly  [ ] C  [ ] FORTRAN  [ ] Java  [ ] Ruby  [ ] Prolog
[ ] Rejection of orthodox programming-language theory without justification

[ ] Rejection of orthodox systems programming without justification

[ ] Rejection of orthodox algorithmic theory without justification

[ ] Rejection of basic computer science without justification

Taking the wider ecosystem into account, I would like to note that:

[ ] Your complex sample code would be one line in: _______________________

[ ] We already have an unsafe imperative language

[X] We already have a safe imperative OO language

[ ] We already have a safe statically-typed eager functional language

[ ] You have reinvented Lisp but worse

[ ] You have reinvented Javascript but worse

[X] You have reinvented Java but worse

[ ] You have reinvented C++ but worse

[ ] You have reinvented PHP but worse

[ ] You have reinvented PHP better, but that's still no justification

[ ] You have reinvented Brainfuck but non-ironically

In conclusion, this is what I think of you:

[X] You have some interesting ideas, but this won't fly.

[ ] This is a bad language, and you should feel bad for inventing it.

[ ] Programming in this language is an adequate punishment for inventing it.

Re:Introducing Swift by tptacek on Monday June 02, 2014 @05:25PM (#7836519)
In addition to being a space-hogging recapitulation of an old, boring Usenet joke, a lot of your checks are wrong; some of them are because the Usenet joke is lame, but some of them are just you missing things, like the fact that Swift interacts directly with C/ObjC, uses the same IDE as Cocoa developers already use, &c.

This lame Usenet joke was a way of punching down at people joining language newsgroups trying to get people to pay attention to their half-baked language ideas. This, on the other hand, is a language that was introduced on stage at WWDC by Chris Lattner. You can see how especially clumsy the joke is by the fact that you checked off a reason Swift "wasn't going to fly". Obviously, it's going to "fly" just fine on the Mac and in iOS.

Re:Introducing Swift by georgewfraser on Monday June 02, 2014 @05:41PM (#7836638)
I posted the checklist partly in jest, but also because I think it illustrates how every programming language ends up stuck with the same trade-offs.
Re:Introducing Swift by serf on Monday June 02, 2014 @07:17PM (#7837127)
Well, I thought it was funny and I enjoyed reading through the list. You're absolutely right that it provides an insight into the past language efforts and the trade-offs that they inevitably encounter.

I hope you remember that when someone tells you something like 'it doesn't work here' that it's an opinion rather than a fact, regardless of how they phrase it.

The USENET era, while sometimes dated, was probably one of times in 'geek' history where we were the closest to one another. The internet was interpersonal, and i'm glad that someone is still trying to propagate the humor and spirit from that time.

Re:Introducing Swift by georgewfraser on Monday June 02, 2014 @09:00PM (#7837570)
I'm not actually familiar with the context in which this checklist was originally written. But I really love it for two reasons:

First, it demonstrates how programming languages have been making the same tradeoffs for years, to the point that someone was able to make a checklist of what's wrong with any programming language that still works years later.

Second, you can fill this out for any of the big programming languages and many will do very badly. It shows how whether a programming language succeeds is unrelated to how good it is. An actually accurate checklist would have one item:

You're programming language will succeed because:

[X] It is tied to a popular platform.

Re:Introducing Swift by tptacek on Monday June 02, 2014 @05:47PM (#7836678)
It really doesn't work here, but also, while I appreciate the spirit you pasted it in, that wasn't the spirit it was written in. (And it takes up a huge amount of space).
Re:Introducing Swift by georgewfraser on Monday June 02, 2014 @06:12PM (#7836828)
It is kind of huge. I tried deleting all the non-checked ones but that defeats the purpose, which is for everyone to form their own opinion of what should be checked.
Re:Introducing Swift by jgamman on Monday June 02, 2014 @08:48PM (#7837527)
WTF is usenet?
Re:Introducing Swift by evolve2k on Monday June 02, 2014 @06:42PM (#7836965)
You make some good points but this post is coming across as really snarky. Might be worth lightening the tone some.
Re:Introducing Swift by platz on Monday June 02, 2014 @05:17PM (#7836478)
Re:Introducing Swift by zwieback on Monday June 02, 2014 @05:11PM (#7836435)
upvoted but needs editing
Re:Introducing Swift by mantrax5 on Monday June 02, 2014 @05:15PM (#7836461)
While half of the things you checked in that copy-paste are wrong, let me take the bait and say why it will work:

- it's not just an arbitrary language, it's the new officially sanctioned programming interface for Apple's gigantic, wildly profitable ecosystem

- it's much more concise than Objective-C

- it's faster than Objective-C

- it's safer than Objective-C

- it has more features than Objective-C

- ...yet it's fully compatible with Objective-C and C code running alongside in the same app.

And last, but not least, if you know how Apple works, you know that somewhere in the range of WWDC 2016-2018, Craig Federighi will be on stage, showing a pie chart and saying "Over 92% of developers have ported their apps to Swift, so screw the other 8%, we're discontinuing Objective-C".

Moving fast and constant change is the name of the game at Apple.

Re:Introducing Swift by oldguysrule on Sunday June 08, 2014 @04:26AM (#7864265)
1) So was Java for a bit. It sucked. Developers ignored it.

2) UIApplication.sharedApplication.delegate vs UIApplication.sharedApplication().delegate - nope. It isn’t more concise. It appears to be a wee bit more verbose.

3) Some benchmarks on the web are saying otherwise. It adds extra bridging and ARC for numbers. I don’t see how it can be faster and even if it is - nobody cares about speed. If I need to beat it, I can drop to C, IMP cache, and kick Swifts sorry little ass.

4) Safer - like the TSA says flying without nail clipp ers is safer? It doesn’t solve any problems I actually have. I think my last type error was in 2005 - took about a minute and a half to find it. I routinely work in dynamically typed languages and avoid static typed languages like the plague they are. I’m not opposed to type annotations when they help, but these just look like cargo cultism - like a lot Swift’s silly “features”.

5) It has less features where it counts - basically a less capable object model, weaker meta model, and more budensome interaction with C code than Objective C and a number of useful Objective C features have been walled off. I have Objective C code that cannot be written in Swift.

6) Except for that kind of dynamic stuff like performSelector: afterDelay: withArguments: and that pesky NSInvocation that isn’t available.

There are better projects around than this pile of crap. I will not be porting anything. Quite a lot of code I have can’t be ported.

Java killed WebObjects. Lets not let Swift kill Cocoa.

Re:Introducing Swift by m_mueller on Monday June 02, 2014 @09:20PM (#7837627)
How is Swift safer than Obj-C?

I'm not sarcastic or anything by the way, I just don't understand yet the foundation behind that statement.

Re:Introducing Swift by swiftlies on Tuesday June 03, 2014 @12:20PM (#7841104)
Are we talking about type safety or general security? Either way, Swift does better than ObjC in both regards.

ObjC was exceptionally type-unsafe. Any object type could be implicitly converted to and from the `id` type:

    NSString* foo = @"hello world!";
    id bar = foo; // no warning
    NSDictionary* baz = foo; // no warning
The Foundation collections all used `id` for the values and keys when they had keys. `NSDictionary` will accept any object as a key, even though it will only work if the key is copiable and hashable, and it does mean that you could have keys of fundamentally different types in the same collection. Values can be heterogeneous too.

As far as type safety goes, Swift is on par with modern languages.

ObjC also inherited several security issues of the C language, like unchecked arrays and unchecked arithmetic. Swift performs bounds checking by default (you can manipulate raw arrays with `UnsafePointer<T>`) and has checked arithmetic by default (you can allow overflows by prefixing the operator with `&`, so `&*`, `&+`, etc). It also never requires you to allocate and deallocate buffers yourself.

So Swift is more secure because it has no buffer overflows, no integer overflows (though they're more an issue when you have buffer overflows) and no unsafe memory management. These are by far the three most commonly exploited vulnerabilities in software.

Re:Introducing Swift by m_mueller on Tuesday June 03, 2014 @10:40PM (#7843739)
Thanks for your elaborate answer, I very much appreciate it. After these discussions, Swift sounds like adopting the best of the worlds of fast and dangerous (C, C++, Fortran), slow and easy (Python, Ruby) and slow and safe (Haskell) languages (I'm listing the extreme examples here from my perspective rather than the actual influences to Swift). I especially like the 'safe by default - unsafe optional' stance, since this gives you the ability to create a working program quickly, but still optimise it later through introducing unsafe behaviour. This can allow Swift to be used for HPC purposes further down the road (provided [1] substantial parts will get Open Sourced, [2] it gets implemented on Linux and [3] it gets support for parallel computing both on node, core and accelerator level). Without having worked with it yet, here's what I'd love to get in order to use it for HPC:

-UnsafeButWarn compiler options -> replaces safe versions of arithmetic / arrays with unsafe ones, but issue runtime warnings whenever unsafe behaviour has occurred. Meant for debugging the runtime into never going unsafe, such that checks can be disabled.

-Unsafe compiler option -> replaces safe operations with unsafe ones. Meant for the production version that has been extensively tested but needs to run as fast as possible.

Re:Introducing Swift by oldguysrule on Monday June 09, 2014 @05:09PM (#7870520)
Dynamic typing is not "type unsafe". Objective C objects are completely "type safe". They are actually true objects in that they can receive and potentially handle any message sent to them.

This is an advanced but powerful feature and is in fact exactly what Dr Alan Kay meant when he coined the term "Object Oriented". Any system that has abstract data types that does not have a default message handling capability is not actually "Object Oriented" and the "type safety" brigade strikes me as a bit like depression era prohibitionists. They can't handle it so nobody should have it.

The "type safety" thing is a myth. I have worked on colossally sized systems written in PERL/Mason, PHP, Ruby, Smalltalk, Java, and C++. You'll note that all but the last two are "type unsafe" by your definition and yet I think my last "type related" error was sometime around 2003.

Also, not all collections are meant to be homogeneous.

>ObjC also inherited several security issues of the C language, like unchecked arrays

Objective C developers use NSArray and NSString. Raw arrays and pointers to raw memory are beyond exceptionally rare in Objective C. This is just more prohibitionist propaganda. In the cases where there really are raw memory accesses - you need them - but for the most part Objective C provided safe alternatives and were used heavily (NSData for instance rather than raw arrays and NSString instead of arrays of char).

Nobody is going to do audio or video processing in Swift. The CoreAudio team used C/C++ because when you need performance, you need performance and bounds checking is inefficient.

I heard this sermon from the C++ people in 1992, and then the Java people in 1998 - there's nothing new here and the myth of "type safety" vs "type unsafe" still isn't really true. It is just a lot of baggage and lost capability we are being sold here.

Raw C is potentially unsafe. Objective C - not so much. You can write quite a lot without even using a pointer (apart from id - a safe dynamically typed pointer).

Re:Introducing Swift by KMag on Tuesday June 03, 2014 @12:52PM (#7841304)
For one, Swift avoids what Tony Hoare calls his Billion Dollar Mistake (conflating optionality and reference types). Because Tony Hoare introduced null references to Algol W, most Algol-derived and Algol-inspired statically typed languages since have made all pointers/references nullable. Some, like Java, have bolted on Lint-like null checkers an afterthought (see @Nullable, @NotNull) outside of the official compiler.

It's really nice to have the compiler not allow callers to pass null to functions where passing null wouldn't make sense, isn't useful, or the programmer was just too lazy to implement null checks. More than half of the functions I write have inputs where null wouldn't have an obvious meaning.

Objective-C's treatment of nil receivers is particularly handy for programming in the small and particularly bad for programming in the large. Sending a message to nil (similar to calling a method on null in many other languages) does nothing other than returning 0 cast to the type of variable you're storing the return value in. Chugging along accidentally accumulating nulls in many cases is worse than segfaulting and giving a nice stack trace.

Certainly in the realm of automated trading software, segfaulting when hitting a programming error is preferable to most other failure modes. Of course, failing to compile is often (though not always) the best failure mode.

Re:Introducing Swift by orkoden on Tuesday June 03, 2014 @07:15AM (#7839344)
It does not have features that often lead to bugs. E.g. the switch statement does not allow fall through and enforces a default case.
Re:Introducing Swift by m_mueller on Tuesday June 03, 2014 @10:42PM (#7843743)
The lack of fall through makes me a bit sad since I think that it's a very powerful programming construct and it usually only hurts people new to the concept - but of course one can live without it.
Re:Introducing Swift by mantrax5 on Wednesday June 04, 2014 @01:54AM (#7844212)
Three things.

First of all, while you can't do this:

    case val:
    case val:
    case val:
        ...
You can do this in Swift, which does the same thing:

    case val, val, val:
        ...
Second, you can fall through in Swift, but you need to ask for it:

    case val:
        ...
        fallthrough
    case val:
        ...
So don't be sad.

And third... Seriously now, it's a "very powerful programming concept"? I bet 9 times out of 10 you use this very powerful programming concept in other languages, you did it by accident, not because you needed its pawa.

Re:Introducing Swift by m_mueller on Wednesday June 04, 2014 @03:57AM (#7844477)
Thanks for the clarification on how to use it in Swift - like this it's indeed the perfect solution by enforcing it to be explicit. Having multiple cases rolled into one is also a very nice option. The snark wasn't really called for though. No, I don't 'use' it by accident, that would in most cases just become a bug. I use it when it makes code more concise rather than having nested ifs. Consider for example ACL rules where you set different privileges by default according to an access level.
Re:Introducing Swift by cratermoon on Monday June 02, 2014 @05:35PM (#7836604)
There's no real objective measure for either 'conciseness' or 'safety', in general terms. Whether or not it's faster in the real world is yet to be seen, and creeping featuritis has never been the hallmark of a great programming language.

It makes good press release and marketing speak, but those assertions are a long way from making the OP 'wrong'.

Re:Introducing Swift by gtrak on Tuesday June 03, 2014 @12:35PM (#7841199)
There are objective measures. There aren't necessarily 'absolute' ones.

Lisp is relatively more concise than C or Java for the same tasks.

Java is relatively safer than C for the same tasks.

Re:Introducing Swift by cratermoon on Tuesday June 03, 2014 @04:30PM (#7842534)
How objective can something be if the criteria vary depending on the comparison?
Re:Introducing Swift by gtrak on Wednesday June 04, 2014 @01:39PM (#7846984)
I'm not sure what you mean.

Lines of code is an objective measure. How meaningful that might actually be, well, that's subjective.

Re:Introducing Swift by mantrax5 on Monday June 02, 2014 @06:08PM (#7836806)
So you take a language with null pointers, unsafe pointer access, possibility of array and buffer overflows (C and Objective-C).

And then you take another where you have no null pointers, no direct pointer access, and no possibility for array and buffer overflows (Swift).

And you say "nah, I look at these two, and I can't objectively tell which is safer"? Are you fuckin' kidding me?

Regarding speed, it's been proven faster by benchmarks, and by the fact the very reason Swift doesn't mix C types and Objective-C types is so the compiler can better reason and optimize the resulting code.

Re:Introducing Swift by Pacabel on Monday June 02, 2014 @07:26PM (#7837166)
I think you're putting words into his mouth, and perhaps intentionally misrepresenting what he wrote.

Swift was announced just a few hours ago. While we can make assumptions about its safety based on its feature set, or we can assume that the very vague performance details Apple provided are valid in a real-world setting, none of this has really been tested or verified independently yet.

What cratermoon wrote is perfectly legitimate. Let's try Swift out in the real world, perhaps for a year or two. Let's get some real data. Then let's analyze that actual data, rather than engaging in unsubstantiated speculation, or trusting some vague performance graphs shown in a conference presentation.

Re:Introducing Swift by mantrax5 on Monday June 02, 2014 @09:32PM (#7837654)
I'm not misrepresenting what he wrote, I'm directly responding to it.

While you may not be aware with recent language development and modern LLVM-based languages in general, to me and many others what was announced at WWDC today wasn't just a set of buzzwords and marketing speak.

Anyone who has been into language design and watched the keynote today can make a pretty good guess about the properties of Swift. There's a book with hundreds of pages of examples and description of the language semantics on iBooks right now. I've been reading it before I posted. I've been playing with the beta Xcode as well.

Swift is not revolutionary in terms of its feature set. But what makes it quite interesting is the fact this is now an official language for Apple app development, and it's quite a bit ahead of Objective-C in... yes. Safety, performance and conciseness. Fact.

Re:Introducing Swift by Pacabel on Monday June 02, 2014 @09:45PM (#7837692)
I'd prefer to see how it fares in the real world before jumping to such conclusions like you seem to be so willing to do.

You may not have been around to experience it first-hand, but we heard a lot of claims made back in the 1990s about how Java and the JVM would increase security and safety.

The arguments made then even overlap with some of those being made in this case! The lack of direct pointer access and manipulation, automated memory management and better bounds checking are some examples of the arguments used then and now.

Yet if you work with computers at all, I'm sure you'd know that many of those claims did not materialize. Flaws have been found in the various implementations of Java and its VM, and these have affected its security and safety in very serious and significant ways, many times over.

Perhaps things are different in the case of Swift. But we won't be able to say for sure until later on, once it has undergone some significant real-world use.

Re:Introducing Swift by mantrax5 on Monday June 02, 2014 @10:06PM (#7837751)
And you're telling me... with a straight face... that Java's lack of direct pointer access, automatic memory management and bounds checking do not make it safer and more secure compared to C and C++?

You really should stop talking.

Re:Introducing Swift by Pacabel on Monday June 02, 2014 @10:12PM (#7837772)
That's obviously not what I wrote, and you would know this had you bothered to read my comment.

I'm saying that such features alone do not actually guarantee safety, if the language's implementation happens to have flaws.

There hasn't been sufficient time and opportunity to see what Swift is like in practice. It's premature to say anything conclusive about it at this point, aside from stating that we don't yet have enough information about it.

Re:Introducing Swift by mantrax5 on Monday June 02, 2014 @10:23PM (#7837800)
The "flaws" discovered in Java aren't in the language, but in the most popular JVM implementations, most of which - surprise - are implemented in C (for the lack of a better alternative).

Writing in Java still remains monumentally harder to fuck up in compared to writing all your code in C or C++.

Furthermore, while Java relies on said relatively complicated interpreter + JIT virtual machine for its execution, Swift has no such virtual machine. All code is analyzed statically and compiled to machine code. The Objective-C runtime which it uses (which is not new - it's the same fucking Objective-C runtime) is a tiny C library, which implements a few basic low-level routines, such as dynamic message-to-method resolution.

So next time it's best for you to shut your mouth if you're ignorant about an issue, than telling people who know better than you to "wait for conclusive evidence".

Re:Introducing Swift by pjmlp on Tuesday June 03, 2014 @03:16AM (#7838528)
I am looking forward to see if Graal[1] replaces Hotspot in Java 9, thus replacing the amount of C/C++ code in the reference implementation.

[1] Oracle's JIT implemented in Java, from the meta-circular JVM Maxime

Re:Introducing Swift by oldguysrule on Monday June 09, 2014 @05:15PM (#7870559)
And quite a bit behind in flexibility and dynamism.

Giant step backwards. Vtables? I don't think so.

override keywords? WTF? Its not so much they removed the C as the "Object".

Re:Introducing Swift by badman_ting on Monday June 02, 2014 @05:10PM (#7836418)
Thanks for posting!