
Swift WTF - constexpr
http://swiftwtf.tumblr.com/
======
empthought
"Xcode 6 beta 3." AKA some software that was never released generally, from
July 2014.

~~~
faitswulff
I thought that was curious, so I put one of their code samples to the test:

Swift WTF:
[http://swiftwtf.tumblr.com/image/88465530183](http://swiftwtf.tumblr.com/image/88465530183))

But it looks fine on my machine (Xcode 6.2):
[http://imgur.com/rJU7lcx](http://imgur.com/rJU7lcx)

------
beltex
_“Most perplexing feedback on Swift: folks who see it (and judge it) as the
end of a trek - but don 't realize it is the start of a new world.”_

Chris Lattner

[https://twitter.com/clattner_llvm/status/474082459860992000](https://twitter.com/clattner_llvm/status/474082459860992000)

------
zak_mc_kracken
I predict this blog will run out of content real fast. I also notice the
author conveniently left out the timestamps for their posts.

Swift is still very new, crashes in the language and in the IDE will not
surprise anyone who calls himself a software engineer.

I don't write code on iOS or MacOS but Swift looks very solid to me and an
obvious improvement over Objective C.

~~~
le_lenny_face
>Swift is still very new, crashes in the language and in the IDE will not
surprise anyone who calls himself a software engineer.

And yet Rust is reliable as fuck even in its current shape.

Swift has no excuse to be so unpredictable, especially given that it's back by
a humongous commercial company.

~~~
pcwalton
> And yet Rust is reliable as fuck even in its current shape.

I appreciate your vote of confidence in the team, but Rust has been in
development for five years at this point, while Swift hasn't. :)

~~~
bydo
Swift started private development in July 2010.[1] So not quite five years,
but pretty close.

1: [http://nondot.org/sabre/](http://nondot.org/sabre/)

------
woah
Learning iOS dev, coming from a js background, I have very few complaints
about swift. It is in fact a very nice language.

The biggest pain is apple's frameworks and ide. The APIs are very inelegant
and arbitrary. The worst thing is the drag and drop interface builder. I
believe that the people who designed it never actually built an iPhone app
with it. You can always get about 80% of what you want, then you have to
resort to some outrageous hack and stitch the rest of it together with verbose
imperative code. Declarative web dev with html really is a huge step up from
Apple's stupid drag and drop thing.

Hopefully Swift is the start of Apple putting together a sane, modern
development environment.

~~~
JimDabell
> The biggest pain is apple's frameworks and ide. The APIs are very inelegant
> and arbitrary.

I can't agree with that at all – Apple's frameworks are among the most
consistent I've ever seen. They have a small number of solid design patterns
that they stick to that serve them very well. Picking up new frameworks is
usually extremely easy because of this consistency. They are _far_ beyond
JavaScript in this respect.

> The worst thing is the drag and drop interface builder. I believe that the
> people who designed it never actually built an iPhone app with it. You can
> always get about 80% of what you want, then you have to resort to some
> outrageous hack and stitch the rest of it together with verbose imperative
> code.

Interface Builder certainly has its shortcomings, but the most frequent
complaints I see about it are from people who haven't taken the time to learn
it properly and fall back to imperative code in preference to learning how to
use Interface Builder properly.

Also, 80% declarative UI and 20% imperative code is a pretty fair mix – unless
you are designing extremely simple applications, you shouldn't expect to put
together an entire user interface using nothing but drag and drop tools.
That's not an effective way to work regardless of the quality of the drag and
drop tools.

> Declarative web dev with html really is a huge step up from Apple's stupid
> drag and drop thing.

They are really two different worlds. Most of the time, one or the other is
clearly the better choice for any given project, but it doesn't really make
sense to say that one is better than the other overall.

~~~
woah
Idunno... its a matter of opinion I suppose. But a drag and drop editor is
just foolish, and they have never worked well. Here's how you adjust kerning:

[http://stackoverflow.com/questions/7370013/how-to-set-
kernin...](http://stackoverflow.com/questions/7370013/how-to-set-kerning-in-
iphone-uilabel)

They really should have woken up and done a nice markup language and a styling
language to go with it a very long time ago.

~~~
JimDabell
> a drag and drop editor is just foolish, and they have never worked well.

They work great for what they are designed for if you learn how to use them
effectively. If you use them for things they aren't designed for or you assume
that just because it's a GUI editor you can click around and build things
without knowing what you are doing, then you're going to run into problems.
This is not a problem with the tool.

> Here's how you adjust kerning

No, that's how you adjust kerning if you want to do it manually as a one-off
task. It's trivial to wrap that up into something you can use in Interface
Builder for day-to-day work.

This is exactly the kind of thing I was referring to wit the 80/20 split I
mentioned. You use Interface Builder to create your user interface. It's not
Photoshop. Fine control over the details, such as character-by-character
adjustment of kerning, is more effectively done elsewhere. But just because
you don't have Photoshop-level control over the details, it doesn't meant that
it's not a great tool for the other 80% of GUI work.

I also don't understand how pointing out how to do kerning with code is a
criticism of Interface Builder. You realise that if you create all your GUIs
by avoiding Interface Builder you still have to use those APIs for kerning?
That's not how you do kerning in Interface Builder, it's got nothing to do
with Interface Builder. That's how you do it in code.

------
gleenn
The equality and truthiness oddities are the worst. One of my biggest pet
peeves about languages is weird equality rules. PHP is one of the worst, there
is a huge table of crazy rules that I suppose expert PHP people can remember,
but it just seems crazy.

Languages like Ruby and Clojure have it best: nil and false are falsy,
everything else is truthy.

~~~
AnkhMorporkian
PHP is pretty bad, but I think JS really takes the crown for insane equality
comparisons. Basically every weird equality comparison from PHP is in JS,
along with some other humdingers like 0 == [].

And my favorite, '\n\r\t' == 0

~~~
quarterto
There is _never_ a good reason to use ==.

~~~
AnkhMorporkian
I totally agree, but they were bringing up the insane equality rules in PHP
using the == operator, so I did likewise in Javascript. Both languages luckily
have fantastically logical === operators.

------
guru_meditation
The examples look really scary.

So far I understood Swift to be the next big thing in terms of hot programming
languages with a functional flavor.

Those more proficient with Swift, are posted screenshots manifestations of
bugs or are we seeing correct output?

Hoping these are bugs that have been fixed in the meantime.. otherwise this
reminds me of Javascript type promotion..

~~~
sho_hn
> So far I understood Swift to be the next big thing in terms of hot
> programming languages with a functional flavor.

Swift is tightly coupled to Apple's platforms (which are of course
commercially very viable, and if you develop for them you should be looking at
Swift), under a proprietary license and developed under closed governance.
It's a legitimate product, but under those circumstances it doesn't really
have a shot at being a NBT in _programming_ by _itself_ , beyond contributing
its ideas to wider discourse.

It's obvious that no generally relevant library/infrastructure will be written
in Swift, for example; if anyone with a great idea choses to implement it in
Swift first for whatever reason, it will be a reimplementation in another,
more widely useful language that gains widespread popularity.

~~~
chongli
What does NBT stand for?

~~~
sho_hn
"Next Big Thing", taken from the OP.

------
valevk
"There are only two kinds of languages: the ones people complain about and the
ones nobody uses."

~~~
s_kilk
Swift may in fact be the exception to that rule, as everyone complains about
it and almost no-one uses it ;)

~~~
itg
If the ones complaining don't even use it, it says much more about those
people. ;)

------
MCRed
This blog is from when the language was first announced, yet most people
commenting seem to think it is current, and thus imply that SWIFT is in worse
shape than it is.

Flagged.

------
i_s
Are all the issues with Swift to be expected, or does it seem like there are
more issues with Swift than one would normally expect normal from a new
programming language?

------
drinchev
IMHO those bad examples are more or less bad, because of the high expectations
and reputation of the company that released the language. Having in mind the
age of Swift this site would not be so surprising if behind it there was a
smaller team.

It would be really better if Apple go back in time and release working
products in their first version. I understand having so big user (developer)
base is hard, but as far as what we see from the financial reports they can
easily afford having better software, by improving some development processes.

~~~
oldmanjay
you classify a problem you don't even fully understand as easily solved
because you're willing to spend other people's money freely. you have upper
management written all over you.

~~~
drinchev
Great reply, although I was hoping to make a discussion out of this.

Negative sentences doesn't contain as much information as positive ones.

"I don't like what you like" carries less information than "I like [something
different]".

In other words. If you tell me what your opinion is I might change mine too.

