News for hackers. Stuff that matters.
Re:IBM says Swift is ready for the enterprise by superJimmy64 on Monday September 26, 2016 @09:11AM (#12581469)
I literally just started to go back and re-learn some of the core concepts for the latest version... wow is Swift ugly!

EDIT: I'm not attempting to discredit the greatness that can be had... Just wanted to describe a feeling which I had while using it is all!

Re:IBM says Swift is ready for the enterprise by ebbv on Monday September 26, 2016 @09:15AM (#12581497)
I don't see how your second sentence follows from the first one? It's true that Swift is heavily type safe but that makes it appealing to me. I actually really enjoy writing Swift.

Would you rather it were dynamic so you could write less code or something?

Re:IBM says Swift is ready for the enterprise by superJimmy64 on Monday September 26, 2016 @09:18AM (#12581514)
I should have specified that it wasnt an attempt to put down the language, as there are many, MANY caveats... only wanted to point out how writing it almost makes me feel unclean somehow hah
Re:IBM says Swift is ready for the enterprise by manmal on Monday September 26, 2016 @09:14AM (#12581487)
It's a systems language, and imo way more beautiful than c++.
Re:IBM says Swift is ready for the enterprise by superJimmy64 on Monday September 26, 2016 @09:16AM (#12581503)
Absolutely. I'm not attempting to put it down as somehow not worthy of anyones time, just thought I'd mention how "cushioned" it all felt :P
Re:IBM says Swift is ready for the enterprise by manmal on Monday September 26, 2016 @09:20AM (#12581531)
What language do you prefer over Swift? I'm curious.
Re:IBM says Swift is ready for the enterprise by snovv_crash on Monday September 26, 2016 @11:43AM (#12582766)
C++11 with review-enforced RAII. Boost if you need special stuff involving odd data structures. gtest/gmock. Depending on what you're doing, add some Qt5, OpenCV, OpenMP, RapidXML/RapidJSON, any C library ever written - and there are BSD/LGPL libraries for pretty much anything. Make plugins with Lua. Run tests in Valgrind.
Re:IBM says Swift is ready for the enterprise by superJimmy64 on Monday September 26, 2016 @09:30AM (#12581617)
I'm not sure I would choose something over the latest version, primarily because of how little a time investment using it can be... but then again it all comes down to what the task at hand is doesn't it ;P
Re:IBM says Swift is ready for the enterprise by themihai on Monday September 26, 2016 @09:36AM (#12581665)
Yeah but it can't replace C++. Swift was designed to make programming fun/nice not to replace C or C++.
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:07AM (#12581895)
"Swift is intended as a replacement for C-based languages (C, C++, and Objective-C). "

Taken from https://swift.org/about/

"Swift is a successor to both the C and Objective-C languages."

Taken from https://developer.apple.com/swift/

Re:IBM says Swift is ready for the enterprise by themihai on Monday September 26, 2016 @10:15AM (#12581950)
Swift can't do realtime. It has automatic memory management. How do you replace C or C++ with Swift for that? What they mean is that Swift replaces Objective-C on user facing apps(on Apple devices) but I doubt you will see the critical parts of the OS (kernel, drivers, etc) written in Swift.

It's almost like saying javascript will replace C/C++. I want a nice language like Swift (or Go) to replace C but there is none. Rust was the best/latest failed attempt.

Re:IBM says Swift is ready for the enterprise by mikeash on Monday September 26, 2016 @10:22AM (#12582009)
You can essentially write C in Swift by using UnsafePointer and such. If you avoid using reference types then you won't get any automatic memory management. I don't think it's quite ready to replace C as a kernel or driver language, but it's not that far off.
Re:IBM says Swift is ready for the enterprise by themihai on Monday September 26, 2016 @02:42PM (#12584457)
Is there any open source library that does that? I know in theory many things are possible but it would be great to actually test it/see it in action. I never thought of Swift as a language with zero cost abstractions and deterministic performance. If it works I think it really gives it a leg up.
Re:IBM says Swift is ready for the enterprise by mikeash on Monday September 26, 2016 @02:49PM (#12584520)
It's pretty uncommon, so I'm not sure. If I may toot my own horn a bit, you may find the code to my memory dumper interesting:

https://github.com/mikeash/memorydumper2

I also gave a talk on this subject a couple of years ago. It's out of date by now, but the basics are still more or less intact:

https://vimeo.com/107707576

Or peruse the standard library documentation for UnsafePointer, UnsafeRawPointer, UnsafeMutablePointer, and UnsafeRawMutablePointer. These are built-in types that the compiler knows about, and code that uses them should compile down to essentially the same stuff as C pointer code would.

Re:IBM says Swift is ready for the enterprise by aaronbrager on Monday September 26, 2016 @10:31AM (#12582101)
This is especially true in Swift 3, which has many improvements around this type of programming.
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:32AM (#12582118)
> Swift can't do realtime. It has automatic memory management. How do you replace C or C++ with Swift for that?

Of course it can, it is just a matter of OS vendors caring to push it down developers throats.

There are ways to manually manage memory if required to do so, but then you suffer the consequences of dealing with Unsafe*.

Re:IBM says Swift is ready for the enterprise by mpweiher on Monday September 26, 2016 @10:20AM (#12581994)
Those are the claims. The reality does not match those claims.
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:30AM (#12582085)
Not, yet.

That is how systems programming languages get adopted, when OS vendors do "my way or the highway".

Re:IBM says Swift is ready for the enterprise by superJimmy64 on Monday September 26, 2016 @09:39AM (#12581697)
Agreed. Certainly if the dev has any regard for things like performance and security
Re:IBM says Swift is ready for the enterprise by mpweiher on Monday September 26, 2016 @09:24AM (#12581564)
It's not really predictable enough for a systems language.
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:09AM (#12581905)
Can you predict what your C compiler with going to do with your code, taking into account UB and compiler specific implementation behaviors not specified by ANSI C?
Re:IBM says Swift is ready for the enterprise by mpweiher on Monday September 26, 2016 @10:19AM (#12581979)
More than with Swift. I routinely see 100x - 1000x and more performance difference between -O0 and -O in Swift. Considering that the optimiser doesn't give warnings or errors if it can't apply optimisations, that's out of bounds for me for a systems programming language. YMMV.

The whole UB idiocy is a different matter, though related because it's perpetrated by roughly the same group of people, for similar nonsensical and non-validated reasons. See my post http://blog.metaobject.com/2014/04/cc-osmartass.html

See also: http://www.complang.tuwien.ac.at/kps2015/proceedings/KPS_201... and Proebsting's Law.

Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:34AM (#12582133)
> More than with Swift. I routinely see 100x - 1000x and more performance difference between -O0 and -O in Swift. Considering that the optimiser doesn't give warnings or errors if it can't apply optimisations, that's out of bounds for me for a systems programming language. YMMV.

Improvements required for the toolchain in a young language, than Apple, IBM and others will certainly improve.