Video walkman sold
/It’s taken a while, but I’ve finally sold my broken video walkman. I had to drop the price, what with it being broken and all but I hope that the new owner is able to do something useful with it.
Rob Miles on the web. Also available in Real Life (tm)
It’s taken a while, but I’ve finally sold my broken video walkman. I had to drop the price, what with it being broken and all but I hope that the new owner is able to do something useful with it.
I got asked today what Bitcoins and NFT (Non-Fungible Tokens) are all about. So I thought I’d write something.
Let's start with your bank. Whenever you receive some money (yay!) or pay a bill (boo!) your bank adds a transaction record to a list held in your account records. If I was running the bank, I'd be very worried about someone messing with this transaction list. I wouldn’t want a cunning programmer who works for me giving themselves extra cash, deleting their spending records or fiddling with their transactions.
One way to stop such tampering is to turn a transaction list into a blockchain. Each bank transaction is now stored in a block which is linked to the ones before and after it. Each block contains a cryptographic hash of the block before it in the chain.
What's a cryptographic hash? I hear you ask. It's a way of validating the contents of a block of data. What does that mean? Well, assume that I want to store my name, "Rob Miles", and I want you to be able to prove that the stored name is correct.
I could store my name along with a value that proves the name is correct. A bad way to do this would be to store "Rob Miles" and the number 829. The value 829 is the result of adding the character codes for my name together. The letter R has the value 82, o is 111 and, b is 98 and so on. When you read back the name you calculate the check value from the data and compare it with the stored value. If they are different either the hash or the data are wrong. This validation mechanism is called a checksum and it is used throughout computer networks to detect data corruption caused by transmission noise.
We don't use checksums to validate the data in a block because it is too easy to fool. You could use 829 to prove a name was "Rob Miles", but this value would also work for the name of my strange cousin "Rpa Miles" because character code for p is one greater than o, and the character code for a is one less than b. A cryptographic hash is a transformation created to produce a different value for every unique lump of data that it receives. Of course, this is not really possible. If the hash value is of finite size (say perhaps 10 digits) and the block of data being hashed is very large (say perhaps a megabyte) there must be lots of blocks of data that would generate the same hash, but the chances of this happening are sufficiently small for us not to have to worry about this. A cryptographic hash has one other feature, it is designed to be non-reversible. In other words, it should be very hard to work out the data contents of a block given the hash value.
If a block contains the cryptographic hash of the one before it in the chain it makes it impossible to modify a block without breaking the chain, since the hash value in the following block would now be wrong. It is also impossible to add or remove blocks in the chain because his would also corrupt the hash values.
Block chains are actually a great way to store data. Consider hospital patient records. You could store details of each patient in a huge data structure and then modify the contents of that structure each time something about the patient changes. If they change their name your program would have to find the patient record, modify the name in the record and store the record again, which would be quite hard work. It would be much better to hold each patient record as a blockchain. Rather than change the properties of the patient record you just add another block to the chain that describes the change you have made. The disadvantage is that to get the up-to-date status of a patient you have to scan down the blockchain, but the advantage is that you get a complete history of changes to the record for free, because all changes are stored in the chain.
So, blockchains provide a great way to store structured data, but what about cash? Lets assume that you want to start your own currency. You don't want to tie it to any particular bank or organisation. Instead, you want the currency to be as open and useable as possible. Well, it turns out that a blockchain can help here.
You create a library of software that allows anyone to use their computer to host and manage account blockchains. Transactions are inherently secure because they are stored as blocks in the chain. The account storage is robust because the blockchains are stored on lots of machines which talk amongst themselves and make sure that all the chain stores are synchronised. The only problem that you have now is persuading people to run your currency server code on their machines. Enter our digital currency.
Up until now humanity has based its currencies on something physical, starting with things like lumps of gold but more recently coins and bank notes. We manage our money using phones and computers but underpinning it is the principle that you can walk into a bank and ask for your cash in physical form to take home and hide under your mattress (don't do this). The bank just holds a number that specifies how much cash you have, not the money itself.
A digital currency replaces the gold or bank notes with the solution to a digital puzzle. This solution must be calculated by a powerful computer and once it has been obtained and verified it can be used in transactions. The process of creating these solutions is called "mining". Around the world (usually where the electricity is cheap) you can find buildings full of computers working on solving these puzzles and adding solutions to the blockchains of their owners. They are literally making money. The mining computers also host the blockchain servers that underpin the currency, recording the movement of the digital cash using blocks in account blockchains.
It's possible for you to start with no digital money, run your computer for a while, generate some currency of your own and start spending it but a quicker way to get started is create an account with a broker who will exchange your digital currency into old-style cash and back. You use a program that acts as your "digital wallet". Once you have signed into the program you can use it to give other people your digital cash or ask your broker to move your money in and out of the digital domain.
The problem with a digital currency is that it is not underpinned by anything. If you look carefully at a British banknote, you will see that written on it is the phrase "I promise to pay the bearer on demand the sum of x pounds", where x is the value of the bank note. In olden times each banknote was backed by gold. You could go into the Bank of England and ask them to exchange your pound notes for lumps of gold from the treasury. We moved off the "gold standard" a long time ago but the principle remains. The UK government stands behind your wallet. The Bank of England works to make sure that the pound has a particular value of itself and in relation to other currencies. It is unlikely that all our pounds will suddenly become worth a lot more or a lot less. It has to be like this otherwise nobody could do any business.
No such safeguards exist for digital currencies. Massive speculation can (and does) cause their value to skyrocket and then plummet. Digital brokers can vanish taking their customer's money with them. If someone finds a bug in the software that implements the currency the whole thing could disappear overnight. Investing in a digital currency is not without risk, to put it mildly.
Bitcoin is the most popular digital currency. It's been going since 2008. You can buy bitcoins, or parts of them and use them to pay for stuff or as an investment. They are never going to replace proper money though. One issue is that the time it takes to complete a transaction (create a block, add it to the blockchain and replicate it over multiple servers) is around 10 minutes. So, by the time you'd managed to pay for your cup of coffee using a bitcoin it would be rather cold.
Another popular digital currency is Ether. This currency is underpinned by an open-source framework called Etherium. Blockchains stored in Etherium can also hold transactions managing Non-Fungible tokens or NFTs. So, what is a non-fungible token?
The word fungible means "interchangeable". If I buy a batch of bricks to build a wall all the bricks will be the same size and shape and I can use any one brick in place of any other. My bricks are fungible. If I want to make unique bricks (perhaps for a wall of remembrance) I could carve a different message on each one. Now I can't swap one brick for another without changing the wall. So, a non-fungible token is one that can be proved to be unique.
If you think about it, it would be quite easy to copy a "non-fungible" brick. You'd just have to create a new brick with an identical message on it. However, when the Etherium system creates a non-fungible token it makes sure that the new token is unique within the Etherium universe. The token can then be moved between owners using transactions that are stored in a block chain by the Etherium system. I can purchase a non-fungible token by using a broker to get some Ether funds and use them to buy it. The transaction is stored in an Etherium blockchain and I can use this as proof that I own that non-fungible token.
Owning a non-fungible token sounds like it might be fun, but it gets real when we link the token to something else. One of the problems with the digital universe is that it is very difficult to maintain and manage "ownership" of an asset. You might have created a photograph or piece of music but once you put it into the digital domain it is very hard to stop people taking copies for free. And when you do find someone who has copied your work it is also hard to prove that you're the original owner.
The Etehrium system lets you bind a non-fungible token to a digital asset (which could be a document, a picture, a music track or any other data file). The binding process generates a transaction in a block chain managed by Etherium linking the non-fungible token with the asset. We can then create another transaction that records the purchase of the non-fungible token by the “owner” of the asset. This allows the owner to say "I own this". The digital asset can still be copied, but at least the owner has a a way of proving they have been wronged and claiming some recompense. An owner of a non-fungible token can sell it to someone else, which generates another transaction which is added to a blockchain.
So, at this point we have currency system which operates outside the "normal" banking space and a way of digitally conferring "uniqueness" on things and proving ownership of them - at least within the Etherium system itself. And now human nature can take over. The first thing that happens is that a lot of people pile into the digital currency arena and push up the value of everything. This does not mean that the digital currency has any inherent value, it just means that lots of people think it has. The second thing that happens is that people start assigning non-fungible tokens to anything and everything and an industry springs up generating things that have no value except for the fact that they have unique non-fungible tokens assigned to them. Remember that owning a non-fungible token that represents an item doesn't give you any control over that item, it just means that you can brag about what you’ve got and raises the vague possibility that in a perfect world you might be able to get some royalties or perhaps sell the "ownership" to another person in the future. Someone compared the whole thing to "selling plots of land on the moon" and I can see their point.
And here we are. Apparently, London tube stations are full of adverts offering the chance to join this new revolution. I can see why people might be interested in getting involved. In a world where if you play by the rules, work hard, save and do all the right things you still can't afford to buy the house that you want (even though your parents and grandparents managed to get theirs quite handily) you might feel that you deserve a short-cut of some kind. And perhaps the early adopters will do quite well out of it. But I worry that time has already passed.
It might be fun to buy non-fungible tokens directly from an artists who’s work you really admire, but to be honest I’d rather go down to the Ferens Art Gallery open exhibition and buy something physical to hang on the wall.
I’ve decided that I really want to do this. If I take a camera or two I think that my desire to get a photograph might able to offset my fear of heights.
You know you’re getting old when your blog starts to fill up with recommendations for coffee shops.
Anyhoo, The Old Lamp Room in Cottingham is lovely. It is right by Cottingham station. In the building where they used to prepare lamps for steam trains. We had a drink and a scone and were able to sit outside and watch the trains go by. Great place. The food menu looks good too.
I've spent a lot of my time teaching C#. And the starting point for my students was always an empty console application. Something like this:
using System;
namespace OldSchoolConsole
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}This is what you used to get when you created an empty console application in Visual Studio. It brings in the System namespace so that you can interact with the user and then creates a namespace and a class containing the Main method that makes everything happen. (in this case print "Hello World!")
However, if you use Visual Studio 2022 and .NET 6.0 to create an empty console application you will get this:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");The link in the code gets you to a description of what has been done and the C# features that make it possible. I can understand the reasons for the change. You can run a Python or JavaScript program from a single statement and so someone must have thought that C# needed that feature too. However, I'm not convinced that the change is a good one.
I really liked the way that the old arrangement forced the reader to consider the way C# programs are structured and managed. My C# Yellow Book makes a big feature of going through all the statements in a complete program right at the start, so readers appreciate how C# programs fit together. The new single line arrangement might give the impression that I'm doing stuff that is unnecessary and making things complicated when I'm really paving the way for understanding of how everything works. The new design doesn't really make it easier to construct programs. If you want to use classes in your simple one-line program it all falls apart with build errors that make little sense to the beginner.
The good news is that you can just delete the one line solution and go back to the old program if you want to. Which is what I plan to tell people to do.
I’ve just decided I’m wrong here. If I think about the issue properly (something that only ever seems to happen after I’ve posted an article) I reckon that the new console format is a good idea, especially from the point of view of teaching programming. When I wrote Begin to Code with C# I invented a framework (called Snaps) that makes it trivially easy to create a universal windows application with a minimum of surrounding code. This change is doing exactly the same thing for console apps.
My argument above doesn’t point up a flaw in the new design, it points up a desire on my part to keep my teaching sequence the same, rather than look at simplifying the learning process.
I’m now going to re-write the first part of the C# Yellow Book to make use of this new feature and make it easier to focus on what programs do before moving into the features that make solutions easier to manage. My apologies to the .NET 6 team, you’ve actually done something really nice.
Trinity Market in Hull is a wonderful place to visit. Lots of very interesting things to buy and great places to eat and drink. And all indoors and heated. Plus a nicely set up meeting space they use for all kinds of things. Including half-term crafting events for little people. Lovely. Count us in.
The event was organised by Hull Libraries who do some lovely stuff around the city. And in the library. They had coloured paper, feathers, stickers, glue, pipe cleaners and all the crafting stuff that kids (and me) like playing with. Thanks very much for organising it and making one little lady a very happy bunny. Whose happiness only increased when we swung by Dinsdales in Hepworth’s Arcade to buy a joke on the way home.
We also grabbed a coffee in the market from these folks which was excellent and extremely good value. They do very nice de-caffeinated too.
No wonder I look worried
The original Pokemon games kind of passed me by. Perhaps I was a bit too busy with other things when they first came out, or maybe I was anxious not to be seen to be taking over the games that my kids were playing at the time. Well, that ship has well and truly sailed now… So when Pokemon Legends Arceus came along I was tempted. The game seems to have a nice exploration angle and although the graphics didn’t look the best they looked good enough to build a solid atmosphere. So I stumped up the cash and downloaded a copy.
I’ve not done much yet. Just the training missions. But I am having fun, and it looks like there is a lot of depth to the whole thing.
The nights are getting brighter and there are things like this out. Could we be approaching the end of winter? Rather hope so.
We have a house guest for the next few days. Turns out her favourite TV show at the moment is “Boy Girl Dog Cat Mouse Cheese”. You can find it on BBC iPlayer and also on Netflix. Not the most relaxing watch, but fun. And it has cheese in it.
I’ve spent the day sharpening my pencils (no idea why) choosing font types, rearranging my desktop shortcuts, emptying my wastebasket, and tidying my desk very slightly. Then I finally got around to writing the agenda slide for my Red Nose Day presentation in rhyme. I hope you like it. It took a long time to write……
You can sponsor me here. And the best part is that if you sponsor me you don’t have to remember to watch the session at 7:00 pm on Friday 18th March (link here)
I was up town yesterday for the hardware meetup and the lighting was rather good. So I took a few pictures of the place. Above is City Hall, where I used to help with degree ceremonies back in the day.
This is part of Hull Maritime Museum, which is just undergoing a massive refurbishment.
This is an awesome mosaic which is now being preserved.
The design looks even more impressive close up.
We had our first in-person hardware meetup of the year tonight and it was a roaring success. The theme for the evening was “Thermal cameras” and Brian had brought along his thermal camera equipped Pi which has a really nifty screen. You can see it action above. Faces show up as bright red, with windows and other cold things dark blue.
Pretty much everyone had brought along some stuff to talk about. Ion had brought along some amazing creations, including a super accurate crystal controlled clock which he had built from scratch, including a custom designed four-layer printed circuit board.
Richard had brought his beautifully built “Completely Useless Machine”. To find out what it does you have to flick the switch.
I was going around making tiny printed portraits of people using the Kidizoom camera. You can just see one of Richard underneath his device above. It turns out that if you take a photo with the camera and then convert it in to a “colouring in” picture you get some nice looking line art printed out.
We’re going to try and meet up in person once a month from now on. If you’re in Hull and you fancy coming along it would be lovely to see you. I’ll be posting the details of the next meetup soon.
The flowers arrived on Valentine’s day. We’ve just finished building them and finding a vase to fit. This is just half of the set, we thought they’d work best as two bunches. Great fun and almost romantic.
I’ve just set up the JustGiving page for the Red Nose Day lecture in rhyme next month. For every donation I’ll add an extra cheese pun.
https://www.justgiving.com/fundraising/rhyming-rob-miles
And remember, if you sponsor me you don’t actually have to watch the presentation. In fact, you might prefer it that way.
Blimey. Twenty years eh? The .NET framework has been part of nearly a third of my life. Highlights for me:
Going to amazing sessions at Cambridge University and learning all about the new framework from the people that built it.
Launching the first ever .NET Masters Course at Hull University and delivering a couple of modules for it, including one where we modified the razor open source .NET compiler to make broken programs and then got the students to try and debug their code with it.
Switching to C# as our teaching language in the department and creating the world famous (in my world) C# Yellow Book.
Getting into mobile development with the .NET Compact Framework and revelling in being able to create C# code for a mobile platform.
Exploring the XNA Framework and making the immortal “Cheese Lander” game. Running it on a Zune (because I could).
Putting .NET programs into teeny, tiny devices using the .NET Micro Framework.
Running Sliverlight and XNA in a Windows Phone on what is still the most beautiful user interface there has ever been for a mobile platform.
Using .NET Gadgeteer to make amazing embedded devices, even down to their circuit diagrams. All in Visual Studio with in-device debugging.
Using ASP.NET to create a web controlled multi-player robot fighting game for Three Thing Game.
Writing the first Begin to Code book for C# and building an entire UWP environment called Snaps to make it easier to make useful applications quickly.
Here’s to the next 20 years.
A programming language is like any other language. It must evolve over time to reflect the ways that it is used. One of the things I love about C# is how it has grown over the years. One of the latest changes is the addition of a !! operator (otherwise known as the “bang bang” operator). This is causing a bit of debate, which is great because changes to a programming language should always be made on the basis of a proper discussion. But you might be wondering what all the debate is about. So here’s a quick explanation of what is going on.
C# has always had methods. A method is a thing you can ask an object to do. For example, you might have an object which you can ask to serve a drink:
barkeeper.serveBeer();
barkeeper.serveCoffee();Then you might decide that rather than have a lot of different methods for different kinds of drink it would be easier to make a method that accepts an argument that tells it the kind of drink that is required:
barkeeper.serveDrink("Beer");
barkeeper.serveDrink("Coffee");The serveDrink method can look at the value of the argument and decide what to do:
void serveDrink(string drinkName)
{
// test the name and make an appropriate drink
}So far so sensible, although we have made things slightly easier in one respect (we can use serveDrink method to serve any drink rather than having to make lots of methods) by making things slightly more difficult in another (the serveDrink method has to decide what drink is to be made and what to do if a matching name is not found). For example, what should happen when the following code runs?:
barkeeper.serveDrink("BEER");The above code is asking for a beer, but the name is all capital letters. Does the method deliver a "Beer", or does it fail with an error. If it fails with an error, how does the user of the program know that an error has occurred? At this point we have to invent a convention for our application. We might say that the serveDrink method will throw an exception if it is given a drink type it doesn't recognise. That's fine as long as the behaviour is documented so that users of the method now how to use it.
But what about bang bang? I hear you ask. The operator is intended to make life easier for programmers by automating the handing of null references. Consider what would happen if someone did this:
barkeeper.serveDrink(null);This code will ask for a drink but provide a null reference as the drink description. A null reference is not the same as an empty string, it is a reference that points to nothing. This is like asking the barkeeper for a drink and then falling over on the floor before you tell them what you want. An attempt by the serveDrink method to use this null reference will result in the method failing in some way.
Naughty hackers love this kind of situation. They might discover that asking for a null drink causes the serveDrink function to crash just after it has opened a bar tab, so that they can then continue to order drinks for free. They might find it serves out the most expensive drink in the bar.
As the person who is writing the serveDrink method you don't want anything like this to happen. So in the method you add a test to make sure that the argument is not a null value:
void serveDrink(string drinkName)
{
if (drinkName is null) {
throw new ArgumentNullException(nameof(drinkName));
}
// test the name and make an appropriate drink
}The first thing this serveDrink method does is check to see if the drinkName is null. If it is null an exception is thrown which exits the method instantly. This exception may or may not be handled by the caller, that is up to them. However, we have made sure that the serveDrink method won't do anything stupid if given a null reference. (of course we now have to worry about the issues that might be caused by this method throwing an exception thougth - welcome to the world of error handling).
What the bang bang operator does is make the above test for us automatically.
void serveDrink(string drinkName!!)
{
// test the name and make an appropriate drink
}In this verson of the code an exception is thrown if drinkName is null. I don't have to remember to add the call. This might make my programs slightly safer. But it also means that readers of the code need to understand what !! means in this context. They might look at it and think that the drink is very important, or hot, or something else. They might not know what it does and add their own tests for null which don't do what they expect. Hence the debate.
My opinion? I split language features into two categories. Cake and icing. This is definitely icing. I'd never use it personally, as I like my error handling code to be very visible to someone reading my programs. Plus I don't like situations where readers need to know "special stuff" to make sense of what they see. However, it's not a thing I'd stress about too much either way. I just love the way that C# is still striving to move forwards.
You can find out more about this proposal and the debate here.
I’m playing with some ideas for the introduction to an update of the C# Yellow Book. I don’t want people to end up thinking that a developer writes programs. I think a good one does a lot more than that:
I like to think of a developer as having three heads. I think that to be a good developer you should be capable of wearing any of these heads, although you will probably be better with one head or another. If you are working in a team, you might find that team members gravitate towards one particular head, but everybody should know what the heads do. The heads are:
This head is friendly, approachable, and constructive, but not above asking hard questions about what should really happen or why something is being done the way it is. This head is good at writing things down and then showing them to people to make sure that everyone agrees what is being made. It has a twin - the "This is what I'm going to build" head which is used when you are making something for yourself.
When you first start programming you don’t use this head very much because the things that you do are set out as exercises for you to have a go it. However, if you can get good with this head it will vastly improve your usefulness as a developer.
This head is good with technology. It can take the problem definition from the first head and build a solution using software and hardware. Making it work might involve creating an overall design, breaking things into components and then making each component in turn. For a large development this head might have to assemble and manage a team of people. Testing will form a big part of the process; this head is very keen to be able to prove that it has made something that works. This is the head that most people think developers wear all the time. I think it is the hardest head to learn to use because when you are learning program it is very difficult to know where to start when confronted with a problem and asked to make something that provides a solution.
This head is a bit of a worrier. You might think it comes into play once the "Make something that works" head has finished but this is not quite how it works. This is a head that you pop on every now and then to look at how things are going. It's the one that asks the hard questions when finding out what is wanted. It's also the head that looks at a solution and worries about things like reliability (are there things that can go wrong), security (can the system be successfully attacked), scalability (what happens if we get lots of users) and business (can we be sure we are going to get paid for all this). This head really wants to make something good, but it also has a sense of perspective and is happy to negotiate what "good enough" means, as long is that is written down and everyone agrees about it.
In a team the heads can turn into different roles for team members. Whatever happens I think it is really useful if a developer stops every now and then and thinks “I wonder what my other heads would think of this?”.
We’re holding our first in-person meetup event of 2022 next week at the Makerspace in Hull. At this event we are going to take a look at what a thermal camera can do for you. Brian has got one running into a Raspberry Pi and has been doing some tests.
Of course we’ll be bringing along other bits of hardware to talk about and you are welcome to bring yours too.
If you’d told me thirty years ago that I would still be doing Red Nose Day lectures in Rhyme in 2022 I’d have said “Who are you?” and “Why can’t you tell me anything useful like ‘Buy Google Shares’?”
But that’s by the by. I’m doing it again, sooner than I expected. For now, just make a place holder in your diary and get ready to flex your wallet a bit. This time I’m going to tell you some Genuinely Useful stuff about how the web works. You don’t need to know how to program, or anything much about computers. But by the end you’ll know a bit about how the web works, have played a silly game and heard more cheese puns that you really want to.
Keep coming back to here and I’ll update you with progress, including the all-important link where you can donate your socks off.
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.