Thursday, March 7, 2024

The doom of C++

The C++ programming language is successful. It has been popular for decades. It has been used in large, important systems. It has grown over the years, adding features that keep it competitive with other languages.

And it may be on its way out.

Other languages have challenged C++. Java was an early challenger, back in the 1990s. The latest challenger is Rust, and there is a good case for it. But I think the demise of C++ will not be caused by another language, but by the C++ language itself.

Or more specifically, changes to the language.

Consider a recent change to the C++ standard, to add variadic parameters to template functions.

I understand the need for variable -- excuse me, variadic -- parameters.

And I understand the desire by the C++ committee to minimize changes to the C++ syntax and grammar rules.

But code looks like this:

void dummy(auto&&...) {}

template<std::same_as<char> ...C>
void
expand(C...c)
{
  std::tuple<C...> tpl(c...);

  const char msg[] = { C(std::toupper(c))..., '\0' };
  dummy(msg, c...);
}

This code is not easy to read. In fact, I find it a candidate for the long-ago obfuscation contest.

This enhancement is not alone. Most changes to the C++ specification, over the past two decades have made C++ harder to read. The result is that we have lost the readability of the original C, and the early C++ syntax. This is a problem.

While it was possible to write obscure and difficult-to-read C code (and C++ code), it wasn't inevitable. It was, with care, possible to write code that was readable. Not merely readable by those who knew C or C++, but by almost anyone familiar with a programming language or the concepts of programming. (Although the concept of pointers was necessary.)

The changes to the C++ standard have resulted in code that is, in a word, ugly. This ugliness now is inevitable -- one cannot avoid it.

Programmers dislike two types of programming languages: wordy (think COBOL) and ugly (what C++ is becoming).

(Programmers also dislike programming languages that use the ':=' operator. That may fall under the category of 'ugly'.)

The demise of C++ won't be due to some new language, or government dictates to use memory-safe programming languages, or problems in applications.

Instead, C++ will be abandoned because it will be considered "uncool". As the C++ standards committee adds new features, it maintains compatibility at the cost of increasing ugliness of code. It is a trade-off that has long-term costs. Those costs may result in the demise of C++.

Thursday, February 15, 2024

Ad blockers and the future of the internet

YouTube has gotten a lot of notice recently. They have set procedures to ... discourage ... the use of ad blockers. Viewers with ad blockers are limited to three videos. The internet is up in arms, of course, because their favorite free video site is no longer free. (Views who subscribe to YouTube premium and pay a monthly fee are not shown ads and are not limited to three videos.)

But I think YouTube may be showing us the future.

Some thoughts on advertisements:

There are two reasons to use ads: one is to present an image to the viewer, the other is to get the viewer to click (or tap) on the link and go to the sponsor's web site. (I will ignore the installation of malware.)

Displaying the image is desired. Image-only advertisements are similar to ads in newspapers and magazines (the old, paper format of newspapers and magazines).

Users clicking on ads is also desired, as it presents products or services or subscriptions to the viewer, with the ability to complete the sale.

Advertisements are useful to the web site because they provide revenue. The advertiser pays the hosting web site a small fee for each display of the ad (each "impression") or each click-though, or each click-through that results in a sale. (Or some combination of those.)

I understand the use of advertisements. They provide revenue to the host web site, and the company running that web site needs to pay for the operation and upkeep of the site. Even a small, simple, static web site must be hosted on a server somewhere, and that server costs money to buy (or rent) and needs electricity and a network connection.

There are, of course, other ways to pay for a web site. One can limit content to subscribers who pay a monthly or annual fee. (The subscription model.) One can get a grant from a patron. One can ask viewers for contributions. (The public broadcast model.) One can run the web site as a hobby, paying for it oneself. Those methods are all valid but not always feasible.

A description of ad blockers: 

Ad blockers work in one of two configurations: a plug-in to a browser, and a process on a separate device that monitors network traffic and drops requests to web sites deemed to be "ad servers".

The browser plug-in is the most common. It sits in the browser and watches each outbound request. The plug-in has a list of "known ad servers" and requests to those servers are intercepted. The request is never made, and therefore the ad is not retrieved or displayed.

Browser-based ad blockers can be configured to allow some web pages to display ads. The user can establish an "allowed" list of web sites; these web sites are allowed to display ads and the plug-in will let requests from those web pages (or rather web pages loaded from those web sites) through to their destination servers.

The other form of ad blocker is a separate device, one that sits on the network but in its own server. It does not live in a browser (useful for browsers that don't allow ad blocking plug-ins) and other devices such as tablets and phones. The ad block server, like a browser plug-in, monitors outbound requests and intercepts those going to known ad servers.

The advantage of the ad block server is that it blocks ads to all devices on your local network. (Note that when you use a device on a different network, like at a coffee shop, the ad block server does not intercept requests and you will see advertisements.) An ad block server can be configured to allow requests to certain destinations, which is not quite the same as allowing requests for pages loaded from certain web sites. The ad block server knows only the destination address, not the web page that made the request, or even the application that made it.

Both types of ad blockers can let some advertisements through, even unwanted advertisements. Ad blockers use a list of "known ad servers"; requests to destinations on the list are intercepted. A new ad server, at a new address, won't be blocked -- at least not until the list of ad servers is updated. The provider of the ad blocker usually is the one to make that update.

Ad blockers don't block ads from the host web site. A web page can request additional text and images from its origin web site (and they usually do). Those requests can bring text and images useful to the viewer, or they can bring text and images that are advertisements. The ad blocker cannot examine the additional text and images and decide which is useful and which is advertisement. Therefore, all requests to the origin site are allowed.

So ad blockers work, but they are not perfect.

Now we get to the interesting question: Are ad blockers ethical? Are they moral? Is it wrong to use an ad blocker?

Some thoughts:

One argument is that they are ethical. The web browser lives on my computer (so the argument goes) and I have the right to choose what is and what is not displayed on my computer.

The counter argument is that advertisers pay for the display of ads, and if ads are not displayed (in significant numbers), then the advertisers will stop paying and the web site will lose revenue and possibly go out of business.

(A counter, counter argument runs along the lines of: Display ads all you want, I don't look at them and I never click on them, so the web page is merely wasting their time and effort by displaying ads. By using an ad blocker, I am saving the web site the effort of sending the advertisement to me. The argument is  tenuous at best.)

Where do we go from here?

I think YouTube is showing us the future. In its fight against ad blockers, YouTube acts in two ways. First, it limits the number of videos that any one person (using an ad blocker) may view. (Some have accused YouTube of deliberately slowing videos or reducing resolution, but these effects may have been accidental. Let's ignore them.)

YouTube also encourages viewers to subscribe to its premium level, which removes the ads. Some videos on YouTube have built-in advertisements much like the native ads of web pages. YouTube does not remove those, and ad blockers cannot detect and disable them. Overall, the number of ads is greatly reduced.

Web sites cost money to run, and that money must come from somewhere. If viewers block ads, then money will not come from ads, and the money must come from another source. Web sites without revenue from advertising must use a different revenue model.

Future historians may point to YouTube switching from advertisement revenue to subscription revenue and say "Here. Here is where the change from advertising to subscription revenue started. YouTube was the first."

Thursday, February 8, 2024

Spacial computing

There's been a lot of talk about Apple's new Vision Pro headset. I'm not sure that we in the general public (meaning those of us outside of Apple) know what to make of it. What can we do with it? How will it help us? I don't have answers to those questions.

I'm not sure that the folks at Apple have the answer to those questions, despite their impressive demo for the Vision Pro.

Apple uses the term "Spacial Computing" to separate the Vision Pro headset from other devices. This makes sense. A headset is different from a laptop or a smartphone. Not only is the hardware different, but the methods of interaction are different.

If we look at the history of computing, we can see that the different generations of computers used different methods of interaction.

Mainframe computers (IBM's 1401 and System/360) made computation commercially possible -- for large, well-funded organizations such as governments and national corporations. Interaction with mainframes was with punch cards and printouts. Programs read and processed data in batches, at scheduled times.

Minicomputers were a variation of mainframes. They made computing available to smaller (or at least less large) organizations. Yet they also changed computing. Interaction with minicomputers was through terminals, with either paper or screens similar to today's displays. People could interact with programs, instead of supplying all of the data up front.

Personal computers were a variation of minicomputers. They made computation possible for individuals (upper middle class individuals). Interaction with personal computers was not with terminals but with keyboards and built-in displays. Most displays had graphics. People could see charts and graphs, and later pictures.

(Even the IBM PC 5150 with the monochrome display adapter had character graphics. And that card was quickly replaced by the Hercules monochrome graphics adapter with full graphics.)

Laptop personal computers were a variation of personal computers. The software was usually the same as personal computers (but not always; some had custom software) and their displays were often smaller than those on "real" personal computers. Interaction was mostly the same (keyboard and display) They made computing portable. They also made networking common.

The connection between laptops and networking is muddled. Networking was available for desktop computers, usually as an option. And laptop computers existed before networks for desktop computers, but they were rarely used. The combination of laptop and network was powerful, and arrived with a more capable set of hardware for laptop computers. The trio of portable, network, and hardware forged a useful tool.

Smart phones were a combination of cell phone and laptop computer. (Or improved versions of personal digital assistants such as the Palm Pilot.) They made computing not merely portable but mobile -- an individual could do things while moving. They (specifically the iPhone with iTunes) eased the consumption of music and movies and games. Computing became entwined with entertainment. Interaction changed from keyboard and display to touchscreen and display, and sometimes voice.

Each generation of computing changed the nature of computing.

So where does that put Apple's Vision Pro?

I think that we can agree that the interaction with a headset will be different from the interaction with a smart phone. The screen is present but not touched. I expect that, initially, a set of gestures borrowed from smart phones will be used, and later new gestures will be invented for headsets. A smart phone with its small screen can display one app at a time.  The headset screen occupies a much larger section of our vision, so we can expect more things to happen at the same time.

I expect headsets to be used for entertainment and the consumption of information. Expanding today's video games to the larger screen of the Vision Pro seems a natural (although perhaps non-trivial) move. Beyond games, the analysis of data could use the "larger" screen to display more information in graphical form. Music is probably not a strong point for headsets, but music with video is likely to be popular.

Each generation of computing saw new applications, applications that made little sense for the previous generation. I think this will continue, and we will see new applications specific to the Vision Pro (or headsets in general). And just as the old generations of computing styles are still with us, they will continue to stay with us. The computing that they perform is useful -- and not always appropriate on later platforms. Some things work better on new systems, and some things work better on old systems.

I will be watching the innovations for headset computing. But just as I did not immediately run out and buy a laptop computer when they first came out, or a smart phone when they first came out, I won't be buying a Vision Pro -- at least not for a while.


Tuesday, November 28, 2023

Today's AI means QA for data

Some time ago, I experimented with n-grams. N-grams are a technique that reads an existing text and produces a second text that is similar but not the same. It splits the original text into pieces; for 2-grams it uses two letters, for 3-grams it uses three letters, etc. It computes the frequency of each combination of letters and then generates new text, selecting each letter based on the frequency of occurrence after a set of letters.

For 2-grams, the word 'every' is split into 'ev', 've', 'er', and 'ry'. When generating text, the program sees that 'e' is followed by either 'v' or 'r' and builds text with that same pattern. That's with an input of one word. With a larger input, the letter 'e' is followed by many different letters, each with its own frequency.

Using a program (in C, I believe) that read text, split it into n-grams, and generated new text, I experimented with names of friends. I gave the program a list of names and the program produced a list of names that were recognizable as names, but not the names of the original list. I was impressed, and considered it pretty close to magic.

It strikes me that the AI model ChatGPT uses a similar technique, but with words instead of individual letters. Given a large input, or rather, a condensation of frequencies of words (the 'weights') it can generate text using the frequencies of words that follow other words.

There is more to ChatGPT, of course, as the output is not simply random text but text about a specified topic. But let's focus on the input data, the "training text". That text is half of what makes ChatGPT possible. (The other half being the code.)

The training text enables, and also limits, the text generated by ChatGPT. If the training text (to create the factors) were limited to Shakespeare's plays and sonnets, for example, any output from ChatGPT would strongly resemble Shakespeare's work. Or if the training were limited to the Christian Bible, then the output would be in the style of the Bible. Or if the training text were limited to lyrics of modern songs, then the output would be... you get the idea.

The key point is this: The output of ChatGPT (or any current text-based AI engine) is defined by the training text.

Therefore, any user of text-based AI should understand the training text for the AI engine. And this presents a new aspect of quality assurance.

For the entire age of automated data processing, quality assurance has focussed on code. The subject of scrutiny has been the program. The input data has been important, but generally obtained from within the organization or from reputable sources. It was well understood and considered trustworthy.

And for the entire age of automated data processing, the tests have been pointed at the program and the data that it produces. All of the procedures for tests have been designed for the program and the data that it produces. There was little consideration to the input data, and almost no tests for it. (With the possible exception of completeness of input data, and input sets for unusual cases.)

I think that this mindset must change. We must now understand and evaluate the data that is used to train AI models. Is the data appropriate for our needs? Is the data correct? Is it marked with the correct metadata?

With a generally-available model such as ChatGPT, where one does not control the training data, nor does one have visibility into the training data, such analyses are not possible. We have to trust that the administrators of ChatGPT have the right data.

Even with self-hosted AI engines, where we control the training data, the effort is significant. The work includes collecting the data, verifying its provenance, marking it with the right metadata, updating it over time, and removing it when it is no longer appropriate.

It strikes me that the work is somewhat similar to that of a librarian, managing books in a library. New books must be added (and catalogued), old books must be removed.

Perhaps we will see "Data Librarian" as a new job title.

Monday, October 30, 2023

Apple M3

I found Apple's presentation "Scary Fast" to be not scary but somewhat disturbing. Or perhaps "disappointing" is the better adjective.

Apple's M3 processors are impressive, but perhaps not as impressive as the "Scary Fast" presentation implies. I'm not saying that Apple is lying or presenting false information, but they are picking the information very carefully.

Apple compares the M3 to the M1 processor, and the MacBook Pro (with an M3 Pro) to the fastest Intel-based MacBook.

I find those comparisons odd. Why compare the M3 to the old M1 processor? Why not compare it to the M2. And comparing an M3-based MacBook Pro to an Intel-based MacBook seems even odder. (Is anyone still using Intel-based MacBooks? Other than me?)

But Apple's cherry-picking for performance comparisons is not the major disappointment.

The big issue, the one issue that I think Apple misses completely, is that its hardware is outrunning its software. Apple's M3 processors are fast and capable, but so were Apple's M2 processors. The M2 processors were so powerful that the low-end, plain M2 processors was more than enough for almost everyone. If I were equipping an office with Apple devices, I would give everyone a MacBook Air, or possibly a low-end MacBook Pro. Those are enough for just about all typical office work. (Folks editing video or running large test sets might benefit from the higher processors, but they are a small portion of the audience.)

Apple's hardware is faster than everyone else's, just as high-end sports cars are faster than the average automobile. But for most people, average automobiles are good enough. Most people don't want the expenses of a high-end sports car, nor can they take advantage of the speed. Apple's M3 processors are fast, but pure speed translates into performance for only a few users. It is quite likely that today (that is, with no M3 processors in the field) most people have computers that are more than fast enough for their needs.

Apple concentrates on hardware and invests little in a number of other areas:

- Cloud-based computing
- Artificial intelligence
- Design of programming languages, multi-threaded applications, parallel tasks, and coordination of distinct processes
- Programming tools, from command-line tools to IDEs
- Automated testing of GUI programs
- Voice recognition

That's not to say that Apple has done nothing in these areas. My point is that Apple has done a small amount and relies on others to do the work in these areas. And that work isn't getting done. Apple's obsession with hardware is costing them opportunities in these areas. It holds Apple back, preventing it from growing the technology. It also holds us back, because we have to wait for Apple.

Tuesday, October 10, 2023

Apple, TSMC, and 3nm chips

The news from a few months back is that Apple has purchased all of TSMC's capacity for 3nm chips for one year. That's a pretty impressive deal. It gives Apple exclusive access to TSMC's latest chip technology, locking out all other PC manufacturers. It also shows that Apple is planning on a lot of sales in the coming year.

Yet I see a dark side to this arrangement.

First, it places a cap on Apple's sales in the year. Apple has "maxed out" its chip source; it cannot get more from TSMC. Apple's growth is now constrained by TSMC's growth, which has been less than planned. (TSMC's new fabrication plant in Arizona has been delayed and cannot produce multi-chip assemblies.)

With a cap on production, Apple must choose carefully which chips it wants from TSMC. What percentage will be M2 chips? M2 Pro chips? A17 chips for iPhones? If Apple guesses wrong, it could have a lot of unsold inventory for one product and be unable to meet sales demand for another.

Second, it makes allies of PC manufacturers (anyone who isn't Apple) and chip manufacturers (anyone who isn't TSMC). TSMC may have difficulty winning business from Lenovo, Dell, and even Microsoft. The arrangement probably doesn't help Apple's relationships with Intel and Samsung, either.

Third, it shows that Apple's latest processors are not second-sourced. (Second-sourcing was a common practice in the 1980s. It reduced risk to the customer and to the primary manufacturer.) Not having a second source for its processors means that any disruption to manufacturing will directly the finished products. If TSMC cannot deliver, Apple has nowhere to turn.

It may be that Apple's chips cannot be second-sourced. I don't know the details, but it may be that Apple provided specifications for the chips, and TSMC designed the chip layout. If that is the case, then it is most likely that TSMC owns the layouts, not Apple, and for Apple to get chips from Intel or Samsung those companies would have to start with the specifications and design their own chips. That's a lengthy process, and might take longer than the expected lifetime of the chips. (The M1 chip is all but obsolete, and the M3 is already replacing the M2 chip. The "A" series chips have similarly rapid turnover.)

So Apple purchasing all of TSMC's capacity for a year sounds impressive -- and it is -- but it also reveals weaknesses in Apple's position.


Monday, September 11, 2023

Google raises prices, which may be a good thing

Google has raised prices for several of its services. The annual rates for Workspace, YouTube Premium, and Nest are all going up. The internet is not happy, of course. Yet I see a benefit in these price increases, and not just to Google. I think consumers may benefit from them.

It does sound odd. How can consumers -- who pay these prices -- benefit from increases? Wouldn't they benefit more from decreases in prices?

My answer is: not necessarily.

My thinking is this:

While Google is a large company, with many products and services, most of its revenue comes from advertising.  One could say that Google is an advertising company that has a few side projects that are supported by advertising revenue.

The model was: make a lot of money in advertising and offer other services.

Google was -- and is -- wealthy enough that it could give away e-mail and storage. When Google first offered it's GMail service, it allowed up to one Gigabyte of storage to each user, an amount that was unheard-of at the time.

It's tempting to want this model to continue. It gives us "something for nothing". But letting advertising pay for everything else has a downside.

When a service depends on revenue from advertising, it is natural for the company to expect that service to help advertising. If the service doesn't, then that service is either changed or discontinued. (Why continue to offer a service that costs money to maintain but doesn't help with revenue?)

Google has a reputation for cancelling projects. Perhaps those projects were cancelled because they did not provide revenue via advertising -- or didn't help the advertising group gain customers, or better market data, or something else.

When a service is funded by advertising, that service is beholden to advertising.

In contrast, when a service has its own revenue -- enough revenue to generate a profit -- then that service is somewhat isolated from the advertising budget. If YouTube Premium costs $X to run and brings in $Y in revenue (and Y is greater than X) then YouTube Premium has a good argument to continue, despite what the folks in advertising want.

The same goes for other services like Nest and Google's cloud storage.

I expect that no one enjoys increasing prices. I certainly don't. But I recognize the need for services to be independent, and free of the influence of other lines of business. Higher revenue leads to services that are stronger and longer-lasting. (Or so I like to think.)

I may grumble about the increase in prices for services. But I grumble with restraint.