<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kenneth Falck (@kennu)</title>
	<atom:link href="https://kfalck.net/feed/" rel="self" type="application/rss+xml" />
	<link>https://kfalck.net/</link>
	<description>Kenneth Falck&#039;s Blog</description>
	<lastBuildDate>Mon, 31 Aug 2020 03:26:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.4.2</generator>

<image>
	<url>https://kfalck.net/uploads/cropped-T02MZBG9C-U97PSCZ53-d9afdb751d1f-512-1-32x32.jpg</url>
	<title>Kenneth Falck (@kennu)</title>
	<link>https://kfalck.net/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>The Rise of Step Functions</title>
		<link>https://kfalck.net/2020/08/31/the-rise-of-step-functions/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Mon, 31 Aug 2020 03:03:09 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/?p=868</guid>

					<description><![CDATA[The idea of Step Functions is to define cloud backend processes as visualizable graphs and to reduce the number of traditional lines of code you have to write. For example, customer orders are a typical application for Step Functions. When you model your orders using Step Functions, you&#8217;re not just storing the order information in [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The idea of <a rel="noreferrer noopener" href="https://aws.amazon.com/step-functions/" target="_blank">Step Functions</a> is to define cloud backend processes as visualizable graphs and to reduce the number of traditional lines of code you have to write. For example, customer orders are a typical application for Step Functions. When you model your orders using Step Functions, you&#8217;re not just storing the order information in a database. You are also defining how the order is processed from payment to fulfillment according to predefined rules.</p>



<figure class="wp-block-image size-large is-resized"><img src="https://kfalck.net/uploads/stepfunction-1024x380.png" alt="" class="wp-image-875" width="810" height="300" srcset="https://kfalck.net/uploads/stepfunction-1024x380.png 1024w, https://kfalck.net/uploads/stepfunction-300x111.png 300w, https://kfalck.net/uploads/stepfunction-768x285.png 768w, https://kfalck.net/uploads/stepfunction.png 1470w" sizes="(max-width: 810px) 100vw, 810px" /><figcaption>Fig 1. Step Function example from <a rel="noreferrer noopener" href="https://webcat.fi" target="_blank">WebCat</a></figcaption></figure>



<p>Technically you are defining state machines and state transition rules. These states typically represent integrations between  backend systems  (internal and external) and sometimes human processes such as physically delivering products by mail.</p>



<p>I talk about Step Functions here, but that is just the Amazon product. Azure has Durable Functions and most other cloud platforms probably have something similar. The interesting thing to me is the new low-code programming paradigm that they are enabling.</p>



<h2>The Big Promise</h2>



<p>When you define your business processes with Step Functions, you gain a few important abilities:</p>



<ul><li>Visualization: It&#8217;s easy to render the business process as a visual graph. In fact, AWS Console does this automatically for all Step Function executions.</li><li>Observability: You can see the current state of your business process and what&#8217;s going to happen next. You can also track errors in once central place.</li><li>Retrying: When an error occurs in an operation in the middle of the business process, you can have rules to automatically retry the operation before giving up.</li><li>Error handling: When an error occurs in the middle of your business process, the entire process is aborted. The error is not mysteriously lost in a swamp of log files. You don&#8217;t end up in a &#8220;nothing happens&#8221; state because a Lambda function didn&#8217;t trigger the next SQS or SNS message.</li><li>Scalability: If your business process involves operations that can run in parallel, Step Functions will let you do that and collect the results. The process will continue when all the parallel steps have completed.</li><li>Modularity: When your business process is defined as a collection of independent states whose input and output are JSON objects, it becomes possible to exchange the implementation of any state with something else that consumes and emits the same JSON objects.</li></ul>



<p>All these abilities are features that you could program yourself from scratch, but now you don&#8217;t have to. Instead, you define the broad outline of your business process using Amazon States Language (ASL). Then you add small pieces of actual code using TypeScript or Python or whatever language you wish to use.</p>



<p>The price is a learning curve. The ASL language itself is not complicated, but figuring out how to properly use it can sometimes be. The most challenging issue is how to model your state inputs and outputs. They are just regular JSON objects, but the way that Step Functions can process them is rather limited and the objects can get complicated.</p>



<h2>The Challenge of Increasing Complexity</h2>



<p>You will quickly experience the complexity of managing state inputs and outputs when you define a bigger Step Function that involves many states. Perhaps it has a Map state, a few Choice states, some Lambda function executions and some external Step Function executions. All these different operations return their outputs in different ways, and the state that is flowing through your state machine is affected by them.</p>



<p>For example, Lambda function output is received as a Payload object, which you typically assign to a Result object using ResultPath. If your Lambda function returns an object like <code>{"hello": "world"}</code>, the actual output will then be <code>{"Result": {"Payload": {"hello": "world"}}</code>.</p>



<p>If you happened to call that Lambda function from a Map state, you will actually get an array of those output objects. And since you again need to use ResultPath to preserve the original Step Function input, the output will look something like {<code>"Result": [{"Result": {"Payload": {"hello": "world"}}, {"Result": {"Payload": {"hello": "world"}}]}</code>.</p>



<p>To makes things a little more complicated, your states can also have Catch handlers which are called when an error occurs. They will receive the error object and they can return a valid output if they decide that the execution can continue. This introduces a new variation to your state machine, so sometimes the output might be <code>{"Error": {"Error": "xxx", "Cause": "yyy"}}</code>.</p>



<p>So, in my view, the main problem of Step Functions is how to mentally comprehend the exact structure of the input and output objects at any given state of the state machine. You very easily lose track of all those <code>Results</code> and <code>Payloads</code> and <code>Errors</code>. Then you typically start guessing and tweaking the inputs and outputs until the system appears to work.  When your Step Function is complicated enough, you can&#8217;t manually test every possible state (including the error states), and you inevitably start introducing bugs to the logic.</p>



<h2>How to Manage Complexity</h2>



<p>The way that Step Functions pass an input object to the next state is basically like an undocumented API with no schema definition and no type checking. In my view, this is currently its biggest shortcoming. Lack of input/output schema definitions makes it difficult to develop complex state machines. It is entirely up to the developer to write down the schemas in comments or in some external documentation. That quickly gets verbose and inconvenient.</p>



<p>If Step Functions had built-in schemas for state input and output, you could validate the state transitions during development. For instance, when you use Visual Studio Code to develop your Step Functions, you might immediately see red errors when you&#8217;re trying to pass an invalid input to a state. This could also be a deploy-time feature of AWS CDK. It would refuse to deploy a state machine when it detected invalid state inputs. It would basically work like TypeScript type checking.</p>



<p>Another approach, perhaps complementary to schema validation, would be to visualize the inputs and outputs during development. Tooltip hints in Visual Studio Code would tell you what kind of input a state expects, what kind of output a state emits, and how they are transformed by the Step Functions directives like InputPath, OutputPath, ResultPath and ResultSelector.</p>



<p>A third solution, also complementary, would be to replace the current input / output directives with a more flexible JSON transformation feature. Currently, Step Functions can only &#8220;prune&#8221; JSON objects by picking one or more attributes from an output object. It would be much more helpful (although also much more complicated) to have transformation functionality similar to the jq CLI command. The jq command can process JSON objects and arrays dynamically and synthesize new objects from their attributes. That would let you &#8220;flatten&#8221; the outputs and to synthesize the inputs with more freedom, ultimately keeping the actual state as simple as possible.</p>



<h2>The Next Level</h2>



<p>I believe that Step Functions will not be programmed using code in the future. There will be visual tools for designing business processes and their state transitions. These tools will include schema validation features to manage the complexity issues I described earlier. They will make it foolproof to create Step Functions that will not fail because of an input/output syntax error. They will also warn you when they detect other logical errors in your process definition.</p>



<p>The new development tools will also let you embed TypeScript code (or other languages if you wish)  into the state machine states where traditional programming is required. It will be possible to edit the entire business process visually, and drill down to the low-level code with a simple click. This will be either browser-based or happen inside Visual Studio Code.</p>



<p>I don&#8217;t believe in the idea of extending Step Functions with lower-level features that would replace manual programming completely. It&#8217;s not practical to write every single line of code with visual logic. Step Functions will define the broad strokes of your business processes and let you add more detailed logic using traditional code. The amount of traditional code will decrease but never quite reach zero.</p>



<p>I believe that the new visual tools will also cover other parts of your cloud infrastructure than just Step Functions.  Ideally, you&#8217;ll use the same tools to design your REST APIs and GraphQL APIs and to define shared JSON data models and DynamoDB data tables. There will be some parts of your cloud stack that are not convenient to define using visual tools. You&#8217;ll define them using traditional AWS CDK code blocks or CloudFormation fragments when necessary.</p>



<p>With the increasing popularity of AWS CDK, more and more reusable abstract cloud components will be available. When someone has already designed a suitable Step Function or a Lambda function, or a more complicated AWS CDK Construct that solves your problem, you can just add it to your project. The new visual tools will need to be modular in this sense.</p>



<p>The overall goal will be to reduce unnecessary manual work (repetitively typing code) and also to reduce the cognitive load of remembering all the details of your business process in your head. Eventually you&#8217;ll be able to design and manage cloud-based systems using comfortable visual tools that let you easily zoom in to the low-level code when it&#8217;s necessary. This ultimately means less work and faster development times.</p>



<p>If you&#8217;d like to discuss this topic, you can just tweet to <a href="https://twitter.com/kennu" target="_blank" rel="noreferrer noopener">@kennu</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Back to WordPress (but Serverless)</title>
		<link>https://kfalck.net/2020/08/12/back-to-wordpress-but-serverless/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Wed, 12 Aug 2020 01:11:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/?p=848</guid>

					<description><![CDATA[I started this blog back in 2004 using a blogging system that I programmed myself. At the time, Nokia 9500 Communicator was the latest Symbian smartphone. Facebook was still called The Facebook and was being used in universities. World of Warcraft hadn&#8217;t yet been released. Since then, this blog has moved over to various technology [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I started this blog back in 2004 using a blogging system that I programmed myself. At the time, Nokia 9500 Communicator was the latest Symbian smartphone. Facebook was still called The Facebook and was being used in universities. World of Warcraft hadn&#8217;t yet been released.</p>



<p>Since then, this blog has moved over to various technology platforms. They have been based on PHP, Python, Node.js and AWS Lambda. I&#8217;ve used at least Django, Drupal, WordPress and Contentful to manage the content. Contentful was the latest platform. It worked alright, but I never really enjoyed using  it. To make it really comfortable, you need to build your own CMS user experience around Contentful.</p>



<p>Some time ago AWS released support for <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html">Lambda Layers</a>. This made it possible to run <a href="https://github.com/stackery/php-lambda-layer">PHP applications on Lambda</a>. That, combined with <a href="https://aws.amazon.com/blogs/compute/announcing-improved-vpc-networking-for-aws-lambda-functions/">faster VPC cold start times</a> and <a href="https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/">EFS support</a>, makes it possible to now run WordPress as a serverless application.</p>



<p>Here is the basic idea of my Serverless WordPress architecture:</p>



<figure class="wp-block-image size-large"><img src="https://kfalck.net/uploads/WordPressServerless.png" alt="" class="wp-image-850" srcset="https://kfalck.net/uploads/WordPressServerless.png 721w, https://kfalck.net/uploads/WordPressServerless-300x233.png 300w" sizes="(max-width: 721px) 100vw, 721px" /></figure>



<p>As you can see, I&#8217;m not exposing WordPress directly to he Internet.  Instead I&#8217;m exporting the content as static HTML and serving it through S3 and CloudFront. WordPress only works as a CMS management tool in this setup.</p>



<p>You might also notice that the architecture is not fully serverless. It still requires a MariaDB SQL server. AWS offers Aurora Serverless as a replacement, but I don&#8217;t appreciate its 30-second cold-start delay. It doesn&#8217;t work well with API Gateway&#8217;s maximum request timeout of 30 seconds. In practice you get an error whenever you try to use WordPress after being idle for long enough for Aurora to scale down to zero.</p>



<p>Everything else than MariaDB, however, scales down to zero quite cleanly. I  won&#8217;t get charged unless I&#8217;m writing articles or  someone actually reads the blog. CloudFront and S3 are billed by the number of HTTP requests and the amount of data transferred to the Internet. API gateway, Lambda and EFS are billed only when I&#8217;m actively writing articles. S3 and EFS are billed monthly for a tiny amount of data storage, but that&#8217;s counted in cents.</p>



<p>My experience so far is that WordPress works absolutely great as a Serverless application. Lambda  adds a few hundred milliseconds to each request, but it&#8217;s not too much when you spend most of the time editing articles that are saved in the background. The user interface is great for quickly uploading images and experimenting with visual layouts.</p>



<p>In the long term I will need to update WordPress occasionally. It can&#8217;t update itself because the Lambda filesystem is read-only. This increases its security significantly as PHP files cannot be overwritten. I do have a deployment script that automatically downloads the latest WordPress package, configures WordPress, and deploys it as a Lambda function. The main risk, in my estimation, is that some WordPress bug allows malicious content to be injected into the SQL database before the bug is patched. Luckily that by itself does nothing until the malicious HTML is also exported to S3.</p>



<p>If you&#8217;d like to discuss this topic further, you can reach me on Twitter as <a href="https://twitter.com/kennu">@kennu</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Architecture has become a dirty word</title>
		<link>https://kfalck.net/2019/06/11/architecture-has-become-a-dirty-word/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Tue, 11 Jun 2019 12:00:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2019/06/11/architecture-has-become-a-dirty-word/</guid>

					<description><![CDATA[In this awesome talk from React Finland 2019, Monica Lent discusses software architecture in understandable and well-defined terms. The talk rejects casual use of big words like &#34;architecture&#34; and &#34;technical debt&#34; and demands you to define what they really mean when you use them. Monica Lent&#39;s definition for software architecture is &#34;enabling constraints&#34;. An architecture [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this awesome <a href="https://youtu.be/d_BtZ8bv0sw?t=27583" title="React Finland 2019">talk</a> from React Finland 2019, <a href="https://twitter.com/monicalent" title="Monica Lent">Monica Lent</a> discusses software architecture in understandable and well-defined terms.</p>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/d_BtZ8bv0sw?start=27583" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p>The talk rejects casual use of big words like &quot;architecture&quot; and &quot;technical debt&quot; and demands you to define what they really mean when you use them.</p>
<p>Monica Lent&#39;s definition for software architecture is &quot;enabling constraints&quot;. An architecture defines the constraints that will enable people to work productively on a project. When there is too little architecture, people will generate an overly complicated and hard to maintain system over time.</p>
<p>Cloud solution architects have been lucky in recent years. Amazon AWS provides a very well thought-out architecture for Serverless applications in particular. As an architect, you mainly need to know all the available building blocks and their non-functional attributes, such as pricing and scalability options. You can then create a cloud architecture just by combining these blocks into a system that matches your requirements.</p>
<p>Frontend architects need to do a bit more work, because they have more options available to them. There is some consensus about the most important things, like state management and component frameworks. You pick a state management framework like Redux or MobX, and a component framework like React, and together they define most of your architecture.</p>
<p>Architecture may also include a number of general development principles. Monica Lent&#39;s presentation includes some of them, such as <em>inward-only pointing dependencies</em> and <em>conservative code reuse</em>. There&#39;s nothing wrong with good principles, but developers will quickly forget them. If you want to enforce a principle, it needs to be somehow baked into the development process.</p>
<p>For example, AWS Lambda functions are always stateless, because they have no way to store state anywhere. This is often inconvenient at first, but the end result is an extremely robust and scalable microservice architecture. Lambda-based development enforces good architecture in this sense.</p>
<p>Amazon DynamoDB, on the other hand, presents a much more difficult architectural challenge. An architect may have initially designed a good database scheme for DynamoDB, but eventually developers need to add more entities and views to the system. DynamoDB doesn&#39;t set any constraints on what you store in the database and sooner or later bad decisions are made.</p>
<p>Referring to Monica Lent&#39;s talk again, one way to maintain best practices over time is to encode them into automated tests. Such tests can enforce specific rules about software dependencies, for example. The challenge, then, is how to write automated tests that enforce good DynamoDB database design. It&#39;s a challenging thought but certainly not impossible.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Storing AWS CLI Credentials in 1Password</title>
		<link>https://kfalck.net/2018/03/18/storing-aws-cli-credentials-in-1password/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Sun, 18 Mar 2018 12:00:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2018/03/18/storing-aws-cli-credentials-in-1password/</guid>

					<description><![CDATA[If you are an avid Amazon AWS user, you may have noticed that the AWS CLI command line tools nowadays support sourcing credentials from external processes. This feature can be combined with 1Password&#39;s command line tool, which allows you to query 1Password items using the op shell command. By moving the AWS credentials to 1Password, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>If you are an avid Amazon AWS user, you may have noticed that the AWS CLI command line tools nowadays support <a target="_blank" href="https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#sourcing-credentials-from-external-processes" rel="noopener noreferrer">sourcing credentials from external processes</a>. This feature can be combined with 1Password&#39;s <a target="_blank" href="https://support.1password.com/command-line/" rel="noopener noreferrer">command line tool</a>, which allows you to query 1Password items using the <strong>op</strong> shell command.</p>
<p>By moving the AWS credentials to 1Password, you will be able to delete your ~/.aws/credentials file, which is otherwise an attractive target for malware and other hacking attempts (but check the caveats section below before you do that).</p>
<h2 id="installation">Installation</h2>
<p>First, install all the required software.</p>
<ul>
<li>Install the <a target="_blank" href="https://aws.amazon.com/cli/" rel="noopener noreferrer">AWS CLI</a> if you haven&#39;t already.</li>
<li>Install the <a target="_blank" href="https://support.1password.com/command-line/" rel="noopener noreferrer">1Password CLI tool</a>.</li>
<li>Install the jq tool, for instance using <em>brew install jq</em> on macOS.</li>
</ul>
<h2 id="credential-setup">Credential setup</h2>
<p>Then, move your credentials from the local AWS credentials file to 1Password.</p>
<ul>
<li>Create a 1Password item to hold your AWS credentials. Use two custom fields to store the Access Key Id and Secret Access Key. In this example, the fields are named <em>aws_access_key_id</em> and <em>aws_secret_access_key</em>.</li>
<li>Follow the 1Password instructions on how to perform the first sign-in using the <em>op signin</em> command, and how to sign in more easily after that (omitting the secret key).</li>
<li>If you want to, remove the old credentials from ~/.aws/credentials.</li>
</ul>
<h2 id="configuration">Configuration</h2>
<p>Next, add an entry that looks like this in your local ~/.aws/config file:</p>
<pre><code>[profile my-account]
credential_process = sh -c &quot;op get item &#39;Name Of Item&#39; | jq &#39;.details.sections[0].fields | map({(.t):.}) | add | {Version:1, AccessKeyId:.aws_access_key_id.v, SecretAccessKey:.aws_secret_access_key.v}&#39;&quot;</code></pre>
<p>Make sure that <em>Name Of Item</em> matches the name you entered for the 1Password item, and that <em>aws_access_key_id</em> and <em>aws_secret_access_key</em> match the custom field names you used to store your Access Key Id and Secret Access Key. The above script assumes that they are in the first section. If you put them in a separate section, you may need to change the <em>sections[0]</em> clause to match it.</p>
<p>If you are on a platform that doesn&#39;t support the <em>sh</em> shell, you may neet to figure out how to perform a similar piping operation. Alternatively you could also create a separate script file somewhere, and move the complex script command line from ~/.aws/config to there.</p>
<h2 id="testing">Testing</h2>
<p>Once the entry in ~/.aws/config is in place, you should be able to test the integration using AWS CLI:</p>
<pre><code>aws --profile my-account iam get-user</code></pre>
<p>If you see a valid-looking User JSON response that includes your AWS IAM UserId, UserName and Arn, congratulations, it&#39;s working properly. If you see an error, you may need to refresh your sign-in session first (<em>op signin</em>) and try again.</p>
<h2 id="caveats">Caveats</h2>
<p>When you remove your credentials from ~/.aws/credentials and use the <code>credential_process</code> option instead, some third party tools that use AWS SDK may stop working. For instance, I have created an issue about this in the <a target="_blank" href="https://github.com/serverless/serverless/issues/4838" rel="noopener noreferrer">Serverless Framework</a> project. It&#39;s not quite clear whether Amazon plans to support this automatically in all AWS SDK based apps, or whether it&#39;s intended to be an AWS CLI only feature.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Selainlouhinta</title>
		<link>https://kfalck.net/2017/10/22/selainlouhinta/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Sun, 22 Oct 2017 22:19:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2017/10/22/selainlouhinta/</guid>

					<description><![CDATA[Selainlouhinnasta on puhuttu jo jonkin aikaa. Viimeksi asia oli esillä pari viikkoa siten, kun Pirate Bay alkoi louhia vierailijoidensa selaimissa Monero-virtuaalivaluuttaa. Cloudflare otti asiaan yllättävän jyrkän kannan ja alkoi blokata selainlouhintaa harjoittavia sivustoja. Mutta kun Flash-bannerimainokset aikanaan keksittiin, niihin olisi voinut suhtautua ihan samalla tavalla. Kukaan ei halunnut mainoksia ja ne kuluttivat kyselemättä sekä tietoverkkojen [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Selainlouhinnasta on puhuttu jo jonkin aikaa. Viimeksi asia oli esillä pari viikkoa siten, kun Pirate Bay alkoi louhia vierailijoidensa selaimissa Monero-virtuaalivaluuttaa.</p>
<p>Cloudflare otti asiaan yllättävän jyrkän kannan ja alkoi blokata selainlouhintaa harjoittavia sivustoja. Mutta kun Flash-bannerimainokset aikanaan keksittiin, niihin olisi voinut suhtautua ihan samalla tavalla. Kukaan ei halunnut mainoksia ja ne kuluttivat kyselemättä sekä tietoverkkojen että tietokoneiden kapasiteettia.</p>
<p>Selainlouhintaa voi ajatella virtuaalimaksamisen yksinkertaistettuna muotona. Asiakkaan ei tarvitse erikseen hankkia valuuttaa lompakkoonsa ja suorittaa ostotransaktiota. Sen sijaan hän vain tarjoaa hieman oman tietokoneensa laskentakapasiteettia valuutan louhimiseen. Jos sivusto käyttää liikaa kapasiteettia, tietokone hidastuu häiritsevästi eikä käyttäjä viitsi enää palata sivustolle.</p>
<p>Toisin sanoen nyt on vihdoinkin keksitty keino, jolla käyttäjä saadaan maksamaan sisällöistä ja palveluista tekemättä varsinaista ostopäätöstä. Teknisesti ottaen hinta näkyy hieman kohonneena sähkölaskuna.</p>
<p>Insinööriluonteisia ihmisiä saattaa kismittää ajatus, että virtuaalivaluuttaa ja lohkoketjuja käytetäänkin pakotettuun louhintaan eikä mikromaksamiseen, kuten moni oli ajatellut. Selaimessa louhiminen on tehotonta ja haaskaa resursseja. Mutta konversioprosentti on lähellä sataa, sillä kukaan ei voi erikseen edes miettiä ostopäätöksen tekemistä.</p>
<p>Selainlouhintaa estämään on tietenkin jo kehitetty erilaisia laajennuksia, kuten esimerkiksi Coin-Hive Blocker. Jos louhinta on liian häiritsevää, estolaajennuksista saattaa tulla jopa virallinen osa selaimia. Tämä pätee erityisesti mobiiliselailuun, sillä akkukapasiteetin käyttäminen selainlouhintaan voi käydä nopeasti ärsyttäväksi.</p>
<p>Toisaalta voisi nähdä sellaisenkin tulevaisuuden, jossa palvelun ilmaisversio rahoitetaan selainlouhinnalla ja maksullisen version voi halutessaan tilata erikseen. Siinähän ei ole mitään erityisen uutta, että mainoksetkin saa pois maksamalla palveluista kuukausimaksua.</p>
<p>Jos käyttää vielä hitusen enemmän mielikuvitusta, niin selainlouhinnan voisi myös ulkoistaa kolmannelle osapuolelle. Silloin kännykän käyttäjä maksaisi siitä, että joku toinen taho suorittaa verkkopalvelun käytön edellyttämän selainlouhinnan hänen puolestaan, jolloin kännykän akku ei tyhjenisi.</p>
<p>Kauemmas tulevaisuuteen katsoessa herää kysymys, perustuvatko virtuaalivaluutat kuitenkaan ikuisesti louhintaa ja laskentakapasiteettia edellyttävään proof-of-work-malliin. Ethereumissa on jo suunniteltu siirtymistä proof-of-stake-malliin, joka jättäisi turhan laskennan kokonaan pois. Silloin selainlouhintakaan ei olisi enää mahdollista.</p>
<p>Toisaalta verkkopalveluissa liikkuu niin paljon rahaa, että kyllä jokin virtuaalivaluutta niitä jää tarvittaessa pyörittämään proof-of-work-mallillakin. Eikä sekään ole mahdoton ajatus, että selainlouhintaa varten keksitään jossain vaiheessa ihan uudenlainen, juuri siihen tarkoitukseen optimoitu lohkoketjutekniikka, joka ratkaisee esimerkiksi mobiilikäytön ongelmat uudella tavalla.</p>
<p><a href="https://www.linkedin.com/pulse/could-cryptocurrency-kill-online-advertising-carl-whalley/">https://www.linkedin.com/pulse/could-cryptocurrency-kill-online-advertising-carl-whalley/</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Ethereumin pakkopäivitykset</title>
		<link>https://kfalck.net/2017/10/12/ethereumin-pakkopaivitykset/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Thu, 12 Oct 2017 18:19:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2017/10/12/ethereumin-pakkopaivitykset/</guid>

					<description><![CDATA[Ethereumin seuraava &#34;hard fork&#34; eli pakollinen päivitys muistuttaa siitä, että tietojärjestelmiä on vaikea tehdä kerralla täydellisiksi. Päivityksiä tarvitaan ja välillä kaikkien on pakko tehdä päivitys yhtä aikaa, jotta verkko pysyisi yhteensopivana. Nämä pakkopäivitykset jakaantuvat karkeasti ottaen kahtia: sellaisiin, joista kaikilla on yhteisymmärrys, ja sellaisiin, joista kiistellään. Viimeisin isompi kiista aiheutti Ethereumin jakaantumisen erilliseen Classic-haaraan. Samanlaisia [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Ethereumin seuraava &quot;hard fork&quot; eli pakollinen päivitys muistuttaa siitä, että tietojärjestelmiä on vaikea tehdä kerralla täydellisiksi. Päivityksiä tarvitaan ja välillä kaikkien on pakko tehdä päivitys yhtä aikaa, jotta verkko pysyisi yhteensopivana.</p>
<p>Nämä pakkopäivitykset jakaantuvat karkeasti ottaen kahtia: sellaisiin, joista kaikilla on yhteisymmärrys, ja sellaisiin, joista kiistellään. Viimeisin isompi kiista aiheutti Ethereumin jakaantumisen erilliseen Classic-haaraan. Samanlaisia haarautumisia on tapahtunut Bitcoinillekin.</p>
<p>Pakolliset päivitykset ovat sen vuoksi erityisen mielenkiintoisia, että ne muuttavat lohkoketjuun tallennettujen älysopimusten semantiikkaa. Tässä Byzantium-päivityksessäkin lisätään älysopimuksiin uusia toimintoja. Periaatteessa tietysti vanhat sopimukset pysyvät ennallaan, mutta varsinaisesti tästä ei ole mitään takeita, koska vanhojakin sopimuksia on toisinaan muutettu jälkeenpäin.</p>
<p>Pakkopäivitysten myötä ainakin allekirjoittaneelta on karissut puhtaan ideologinen usko lohkoketjujen ja älysopimusten pysyvyyteen jo jonkin aikaa sitten. Sopimuksista päätetään poliittisella konsensusprosessilla, jota hallinnoivat toisaalta Ethereumia kehittävä yritys ja toisaalta isot louhijatahot. Jos nämä yhdessä haluavat muuttaa sopimuksia jälkeenpäin, se onnistuu.</p>
<p>Ennen pitkää tullaan siis tilanteeseen, jossa älysopimuksista syntyviä erimielisyyksiä täytyy tulkita myös &quot;oikean maailman&quot; oikeuslaitoksessa. Siitä tulee mielenkiintoista, koska lohkoketju on globaali mutta lait ja tuomioistuimet eivät. Miten toimitaan tilanteessa, jossa vaikkapa yhdysvaltalainen yritys on myynyt suomalaisille omistajille virtuaalisia osakkeita, ja osakkeet yllättäen katoavatkin lohkoketjusta pakkopäivityksen myötä?</p>
<p><a href="https://blog.ethereum.org/2017/10/12/byzantium-hf-announcement/">https://blog.ethereum.org/2017/10/12/byzantium-hf-announcement/</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>TypeScript vs. Flow</title>
		<link>https://kfalck.net/2017/08/31/typescript-vs-flow/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Thu, 31 Aug 2017 20:32:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2017/08/31/typescript-vs-flow/</guid>

					<description><![CDATA[Tällä kertaa on mielessä pohdintaa JavaScriptin tyypityksestä. Olen viime aikoina kokeillut TypeScriptiä, joka on Microsoftin kehittämä tyyppilaajennos JavaScriptiin. Se sopii erityisen hyvin yhteen Visual Studio Code -editorin kanssa, joka osaa hyödyntää TypeScriptin ymmärrystä muuttujien ja objektien tyypeistä. Editori näyttää tyyppien perusteella varoituksia ja automaattitäydennyksiä käyttöliittymässään. Facebook on puolestaan kehittänyt TypeScriptille kilpailijan nimeltä Flow. Se toimii [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Tällä kertaa on mielessä pohdintaa JavaScriptin tyypityksestä. Olen viime aikoina kokeillut TypeScriptiä, joka on Microsoftin kehittämä tyyppilaajennos JavaScriptiin. Se sopii erityisen hyvin yhteen Visual Studio Code -editorin kanssa, joka osaa hyödyntää TypeScriptin ymmärrystä muuttujien ja objektien tyypeistä. Editori näyttää tyyppien perusteella varoituksia ja automaattitäydennyksiä käyttöliittymässään.</p>
<p>Facebook on puolestaan kehittänyt TypeScriptille kilpailijan nimeltä Flow. Se toimii samalla periaatteella, eli osaa varoittaa tyyppivirheistä ja kääntää koodin niinikään tavalliseksi JavaScriptiksi. Se toimii niin Atomissa kuin Visual Studio Codessa, kuten TypeScriptkin.</p>
<p>Pointti näissä molemmissa tyyppijärjestelmissä on se, että tyyppejä tarvitsee määritellä vain sen verran kuin itse parhaaksi katsoo. Kehittämisen voi aloittaa tuttuun tapaan dynaamisesti ilman erillisiä tyyppimerkintöjä. Sitten, kun jokin kohta koodissa alkaa näyttää turhan monimutkaiselta ja vaikeasti hahmotettavalta, siihen voi lisätä tyypityksen.</p>
<p>Yksinkertaisissa web-projekteissa tyypityksestä on oikeastaan eniten iloa silloin, kun käytettävät kirjastot sisältävät valmiit tyyppimääreet. Esimerkiksi AWS SDK -kirjastoa käyttäessä näkee jo editorissa varoituksen, mikäli on unohtanut jonkin parametrin DynamoDB-hausta. Tämä nostaa tuottavuutta aika merkittävästikin silloin, kun virheen muuten huomaisi vasta paljon myöhemmin Lambda-funktiota pilvessä ajaessa.</p>
<p>Oleellista on, että tyyppien käyttöönotto ei tee JavaScript-kehityksestä yhtä jäykkää kuin kokonaan staattisiin tyyppeihin perustuvissa kielissä, kuten Javassa tai vaikkapa Haskellissa. Olin itse aiemmin huolissani tyypityksen &quot;viraalisuudesta&quot;, joka pakottaisi lisäämään tyyppimääreet ketjureaktiomaisesti kaikkialle, mutta toistaiseksi on vaikuttanut siltä, että muutaman any-tyypin lisääminen tarvittaessa sinne tänne riittää ainakin TypeScriptissä ja luultavasti Flowssakin. Tämä riippunee kuitenkin paljolti myös käytettyjen kirjastojen tyypityksen tasosta.</p>
<p>Netistä löytyy erilaisia vertailuja TypeScriptin ja Flown eroista enkä osaa vielä itse lähteä ottamaan niihin juurikaan kantaa. Jollain tavalla pitäisi kuitenkin osata päättää, haluaako sitoa oman koodinsa mieluummin Microsoftin vai Facebookin teknologiaan. Toistaiseksi TypeScriptin käyttökokemus on ollut erittäin hyvä, mutta toisaalta koska käytän myös paljon Reactia, Flow houkuttaa tavallaan enemmän.</p>
<p>Eräs TypeScriptin selkeimmistä eduista omassa käytössäni on ollut serverless-plugin-typescript, joka tekee TypeScriptin käyttämisestä Serverless-mikropalveluissa erittäin helppoa. Se kääntää .ts-tiedostot automaattisesti .js-tiedostoiksi ja julkaisee Lambda-funktiot pilveen. TypeScript sisältää myös async/await-tuen, joten mitään lisäkikkailua Babelilla ei tarvita.</p>
<p>Pahoin pelkään, että saman lopputuloksen saaminen aikaan Flowlla vaatisi paljon enemmän erilaisten pluginien asentamista ja konfigurointia, ja se async/await-tukikin pitäisi luultavasti virittää jonnekin erikseen. Luultavasti käytän sen vuoksi itse ainakin tässä vaiheessa enemmän TypeScriptiä, mutta seuraan samalla Flow-työkalujen kehittymistä.</p>
<p>Jossain vaiheessa edessä voi vielä olla vanhojen TypeScript-annotaatioiden vaihtaminen Flow-annotaatioksi. Sitten nähdään kuinka paha rasti sekin on. Toisaalta mikropalveluiden ja Amazon Lambdan ansiosta tällaiset migraatiot ovat nykyään aika pieniä ja ne voi tehdä aina vain yhteen mikropalveluun kerrallaan &#8211; ainakin jos on osannut pitää palvelut oikeasti mikrokokoisina.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Contentful käytössä</title>
		<link>https://kfalck.net/2017/08/12/contentful-kaytossa/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Sat, 12 Aug 2017 12:00:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2017/08/12/contentful-kaytossa/</guid>

					<description><![CDATA[Otin tänään käyttöön Contentfulin blogini sisällön hallinnassa. Sisällöt olivat aiemmin markdown-tiedostoina Git-versiohallinnassa. Markdown-tiedostot on melko vaivatonta ladata Contentfuliin pienellä Python-skriptillä. Julkaiseminen onnistuu vastaavalla skriptillä, joka hakee sisällöt Contentfulista ja luo samanlaiset markdown-tiedostot julkaisua varten. Julkaisuprosessi on nyt: Contentful ⇒ Markdown ⇒ Phenomic ⇒ Amazon S3 ⇒ CloudFront Contentful on vaihdellut ajan mittaan ilmaisen käytön rajoituksiaan, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Otin tänään käyttöön <a href="https://www.contentful.com/">Contentfulin</a> blogini sisällön hallinnassa. Sisällöt olivat aiemmin markdown-tiedostoina Git-versiohallinnassa. Markdown-tiedostot on melko vaivatonta ladata Contentfuliin pienellä Python-skriptillä. Julkaiseminen onnistuu vastaavalla skriptillä, joka hakee sisällöt Contentfulista ja luo samanlaiset markdown-tiedostot julkaisua varten.</p>
<p>Julkaisuprosessi on nyt: Contentful ⇒ Markdown ⇒ Phenomic ⇒ Amazon S3 ⇒ CloudFront</p>
<p>Contentful on vaihdellut ajan mittaan ilmaisen käytön rajoituksiaan, joten nähtäväksi jää, sopiiko se jatkossakin henkilökohtaiseen käyttöön. Tällä hetkellä ilmaiseksi voi luoda kolme erillistä sivustoa, joissa kussakin voi olla 10.000 artikkelia. Contentfullin sisältömalli on toimiva ja yksinkertainen, ja sopii hyvin yhteen markdown-sisällön kanssa, joten tarvittaessa ei ole suuri ongelma siirtää sisältöjä sieltä jonnekin muualle.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>REST-rajapintojen sivuttaminen</title>
		<link>https://kfalck.net/2017/07/26/rest-rajapintojen-sivuttaminen/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 22:25:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2017/07/26/rest-rajapintojen-sivuttaminen/</guid>

					<description><![CDATA[Kävin tänään mielenkiintoista (melko teknistä) keskustelua Twitterissä ja Facebookissa siitä, miten REST API -rajapintojen sivuttaminen kannattaa nykyään toteuttaa. Esiin nousi lähinnä kaksi kilpailevaa vaihtoehtoa: (1) Sivuttaminen käyttäen HTTP-metadata-otsakkeita kuten X-Total-Count, X-Page-Count, jne. Tällöin varsinainen JSON-tieto voidaan palauttaa taulukkomuotoisena (array). (2) Taulukon kuorruttaminen metadata-objektilla. Rajapinnan palauttama tieto on silloin esimerkiksi muodossa {&#34;items&#34;:[&#8230;], &#34;totalCount&#34;:123}. Kummallakin vaihtoehdolla on [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Kävin tänään mielenkiintoista (melko teknistä) keskustelua Twitterissä ja Facebookissa siitä, miten REST API -rajapintojen sivuttaminen kannattaa nykyään toteuttaa.</p>
<p>Esiin nousi lähinnä kaksi kilpailevaa vaihtoehtoa:</p>
<p>(1) Sivuttaminen käyttäen HTTP-metadata-otsakkeita kuten X-Total-Count, X-Page-Count, jne. Tällöin varsinainen JSON-tieto voidaan palauttaa taulukkomuotoisena (array).</p>
<p>(2) Taulukon kuorruttaminen metadata-objektilla. Rajapinnan palauttama tieto on silloin esimerkiksi muodossa {&quot;items&quot;:[&#8230;], &quot;totalCount&quot;:123}.</p>
<p>Kummallakin vaihtoehdolla on hyviä ja huonoja puolia, jotka ovat pitkälti periaatteellisia. Itse olen nykyään enemmän käytännöllisyyden kuin periaatteellisuuden kannalla, joten kallistun tässä tapauksessa vaihtoehtoon (1).</p>
<p>Perusteluni tälle ovat:</p>
<ul>
<li>
<p>Rajapinnan peruskäyttötapaus on mahdollisimman yksinkertainen, koska se palauttaa aina arrayn. Vastaanottajan ei tarvitse tehdä minkäänlaista sovitusta poimiakseen kuorruteobjektista erillisen &quot;items&quot;-attribuutin.</p>
</li>
<li>
<p>Sama periaate sopii sekä sivutettuihin että sivuttamattomiin rajapintoihin. Jos rajapinta ei tue sivuttamista, se ei palauta X-otsikoita. Kummassakin tapauksessa palautettu data on aina JSON-array. Vastaanottaja voi jättää sivuttamisen kokonaan huomiotta mikäli ei tarvitse sitä.</p>
</li>
<li>
<p>Rajapinnan kehittämisen voi huolehti aloittaa ilman sivutusta. Jos sivutusta myöhemmin kuitenkin huomataan tarvittavan, se voidaan laajentaa siististi aiemman rajapinnan päälle X-otsakkeilla, aiheuttamatta välittömiä yhteensopivuusongelmia.</p>
</li>
<li>
<p>X-otsakkeiden käyttö toimii nykyään selaimissa ongelmitta CORSin kanssa, kunhan rajapinta palauttaa asianmukaisen Access-Control-Expose-Headers-otsakkeen.</p>
</li>
<li>
<p>X-otsakkeet on nykyään helppo lukea selainten fetch()-rajapinnan palauttamasta vastineesta metodilla response.headers.getHeader(&#39;X-Total-Count&#39;).</p>
</li>
</ul>
<p>Linkit keskusteluihin:<br />
<a href="https://twitter.com/kennu/status/890271051657220096">https://twitter.com/kennu/status/890271051657220096</a> <a href="https://www.facebook.com/kennu/posts/10155607701699468">https://www.facebook.com/kennu/posts/10155607701699468</a></p>
<p><a href="https://twitter.com/kennu/status/890271051657220096">https://twitter.com/kennu/status/890271051657220096</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Versiohallinnat pitäisi salata</title>
		<link>https://kfalck.net/2017/07/05/versiohallinnat-pitaisi-salata/</link>
		
		<dc:creator><![CDATA[Kenneth Falck]]></dc:creator>
		<pubDate>Wed, 05 Jul 2017 14:15:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://kfalck.net/2017/07/05/versiohallinnat-pitaisi-salata/</guid>

					<description><![CDATA[Tänään olen pohtinut, onko Git-versiohallinta vanhentumassa, koska se tallentaa kaiken datan salaamattomana omaan tietokantaansa. Maailmalla on käynnissä yleinen trendi muuttaa kaikki tietovarastot salatuiksi. Ennen pitkää salaamattoman datan säilöminen alkaa tuntua samalta kuin salasanojen tallentaminen paljaaltaan tietokantoihin. Se oli normaalia vielä 1990-luvulla, mutta nykyään se ei tulisi enää mieleenkään. Gitin osalta asia on tietysti erilainen riippuen [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Tänään olen pohtinut, onko Git-versiohallinta vanhentumassa, koska se tallentaa kaiken datan salaamattomana omaan tietokantaansa. Maailmalla on käynnissä yleinen trendi muuttaa kaikki tietovarastot salatuiksi. Ennen pitkää salaamattoman datan säilöminen alkaa tuntua samalta kuin salasanojen tallentaminen paljaaltaan tietokantoihin. Se oli normaalia vielä 1990-luvulla, mutta nykyään se ei tulisi enää mieleenkään.</p>
<p>Gitin osalta asia on tietysti erilainen riippuen siitä, puhutaanko avoimen lähdekoodin projekteista vai yksityisistä projekteista. Avoimien projektien on suotavaa olla salaamattomasti näkyvissä koko maailmalle, mutta toisaalta niissäkin on usein tarpeita säilytellä yksittäisiä salattuja tiedostoja, joihin pääsevät käsiksi vain harvat ja valitut.</p>
<p>Yksityiset projektit voisivat olla kokonaan salattuja, jolloin kehitystiimien pitäisi jakaa keskenään salausavaimet päästäkseen koodiin käsiksi. Tämä on toisaalta ristiriidassa nykyaikaisten web-työkalujen kanssa, sillä GitHubin ja Bitbucketin kaltaiset palvelut olettavat pääsevänsä käsiksi versiohallintaan tallennettuun dataan muodostaakseen siitä diffejä ja pull-requesteja.</p>
<p>Ongelma olisi kenties ratkaistavissa käyttämällä repositoryissa useaa eri salausavainta, joista yksi annettaisiin GitHubille web-käyttöliittymää varten. Jollain toisella avaimella taas salattaisiin sellaiset tiedostot, joita edes GitHubin ei haluta näkevän. Kaikki data olisi kuitenkin repositoryissa salattuna, sekä pilvessä että kehittäjien koneilla, ja täten yhtenäisesti hallittavissa salausavaimia käyttäen.</p>
<p>En tiedä taipuuko Git tähän ja onko sen kehittäjillä halukkuuttakaan viedä sitä tähän suuntaan. Alan kuitenkin nyt ounastella, että tässä asiassa tapahtuu vielä suuri murros, joka voi johtaa uudenlaisten versiohallintojen käyttöönottoon.</p>
<p><a href="https://twitter.com/kennu/status/882589814901673986">https://twitter.com/kennu/status/882589814901673986</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
