Swift is great. For MacOS, iOS and iPadOS. But it’s not good for other things. How is that, you ask, a language which is good for MacOS is not, for example, good for server-side Linux? Or since you can script it, why isn’t it better than PHP?
Well the short answer is target environment, which I have come to understand — as the epiphany of my long programming career — to be the king of all languages and language choices.
As of now my son and I have reviewed more than 10 languages. And one thing keeps cropping up; for each environment there are a series of languages which are best suited to that environment. For example, as long as command lines exist, C will exist — because C is, de facto, the command line; along with it’s stdin and stdout and stderr.
As long as Linux and Windows will exist, C, C++, Java and C# will exist — as well as a handful of other, smaller languages.
As long as MacOS exists, Swift, and likely Objective-C (all rumors to the contrary) will exist. You simply do not deprecate 20 years worth of codebase, 50% of which your OS is written in, overnight. It’s always going to be there, available, even for many years after everyone stops using it.
So when it came time for my son and I to write our first real application, we considered one environment and one environment only; the web. Why is simple; all consumer computing platforms today fall into one or more of of three categories:
- The ability to consume media (play games and/or watch tv, movies, music, etc)
- The ability to create media (content creation including programming)
- The ability to surf the web.
Now look around you. While many computers exist to do #1, and many exists to do #2, and some even can do both, all computing platforms can do #3. In fact, performing #3 is more important than doing #1 or #2. Look at the iPad and iPhone and Android phones and tablets. Long before they could seriously perform tasks #1 and #2, they were designed around being able to perform #3 as a primary function. In fact, it could be argued that without being able to do #3 it would not matter how great a computing product was, no one would buy it.
#3 is really code for “the internet”, which is the target environment which all computers use as a standard environment. By environment I mean a GUI of some sort (Windows, Cinnamon, MacOS, iOS and so forth), a command line (shells of various sorts), server-side, and other. For example a command line program for Linux simply will not run on iOS; the two target environments are different. This is reflected in what is considered a “standard library” to each kind of program.
The Most Interesting Target Environment in the World
The Web is the most interesting target environment in the world because it is not designed as an operating system; and it is not designed as specific hardware; but now, the browser itself has become a virtual machine. But not just any virtual machine. A standardized virtual machine, that looks and acts the same anywhere. The only real major concern is the screen size; and since we know it is variable we can design a flexible (reactive, some call it) way of presenting information on the screen.
And now, with Web Assembly, you can write programs that run on the Web in almost any programming language that you can think of.
But the use case alone is so compelling that I honestly cannot understand why people write native apps for mobile. “To use the app store’s infrastructure” does not make sense since hundreds to thousands of new apps and games are released over various internet program stores every day. If your app is worth it, having the larger target market is going to be worth more than the infrastructure. What you want to do is avoid getting lost in the mix so badly that only a distribution network can save your program. Just remember — in the end, you can always write native stubs which access and interface with your server-side API to leverage the native platform’s secure payment and user identification capabilities, all the while acting mainly like a web browser.
Anyone who says differently is selling something.