Thursday, January 22, 2015

Elon Musk, Satellite Broadband, Space Internet, Mars... quantum entanglement?

Elon Musk talks Satellite Broadband


Musk's Semi-Futuristic Plans

When I read a recent Bloomberg article about Elon Musk (of SpaceX & Tesla fame) and his newest ideas / plans to launch a vast network of communication satellites, I was both intrigued by his plans for a dual-altitude network of satellites but also a bit let down that he did not also go a bit further "out there" with some long-term technology visions like he is known for.

He mentioned being able to using SpaceX to help launch a vast array (thousands) of satellites that would comprise this new space Internet / network.  He also mentioned why the dual-altitude plans make sense — including facts about reduced latency between the ground user and the lower-orbit satellites, coupled with the higher speed of light in a vacuum (e.g., space) vs. speed of light through fiber optic cables (that can be 40% lower).  As anyone with current satellite Internet technology knows, latency (i.e., lag time) is currently a big issue and makes the service not even remotely usable (compared to terrestrial Internet connections) for gaming, real-time communication (e.g., Google Voice), etc.

The planet Mars enters the picture next as Musk envisions connecting another set of Mars-orbiting satellites back into to Earth-orbiting network at some point in the future.  This will truly be needed if humans make any serious push to explore Mars (with "boots on the ground" especially), but why stop with Mars?  Other targets in our solar system seem perhaps even more hospitable than Mars — like the dwarf planet Ceres, or Jupiter's moons Europa and , or Saturn's moon Titan — and, presumably we will need network connectivity there also.

But, a network of satellites surrounding Earth needs to be connected to those other satellites on Mars, and with current technology this implies absolutely massive latency due to the distance between Mars and Earth.  When you have a light-speed minimum (one-way) distance of 4 minutes between Earth and Mars when the two planets are closest in their orbits (and a maximum of 24 minutes one-way when at their furthest), it does not take long to see the huge issues that will follow.  Who wants to wait up to 48 minutes for a "ping" to return??

As such, Elon Musk has some great ideas for the near term, but how about some very forward-looking prognostications about the technology that will make nearly the entire (satellite-based) scheme (hopefully) obsolete in the future?

Seriously Futuristic Plans : Quantum Entanglement Networks

Zero Latency.  Distance irrelevant.  Latency between New York and London: zero.  Latency between Earth and Mars: zero.  Quantum entanglement makes this a possibility (at least in my semi-educated opinion), and whatever company commercializes this and takes it big-time is going to be worth more than every other communications and networking company put together.  What would you pay for truly "instant" communications between any two points at any arbitrary distance apart?  Lots.  And, it would fundamentally change all sorts of industry.  That aside, let me get back on point...

Quantum entanglement or QE (aka, "spooky action at a distance", per Einstein), which allows two entangled particles (electrons and photons, e.g.) to "share state information" instantly at any arbitrary distance, is not just theoretical, it has been demonstrated in very real experiments.  I expect these varied experiments to yield a practical (data-communications) application within the next 2 or 3 decades.

There is still considerable debate about whether FTL (Faster-than-Light speed) communications are truly possible using QE — in fact plenty of information out there says it is impossible — , but, if it is and if some brilliant scientists figure out a way to communicate data at FTL speeds (i.e., "instant" regardless of distance), everything changes.  Mars, Europa, Titan... here we come with instant connectivity to our home-planet Earth!

Apparently Elon Musk did not want to sound crazy by suggesting deploying a series of quantum-entangled network switches, so I did it here for him.  Keep in mind: these do not need to be located on satellites: they can be placed on the ground anywhere on Earth, on Mars, etc... the entangled particles should not care where they are located.  Thus, the need for satellites could be removed instantly if this type of communication is achieved.

I may ultimately be wrong in thinking that the final frontier in communications must be a fully FTL quantum-entangled network backbone, but I prefer to hold out hope for something that will once and for all solve the latency problem that plagues both Earthbound and inter-planetary-body communications currently.  Maybe Google could help fund making a QE solution a reality?

Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Nvidia CUDA, VMware, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.

Monday, October 13, 2014

Delphi Programming Popularity Increases in 2014?

Do you Believe the Delphi-Programming Statistics?


TIOBE Programming Language Popularity Index for October 2014 —Delphi Popularity Soars?

The TIOBE Programming Language Popularity Index for October 2014 shows Delphi / Object-Pascal moving upwards 6 notches from #17 at this time in 2013 to position #11 in 2014.  My use of question-marks in the blog title and main heading perhaps says it all: I question the accuracy of these rankings / statistics.

This is not to say I have not referred to these rankings before to back an observation I have made personally about various programming language and technology trends. In fact, I used the index to demonstrate how Google Dart popularity was rising in 2013 (in fact Dart is now #17 vs. #81 a year ago). I also believe the May, 2013 blog I wrote questioning whether Delphi programming is dead, and which referred to the TIOBE index at that time also, can lean on such rankings for some backing-data.  So, can the index be "wrong" and still offer enough "right" information to add value to an argument or decision-making process on occasion?

First, a bit of background on this programming-language-popularity index...

As quoted from the TIOBE site (hereinafter, "Quote A"):
"The index can be used to check whether your programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system."
and
"The TIOBE Programming Community index is an indicator of the popularity of programming languages."
Yeah, right!  Delphi is obviously taking off now (sarcasm abounds)! 

My Opinion, Explained

I believe I can understand how such a statistical move — like this current apparent substantial (and difficult to believe) resurgence in Delphi popularity — can be explained, given the key indicator this index is based on:
"Basically the [ranking] calculation comes down to counting hits for the search query (across 25 search engines) for: +"<language> programming""
Essentially, I posit that the TIOBE index is fundamentally flawed and a rather absurd way to truly know the "popularity" of a programming language, because [web] search behavior is not well-correlated with actual programming language activity, software projects, or technology hiring, and here is why...

The flaw in the index, in my opinion, is especially amplified in the case of languages that are "niche" or insignificant or perhaps even entering obsolescence, and the flaw exists not just as languages are sliding out of favor but also as new ones are fighting to get noticed as the next great software development language of choice.

Aside from maybe giving a slight bit of insight into "macro shifts" in the appeal and perhaps adoption (or lack thereof) of certain programming languages, I do not see much real value in this index.  The rankings of "stable" languages that occupy the top few ranking positions over long periods of time —  C, Java, Objective-C, C++, and C# which collectively hold the top 5 rankings currently — seem semi-believable, but, you cannot tell me that Delphi is more popular than JavaScript in 2014 (as the TIOBE index currently shows JS one step below Delphi) and that my programming skills repertoire would be better served knowing Delphi than JavaScript right now.  That is absurd.  Just search indeed.co.uk for London jobs mentioning Delphi skills (be sure to ignore the 6 unrelated hotel-operations software named Delphi) and compare the 3 (YES, THREE TOTAL DELPHI JOBS in London) to the nearly 2000 jobs in London that require JavaScript skills.

So, how could the TIOBE index be so wrong, and how can I have been so right when I pondered whether Delphi programming is dead last year?

Popularity skewed by unemployed Delphi developers?

I am sure I am not the only Delphi developer that is curious about the (minimal) presence of Delphi jobs, the current state of Delphi programming languages and tools, and so forth, that searches the web on a semi-regular basis using search-terms including "Delphi programming jobs" or similar phrases.   This search activity does not imply I have coded a single line of Delphi recently, nor does it mean there are any substantial number of Delphi software development projects to be found anywhere — in fact, such searches generally confirm the opposite: there are incredibly few Delphi jobs and Delphi programming opportunities anywhere, from what I see (especially relative to other "popular" languages on that programming-language index page).

So when I and others (that have Delphi skills which are essentially wasting away as fewer and fewer Delphi opportunities exist) go searching the web on the off chance there is actually a software development project that could use my Delphi programming skills (and actually pay me for those skills), we are somehow upping the "popularity" of Delphi according to TIOBE index.  This is just wrong.

As I put forth when positing this argument in the first place, I believe niche programming languages are going to be much more likely produce massive distortions in the popularity rankings for varied reasons.  First and foremost, software developers and programmers want to know that their skills may actually earn them money!  As such, they search for jobs that use: 1) the skills they already have, even if those skills are falling out of favor in the mainstream programming circles, and 2) skills they may be able to quickly migrate to in order to gain employment, maintain employment, and/or up their earnings with (ideally while not choosing "another Delphi" that turns out to be a career dead-end).  Period.

The first search-reason (i.e., finding jobs using one's existing skills) is where Delphi falls, and perhaps since Delphi is such a fantastic software development platform it encourages those with Delphi skills to be ever-persistent in their search for anyone willing to employ them using Delphi instead of another language. The second reason (i.e., finding skills to migrate to that will get one employed) is where things like Google Dart fall, and for all I know it is where Delphi developers are looking (in addition to JavaScript users that want true object-oriented class-based development) since the Dart language and features looks a lot like Delphi (certainly more so than JavaScript).

In any case, I believe the TIOBE index needs to be substantially altered in order to remain relevant.  In order to address Quote A with any real credibility, it needs to incorporate some job-postings data.  You cannot tell me that my programming skills are up-to-date if there are essentially zero jobs anywhere that actually rely on such skills.  That is just nuts.  And, a quick sanity-check on the relative rankings of "popularity" can be done by comparing even at a super-duper-high-level the number of jobs available that reference each programming language as a required skill for the open position.

I am glad the TIOBE index exists even as I find it fundamentally flawed.  I still use it for very, very high-level insight into what is going on in the programming language arena, but I also couple it with my own observations and insights for some sort of "reality checking" of the data.  Parts of the rankings are quite believable and match up with the reality I see in job postings, technology articles, presentations, and so forth, even as other parts of the rankings (like Delphi) do not.

So, take it all as you wish, and whilst busy wishing, maybe all of us that still appreciate how wonderful Delphi programming is should be wishing that there will be jobs out there to put our skills to use before we all finally give up looking and see Delphi fall off the charts completely.


Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Nvidia CUDA, VMware, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.

Tuesday, July 15, 2014

How to Include an HTML File in another HTML File Without a Server or Code

Include HTML Files In HTML by Reference Without Any Server Technology

I have meant to write a blog about this for quite some time, and the newest Chrome 36 Beta release notes reminded me to do so now that yet another way of including HTML files within HTML files (without any particular server requirement and without JavaScript) exists —  i.e., you do not need ASPX and you do not need PHP or other server-side technology, and you do not need JavaScript.

The first method I will discuss is one I have used since as far back as Chrome 24, Firefox 17, and even Internet Explorer 9 (IE9) — "seamless IFrames". The second technique is the one that Chrome 36 Beta has implemented — "HTML Imports". Until all browser vendors support the new HTML imports, my "old" way will still work fine.

"How to" Include HTML Files — using Seamless IFrames

This technique is probably best described by way of example code. This way to implement "include" files in HTML5 without ANY "server" works to include any file referenced by "file:\\..." addresses or relative URL addresses.

In the “container” document (i.e., the “outer” document into which you would like to import / “include” content from another HTML file):

<div class="content">
   <iframe id="top-nav" seamless="seamless" src="include.top.nav.html" ></iframe>
</div>

Then, inside that external / referenced HTML file (in this example, “include.top.nav.html”), we simply include the HTML that we want to appear inside the iframe — in this case a simple reusable section of HTML with my navigation HTML code in it:
<div id="topnav">
   <a href="some-page-to-navigate-to.html" target="_top">link to home page</a>
</div>

Note the use of “_top” to indicate that our navigation is going to affect the outermost document; if we omit this, the contents of the iframe will be what changes during navigation instead of the contents of the outer container document.

Let us also assume we perhaps we want to style this iframe, so in our referenced CSS file we do so  — in this case I simply want to make sure it sizes to 100% of the container div's width and height:

     /*Set the seamless iframe properties; size as needed to fit embedded content*/
     #top-nav {
          width: 100%;
          height: 100px;
     }


A more complete view of the outer HTML document that includes the reusable HTML by way of the seamless iframe looks something like this:

<!DOCTYPE html>
<html>
<head>
    <title>DEFAULT DOCUMENT TITLE</title>
    <link rel="stylesheet" href="my_styles.css">
    <meta charset=utf-8>
</head>
<body>
    <div class="content">
        <iframe id="top-nav" seamless="seamless" src="include.top.nav.html" ></iframe>
        <h1 class="document-name">DOCUMENT NAME HERE</h1>
        <p>Paragraph...</p>
    </div>
</body>
</html>


Hopefully this was somewhat easy to follow.  Try it out.  This technique came in super-handy for a local HTML-Based WIKI I created that did not require any web-server to run.  I can access the WIKI pages from Chrome, Firefox, and IE and the included HTML file(s) work just fine with no web server and no dynamic language or dynamic web-page technology.


"How to" Include HTML Files — using HTML Imports (rel="import" directive)

This is an alternative serverless "include HTML file" method that has just recently come available in browsers like Chrome 36 (note: it has existed since Chrome 31, but you had to enable the experimental feature; now it is "on" by default).   If you took a look at the Chromium Blog release notes link (above), you will see a quick overview of this new technique, and I have pasted their description and example here for quick reference:

HTML Imports
HTML Imports, part of the Web Components standards umbrella, offer a way to include HTML documents in other HTML documents using <link rel="import">:
<head>
  <link rel="import" href="/path/to/imports/stuff.html">
</head>
An HTML Import can contain CSS, JavaScript, HTML, or anything else an .html file can include. This means they provide a convention for bundling related HTML/CSS/JS (even other HTML Imports) into a single package, making them a fantastic tool for delivering Web Components to users.

The first technique I showed (seamless iframes) can accomplish the same thing to an extent, but this new rel="import" technique is certainly the preferred way to go in the long term.  I look forward to this being widely adopted (hopefully sooner rather than later), but it seems Chrome is the only game in town today.  There are much "bigger picture" reasons why the rel="import" implementation is important as it is quite handy for web components packaging (something I plan to use in my SVG Dart Widgets, eventually).  Search the web for more examples and have fun with either, or both, of these ways to import HTML file contents into another HTML file without the need for server-side technologies.

Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Nvidia CUDA, VMware, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.

Sunday, July 13, 2014

UK NHS GMS1 Fillin Editable PDF file - Family doctor services registration form

United Kingdom NHS Form GMS 1 — Fillable, editable PDF file


Finally, a fill-in NHS GMS1 Adobe Acrobat Form

I just recently relocated to the UK, and one of the first things I set about doing was registering as a new patient with the UK NHS (National Health Service).  One of the forms you must fill out and turn in to a GP (General Practitioner) office is the NHS Family doctor services registration form GMS1.

As my handwriting is not always the easiest thing to read (like that of many people), I tend to always look for edit-able, interactive, fill-in / "fillable" PDF forms that I can actually TYPE my BLOCK CAPITALS into instead of writing by hand.  So, I went searching the Internet for a publicly available Acrobat (PDF file) that would allow me to type my answers... and, I searched,... and searched,... and all I kept locating were copies of the same NON-editable NHS GMS1 file like there is on the NHS website here.

I was actually surprised that the NHS would not publish a fillable PDF, especially given how they were again recently ranked #1 worldwide for health systems, and anything to reduce potential data-entry errors should lead to savings (and, reading typed letters is easier than reading what people write by hand, invariably).

I Created, and am now Sharing, a NHS GMS1 PDF Fill-In Form

Since I could not find a fill-in version of the NHS GMS1 file, I created one using Adobe Acrobat Pro that includes these features:

  • many of the common fields are now editable
  • there are clickable check-boxes where appropriate
  • some basic "rules" / filters exist on certain fields (like numeric-only date-components)
  • "hints" or "tooltip text" (when hovering over fields) have been added to some fields
  • red-outline added around Surname and First Names fields to show they are required fields.

If there is enough demand for it, I can go ahead and finish making ALL the fields editable.  If this form has been helpful, please post a comment, and feel free to request further enhancements to what can be edited and completed by typing.  Better yet, perhaps someone at the NHS can get hold of me and have me complete this thing and then make it available on their website?

Download the Editable / Fillable NHS GMS1 PDF Form...

Get the Editable NHS GMS1 PDF Form Here (should open in your browser if using Chrome, and you can download to edit too of course).


I admit, this is not my standard software-related blogging topic
, but perhaps this will help others that want a way to compete the NHS GMS1 form by typing the data in via a computer or smartphone and printing the filled-in PDF to take to the doctor office.  I can't be the only one that wanted this, right?


Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Nvidia CUDA, VMware, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.

Tuesday, March 11, 2014

Google Dart, Polymer Dart, SVG Widgets Released

Google Dart, Polymer Dart, SVG Widgets Source Code Released


Source Code for my Polymer Version of SVG/Dart Widgets now on Github

Just a quick post to provide people with the link to the latest version of my open source Dart / SVG UI widgets that now use Polymer.dart. This latest version uses Polymer.dart primarily for interacting with the ShadowRoot DOM and for encapsulating most of the SVG structure within template files (SVG that was previously created in-code).  At a future date (once Polymer has stabilized more), I may extend it to make better use of additional Polymer templates features.

Works with Dart SDK 1.1.1 stable.  I will eventually update it to support newer Dart and Polymer releases (though, it should remain working unless Polymer changes something in a big way).

Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Nvidia CUDA, VMware, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.

Saturday, November 16, 2013

Google Dart Programming Language Milestone: Version 1.0 Released

Google Dart Reaches Stable 1.0 Release


Exciting times for web-developers frustrated by JavaScript!

I have been following the Google Dart language and associated software development APIs / Libraries since very early in the Dart life-cycle.  My early Dart-related blog postings began over a year and a half ago, and as impressed as I was with Dart and its objectives back then, I am even more impressed by Dart and the software development ecosystem that has emerged since.

The Dart language itself is but a small part of the story here.  In addition to the class-based object-oriented modern programming language, one of the greatest things about Dart is the included libraries for things like Collections, Asynchronous operations, and much more — just check out all the available standard Dart API libraries for common web software development tasks.  In addition to those, there are a growing number of community-sourced projects and libraries available on Github or the Dart "Pub" Package repository.

I have published my own open-source Dart / SVG Widgets on Github, and just finished updating them to be compatible with the 1.0.0 release of Dart.  These are only "experimental" or "alpha" stage UI Widgets, and require more work to make use of some of the newer features of Dart that were not around when I first wrote this code (e.g., Streams and such).  But, writing that open-source proof-of-concept SVG-UI-Framework in Dart definitely provided good experience and helped maintain my interest in Dart while the product made its march toward "stable 1.0" release.

The down-side of Dart...

After using Dart for web development work, I simply cannot stand to code JavaScript!  That is the biggest "down-side" or Dart for me... it has further eroded my ability to tolerate the (normal) hideous and unmaintainable JavaScript that usually accompanies any substantial web applications these days.  I am spoiled now!  And, any time I look at the source-code behind large JS libraries, I can barely stand it. Dart is just so fantastically better designed for building modern robust web functionality than JS.  Give it a try, you'll like it.

[NOTE: Dart can *output* JS code that runs on any modern browser, and the code runs fast!  So, why subject yourself to the typical maintenance nightmare of working directly in JS when you do not have to?]

There is also always Microsoft TypeScript if you prefer their approach to improving JS.

Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Nvidia CUDA, VMware, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.

Monday, October 14, 2013

SQL Moving Average Query Techniques and Performance Comparison

SQL-Server Solutions to Moving-Average Query Requirements


Moving-Averages Overview

I recently posted some additional SQL-Server queries, functions, and stored procedures source code to our online public freeware SQL code library. Among this set of SQL queries are a few pieces of code that address the topic of moving averages and approaches to calculating moving average values using only SQL.

Moving averages — and/or rolling averages, moving means, sliding averages, running averages, temporal averages, etc.  — are a common data requirement in these problem domains:
  • financial instrument pricing, and especially the analysis of financial time-series values and information: e.g., stock prices, commodity prices, interest-rates, etc. where it is very common to look at indicators like a 30-day or 90-day moving-average-price
  • operational indicators at a business: production and sales volume trends, error/defect rates trends, and so forth
  • economic indicators like unemployment and jobless claims, new home construction rates
  • environmental indicators like seasonal temperature trends, rainfall, snowfall, and so forth
  • and countless other applications where "smoothing" or "trending" or "momentum" is to be included in some analysis or reporting or charting.
Whether your moving-average needs are best served by SQL-only algorithms, as opposed to perhaps client-side number-crunching and/or non-SQL Server-side code (like .NET CLR procedures), is for you to decide, but with the techniques I have demonstrated, at least you can consider a Transact-SQL-only solution if you choose (and one that is set-based as opposed to relying on cursors).

SQL-only Solutions Compared

See my Set-based Moving-Averages SQL Example 1 page, as I will reference the techniques on that page in my discussion here.

That page and example includes execution-speed / performance comparisons between techniques also (run against the AdventureWorks sample database).  That page demonstrates three different approaches to solving (using only SQL-Server T-SQL) the moving average challenge using:
  1. my own custom approach to calculating a rolling average that takes advantage of some interesting features of Transact-SQL that, although may not work "forever" with every future release of SQL-Server, have worked fine from SQL-Server 2005 through SQL-Server 2008 and 2008r2 and SQL-Server 2012.

    The technique relies on CASE statements and a (so far, so good) predictable order-of-processing the values-assignments within the UPDATE statement where I use local-variables to maintain a "queue" of values as well as break-level-reset tracking information.  This code is quite speedy and flexible and easily adapted to related problem domains.

  2. an example of solving the same problem using a CTE (Common Table Expression) coupled with APPLY (CROSS APPLY / OUTER APPLY that are Microsoft SQL-Server specific extensions to ANSI SQL).  This approach is SLOW!

  3. A newer ANSI-SQL compatible solution that is available to you if you have SQL-Server 2012 or newer that implements the windowing functions using OVER and PARTITION BY.  This method is the simplest solution, is the fastest running, but requires SQL2012+ and also lacks the ability to easily change the "window size" (i.e., number of data-points the moving-average is based upon) without dynamic SQL.

Performance Results / Limitations Examined 

I have been very pleased with the performance of my custom solution to this problem and have used this approach (#1 above) for years now.  Sure, I could simplify my code using SQL-Server 2012's new OVER / PARTITION BY abilities while also gaining a performance boost.  But, until SQL-Server makes the PARTITION window-size (in the "ROWS BETWEEN integer_value_here PRECEDING AND CURRENT ROW" portion of the command) able to utilize a variable instead of a hard-coded integer value, this newest SQL method has limited value in my opinion.

My custom approach comes amazingly close to the native speed of the newer SQL-2012 windowing features, while also having the advantage of being able to handle a variable-window-size (which is perfect for requirements where you want to pass a moving-average-window-size value as a parameter to the procedure).

Notice that I hardly give the APPLY / CTE "solution" much thought.  I presented it as an "option" for a set-based solution to this problem, but its performance is awful and the APPLY is Microsoft-specific as well.  So, I might as well use my own custom approach that may rely on the specifics of MS T-SQL processing-order while gaining the advantage of speed and a rather simple-to-understand approach (as compared to the CTE/APPLY which I find not-readable or easily understandable by comparison).

Conclusion

There are certainly multiple ways to solve the rolling-average / moving-average problem using only SQL, and the choice is yours as to which approach best fits with your needs and situation.  I'd say that if you have a static-window-size and are using SQL-Server 2012 or newer, then the obvious choice is the newest OVER / PARTITION approach.  But, I personally have not run into rolling-average requirements that did not include a variable "window" (e.g., allowing a user to choose how many data-points, periods, etc to include in the average, as specified in a run-time query parameter).

Check out the other SQL queries, functions, and stored procedures I have in my code library for other related problems and solutions like running subtotals and much more.  I have made it all available as open-source-software (OSS) under a very permissive MIT License.  If you want to learn how to compute moving averages using only SQL, and solve other interesting problems within Microsoft Transact-SQL, this resource should provide some very useful information and ideas. Enjoy.


Continue to read this Software Development and Technology Blog for computer programming, software development, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, JavaScript, SVG, and more. Also, my Free Software and Source Code Library (SQL-Server, Delphi, Dart, SVG, ...) provides a categorized library of source-code I have posted here — though, updates may lag behind this blog.