-
On the Same Page
At the end of 2021 GitHub pages deployments moved to using GitHub actions. When a site is deployed you can see the jobs running to generate your site, package it up ready to be deployed, and push it to the GitHub Pages service. Lets try using these actions in a custom GitHub Actions workflow to build and deploy a site without using Jekyll.
Continue reading → -
Into the Dark
I’ve finally dragged this blog into the 21st century with the addition of Dark Mode. In this post I’ll walk through some of the main tasks, and dig into the approach I took.
Continue reading → -
Red Green Syntax Trees - an Overview
It’s no secret that I’m a big fan of a good parser. One of the key parsing techniques that I have tried to focus on in the past is “infallible parsing”. The idea that for any input the parser should always generate some output. This is important to try and give as accurate a set of errors as possible when malformed or partial code is being analysed. An idea that builds on this is lossless syntax trees. In this post I’ll discuss a high level overview of a kind of lossless tree, discuss where it came from, and how it can help when parsing and compiling.
Continue reading → -
Granola Slices
A quick and easy recipe for the flapjack I miss from the office.
Continue reading → -
Error Recovery in FParsec
An interesting discussion on error recovery with the
Continue reading →nom
parser combinator in Rust has been sitting on my “To Read” list for a few months. After re-reading it a few times I have been inspired to try out the approach in that article using the FParsec library. -
A Captivating Resolution
Compilers are generally split into three stages: syntax, semantic, and emit. The translation from syntax tree, produced by the first stage, to semantic tree, consumed by the latter stages, is called binding. Binding involves walking the syntactic representation, resolving variable references, and producing a tree based on the semantic structure of the program. For a single scope variable lookup is fairly simple. When dealing with lambdas that can capture values from an outer scope things get more complex. In this post I’ll walk through developing a simple binder that can handle lambda captures.
Continue reading → -
LISP in Two Days with Rust
As a sidetrack from the development of my programming language I’ve spent some time developing a LISP. The plan is to use the language as a testing ground for experimentation with transforming an AST in Rust. The syntax of LISP is simple and was developed to be easy to parse. I figured it would make a good starting point for an experimental compiler.
Continue reading → -
Optional Extras
A neat feature of the
Continue reading →Option<T>
type in Rust is that it implements theFrom<T>
trait. This allows for ergonomic optional parameters: -
Racing Onwards
I’m a long term Emacs user. When I first started writing rust I concocted an Emacs configuration using
Continue reading →racer-mode
andrust-mode
directly which got the job done. Since then the state of Rust editor support has come a long way. I’ve finally taken the plunge and moved to RLS for a richer language completion experience. -
Once More with Handlers
I previously wrote about creating a custom authentication middleware in ASP .NET Core. With the move to ASP .NET Core 2.0 this approach at creating custom authentication providers no longer works. It’s time drag custom authentication into the Year of the Fruit Bat with an ASP .NET Core 2.0
Continue reading →AuthenticationHandler
. -
Upon Reflection
I’ve been spending most of my time recently performance profiling and optimising one of our main services. Part of its job involves exposing data objects through a generic interface. The abstraction allows public properties on each object to be read using an untyped indexer. To do this we look up all the properties of each data object via reflection and cache them so later reads and writes are quicker. Turns out this caching is not enough. With many short-lived objects we ended up almost half our time in some performance critical paths just populating this reflection cache. The initial implementation is naïve, but what can be done about it?
Continue reading → -
Make it work Switch
During some performance testing of an application a colleague and I had trouble processing more than 150 requests per second per instance. After much hair-pulling the bottleneck was identified as the
Continue reading →ServicePointManager.RequestLimit
. This global variable controls the number of parallel HTTP requests that a .NET app will make to a given domain. By default it is set to 2, throttling the load that an off-the-shelf .NET app can place on a remote server. -
Authentication Middleware in ASP.NET Core
There are two sides to the auth story in ASP .NET Core: authentication and authorisation. Authorisation is usually controlled in an MVC app with the
Continue reading →[Authorize]
attribute. The simplest, no-argument[Authorize]
checks that the user has a single identity which is authenticated. Authentication is responsible for inspecting the request and adding known identity information about the user. In many cases this will be validating OAuth or JWT. -
Rusting up Some Iron
Rust is one of my favourite languages. One of it’s great strengths is its ecosystem of crates, another is the FFI system which enables writing native extensions when performance or safety is required. Over the last week I’ve been pulling these two together in IronRure, a .NET Standard wrapper around the Rust
Continue reading →regex
crate. -
The Pragmatic PasswordBox
In WPF the
Continue reading →PasswordBox
control does not expose the password it contains through data binding. It is a security feature designed to protect the sensitive data the box contains. It is however quite a faff and has sparked much debate. -
The Dark Side
At work I’m paid to write C#. At home I’m a dedicated Mac user. When I initially learnt C# for the job interview years back I had to use Mono to run it on my Mac. A lot has changed in the .NET world since then, most notably the arrival of .NET Core. So I finally decided to give it a try.
Continue reading → -
The Lies
At the weekend I was listening to Stereophonics ~ Performance and Cocktails. The song Half the Lies you Tell Ain’t True reminded me of a certain public figure. I have no idea why.
Continue reading → -
The Missing Link
LLVM is great for hacking about with languages. It takes a lot of the complexity out of code generation. It allows you to turn your
Continue reading →SyntaxTree
or whatever you’ve got into real live object code. Code you can directly execute. Well, almost. -
Low Down - Part 2 - Initialisation
In my previous post I left out something quite important: initialising the components of LLVM we wanted to use. Luckily there’s a quick and easy way to get that sorted, and we get to learn about a neat part of the Rust standard library.
Continue reading → -
The Low Down - Using LLVM From Rust
LLVM is a collection of libraries and programs for creating compilers. It is built around a powerful intermediate representation, LLVM IR. It has tools for compiling LLVM IR to native instructions, performing optimisations and even performing JIT compilation. The libraries that power this have an extensive C API allowing you to harness this power yourself, so that’s what we’re going to do! I’ll show you how to create a simple Rust program which creates a simple function from scratch in LLVM.
Continue reading → -
Top-down Operator Precedence Parsing in Rust
Following on from from creating a tokeniser the next step is writing a parser. The simplest way to create a hand-rolled parser is using recursive decent. In this parsing method each non-terminal in the grammar is converted into a function which encodes it’s parsing logic. This is great for parsing things like function definitions, variable declarations and other parts of a language which can be easily recognised from their prefix. Where it falls down a bit however is parsing expressions with infix operators. This is where Pratt operator precedence parsing comes in.
Continue reading → -
Doing Nothing
When hacking on a problem it’s easy to get carried away with the how. How are you going to divide up the implementation. How are you going to ensure it’s testable. Usually these hows are quite narrow.
Continue reading → -
768 is the Magic Number
When reconstrucing a binary MSMQ message from a backup I was first tempted to just set the
Continue reading →Body
property on the message directly. This doesn’t quite work however as theBody
property is serialised with whatever formatter you’re using when the message is sent. -
Hacktoberfest
One of my favourite new languages right now is Rust. It’s an interesting combination of strong typing, low level control and memory safety. Rust is a rapidly growing and changing language, and now is a great time to get involved as part of Hacktoberfest.
Continue reading → -
A Rusty Guide to Tokenising by Hand
I recently wrote about creating a tokeniser in C++ using Ragel. In that post I created a lexer which recognised a set of three tokens. In this post I’ll discuss creating a lexer by hand in Rust to recognise the same language.
Continue reading → -
Microcrates: Little Flecks of Rust
Gists are really just git repos with no directory structure. This is something that some Rubyists have taken advantage of in the past to create “Microgems”. Would it be possible to do the same thing in Rust?
Continue reading → -
Tokenising in C++ with Ragel
Ragel is an alternative to Lex/Flex for creating lectures from a set of regular expressions. It is far more powerful however. Where Lex allows you to chain together a set of regular expressions and run some actions written in C or C++ in response to a match Ragel allows you to generate an arbitrary state machine by combining regular expressions and then run actions at any point in the matching of those expressions. It also supports a wide variety of ‘host’ languages, including C#, Ruby and Go.
Continue reading → -
Joining the Disqusion
I have finally got around to adding commenting to this blog. In the end it turned out to be quite simple.
Continue reading → -
Sneakernet Push
I’ve been living without internet recently. That hasn’t stopped me writing code though. If anything it has accelerated the process. I’m mainly using Git these days. It’s more than at home working without a connection to my repos on GitHub. Every now and again I like to back things up though. That’s where the “Sneakernet Push” comes in.
Continue reading → -
Testing Times
It’s been a hectic few months. I’ve just moved from the blistering sunshine of the south of England to the chilly embrace of the north. That means I’ve not been able to spend that much time writing code outside of work. Now things have calmed down a bit I decided to integrate google test into a C++ application I am developing. This is the story of just how easy that was.
Continue reading → -
The First Solution and The Best Solution
There is a saying. I’m not sure where it comes from. I’m not even sure if I made it up entirely. But I find it entirely appropriate when developing software.
Continue reading → -
Loosing Focus
The air is warm. Too warm perhaps. There is almost no wind at all. What breeze there is does nothing to cool. Lights twinkle on the skyline in intricate patterns. I slide them out of focus. Snap.
Continue reading → -
Help, I'm Learning (and It's Fun)
It all started one fateful day, as these things have a habit of doing. A friend was playing a game on his laptop where he launched rockets into space. He informed me that it was called “Kerbal Space Program”. I thought nothing of it until I came across the game again in the Seam store. Now I’m hooked.
Continue reading → -
A Splash of Colour
I began my text editing journey, as many do I am sure, with Notepad.exe. When I made the transition to OS X I began searching for an editor to replace it. The then-free Smultron was that editor initially. Since then I have used many editors, from the wonderful TextMate to the cheap-and-cheerful GNU nano. I even tried vim and, of course, Emacs.
Continue reading → -
Secure for the Common Case
“I’ll have to type in that thing again” my dad moaned. “They gave me a new laptop and I haven’t used it on the wireless yet.” he explained. The “thing” he was referring to of course was the wireless key. A completely incomprehensible string of numbers and letters that took up three lines on the back of the junk-mail envelope in his hand. I began wondering exactly how secure the house wireless password was.
Continue reading → -
How to Recognise a Tortoise
Computer vision is an area which I had a distant interest in for quite some time. I appreciate that the task of vision is a complex one and always imagined that there must be some great algorithms behind the task. The process of computer vision, like many areas of artificial intelligence, is one where it is so easy to view the actions of a computer as those of a person. It was this lingering interest, with a touch of reverence, that prompted me to choose a vision project in my final year of university. It completely changed the way I think about artificial intelligence.
Continue reading → -
Testing Testing Testing
Scripting languages are all the rage these days. I am a fan of Python, although you may prefer Ruby, Node.js or whatever it is the cool kids are using these days. The exact language that takes your fancy however doesn’t really matter. They almost all have one thing in common: Unit tests. This is not a startling realisation, nor is it restricted to the realms of modern scripting languages. I hear that even the assembly code running on the jet engine of your favourite airliner is unit tested (a reassuring fact). Startling or not what is important about unit testing with scripting languages is the ease at which the development cycle progresses. If only it could be as easy for other languages.
Continue reading →