Goodbye Swift Hello Target Environment

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:

  1. The ability to consume media (play games and/or watch tv, movies, music, etc)
  2. The ability to create media (content creation including programming)
  3. 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 for the ubiquity of it all, JavaScript is the key crux of this environment; as for the server side, PHP is probably the most important language, although really anything from Python to Swift could be used. Look at the algorithm “LAMP” which stands for Linux, Apache, MySQL and PHP. The portions “Linux” and “Apache” are merely servers for the content, and the backend of MySQL and PHP. The front end is assumed — it is actually more assumed and standard than Linux, Apache, and MySQL itself. Including PHP in this equation however is a massive compliment to PHP. For most use cases, PHP should be used merely because nothing else is as tightly integrated; but this is changing, and the reality is you can probablyu replace PHP with whatever you want so long as you can really do what you need to do in some other language. To the point where if you’re using some language like Go, Ruby, Rust or Swift (or God forbid, Haskell) just to spite PHP or because you don’t know PHP, you’re doing it wrong. Find a legit reason.

And it is precisely this need to find a legit reason which makes JavaScript such a compelling choice.

Javascript gave us everything Java promised to do, and helped us fight against the evil MonsterSoft even when Java couldn’t, and more.

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.

So as much as C is “small and beautiful”, Java is “great and terrible, beautiful and treacherous as the seas”, and D (or Swift, or something) is “as good as it gets without designing your own language”, and maybe even Python is “the little scripting language that could” — JavaScript is the language that has seen and done it all, which has stood the tests of time and has finally brought peace to the universe.

Anyone who says differently is selling something.