Phillip Trelford's Array

POKE 36879,255

Byte-sized Tweets

This post is part of the .Net Christmas Advent calendar organized by Dustin Morris Gorski on Twitter.

Background

.Net or dotNet is a developer platform from Microsoft from the noughties, inspired by the Java Virtual Machine (JVM) from the 1990s. Both platforms are used by millions of developers, with the JVM used primarily for Enterprise apps and Android mobile app development, and .Net again used primarily for Enterprise apps along with games on Unity.

For a practical example of Enterprise app development style check out FizzBuzz Enterprise Edition;

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

Both the JVM and .Net compile their code to byte code that is typically just-in-time compiled to native code at run-time, where in computer programming a byte consists of 8-bits. This was probably inspired by the 8-bit microcomputers of the 1980s 8-bit like the ZX Spectrum stored instructions in 8-bit codes that were then interpreted at runtime.

.Net and the JVM support multiple programming languages, for example on the JVM Java, Kotlin and Scala are popular and on .Net C#, F# and VB.Net are popular.

The generated byte code of the JVM and .Net allows programs to be run on different operating systems and processors, for example both can run on an Intel PC running Windows or a Raspberry Pi with an ARM chip. But things have moved on,  and it doesn't just stop at byte code anymore, code can be transpiled to run on the web as JavaScript, with libraries like Fable, or even executed in response to a Tweet...

.Net Tweets

Back in 2014 Mathias Brandewinder produced the @fsibot which lets you tweet F# code to it, and it will execute the code and return the result. This gives the programmer the power to write and execute FizzBuzz without leaving Twitter at all:

On the Advent calendar theme, this can be used to produce a Christmas tree:

-

This is great but the code is limited to 144 characters and the response to text only output...

BBC Tweets

In 2020 the @bbcmicrobot / https://www.bbcmicrobot.com/ a recreation 8-bit BBC microcomputer from the 1980s allowing you to tweet a full 280 characters of BBC BASIC, and with the BASIC supporting graphics programming by default, you can receive the response back as an animated GIF back! But it doesn't stop there, you can even see your programs run on a virtual BBC in 3D: https://virtual.bbcmic.ro/

A Christmas tree

to a Snowflake

Image

Can you write FizzBuzz in a Tweet for the BBC Micro?

Happy Christmas code tweeting…

Procedural Invaders

Procedural invaders are space invader like characters generated as 5 x 5 pixel characters from just 15 bits using symmetry. The earliest post on procedural invaders appears to be from a J Tarbell in 2003. Thanks go to Ross McKinlay for suggesting having a look.

Below are some sheets of randomly generated invaders with generated names that you can click on to generate a tweet with F# code that generates the invader as ASCII art when sent to Mathias Brandewinder’s @fsibot.

invaders ocodehkiauoyemixuoocuucenotiyofecalepergucjucjoxnoxebatigzuyanitiereypunefegaajusaacorgipciguweejeqemaulaiborruxuvawedayamgasihhedlorifuaelioixejqabexiqiiboquaiwazavvijuzapbuiouxompoqqesonteuitocijwuwtalmufefuysurbuwpujxorroirajjokijgobfibqeejiokusiporixxokajavgolcoqeloooviwemisaguxovegnujepfequpeuaiutoazeleinijtirqenqaesiozawufafuaavexuzumiupomrijeeqipokeeaumehmooezuxixifihohaicebyezboiniokamugucar

invaders

uleraitupisurleyfopupitqohteerodeguzocvunujqeracaciugiktufewkomigepdufuqwoesusahawayuyrayutixezajexowusqixtomurexhaquobepruomagxiihookuzidomexixiuqoqekoyohviiuyugajihakqubseqeweficosepbieebafaaouheeguqkoogamvabbenpoaouoivifhivesjeecoiduvooauuuveuwirigguqfoakedzoovogxekbalerokitukilimfitjeqarwomiiaonoporgaketagmovuharuarobbanaepuiodaskueajudpeluqoejazosowmeafivxureroxoqroralurotemaearuunafionedqelamfopimukagaxesiscivusamazezalafowosanamutitozunimihodlerduaiupirufeniyakmoeuwaneujeboisiasoleutuserquwazalifqukotjisasojukniqetejeuxocemeaqupjevkefewerarzifaeyovarejuguieiofaqeqiqoyilaphapaoacorzowoibavwosgoakugmuxwahoeweakiizownaqootimqamufutoulimoziecoyumuxuwubovezoynonitlargusiycibqudubueerunleceisiayojaehofayiruuukecamayuaenebuxmoviigosyoyretluqmakirhufoydoruweibihalureociycokuszaanozounuquvofenahyurezzeqhepevcagefhizseupivxigulifohdoleaugoyefageoiuemenvucexinucolayyiwbuzuweluhivqumbizevugeoziucovixufuwusemkoluhikkuykiqindecculapereyoiyigamuxomoppeleorawxunnoqdaxyuvooaituelugoufejayisootauwujzomouuegujefubaomepuvopecitobyoctalqufcirishuspijutisagezuuzayaokobyejigomigeorillehbepsoqezojoyulupazuuedenoxzuscafjiaweoetufeginukgixhoskimadogualexnirmirayapofaqafauwivluwqikhidqewboeepihihawudhebakoecoekadgaweryeguiavadepealowagnuhuwavhoecuqihquvaauwoxtupodengodbecazadopuootadxiblabweeuzaoqiqejeelusosiszohzoruhaoceuqieyadibjinilimufimrasyizuqiovopfayeturoqobitiooayezqozeiisictaufijyovtelivasuvejeaaiouopeteuhurisumxakqivuqeecuavezdaduxiyifawohjumerkihpogquhoqaxuttuvilucewyupgohisfesqipcojdafopoffeduroaiiucadbixufguvebisufataufaysesruwauyipilusxiyalatgugerabxuoweuwufumvadierevicununofipojeofofouehilmorser

Techie bit

The sheets of invaders are drawn on to a bitmap image and saved as a png file (see invader bitmap generation F# snippet), with the bit pattern for each invader generated from the hash code of it’s generated name (see pseudoword generation F# snippet). At the same time a matching HTML image-map is generated with the coordinates of each invader with a link that generates a tweet for the specified name.

 

MSDNify Types

Following on from yesterday’s post on Disinherited Types where I implement an F# type provider that hides inherited members of a type to let you focus on the useful members. The example was the WPF Button control which contains around 300 members via 9 levels of inheritance and appears to flout the object-oriented principle of composition over inheritance.

Microsoft’s MSDN documentation takes another approach to the problem of making relevant members discoverable by grouping members by type, i.e. all properties, all methods, all fields and all events:

Button class docs

MSDNify Type Provider

To give the same discoverable experience in the editor I’ve created the MSDNify Type Provider that groups members by type:

Button by member type

From the filtered member type groups you can select the member you are interested in:

Button events

This in effect mirrors the MSDN docs making it easier to find the useful members.

Source Code

The implementation is very similar to the Disinherited Type Provider discussed in yesterday’s post.

The code is available on GitHub: https://github.com/ptrelford/MSDNify