From e07bed4a2898914cd7266f4479dcc8a3351f5653 Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Mon, 30 May 2022 18:35:58 +0200 Subject: [PATCH] added author tags --- content/post/distrust-antipattern.md | 1 + content/post/enterprisey.md | 1 + content/post/enterprisey2.md | 1 + content/post/from_java_2_rust.md | 1 + .../post/how-to-build-my-new_restservice.md | 1 + content/post/optional.md | 31 ++++++++++++------- content/post/rust_wasm_photos.md | 3 +- content/post/value.md | 1 + 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/content/post/distrust-antipattern.md b/content/post/distrust-antipattern.md index c09d8fc..0b06e24 100644 --- a/content/post/distrust-antipattern.md +++ b/content/post/distrust-antipattern.md @@ -2,6 +2,7 @@ title: "Distrust Antipattern" date: 2022-01-28T10:47:56+01:00 draft: true +author: Sander Hautvast --- __can you trust your own team mates?__ diff --git a/content/post/enterprisey.md b/content/post/enterprisey.md index c9bf859..5a2dd06 100644 --- a/content/post/enterprisey.md +++ b/content/post/enterprisey.md @@ -1,6 +1,7 @@ --- title: "Get Enterprisey with Rust" date: 2022-05-23T17:33:09+02:00 +author: Sander Hautvast draft: false --- Why not use the coolest language out there to do the things you probably still use Java for? Rust is marketed as a 'systems language', whatever that is. It looks to me like a general purpose language, 'turing complete' and whatnot. There are plenty crates for anything web related. There's tools for http servers, database connections, logging. We may also want security, monitoring, telemetry, cloud deployment. Do we want end-to-end testing? Sure. Openapi? Love it. diff --git a/content/post/enterprisey2.md b/content/post/enterprisey2.md index d207575..367434e 100644 --- a/content/post/enterprisey2.md +++ b/content/post/enterprisey2.md @@ -1,6 +1,7 @@ --- title: "Get Enterprisey with Rust, part2: input validation" date: 2022-05-30T17:50:11+02:00 +author: Sander Hautvast draft: false --- Input validation is next on the list of enterprisey features (see also [part1](/enterprisey)). This will be the only new feature to add in this post because we need to add quite a but of boilerplate (sadly) to get it working. diff --git a/content/post/from_java_2_rust.md b/content/post/from_java_2_rust.md index 53faf49..d72063b 100755 --- a/content/post/from_java_2_rust.md +++ b/content/post/from_java_2_rust.md @@ -2,6 +2,7 @@ title: "Rust for Java developers, Introduction" date: 2021-12-17T13:07:49+01:00 draft: false +author: Sander Hautvast --- ![rusty bridge](/img/christopher-burns--mUBrTfsu0A-unsplash.jpg) diff --git a/content/post/how-to-build-my-new_restservice.md b/content/post/how-to-build-my-new_restservice.md index 218cc3c..8826d83 100755 --- a/content/post/how-to-build-my-new_restservice.md +++ b/content/post/how-to-build-my-new_restservice.md @@ -2,6 +2,7 @@ title: "To Stored Procedure or Not" date: 2021-12-07T20:32:49+01:00 draft: false +author: Sander Hautvast --- ### Or: My personal Object-Relational Mapping [Vietnam war story](https://blogs.tedneward.com/post/the-vietnam-of-computer-science/) diff --git a/content/post/optional.md b/content/post/optional.md index 770128f..689c595 100644 --- a/content/post/optional.md +++ b/content/post/optional.md @@ -1,29 +1,36 @@ --- title: "The rust option" date: 2021-12-20T10:55:14+01:00 -draft: true +draft: false +author: Sander Hautvast --- +![choose](/img/vladislav-babienko-KTpSVEcU0XU-unsplash.jpg) -`Option` is a well known construct in many languages. The first time I saw it was in scala, but soon after it appeared in java8. As java still means my livelyhood, it serves as my main frame of reference. I won't be covering all the details, because the java type is really a no brainer: it simply wraps a value _or not_ and what operations (methods on Optional) do depends on there being a value or not. -Rust Option starts with the same premisse. But immediately things start to diverge where it comes to actally using it. In rust the type is more or less mandatory for any optional value, because there is no (safe) `null` reference. So any struct or function that allows the absence of a value may use `std::option::Option` (or just `Option`) whereas in java it's (strangely) discouraged by static code analysis tools for class members and method arguments. Just use `null` they say, but I find it very useful to express the explicit possibility of null values as a valid state. +`Option` is a well known construct in many languages. The first time I saw it was in scala, but soon after it appeared in java8. As java still means my livelyhood, it serves as my main frame of reference. I won't be covering all the details, because the java type is really a no brainer: it simply wraps a value _or nothing_ and what operations (methods on Optional) do depends on there being a value or not. -In a java application that uses IOC `null` is in many instances a 'not yet valid state' ie. a class instance has been constructed but its dependencies have not yet been injected. This is never a valid state once the application is fully constructed and so this would not be a case for an Optional value. +Rust Option starts with the same premisse. But immediately things start to diverge when it comes to actually using it. In rust the type is more or less mandatory for any optional value, because there is no (safe) `null` reference. So any struct or function that allows the absence of a value may use `std::option::Option` (or just `Option`) whereas in java it's (strangely) discouraged by static code analysis tools for class members and method arguments. Just use `null` they say, but I find it very useful to express the explicit possibility of null values as a valid state. -Rust's Option differs from java's Optional first and foremost in that in rust it is en enum. That would not be possible in java, because it's enums are limited in that an enum in java can only have attributes of the same type (for all enum values). Whereas in rust Option::None is different from Option::Some in that Some has a value ie Some("string") and None has not. +In a java application that uses _Dependency Injection_, `null` is in many instances a 'not yet valid state' ie. a class instance has been constructed but its dependencies have not yet been injected. This is never a valid state once the application is fully constructed and so this would not be a case for an Optional value. In java. + +Rust's Option differs from java's Optional first and foremost in that in rust it is an _enum_. That would not be possible in java, because java enums are limited. In java enums can only have attributes of the same type (for all variants). Whereas in rust Option::None is different from Option::Some in that Some has a value ie Some("string") and None has not. In code: -``` +{{}} pub enum Option { None, Some(T), } -``` +{{}} + +Now you might say: _Option{value}_ is more expensive than '_a value or null_' because you have to wrap the value which costs more storage. For this rust has a trick up its sleeve, called _null pointer optimization_ that eliminates the extra memory use. +Read all about this (and more) [here](https://rust-unofficial.github.io/too-many-lists/first-layout.html). construction: -|java.util.Optional|std::option:Option| -|---------------------|---------------------| -| of(T value) | Some(value: T) | -| ofNullable(T value) | Some(value: T) | -* Some(null) will not compile. +|java.util.Optional |Option|example: Option\| +|------------------------------|----------------|--------------| +| Optional.of(T value) | Some(value: T) | Some(1) | +| Optional.ofNullable(T value) | - | - | +| Optional.empty() | None | None | + diff --git a/content/post/rust_wasm_photos.md b/content/post/rust_wasm_photos.md index d0a1843..5be969a 100644 --- a/content/post/rust_wasm_photos.md +++ b/content/post/rust_wasm_photos.md @@ -2,6 +2,7 @@ title: "Let's create an app in webassembly" date: 2022-02-05T20:11:08+01:00 draft: false +author: Sander Hautvast --- ![soup assembly](/img/markus-winkler-08aic3qPcag-unsplash.jpg) Web assembly is cool and new and it lacks nice how-to's for tasks that are by now quite mundane for most web developers. So let's get started using [yew](https://yew.rs/). @@ -176,7 +177,7 @@ So DropImage is now a _Component_, much the same way as in for instance _Angular There are some differences with regular html to be aware of. All _text_ must be surrounded by curly braces {}. A constant string in quotes will simply be turned into the text html child, but you can output any component value, eg: ```{self.value}``` -Note that two event handlers, ```ondragover``` and ```ondrop``` are registered in the drop-zone div. What does ```{link.callback(|e| Msg::Dragged(e))}``` mean? It sends a message called Msg::Dragged with a payload that is the raised html event (e). The component now be able the handle this message. For this you need: +Note that two event handlers, ```ondragover``` and ```ondrop``` are registered in the drop-zone div. What does ```{link.callback(|e| Msg::Dragged(e))}``` mean? It sends a message called Msg::Dragged with a payload that is the raised html event (e). The component is now be able the handle this message. For this you need: ```update``` is called by the framework and it receives an instance of the Msg enum and it will respond by choosing appropriate action. This could mean update the internal component state or the view directly. I fact I doubt if the latter is really what you would want. In fact we could have defined the _images_ div as follows {{}} diff --git a/content/post/value.md b/content/post/value.md index 36a18cc..c784391 100644 --- a/content/post/value.md +++ b/content/post/value.md @@ -2,6 +2,7 @@ title: "On the value of software and pasta" date: 2022-01-17T10:29:29+01:00 draft: false +author: Sander Hautvast --- ![cash](/img/pradamas-gifarry-bVfMuhN9w6I-unsplash.jpg) This week some things 'happened' to me that made me want to read up on the grander scheme of things, meaning economic value, in particular that of software. I'll just list them briefly