Swift is the only language I could find with

July 31, 2021, 9:34 am
Swift is the only language I could find with
Swift is the only language I could find with over 100 keywords. The next closest was PHP at 78. No wonder everyone`s code is so over-complicated. It`s a kitchen sink language that doesn`t know what it wants to be. What`s so special about iOS and Mac apps that requires this?

I don`t think there`s anything that requires it but I think Swift is a pretty nice language. Not perfect but just good enough that I prefer to use it over most other languages.

Are you implying that code written in C++ is easier to read than code written in Swift?

If doubling the number of keywords makes mature developers 10x more efficient it could be a worthwhile compromise. Dubious but possible.

Why did you exclude JavaScript?

Where does JavaScript fit in here?

I wonder how C compares. Writing code in Swift gives me C vibes at times. Allowing you to bolt down how your code is to be used by others, and Im not sure thats a compliment. However, Ive always admired how the language made ref counting invisible in a way obj-c couldnt.

While the science here is flawed I believe the OPs intent here is to address Swifts ever increasing complexity & bloat. Seems like every syntactic suger proposal is approved these days & enables an ever increasing no. of ways to achieve the same task. When is Swift finished?

Why Swiftlang people defend ! Swift is a great replacement for Objc-c. That doesnt mean the lang is not complicated.

Nothing special , Its indeed a complicated language. I used to believe its getting close to C++. Now i think Swift is over C++

There are: - 357 reserved words in COBOL 85 ( - 826 reserved words in SQL ( - 978 symbols in COMMON-LISP ( - Over a million words in English ( Its a trap to think simplicity of a language makes it easier to program. 6502 assembler has only a handful of instructions and addressing modes, but quite difficult for most programmers.

Low key, Swift is really nice to work with, the second best imo is Python

Interesting information. But I think those keywords all have some purpose. Maybe some of them save you from writing hundreds of lines of code inventing that functionality?

C++ as of C++20 has more than 100 including preprocessor keywords. As to complexity, I dont know Swift, but C++ scores well in the kitchen sink department.

There is no correlation between complexity and keyword count. Brainfuck has exactly 8 keywords, yet is infinitely more complex as a programming language. SQLite has 147 keywords: Collin out here just fishing for a ratio

Yeah, that`s quite accurate to the core base used in Swift the real mess circus really starts with additional labels behind `@` since Swift 5.x

Omg youre right, it actually has infinity operators so it is definitely the worst language ever!

Insulting the language is unnecessary.

I write it down on my wall

Go has 25 keywords and ~30 operators.

Swift isnt only for iOS or Mac. Duh.

Kitchen sink is correct. The rabbit-hole runs very deep in a language that is governed by no principles of simplicity but rather an obsessive-compulsive fascination with shorthand syntax and wrappers. See If youre counting swifts attributes and decl modifiers (which look superficially like keywords but are not) then you should count all the options to __attribute in C in its column. Otherwise remove them.

i have no opinion on swift.... but is keyword count really the best way to measure readability? more keywords could lead to more expressive code, fewer more verbosity... more expressive code means more functionality fits on a screen and hence may be more readable

It`s Apple-crap, what did you expect?

Yeah. It has me interested in how one would accurately measure the size of a language, so props for that. Really. :)

The contrast to Kotlin is particularly stark.

Wow! Now I understand how Smalltalk got its name. Swift should be renamed BigTalk

Swift is just a ploy to get developers to voluntarily restrict themselves to only being able to develop for Mac/iOS. Same as Objective C was.

Swift was designed to be a better C++ (source: Lex Fridman interview.) One might argue this kind of bloat is inevitable with that aim.

Still very much a work in progress, and feedback welcome!

Objective-S does include a Its very much early days, but theres also the idea of incremental working, but without lugging around one big soup of everything.

It`s SQL turn now.

Try the guard statement and unwrapping properties. Those are just amazing features. Doesnt require a bunch of additional code and protects from errors and exceptions.

You`re getting categorized by Twitter very oddly And who proved that "minimal syntax" is the best way to optimize for reading and understanding? We would all should be using an assembly with like 10 keywords if that was the case...

Proprietary code Apple won`t share with the world is my guess.

You know you dont have to use all 100. Are you honestly complaining about having many tools at your disposal?

In a real world, a language with many words and vocabulary, is a rich language that you can use to express in richer and more precise ways that you want to communicate. I like a real world programming language.

I thought it would be C

Wow :0 this might explain why there are not much swift developers out there!

Also Property Wrapper add thing "invisibly": from `aPW`, you get projected value `$aPW`. And with newly added property wrapper on func/closure parameter, projected value `$xxx` param, you get `xxx` to access the wrappedValue. Can`t tell by looking at call site or the api...

Don`t forget property wrappers, which aren`t exactly keywords but are a requirement for SwiftUI work. On the other hand, I`d argue SwiftUI`s standard library is way easier to learn than C++`s.

And here I count 80 (the ones starting with like colorLiteral I dont count) - 98 if you count them in. So I dont understand these numbers. The only statistics you can trust are the ones you falsified yourself.

IDK, I was taught to know a platform you needed to know the language, the frameworks, and the IDE. I recently switched to write a new app all in swift. I am an Obj-C diehard because I grew up on both SmallTalk and C. I can write poetry in Objective C. NewApp required somewhere...

I only count 71 here and they count multiple that I wouldnt call a keyword like __LINE__ or true: Do you have any source for these numbers? Can you enlist all keywords in Swift? Id be interested in what counts as a keyword in Swift and what doesnt in others. Swift is much simpler to use than most of these languages listed to me. Maybe its all due to ObjC interop?

PL/compilers nerd here. Honestly the number of keywords vs complexity of language vs complexity of things built with it arent correlated as far as I understand.

Did you try any of Cobol variants? would assume that would be much higher.

Theyre maybe stretching what a keyword is, but I counted 189 keywords listed in the first section of this page about Visual Basic. And 37 unreserved keywords on top of that. SystemVerilog has 248 keywords. Swift is way nicer to use. Interesting, it would be cool to see more languages in this chart, specially for functional languages.

Yeah, Swift has like 100 ways of declaring the same thing, which becomes hard to read as every developer chooses their preferred way, over from all the possibilities.

I believe that for most people it is a better alternative to Objective-C and its raw pointers and tricky memory management (although I personally do like how elegant it can be!) The hard part really is calling dozens of complex and/or fast deprecating APIs (AVFoundation, Metal)

Honest question: why do you claim that a higher number of keywords in a programming language means the language is aimless and causes programs in said language to be over-complicated? What else backs up that assertion? That feels like a very odd jump in conclusion.

Regardless of the validity of counting keywords as a measure of complexity, I do feel like Swift got overly complicated and it would`ve been better to have a powerful macro system like Rust to accomplish some of the things that were added instead.

Nothing. I really feel for iOS devs. My switch to JS from Swift/iOS has turned out to be the best decision of my career.

Which blockchain is working on swift language right to this day ?

becoming bipolar, shuttling between golang 25 and swift

Swift is when iOS and macOS

please make sure that, for C++, the keyword `static` is counted 3 times (and for C, 2)

Its not over complicated as a language, the issue is compatibility with old Obj-C libraries and technologies. Swift as a language is a charm

Not to be missed though is that Smalltalk and Lisp combine the parsimony of the languages with a rich set of tools and libraries.

More complex language for less complex frameworks?

Nothing, but its not a language designed just for iOS and Mac apps. Im aware that the stuff for low-level systems programming isnt really there yet, but AFAIK its still part of the goal.

I`m not sure how definitive this list is, but apparently VAX COBOL had ~550 "reserved words." Have you looked at Objective-S? It tries to do for the 20s+ what Smalltalk did for the 70s/80s. Nothing. To quote Garfield: Ask fish to fetch paper, paper is wet. Ask cat to fetch paper, paper is hole-y. Ask compiler engineers to design a language, you get a lot for the compiler to do.

Larry Wall regarded "kitchen sink" as a design goal, to have whatever features you found useful elsewhere. Go on add Perl. Isn`t a considerable part of this interop stuff like objcMembers, dynamic, selector, keyPath, convention and so on? I think these shouldn`t be considered as "swift keywords" per-se.

Though I do agree in principle with the fact that Swift is becoming more and more complex, the good thing is that one doesnt need to know its full spectrum in order to use it successfully

To me, Swift`s large keyword set is sorta symptomatic of the fact that it`s being created during a moment where the whole industry has been re-assessing what idioms make for approachable code and how they should be taught to people starting out.

C has 131 keywords, and 488 distinct syntax elements (including those 131 keywords). winning

Its interesting comparison. Maybe it means Swift is hyper flexible?

I think this is misleading because other languages address these things with tools like macros, effectively creating dozens of secondary keywords.

Counting keywords to determine language complexity is as useful as comparing LoC of Hello World programs.

C has 79 reserved words -- it is actually very Swift-like in terms of kitchen sink these days. JavaScript has 60.

Also which version of c++? C++20 adds some over c++17.

Counting keywords is a really weird measure of language complexity for a few reasons. - Different languages have different notions of what a "keyword" is.

This just means that Swift is a very well designed general purpose language. Most other languages have evolved from a specific domain. You don`t need to understand the full language to use it in a specific domain

I wonder does having more keywords also affect compile times? Swift has had not so great compile times for a while now.

What about Objective-C, how many keywords?

oof I dont like Swift slander I love Swift and all its imperfections What C++ version did you use?

Whats your goal with these posts?

What`s your definition of keywords? Because depending on that, HyperTalk either has lots more, or zero <_<

Which version of Swift?

Youve got some good points here.

Whats weird isnt even that Swift is too complicated as how its complicated in exactly the opposite way that Objective-C is simple and elegant. Its a strange language to try to have fans of Obj-C adopt.

I think it`s because all languages try to be the magnum opus of languages. That`s certainly the case with newer ones. talked about that a lot. Everyone wants to be the last language you`ll ever need.

It`s about providing an interface and is useful for templating. I`m talking about C++ by the way, not swift. That`s why the libraries have things like that.

is it Swift 5.5 by any chance?

Pascal and C were the first languages I wrote actual programs in. I even had to learn some Modula-2 at uni for good measure. Imagine my joy of learning to structure code by mere indentation in Python. And that literally happened only this year. :)

Enjoy the read! :)

Its the most enjoyable book about computing history Ive read thus far. It was this paragraph (towards the top of the page) about the most powerful language in the world on a page of code that your tweet about Smalltalk`s entire syntax fits on a postcard reminded me of. the wrong chart. Here`s the same chart with Java and Kotlin added. And just like that I have it on Kindle and Audiobook. Thanks for the recommendation!

Adding Java with 57 at a sweet spot

Have you read Dealers of Lightning yet? Youd really enjoy that book about the history of Xerox PARC, Im sure.

Im loving those square brackets, too.

Sure. But when every change brings with it just 6 keywords you end up with over 100 pretty quickly. I think Id be just as happy if SwiftUI and other features looked a little less pleasing in the editor but added a little less complexity to the language.

There is stuff I like about SwiftUI (not dealing with constraints any more is heavenly), but in some respects it all feels a bit too magical for my tastes. Some of that may be because its relatively new to me and itll improve as I learn, but maybe not all.

I do sometimes think that Swift was designed with a bit too much deference to computer language enthusiasts. Im less interested in the language than what it can help me easily create. The value of some of this stuff is dubious to that end.

I appreciate this tweet. I get the desire to add more to a language to support great features like SwiftUI, but (as someone who has been on top of Swift since 1.0) I notice more and more blocks of code that I read and think, wtf is this even doing!? Thats not good.

Ngl now Im kinda curious to see a list of all the possible keywords

I understand there are cool things enabled by Swift, but there are cool things in all these languages. Smalltalk`s entire syntax fits on a postcard and is as cool as anything. The hardest part of programming is reading and understanding other people`s code. Optimize for that.

This isn`t taking things like operator overloading and function builders into account, so you have a language inside a language that almost looks like a different thing altogether.

 
Sponsored links