<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Risav</title>
    <description>The latest articles on DEV Community by Risav (@risavkarna).</description>
    <link>https://dev.to/risavkarna</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F309876%2Ff79e383b-f0d7-4e0b-bea5-f016ed91bd9d.png</url>
      <title>DEV Community: Risav</title>
      <link>https://dev.to/risavkarna</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/risavkarna"/>
    <language>en</language>
    <item>
      <title>MAP III - Types of Types II</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Tue, 14 Apr 2020 13:26:06 +0000</pubDate>
      <link>https://dev.to/risavkarna/map-iii-types-of-types-ii-11ii</link>
      <guid>https://dev.to/risavkarna/map-iii-types-of-types-ii-11ii</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;We need to invert the wasteful trend of learning something as timeless as higher maths only as a means to learn an ephemeral or ever-changing programming language or paradigm. Let's aim instead to explain and discuss foundational mathematical structures like types and categories through these programming languages as visual learning aids. This helps us become better developers in any language, including new ones for quantum computing or even natural language-based programming.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Previously on &lt;a href="https://risav.dev/map-iii-types-of-types-ck8lrxnlx011b79s17rbswwtq"&gt;MAP - Types of Types&lt;/a&gt;, we looked at the type hierarchy of Scala and worked with a basic 'level 1' definition of types. Now we will level up and refine our previous working definition of types as value spaces with a set of allowed operations. At level 2, we will celebrate Function's tying of the knot with Data and how that adds a new dimension, literally as well, to how we have come to define and understand types. We will need to go back to discussing some basics like the very concept of functions and objects. With this slightly boring and unapologetically pedantic detour, we will demystify some commonly held oversimplifications or misconceptions and proceeds towards the more advanced and interesting concepts being on the same page. For instance we will see how functions and objects together create a fast track towards advanced abstract data types and algebraic structures or how classes and objects are simultaneously quite different and so much more than what we have been teaching our kids.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Function weds Data: Domain and Co-domain Spaces
&lt;/h2&gt;

&lt;p&gt;Our last definition of types was mainly concerned with types of data. It was therefore sufficient to think of value spaces, basic syntactics and behavior, understood in the sense of a set of operations on elements of that space. In programming, behavior comes from patterns of actions, which itself comes from operational chunks of code, which in turn act only on either data or other codes.&lt;/p&gt;

&lt;p&gt;It's no surprise that chunks of programming instructions and of data have lived together on the same memory space ever since &lt;a href="https://en.wikipedia.org/wiki/Von_Neumann_architecture"&gt;von Neumann architecture&lt;/a&gt; was first adopted. This intimacy of data and code is lost on many programmers who do not often need to think of the nitty-gritty of the innards of their machines. &lt;/p&gt;

&lt;p&gt;Functions and objects are two major constructs in programming where this intimacy-by-design is directly reflected at the level of program codes. Since they have already 'moved in' together, many languages including Scala makes this an official relationship, which I have cheekily phrased as 'function weds data'.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Object and Class
&lt;/h3&gt;

&lt;p&gt;Just like every construct in Scala has a type, every instance of a type is an object. Scala does not have Java-style primitive types, which do not have objects.&lt;/p&gt;

&lt;p&gt;Whether or not a language follows &lt;strong&gt;&lt;em&gt;object oriented programming&lt;/em&gt;&lt;/strong&gt;, an object in a programming language is a data abstraction representing value(s) in memory. An object has a named identifier and may have properties, methods with read/write access to the object's properties and relationships with other objects. Alike functions, objects have mathematical counterparts too. We will explore them in the next two posts in this series.&lt;/p&gt;

&lt;h3&gt;
  
  
  Templates
&lt;/h3&gt;

&lt;p&gt;A class is famously known as a 'blueprint' or template for instantiating an object. The class defines what properties, methods and relations an object can have and/or from where it inherits them. A class name is also usually the name of the user-defined type of the objects made using the class's constructor, which also usually has the same name as the class. &lt;/p&gt;

&lt;p&gt;This is only partially true in Scala but wholly correct in Scala's more popular cousin Java. In Scala, it is problematic to hold on to the idea of class as a sole blueprint for objects. &lt;/p&gt;

&lt;p&gt;The Scala specs define objects, classes and traits (Java 8+ interface-like abstractions supporting states, mix-in type restrictions, reference to objects of implementing classes) in terms of templates, which are not actually available for programmers. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Templates, not classes, are the actual templates in Scala.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A template definition may be a class template definition or an object template definition or a trait template definition. A class definition or an object definition may be for a regular class of objects or a singleton object or for a case class or a case singleton object. These template definitions are what actually define the type signature of the resulting objects and the constructors or initial values therein define the initial states of those objects. &lt;/p&gt;

&lt;p&gt;This conception of class in Scala is, as with functions, closer to a class in mathematics in the sense that a class definition represents a constrained set of instantiable objects while an object definition is just for one object. &lt;/p&gt;

&lt;p&gt;Scala also throws away the concept of static classes that do not need instantiation in favor of singleton objects created via the object template definition. These static classes, values and methods are hard to reconcile with the object oriented paradigm. They do not support inheritance and dynamic dispatch due to polymorphism, which itself is possible due to inheritance. Lastly they are also tough to mock and unit test easily.&lt;/p&gt;

&lt;h3&gt;
  
  
  Meta
&lt;/h3&gt;

&lt;p&gt;A class may also instantiate other classes in some languages or object systems like Python, CLOS, Object Pascal, Smalltalk, Ruby, Objective C and C++. Such a class is called a metaclass. An object may also have a meta level or more above it. Such an object is called a metaobject. &lt;/p&gt;

&lt;p&gt;As is usual with meta of anything, the metaclasses and metaobjects are parts of advanced concepts in programming. These are useful in understanding reflection, a programming construct's ability to introspect, augment or change its own behavior. In Scala this is achieved via Java's Reflection API and via natively added capabilities since Scala's 2.10 version. We will go on this reflective journey when we start the library developer tracks (L1 - L3) after having discussed the essential maths and concept behind the programmer's track (A1 - A3).&lt;/p&gt;

&lt;h3&gt;
  
  
  Bonus: Classless OOP
&lt;/h3&gt;

&lt;p&gt;However a class is not the only mechanism for defining templates for object instantiation. &lt;/p&gt;

&lt;p&gt;Here's an &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes"&gt;excerpt from MDN&lt;/a&gt; regarding how JavaScript has OOP, better than most other languages known for their OOP, without classes. The ES6 classes are actually just syntactic sugar to make it easier for those used to class based OOP.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A prototype-based language?&lt;/p&gt;

&lt;p&gt;JavaScript is often described as a prototype-based language — to provide inheritance, objects can have a prototype object, which acts as a template object that it inherits methods and properties from. An object's prototype object may also have a prototype object, which it inherits methods and properties from, and so on.&lt;/p&gt;

&lt;p&gt;This is often referred to as a prototype chain, and explains why different objects have properties and methods defined on other objects available to them.&lt;br&gt;
Well, to be exact, the properties and methods are defined on the prototype property on the Objects' constructor functions, not the object instances themselves.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2.2 Functions and Methods
&lt;/h3&gt;

&lt;p&gt;A function is a chunk of code you can call by name. The function, its inputs and output can each be objects. In Scala, they always are.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inputs:
&lt;/h3&gt;

&lt;p&gt;Functions may take values as inputs, possibly operate on these values or create side-effects based on those values or the context, and likely return something in the end. Pure functions however are more well behaved and closer to the functions from mathematics thanks to idempotence, referential transparency, and separation from side effects.&lt;/p&gt;

&lt;p&gt;Informally speaking, the space of all possible values that could be accepted as an input is called the &lt;em&gt;domain&lt;/em&gt; of a function.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Spaces are just sets with added structures. In our context, spaces may have varying dimensionality and each element has its own previously defined level 1 type.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Outputs:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Every chunk of code in Scala that can be put on a single line returns a value.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These lines, which may be typed as blocks for readability, may be either functions or expressions that compose functions. In either case, an output per expression or per function is guaranteed. Even if an expression or function is handling side effects or running into an exception, the previously mentioned &lt;code&gt;Unit&lt;/code&gt; return is guaranteed.&lt;/p&gt;

&lt;p&gt;This style of programming with expressions is called &lt;strong&gt;&lt;em&gt;expression oriented programming (EOP)&lt;/em&gt;&lt;/strong&gt; and is a part of the &lt;strong&gt;functional programming&lt;/strong&gt; paradigm.&lt;/p&gt;

&lt;p&gt;Informally speaking, the space of all possible values that could be produced as an output is called the &lt;em&gt;co-domain&lt;/em&gt; of a function.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.3 Parameter Types and Return Types
&lt;/h3&gt;

&lt;p&gt;Now that we are literally on the same page regarding the lingo and the concepts, let's take these concepts to meet some program codes.&lt;/p&gt;

&lt;p&gt;Since every line is either a function or an expression, we can simply take note of what type of thing goes in and what comes out. &lt;/p&gt;

&lt;h3&gt;
  
  
  if/else-if/else (v1)
&lt;/h3&gt;

&lt;p&gt;This is commonly needed and commonly avoidable expression. Let's break it down.&lt;/p&gt;

&lt;p&gt;How could we write a (basic) version of the if-then expression? We know that it would &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;take a predicate as the first parameter i.e. either a &lt;code&gt;Boolean&lt;/code&gt; or something that returns a &lt;code&gt;Boolean&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;take a function to execute if the above value is true as the second parameter&lt;/li&gt;
&lt;li&gt;the predicate and the function could use any number of parameters of &lt;code&gt;Any&lt;/code&gt; type
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Naive if-then without advannced tytpes&lt;/span&gt;

&lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;ifThen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;someBool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;Any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;someBool&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;unitaryFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;ifThen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;unitaryFunc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// res0: Any = false&lt;/span&gt;
&lt;span class="c1"&gt;// same as the invocation below&lt;/span&gt;

&lt;span class="nx"&gt;ifThen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;unitaryFunc&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// res1: Any = true&lt;/span&gt;

&lt;span class="nx"&gt;ifThen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;unitaryFunc&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// res2: Any = false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is quite a useless if-then in its current form but it gives us a good outline of how if-then works and what we should improve over the course of this series. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As explained in 'Curly Braces and Parentheses' in &lt;a href="https://risav.dev/viva-la-scala-ck8nu72vb029w79s179c38sza"&gt;Viva La Scala&lt;/a&gt; explainer collection, the curly braces you see in if statements and other control structures are nothing more than just simple parentheses substituted for readability and multi-line blocks. &lt;/li&gt;
&lt;li&gt;The if-then structure or &lt;code&gt;p -&amp;gt; q&lt;/code&gt; is logically equivalent to &lt;code&gt;¬p ∨ q&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In terms of improvements, these would be highly necessary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We will need to support more types of parameters and return values for the function being passed to the if-then function.&lt;/li&gt;
&lt;li&gt;We will need to find a way to compose if-then to else-if and else constructs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Function composition requires that the return type of the function passed as a parameter is the same as the parameter type of the function receiving that function as its parameter. How then do you compose functions that need to support incompatible return and parameter types? We will later explore some solutions to this, including monadic ones. &lt;/p&gt;

&lt;p&gt;Here's an an example of how Java's Optional is converted to the monadic version in Scala:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;toScala&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;A&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;A&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt; &lt;span class="nx"&gt;Option&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;A&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isPresent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  match-case
&lt;/h3&gt;

&lt;p&gt;The above example is fairly simple use case for if-else because the Optional container has a nice and simple &lt;code&gt;isPresent&lt;/code&gt; method make it easier to test against a method with &lt;code&gt;Boolean&lt;/code&gt; return type. However here's how the reverse condition is achieved by Scala:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;util&lt;/span&gt;&lt;span class="p"&gt;.{&lt;/span&gt;&lt;span class="nx"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;OptionalDouble&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;OptionalInt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;OptionalLong&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.{&lt;/span&gt;&lt;span class="nx"&gt;lang&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;jl&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="nx"&gt;OptionConverters&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;toJavaOptionalInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Option&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;jl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt; &lt;span class="nx"&gt;OptionalInt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;o&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;OptionalInt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;OptionalInt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;empty&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time we are checking against the possible types. match-case is a better fit for checking against types, which in this case are either &lt;code&gt;Some&lt;/code&gt; or anything else. &lt;/p&gt;

&lt;p&gt;Note that the match construct is also an expression and the curly braces are once again super-powered parentheses which can take multiline values or functions or expressions as arguments.&lt;/p&gt;

&lt;p&gt;The input to the match expression is &lt;code&gt;o&lt;/code&gt; provided as the first operand in infix style and the &lt;code&gt;case&lt;/code&gt; expressions provided together as the later parameter in the curly braces. The return type is determined by the return type of the expression on the right side of the matched case.&lt;/p&gt;

&lt;p&gt;The match-case expression is also capable of checking against values and is especially better suited for cases with too many &lt;code&gt;case&lt;/code&gt;s.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;getEnglishNames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Zero&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;One&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Two&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Three&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Four&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Five&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Six&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Seven&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Eight&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nine&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Not enough fingers!!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;getEnglishNames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// res0: String = Six&lt;/span&gt;

&lt;span class="nx"&gt;getEnglishNames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// res1: String = Not enough fingers!!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How about mixing these two expressions? If you have a use case where you have to check for values while also checking for types, it's best to use both. Here's how Scala converts &lt;code&gt;FiniteDuration&lt;/code&gt; to a Java duration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;toJava&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;FiniteDuration&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ZERO&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;unit&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NANOSECONDS&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ofNanos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MICROSECONDS&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ChronoUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MICROS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MILLISECONDS&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ofMillis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SECONDS&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ofSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MINUTES&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ofMinutes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HOURS&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ofHours&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;TimeUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DAYS&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;JDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ofDays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are pre-existing types. Can we do this with custom types? As we discussed, custom types could come from custom objects or classes. You might have also noticed earlier that class and object template definitions may also have a &lt;code&gt;case&lt;/code&gt; qualifier in front of it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sealed&lt;/span&gt; &lt;span class="nx"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Device&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;IPhoneX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uglyNotchSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Device&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;S10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;holeCamOffset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Device&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;NexS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;popUpCam&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Device&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Pixel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pixels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Device&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;sorry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Old School&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;def&lt;/span&gt; &lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;device&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Device&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;device&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;IPhoneX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ugly&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;S10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nx"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Symmetric but Meh&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;S10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Meh&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;NexS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cool&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;NexS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Clunky&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;px&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Pixel&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;px&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sorry&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;IPhoneX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;// res0: String = Ugly&lt;/span&gt;
&lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;S10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;// res1: String = Symmetric but Meh&lt;/span&gt;
&lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;S10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;// res2: String = Meh&lt;/span&gt;
&lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;NexS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;// res3: String = Cool&lt;/span&gt;
&lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;NexS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;// res4: String = Clunky&lt;/span&gt;
&lt;span class="nx"&gt;howBeautiful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Pixel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;// res5: String = Old School&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;sealed&lt;/code&gt; keyword tells Scala that all possible subtypes or &lt;code&gt;case&lt;/code&gt;s are present within the same file and not dispersed elsewhere in the code. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; statement on the first S10 &lt;code&gt;case&lt;/code&gt; is another way you could mix &lt;code&gt;if&lt;/code&gt; with &lt;code&gt;match&lt;/code&gt;. In this &lt;code&gt;case&lt;/code&gt;, it is called a pattern guard. &lt;/p&gt;

&lt;p&gt;Notice that the ordering of the &lt;code&gt;case&lt;/code&gt;s matters because the fall through is similar to that found in &lt;code&gt;switch&lt;/code&gt; statements in other languages.&lt;/p&gt;

&lt;p&gt;Also note that all but the last &lt;code&gt;case&lt;/code&gt; are still checking against values albeit of value objects. Only the last &lt;code&gt;case&lt;/code&gt; is actually checking against a user defined type.&lt;/p&gt;

&lt;p&gt;We now have a good groundwork to look into try-catch and try-success-failure. We will also be looking into for, for-yield and foreach expressions once we have collection types in our arsenal by the end of the next post. That is also where Scala/Mathematics concepts start to get real fun to play with. &lt;/p&gt;

&lt;h1&gt;
  
  
  Next on 'Types of Types'
&lt;/h1&gt;

&lt;p&gt;To keep the posts from going beyond optimal lengths, we will explore each of the next 'levels' of understanding and defining types in their own posts. Here's a sneak peek. &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Abstract Data Types: Types with Structure and Behavior
&lt;/h2&gt;

&lt;p&gt;Here we will rediscover the good old data structures mostly used in programming through a more formal, functional and scala-ble lens 🧐. Sum and product types will also pave the way for the more involved algebraic data types in the later section.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Sum and Product Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;3.1.1 Union &lt;em&gt;or&lt;/em&gt; Tagged Union&lt;/li&gt;
&lt;li&gt;3.1.2 Tuple &lt;em&gt;and&lt;/em&gt; Record&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.2 Set and List
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;3.2.1 Unordered and Non-duplicated&lt;/li&gt;
&lt;li&gt;3.2.2 Ordered and Random Accessible&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.3 Maps
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.4 Stack and Queue
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.5 Graph and Tree
&lt;/h3&gt;




&lt;h2&gt;
  
  
  4. Algebraic Data Types and HKTs
&lt;/h2&gt;

&lt;p&gt;Here we will (re-)discover universal algebra, ring-like, group-like, lattice-like, module-like, and algebra-like algebraic structures relevant to advanced functional and reactive programming. We will also demystify higher kinded types and similarly exotic higher order concepts. &lt;/p&gt;




&lt;h2&gt;
  
  
  5. A Gentle Introduction to Category Theory
&lt;/h2&gt;

&lt;p&gt;Here we will use the Scala concepts and Type Theory topics thus far to go for a deep dive into Bartoz Milewski's excellent &lt;a href="https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/"&gt;course on Category Theory &lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Further resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;2.1 Classes and Objects Specs in Scala: &lt;a href="https://scala-lang.org/files/archive/spec/2.13/05-classes-and-objects.html"&gt;https://scala-lang.org/files/archive/spec/2.13/05-classes-and-objects.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2.2 Scala source code: &lt;a href="https://github.com/scala/scala/blob/2.13.x/src/library/scala/"&gt;https://github.com/scala/scala/blob/2.13.x/src/library/scala/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;&lt;p&gt;1.1 D. L. Parnas, John E. Shore, David Weiss: Abstract types defined as classes of variables, &lt;a href="https://dl.acm.org/doi/10.1145/942574.807133"&gt;https://dl.acm.org/doi/10.1145/942574.807133&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;1.2 Tony Hoare on his infamous billion dollar mistake: &lt;a href="https://www.youtube.com/watch?v=kz7DfbOuvOM"&gt;https://www.youtube.com/watch?v=kz7DfbOuvOM&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;1.3 Official Scala API Docs and resources: &lt;a href="https://www.scala-lang.org/"&gt;https://www.scala-lang.org/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;1.4 L.G. Meredith, Pro Scala: Monadic Design Patterns for the Web: &lt;a href="http://patryshev.com/books/GregoryMeredith.pdf"&gt;http://patryshev.com/books/GregoryMeredith.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>typetheory</category>
      <category>functional</category>
      <category>scala</category>
      <category>expressions</category>
    </item>
    <item>
      <title>MAP III : Types of Types</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Sun, 05 Apr 2020 03:25:56 +0000</pubDate>
      <link>https://dev.to/risavkarna/map-iii-types-of-types-1l3e</link>
      <guid>https://dev.to/risavkarna/map-iii-types-of-types-1l3e</guid>
      <description>&lt;p&gt;When talking about types in computer science, one could be talking about two types of types. Types from type theory are closely related to the types from type systems used programming languages. Both of these are fun and playing with them illuminates how any language works. It may even help you obtain an A3 or perhaps even the &lt;a href="https://www.scala-lang.org/old/node/8610"&gt;L3-tier&lt;/a&gt; superpowers.&lt;/p&gt;

&lt;p&gt;Previously in the &lt;a href="https://risav.dev/mathematics-anarchitecture-and-processes-ck5nahog004z4qps1w98ldfz0"&gt;Mathematics' (An)architecture and Processes (MAP) series&lt;/a&gt;, we have briefly touched upon Curry-Howard-Lambek isomorphism, which is a trifecta of independent realizations about, among other things, how propositions are types i.e. claims that are true or false, formal proofs, logical calculus' constraints and formulae are types too. With Scala's types, and Java 11+'s and Typescript's later, we will see what it actually means to say something as abstract as 'propositions are types' and why understanding these esoteric and zen sayings can make you a better programmer - in any language, with any kind of type system.&lt;/p&gt;

&lt;p&gt;For getting started with types, we will come up with our working definition of types with increasing levels of technical depth. We will also be iteratively refining our definition and intuitions regarding what types are. As for how types look in programming, here are four simple examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;obligatory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World! &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  
&lt;span class="c1"&gt;// type inferred to be String based on its value&lt;/span&gt;

&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;goodbye&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Goodbye, cruel world...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; 
&lt;span class="c1"&gt;// type explicitly defined to be a String&lt;/span&gt;

&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;emoji&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Char&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;☺&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// Unicode characters are present in Char type's value space&lt;/span&gt;

&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;heteroList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;List&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obligatory&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;goodbye&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// String type allows addition operation &lt;/span&gt;
&lt;span class="c1"&gt;// The composed type List[Any] allows use of any type in heteroList&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is certainly just a picture and certainly not the whole picture. However we will get closer to types through this kind of programmatic representation of types above.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wf0nVi7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://upload.wikimedia.org/wikipedia/en/b/b9/MagrittePipe.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wf0nVi7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://upload.wikimedia.org/wikipedia/en/b/b9/MagrittePipe.jpg" alt="thisIsNotAPipe"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is not a pipe. This is just a representation of a pipe.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Almost every programming construct that you can use has a type. It follows that there are many types of types.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Common Data Types: Syntactic and Semantic bits
&lt;/h2&gt;

&lt;p&gt;Let's start with the primitive ones. Types of values in data are the easiest to intuitively understand. Here at level 1, we will define type as a pre-defined value space for our data which possibly comes along with a set of allowed operations on the values in that value space.&lt;/p&gt;

&lt;p&gt;At level 1, you may find, for instance, a type that does not have any possible operations or one that is simply an alias of another type. These are merely syntactic types. All types have this syntactic aspect in the sense that a type definition ensures the program compiler - and the programmer - that it adheres to the rules and constraints set by the programming language itself, especially regarding what is and isn't allowed to be done with a certain variable or construct.&lt;/p&gt;

&lt;p&gt;For instance, if you find a type definition called &lt;code&gt;Money&lt;/code&gt; in your program, it probably is a syntactic sugar representing some type of fixed or floating point numbering.&lt;/p&gt;

&lt;p&gt;The semantic aspect of a type would be about what it means to have a certain type in the first place. For instance, type semantics could tell you what possible actions are possible on that type or what interactions are allowed with other types. &lt;/p&gt;

&lt;p&gt;For a utility type like &lt;code&gt;Money&lt;/code&gt;, the operations could be inherited arithmetic methods for addition or subtraction or convenience methods composed of other operations like methods for interest rate calculations.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Any and Nothing&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;All types in Scala are different  derivations of the &lt;code&gt;Any&lt;/code&gt; type. Informally, you may call it the mother of all types as it is the &lt;strong&gt;top type&lt;/strong&gt; in Scala's type hierarchy.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Any&lt;/code&gt; of Scala is similar to the &lt;code&gt;Object&lt;/code&gt; type defined by the class also named &lt;code&gt;Object&lt;/code&gt; in Java. In TypeScript, there are two top types &lt;code&gt;any&lt;/code&gt; and &lt;code&gt;unknown&lt;/code&gt;. &lt;code&gt;any&lt;/code&gt; just tells the TypeScript compiler that it should not even bother to do any type checks. So compile time type safety due to aforementioned type syntactics and semantics is effectively disabled for that variable or constant of &lt;code&gt;any&lt;/code&gt; type. So related bugs may only be discovered if unexpected operations are performed on that value at runtime - during testing (hopefully) or in production (yikes). &lt;code&gt;unknown&lt;/code&gt; type signifies that the actual type is yet unknown but can be narrowed down and pin-pointed based on its runtime values, usually using a language construct called type guards. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Any&lt;/code&gt; in Scala has general definitions of &lt;code&gt;equals&lt;/code&gt;, &lt;code&gt;hashCode&lt;/code&gt; and &lt;code&gt;toString&lt;/code&gt; methods. This means that &lt;code&gt;Any&lt;/code&gt; type in Scala allows for checking whether anything equals another and what its hashed or string representation is. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All puns intended. Always.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Type theory and category theory, from which we have type systems in programming, also have something called a &lt;strong&gt;bottom type&lt;/strong&gt;. It is called so because it is at the bottom of the type hierarchy i.e. all types have the bottom type as their subtype. Scala's bottom type is called &lt;code&gt;Nothing&lt;/code&gt; as there is nothing you can assign to a variable or construct of type &lt;code&gt;Nothing&lt;/code&gt;. If a function throws an exception instead of returning any value, it has &lt;code&gt;Nothing&lt;/code&gt; for a return type. We will find further uses of this in later posts, especially when we discuss covariance under parametric polymorphism.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;AnyVal and AnyRef&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In programming, you may be directly using or passing around a value from one memory location to another. These types of values are derived from &lt;code&gt;AnyVal&lt;/code&gt; type in Scala, which itself is a descendant derived directly from the &lt;code&gt;Any&lt;/code&gt; supertype.&lt;/p&gt;

&lt;p&gt;You may also just be referring to where the value is located in your memory space instead of moving those values around. These variables have a reference type, which descends from the &lt;code&gt;AnyRef&lt;/code&gt; supertype, which itself descends directly from the &lt;code&gt;Any&lt;/code&gt; type.&lt;/p&gt;

&lt;p&gt;When you look at the documentation for a type, for example &lt;a href="https://www.scala-lang.org/api/current/scala/Boolean%24.html"&gt;Boolean&lt;/a&gt;, you might find methods that &lt;code&gt;box&lt;/code&gt; or &lt;code&gt;unbox&lt;/code&gt; a value. The &lt;code&gt;scala.Boolean&lt;/code&gt; is a value type but you can wrap your boolean value inside a 'box' made of &lt;code&gt;java.lang.Boolean&lt;/code&gt;, which is a reference type. You might need to do this boxing to access reference type's methods or, in this case, to ensure interoperability with Java clients of your library. Similarly, you can also 'unbox' a reference type into a value type.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Unit and Boolean&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Just like &lt;code&gt;Nothing&lt;/code&gt; allows nothing as its value, &lt;code&gt;Unit&lt;/code&gt; allows only one and the same value, and &lt;code&gt;Boolean&lt;/code&gt; allows only two.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Boolean&lt;/code&gt; type is probably the most well known and easily understood of all. It allows its value to be either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Unit&lt;/code&gt; type only allows one value, which is written as &lt;code&gt;()&lt;/code&gt;. Therefore it holds no information and is very similar to, but not the same as, &lt;code&gt;void&lt;/code&gt; used in C/C++/Java. It also should not be confused with aforementioned &lt;code&gt;Nothing&lt;/code&gt; or with &lt;code&gt;Null&lt;/code&gt; from the next section. We will return back to this type later when we talk about tuples and product types since &lt;code&gt;Unit&lt;/code&gt; can be interpreted as a 0-tuple or a product of no types. We will also see how it is useful when we talk about abstract data types and algebraic data types.    &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Option and Null&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Sometimes a reference is likely to point either to some value or to none of it when the value of the instance of that type is requested for use by the program execution. In many languages, such references lead to a null pointer, which Tony Hoare, the pioneering computer scientist who introduced the null pointer concept, has famously called his billion dollar mistake. &lt;/p&gt;

&lt;p&gt;The functional and type safe solution to this annoyance would be the the type &lt;code&gt;Option&lt;/code&gt; or &lt;code&gt;Optional&lt;/code&gt; (in Java, Scala, Kotlin, Swift, SML, OCaml, Rust) or &lt;code&gt;Maybe&lt;/code&gt; (in Haskell, Agda, Idris). Depending on the implementation, this type may be &lt;a href="https://books.underscore.io/scala-with-cats/scala-with-cats.html#what-is-a-monad"&gt;monadic&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In Scala, &lt;code&gt;Option&lt;/code&gt; is a monadic type and has two subtypes &lt;code&gt;Some&lt;/code&gt; or &lt;code&gt;None&lt;/code&gt;. We will discuss monads in the section on algebraic data types. For now, going by the above box or container metaphor, if you think that in your variable there &lt;em&gt;maybe some&lt;/em&gt; value or &lt;em&gt;optionally none&lt;/em&gt; at all then you can put it inside an &lt;code&gt;Option&lt;/code&gt; box. To check if there are any &lt;em&gt;valuables&lt;/em&gt; in the box, you can simply check the type of the content instead of various &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy"&gt;'falsiness' checks&lt;/a&gt; or nullness checks on the value of the content itself. The type is is guaranteed to be &lt;code&gt;Some&lt;/code&gt; if something is present or &lt;code&gt;None&lt;/code&gt; otherwise. There also exists another similar trio called &lt;code&gt;Try&lt;/code&gt;, &lt;code&gt;Success&lt;/code&gt; and &lt;code&gt;Failure&lt;/code&gt; in Scala. They essentially form a more concise syntax and are used when catching exceptions could be needed as opposed to just dealing with presence or absence of values. &lt;/p&gt;

&lt;p&gt;We will explore examples of the usage of both of these trios when we later discuss pattern matching based on types and control flow structures like try-catch, match-case or for-yield. &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;The &lt;em&gt;Normie&lt;/em&gt; Types&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;These are the common, necessary but boring types that will become interesting when we start composing them with other types and weaving mind-bending - and hopefully helpful - structures later.&lt;/p&gt;

&lt;h4&gt;
  
  
  I. Byte, Short and Int
&lt;/h4&gt;

&lt;p&gt;These types have trivially defined value spaces. Available methods for each type will defer as relevant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;  &lt;span class="c1"&gt;// defaults to Int type&lt;/span&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Byte&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;// (-2^7 to 2^7-1] i.e. -128 to 127&lt;/span&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Short&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="c1"&gt;// (-2^15 to 2^15-1] i.e. -32,768 to 32,767&lt;/span&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="c1"&gt;// (-2^31 to 2^31-1] i.e. -2,147,483,648 to 2,147,483,647&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  II. Long, Float and Double
&lt;/h4&gt;

&lt;p&gt;These are pretty much the same as the above numerical types except they allow for bigger ranges and, in case of &lt;code&gt;Float&lt;/code&gt; and &lt;code&gt;Double&lt;/code&gt;, fractional values with floating point precision.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;l&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Long&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;// (-2^63 to 2^63-1]&lt;/span&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt; &lt;span class="c1"&gt;// 32-bit IEEE 754 single-precision float&lt;/span&gt;
&lt;span class="c1"&gt;// 1.40129846432481707e-45 to 3.40282346638528860e+38&lt;/span&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Double&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt; &lt;span class="c1"&gt;// 64-bit IEEE 754 double-precision float&lt;/span&gt;
&lt;span class="c1"&gt;// 4.94065645841246544e-324d to 1.79769313486231570e+308d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  III. Char and String
&lt;/h4&gt;

&lt;p&gt;A &lt;code&gt;Char&lt;/code&gt; is a literal from the Unicode charset. A &lt;code&gt;Char&lt;/code&gt; can be cast to its corresponding position in the Unicode charset as an &lt;code&gt;Int&lt;/code&gt;, like you can in most languages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;scala&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Char&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;q&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Char&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;q&lt;/span&gt;

&lt;span class="nx"&gt;scala&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;
&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;113&lt;/span&gt;

&lt;span class="nx"&gt;scala&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;emoji&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Char&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;☺&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="nx"&gt;emoji&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Char&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;☺&lt;/span&gt;

&lt;span class="nx"&gt;scala&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;emoji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toInt&lt;/span&gt;
&lt;span class="nx"&gt;res0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9786&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;String&lt;/code&gt; is defined as a sequence of &lt;code&gt;Char&lt;/code&gt;s. You assign a string using quotes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;strQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Now I am become Death, the destroyer of worlds - J. Robert Oppenheimer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="nx"&gt;listToStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;List&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;If I'm not back in five minutes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;just wait longer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;
&lt;span class="c1"&gt;// output: List(If I'm not back in five minutes, just wait longer)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Scala &lt;code&gt;String&lt;/code&gt; relies on &lt;code&gt;java.lang.String&lt;/code&gt; but is also augmented by many useful utility methods from the &lt;code&gt;StringOps&lt;/code&gt; class. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is not necessary to learn these methods or those of any Scala type by heart. You should just get more intimate with the docs and always check the docs before writing a routine or standard looking operation on your own. You can likely also discover them using your IDE's autocomplete or inline documentations. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  IV. The Big and The Rich
&lt;/h4&gt;

&lt;p&gt;There are &lt;code&gt;StringOps&lt;/code&gt; equivalents for the other the other value types called &lt;code&gt;RichBoolean&lt;/code&gt;, &lt;code&gt;RichByte&lt;/code&gt;, &lt;code&gt;RichChar&lt;/code&gt;, &lt;code&gt;RichDouble&lt;/code&gt;, &lt;code&gt;RichFloat&lt;/code&gt;, &lt;code&gt;RichInt&lt;/code&gt;, &lt;code&gt;RichLong&lt;/code&gt; and &lt;code&gt;RichShort&lt;/code&gt;. These &lt;a href="http://w3sdesign.com/?gr=s07&amp;amp;ugr=proble"&gt;proxies&lt;/a&gt; provide additional methods to the above value types. Unlike the case in Java with its primitive and boxed reference types, this pattern allows for keeping the value types lightweight while still providing a rich API and therefore fewer use cases for boxing and unboxing due to performance vs convenience trade-offs.&lt;/p&gt;

&lt;p&gt;Besides the &lt;code&gt;Rich&lt;/code&gt;* ones, &lt;code&gt;scala.math&lt;/code&gt; package provides &lt;code&gt;BigDecimal&lt;/code&gt; and &lt;code&gt;BigInt&lt;/code&gt; classes. These are for calculations with floating-point numbers of arbitrary precision starting with a default precision approximately that of IEEE 128-bit floating point numbers.&lt;/p&gt;




&lt;h1&gt;
  
  
  Next on 'Types of Types'
&lt;/h1&gt;

&lt;p&gt;To keep the posts from going beyond optimal lengths, we will explore each of the next 'levels' of understanding and defining types in their own posts. Here's a sneak peek. &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Function weds Data: Domain and Co-domain Spaces
&lt;/h2&gt;

&lt;p&gt;Here we will introduce functions and methods together with objects and classes. We will see how OOP augments the power of functional programming and how best to avoid the many pitfalls of OOP.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Object and Class
&lt;/h3&gt;

&lt;h3&gt;
  
  
  2.2 Functions and Methods
&lt;/h3&gt;

&lt;h3&gt;
  
  
  2.3 Parameter Types and Return Types
&lt;/h3&gt;




&lt;h2&gt;
  
  
  3. Abstract Data Types: Types with Structure and Behavior
&lt;/h2&gt;

&lt;p&gt;Here we will rediscover the good old data structures mostly used in programming through a more formal, functional and scala-ble lens 🧐.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Sum and Product Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;3.1.1 Union &lt;em&gt;or&lt;/em&gt; Tagged Union&lt;/li&gt;
&lt;li&gt;3.1.2 Tuple &lt;em&gt;and&lt;/em&gt; Record&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.2 Set and List
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;3.2.1 Unordered and Non-duplicated&lt;/li&gt;
&lt;li&gt;3.2.2 Ordered and Random Accessible&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.3 Maps
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.4 Stack and Queue
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.5 Graph and Tree
&lt;/h3&gt;




&lt;h2&gt;
  
  
  4. Algebraic Data Types and HKTs
&lt;/h2&gt;

&lt;p&gt;Here we will (re-)discover universal algebra, ring-like, group-like, lattice-like, module-like, and algebra-like algebraic structures relevant to advanced functional and reactive programming. We will also demystify higher kinded types and similarly exotic higher order concepts. &lt;/p&gt;




&lt;h2&gt;
  
  
  5. A Gentle Introduction to Category Theory
&lt;/h2&gt;

&lt;p&gt;Here we will use the Scala concepts and Type Theory topics thus far to go for a deep dive into Bartoz Milewski's excellent &lt;a href="https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/"&gt;course on Category Theory &lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Beware that category theorists are sometimes insufferable and gave birth to memes like this &lt;a href="http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html?m=1"&gt;one&lt;/a&gt;, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;'A monad is just an endofunctor in the category of monoids. What's the problem?' &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or this one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QLefRe3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1586014084969/1Kio9oLYO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QLefRe3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1586014084969/1Kio9oLYO.png" alt="meme_category_theory.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Further resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;D. L. Parnas, John E. Shore, David Weiss: Abstract types defined as classes of variables, &lt;a href="https://dl.acm.org/doi/10.1145/942574.807133"&gt;https://dl.acm.org/doi/10.1145/942574.807133&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tony Hoare on his infamous billion dollar mistake: &lt;a href="https://www.youtube.com/watch?v=kz7DfbOuvOM"&gt;https://www.youtube.com/watch?v=kz7DfbOuvOM&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Official Scala API Docs and resources: &lt;a href="https://www.scala-lang.org/"&gt;https://www.scala-lang.org/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;L.G. Meredith, Pro Scala: Monadic Design Patterns for the Web: &lt;a href="http://patryshev.com/books/GregoryMeredith.pdf"&gt;http://patryshev.com/books/GregoryMeredith.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>functional</category>
      <category>types</category>
      <category>scala</category>
      <category>categorytheory</category>
    </item>
    <item>
      <title>Play with Spring and Angular: Getting Started</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Thu, 26 Mar 2020 04:58:41 +0000</pubDate>
      <link>https://dev.to/risavkarna/play-spring-and-angular-getting-started-1c45</link>
      <guid>https://dev.to/risavkarna/play-spring-and-angular-getting-started-1c45</guid>
      <description>&lt;p&gt;In this series, we will explore full stack development with Play, Akka, Spring modules and Angular. This will also help you understand how projects like &lt;a href="https://risav.dev/introducing-nepwork-ck5294zz401bvmus1p2oskup0"&gt;nep.work&lt;/a&gt; are built and what one might need to learn or revise to be able to contribute to the &lt;a href="https://github.com/nepwork/handbook/blob/master/stack.md"&gt;nep.work core stack&lt;/a&gt; or to any Play and Angular based stack, for that matter. &lt;/p&gt;

&lt;p&gt;We will start this series by installing the command line interface tools for Play 2.0, Spring Boot and Angular. I strongly recommend using a linux distro with a good package manager and a sensible terminal emulator for the best developer experience. &lt;/p&gt;

&lt;h3&gt;
  
  
  SDKMAN and JVMs
&lt;/h3&gt;

&lt;p&gt;Download SDKMAN from sdkman.io. If you like curling, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://get.sdkman.io"&lt;/span&gt; | bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This shows all available installs on SDKMAN.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sdk list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You have some choices of JDKs to choose from.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sdk list java
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I would suggest Amazon's Corretto if you will be deploying to AWS as it is always a good idea to have development, staging and production environment parity whenever applicable. &lt;/p&gt;

&lt;p&gt;You can also use AdoptOpenJDK or &lt;a href="https://www.graalvm.org/docs/why-graal/"&gt;the magical GraalVM&lt;/a&gt; (&lt;strong&gt;strongly recommended&lt;/strong&gt;) if you are a polyglot developer or want to experience the best available high performance VM.&lt;/p&gt;

&lt;p&gt;For Corretto:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sdk &lt;span class="nb"&gt;install &lt;/span&gt;java 11.0.4-amzn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For GraalVM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sdk &lt;span class="nb"&gt;install &lt;/span&gt;java 20.0.0.r11-grl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Please update the version numbers in this article yourself in the future. For SDKMAN, you can use &lt;code&gt;sdk list &amp;lt;package&amp;gt;&lt;/code&gt; to see available versions.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Spring Boot
&lt;/h3&gt;

&lt;p&gt;Install springboot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sdk &lt;span class="nb"&gt;install &lt;/span&gt;springboot
spring &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;br&gt;
Let's run an obligatory hello world to see if everything is running fine using a helloWorld.groovy file with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RestController&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SimpleWebApplication&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

  &lt;span class="nd"&gt;@RequestMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;welcome&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;"Hello World!"&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Run it using Spring CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;spring run helloWorld.groovy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This command will resolve all dependencies and start a tomcat install on the default port 8080. Check your browser or curl localhost:8080 to see if Hello World! has been displayed. &lt;/p&gt;




&lt;h1&gt;
  
  
  Scala and Play
&lt;/h1&gt;

&lt;p&gt;You should strongly consider using Scala and Play if you are interested in leveling up from Spring Boot/Java. You can still use Spring Data and other awesome spring modules in Scala/Play.&lt;/p&gt;

&lt;p&gt;Installing Scala and sbt is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sdk &lt;span class="nb"&gt;install &lt;/span&gt;sbt
sdk &lt;span class="nb"&gt;install &lt;/span&gt;scala
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can now create a sample Play app with a single command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sbt new playframework/play-scala-seed.g8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To run it simply type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;sbt run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This downloads all the dependencies and starts the system.&lt;/p&gt;

&lt;p&gt;In a browser, enter &lt;code&gt;localhost:9000&lt;/code&gt; to view the welcome page.&lt;/p&gt;




&lt;h3&gt;
  
  
  Nodejs
&lt;/h3&gt;

&lt;p&gt;We will be making use of nodejs' package manager npm, which comes bundled with nodejs. Download it from the download page of their site or via your package manager as explained &lt;a href="https://github.com/nodesource/distributions/blob/master/README.md"&gt;here&lt;/a&gt;. For example, to get Node.js v13.x (with full ICU/i18n support by default) on Ubuntu you would run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sL&lt;/span&gt; https://deb.nodesource.com/setup_13.x | &lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; bash -
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; nodejs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It is a bad idea to use sudo with npm for security reasons. A simple better solution is to set it to install packages to your home directory and then recursively &lt;code&gt;chown&lt;/code&gt; the npm directory with your user and group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.npm/prefix
npm config &lt;span class="nb"&gt;set &lt;/span&gt;prefix ~/.npm/prefix
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;:&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt; ~/.npm/prefix
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we need to update the path environment variables by adding the following in any one among &lt;code&gt;~/.bash_profile&lt;/code&gt; or &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.profile&lt;/code&gt; files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# set node to use user's chowned directory
export PATH="$PATH:$HOME/.npm/prefix/bin"
export NODE_PATH="$NODE_PATH:$HOME/.npm/prefix/lib/node_modules"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After saving the above addition to the file, you have source the file e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.profile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It is a good idea to enable the use of npm's cache whenever possible, especially when you have a lot of projects with similar dependencies. This is effectively the same as setting the now deprecated 'cache-min' option to  &lt;code&gt;9999999&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm config &lt;span class="nb"&gt;set &lt;/span&gt;prefer-offline
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h3&gt;
  
  
  Angular
&lt;/h3&gt;

&lt;p&gt;After nodejs and npm have been installed and configured, install angular CLI globally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @angular/cli
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now create and run your angular hello world using &lt;code&gt;ng new&lt;/code&gt; and &lt;code&gt;ng serve&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ng new hello-world &lt;span class="nt"&gt;--defaults&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;hello-world
ng serve &lt;span class="nt"&gt;-open&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In your browser you can see your new angular application being served at &lt;code&gt;localhost:4200&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  IDEs and Editors
&lt;/h3&gt;

&lt;p&gt;For IDEs, you could use Spring Tool Suite (STS) version of Eclipse for Spring and Visual Studio for Angular. For working on both using the same IDE, you can also install STS on Visual Studio Code or just use Intellij Ultimate, which would be an expensive option but a worthwhile one if your company/team decides to use it. In case your IDE does not recognize the SDKMAN installed JDK, create these symlinks to the usual locations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; ~/.sdkman/candidates/java/current/bin/javac /usr/bin/javac
&lt;span class="nb"&gt;sudo ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; ~/.sdkman/candidates/java/current/bin/java /usr/bin/java
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h1&gt;
  
  
  Bon Voyage!
&lt;/h1&gt;

&lt;p&gt;Now we are all set to explore Scala, Play, Spring and Angular in the future installments of this series on nep.work stack related tutorials. &lt;/p&gt;

&lt;p&gt;We will also use Java 11+, Scala 2.13+ &amp;amp; Typescript 3.8+ from this setup for exploring advanced CS, category theory and other pure mathematics concepts in the  &lt;a href="https://risav.dev/mathematics-architecture-and-processes-ck5ic92qa03jzqks1l2gv7lob"&gt;Mathematics' (An)architecture series&lt;/a&gt; .&lt;br&gt;
​&lt;/p&gt;

</description>
      <category>play</category>
      <category>springboot</category>
      <category>angular</category>
      <category>graalvm</category>
    </item>
    <item>
      <title>Time - II</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Wed, 25 Mar 2020 13:38:02 +0000</pubDate>
      <link>https://dev.to/risavkarna/time-ii-3d0p</link>
      <guid>https://dev.to/risavkarna/time-ii-3d0p</guid>
      <description>&lt;h1&gt;
  
  
  The ABCs and 123s of Time
&lt;/h1&gt;

&lt;p&gt;Time is also in an existential crisis. In &lt;a href="https://risav.dev/time-i-ck7s7kc7300kkzns159cjt4mx"&gt;the previous post&lt;/a&gt; in this series, we have touched upon the semantic crisis of time and the possibility that time may not exist as a feature of the universe as it is but rather a feature of our modes of understanding of the universe. In this second part of the series, we will focus on three ways of understanding time and how these can be represented in mathematics or physics terms. Hopefully this will build up the toolkit we require to easily dissect the more complex philosophical and technical arguments I would like to present in the third and fourth part of this series. &lt;/p&gt;

&lt;p&gt;These three conceptions of time are also highly problematic. McTaggart’s A series, B series and C series of time each have ugly self-contradictions, infinite regressions and outdated philosophical arguments. Furthermore, even mathematics and physics representing the various aspects of these 3 different possible universes do not claim to define time but rather just measure, calculate or represent these conceptions of time. We will be visit &lt;a href="https://en.wikipedia.org/wiki/Euclidean_space"&gt;Euclidean&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Minkowski_space"&gt;Minkowski&lt;/a&gt;  spaces where time may even become an imaginary number via  &lt;a href="https://en.wikipedia.org/wiki/Wick_rotation"&gt;Wick rotation&lt;/a&gt;,  whenever it makes it easier to  &lt;a href="https://en.wikipedia.org/wiki/Interpretations_of_quantum_mechanics#shutup"&gt;‘shut up and calculate’&lt;/a&gt;. I am getting ahead of myself here so we will start at the beginning of philosophy of being and becoming in the west and then jump 2 millennia to find McTaggart again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Heraclitus &amp;amp; Parmenides
&lt;/h2&gt;

&lt;p&gt;The pioneering process philosopher Heraclitus of Ephesus was also prolific in his scientific and logical research. He was a cosmologist, empiricist and a dialetheist logician. For dialetheists, there are propositions that can be both true and false in their logical system, which is recently finding support in modern paraconsistent logic. He also believed in an ever present flux and change. This concept also happened to lend a cool name to my first computer science research group and its online education forum at my university: ‘&lt;em&gt;Panta Rhei&lt;/em&gt;’ which means ‘everything flows’. For Heraclitus it was not just enough to say that everything is always flowing. He would also insist that everything is always ultimately ‘fire’. This fire too is always in a flux because everything is either fueling the eternal monistic fire or being burned down to ashes by it. Eastern scholars, including Krishna from the epic Mahabharat, also had similar sayings about a single monistic energy or spirit always changing its form, dividing itself infinitely into many forms yet remaining complete, infinite and undying. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(This infinite eternal fire would be an interesting topic for a later blog post, when it becomes relevant for our discussions of infinite streams in programming and infinity's types in &lt;a href="https://risav.dev/mathematics-anarchitecture-and-processes-ck5nahog004z4qps1w98ldfz0"&gt;the Mathematics' (An)architecture series&lt;/a&gt; or for the upcoming theoretical quantum computer science topics.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So energy flows and everything flows, all the time. Just like a river always flows downstream. Then, does time itself flow as well? Heraclitus found it impossible to step in the same river twice as the river was always becoming anew. This is similar to how we perceive that a time once passed can never be stepped back in again since current time always seems to be becoming a later time. Two millennia later Nietzsche built upon this and went so far as to say that fixed subjects and entities are not at all possible due to everything’s eternal state of becoming. Becoming in itself is the very process of change in time and space. Perhaps time does flow or have its own eternal state of becoming as well since everything in the world does? &lt;/p&gt;

&lt;p&gt;Perhaps not. Perhaps time is not a part of ‘everything in the world’ in the first place. &lt;/p&gt;

&lt;p&gt;The pioneering metaphysicist Parmenides of Elea, around the same time as Heraclitus, provided one of the first sustained arguments i.e. via a set of premises, deductions and inductions regarding the lack of flux or change in all of reality and regarding the impossibility of actual change, among other things. He argued that whatever is, is. And whatever is not, cannot be. This was an early attempt at defining being philosophically. Furthermore, nothing can come out of nothing, or to be fancy by using Latin - ‘ex nihilo nihil fit’, according to the sustained arguments under the primitive Parmenidean logical calculus. For something to seemingly change, it already has to be that which will provide the illusion of change. But it is in the very nature of it to not really change from what it essentially is, while still making the appearance of change. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(This also assumes some sort of conservation, especially conservation of mass-energy for physical entities. This would be more fodder for the aforementioned upcoming post on infinitude.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Being and The Becoming of Time
&lt;/h2&gt;

&lt;p&gt;Could it be that both Heraclitus and Parmenides are correct? &lt;/p&gt;

&lt;p&gt;In my previous post ‘&lt;em&gt;A Recipe for making a Developer&lt;/em&gt;’, I had argued that Neil Postman’s thesis in ‘&lt;em&gt;Amusing Ourselves to Death&lt;/em&gt;’ that Orwellian 1984 never came into being but Huxleyan Brave New World did was in fact not entirely correct. 1984 is more about a politics-borne dystopia and Brave New World is about a social dystopia. I had made a digression, much like this one, to outline how elements of both dystopias can and do co-exist in our societies. In a similar fashion, I would argue that both Heraclitean ‘panta rhei’ and Parmenidean ‘ex nihilo nihil fit’ are arguments, sustained or otherwise, for two very different albeit interlinked contexts. Having them together is not contradictory since a logical contradiction does not occur when a proposition is true in one context and false in the other. I would argue therefore that there is a false dichotomy between eternal state of being of all of existence and eternal state of becoming of different aspects of reality. I must also stress that I am not invoking dialetheism here and that this is still not a popularly accepted argument in academic philosophy.&lt;/p&gt;

&lt;p&gt;Heraclitus is concerned with becoming. Parmenides is concerned with being.&lt;/p&gt;

&lt;p&gt;With this basic reading of Heraclitus and Parmenides, we are probably equipped to appreciate the modern continuations of their seemingly contradictory arguments. As some of you familiar with the previously mentioned works of McTaggart might have guessed, Heraclitus’ position leads to the tensed and flow-compliant A series of time whereas Parmenides’ position leads to the non-tensed, indexed and unchanging time in B series. &lt;/p&gt;

&lt;p&gt;As mentioned before, becoming in itself is the process of change in time and space. So does the becoming of time itself require an underlying meta-time? And what about the meta-time itself and &lt;a href="https://en.wikipedia.org/wiki/Turtles_all_the_way_down"&gt;how far down do these turtles go&lt;/a&gt;? We can escape from infinitely regressive problems like these in A series by using B series. McTaggart believed that there were problems in B series as well and further that the problems in both A series and B series go away in his less popular C series.&lt;/p&gt;

&lt;h2&gt;
  
  
  The A and B Theory of Time
&lt;/h2&gt;

&lt;p&gt;Following the A, B and C series of time of J.M.E McTaggart, Richard Gale coined the terms A-theory and B-theory. Like most others who studied McTaggart, Gale too did not want to entertain the idea of C-series for reasons we will explore later in this series. Maybe we will find some redemption for the C series after all.&lt;/p&gt;

&lt;p&gt;In an A theoretic universe, time flows from past to the present to the future. In a B universe, there is no flow.&lt;br&gt;
The B universe is a multi dimensional block in which the ‘here’ and the ‘now’ are structurally similar. &lt;em&gt;Anywhere&lt;/em&gt; you are is ‘here’ for you. &lt;em&gt;Anywhen&lt;/em&gt; you are is ‘now’ for you in the same sense. 'Now' is just where you have reached in time. 'Now' is not flowing into the future with each instant. Just as the spatial coordinates change with your body's movement across space, the time coordinates change with your existence’s unending progression across time. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Saying time flows is just as ridiculous as saying space flows. Our existence marches across time, not the other way round. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In a B Universe, addressing the beginning or the end of an entity or even the universe itself is tricky. Every point of time exists eternally but just becomes inaccessible to some observers by becoming either their past or their future while being ‘the present’ for some other observers. An arbitrary event A in time may occur before a particular event P for some observers while A may occur after P for some other observers if A and P are not causally interlinked. &lt;/p&gt;

&lt;p&gt;I mention ‘the present’ in quotes because in B theory, there is no present, or past and future for that matter. However the present may not exist at all and this may be true not just in B theoretic universes. Our senses are never experiencing the present since sensation and perception is never instantaneous. We cannot even ascribe a duration to the present other than, if we are being too stubborn about it, an infinitesimal. However going anywhere lower, let alone infinitely lower, than Planck time does not make sense as our reality itself is built up using time quanta of Planck time and space quanta of Planck length. In other words, in our reality space and time does not have a more fine grained 'pixel resolution' than Planck length and Planck time respectively. &lt;/p&gt;

&lt;p&gt;In case you are wondering, Planck Time is not a good candidate either for the duration of 'present'. There is no reason to believe that Planck Time, derived from Newton’s universal gravitational constant G, Einstein’s relativistic constant c and Planck constant ħ, has any physical significance in how we experience time. It merely represents the time required by light to travel one Planck length in an ideal vacuum of space. Consequentially it describes, firstly, an approximate time scale at which quantum effects dominate, and quantum gravitational effects might become important and, secondly, the upper bound on the frequency of any wave. Nothing we ever do or experience in our human lives or even in our advanced scientific experiments occurs at the Planck scales. &lt;/p&gt;

&lt;p&gt;The A theory is a common sense theory of time that we find easy to digest. We can compare time to the Heraclitean river. Time does seem to be flowing through past, present and future after all. The B theory however is the more scientifically sound theory of time. Einstein would agree with it since his redefinition of space-time and Minkowski’s Minkowski space is what led to the block universe model espoused by B theory in the first place. We can compare it to the Parmenidean view of unchanging reality or roughly to an ocean which displays tides or currents in some sections but remains unchanged overall. In a famous letter of condolence to the family of his childhood friend Besso, Einstein wrote, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Now he has departed this strange world a little ahead of me. [...] That signifies nothing. For us believing physicists, the distinction between past, present and future is only a stubbornly persistent illusion.” &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We should note that although B theory posits that past, present and future are illusory and eternally exist as indexicals, B theory does not imply or constrain us to a deterministic universe where one particular ‘future’ is fixed in the same way that B theory and relativity do not constrain us to a single absolute ‘past’ for every observer anywhere in the universe. We will see that the block model of the universe may not be contained in just 3 dimensions of space and only 1 of time and that there may thus be enough wiggle space for a non-deterministic future. &lt;/p&gt;

&lt;p&gt;Also note how we end up having to use A theory terms like ‘past’ or ‘future’ to describe aspects of B theory. The reverse is also true and thus equally problematic in establishing a primacy or validity of one theory over the other. B Universes would have a hard time reconciling the concept of change and description of processes according to McTaggart. So McTaggart originally rejected both his A series and B series.&lt;/p&gt;

&lt;p&gt;At this point, we have reached the A and the B from the title of this post. Before we dive into the C, we should probably first look at the 123. &lt;/p&gt;

&lt;h2&gt;
  
  
  Time on 1, 2, 3 or more axes
&lt;/h2&gt;

&lt;p&gt;We are used to time being represented along a single straight line. Facebook, Twitter, blogs, Windows 10 and many other popular software interfaces utilize this familiarity to represent chronological ordering of life events, tweets, posts or recently used applications. Linearity of time was not always as naturally accepted before though. Many civilizations and traditions viewed time as a cyclic series. This is evident in our analog clocks which describe the hour of day in modulo 12 or modulo 24 numbering or in our calendars which describe the month of year in modulo 12 numbering schemes. Cyclic nature of time also made sense in predicting crop seeding and harvesting periods or other similar daily or annual loops, back when global warming had not messed with the change of seasons. Since time is famously defined as that which the clock measures, we could have insisted - before the modern quartz, digital or atomic clocks were invented - that the time is the measure of the intervals in our planet's cycles of rotation around an axis or revolution in an orbit. &lt;/p&gt;

&lt;p&gt;We could represent these circular timelines (time arcs?) using &lt;a href="https://en.wikipedia.org/wiki/Polar_coordinate_system"&gt;polar coordinates&lt;/a&gt;. For this we simply have to draw clock hands on top of a polar coordinate system to represent time. The first coordinate can be stipulated to be a constant or a unit distance from the origin. We can safely ignore this for our polar timekeeping activities. The second coordinate which contains the angle of the hand of the clock would be more interesting. Adding more hands to the clock with further subdivisions of the circumference is also possible if we want to have more precision than just seconds. In this way we can keep having an arbitrarily large number of angles providing us more and more precise time. However these representations can still be mapped from polar coordinates to a straight line without loss of information and precision i.e. these are both isomorphic representations of time. Intuitively it seems as if a polar coordinate based circular time representation is 2 dimensional. The plane on which the polar coordinates are drawn is indeed 2 dimensional and we need two numbers for specifying the position of each hand of the clock. Since we have stipulated that each hand of the clock is going to be of the same length, we are now left with 3 angles or n angles if we have n hands on our clock. We can put these angles on a &lt;a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system#Higher_dimensions"&gt;n-dimensional Cartesian coordinate system&lt;/a&gt; and, by construction, this n-dimensional coordinate representation would be isomorphic to our 2 D coordinate representation.&lt;/p&gt;

&lt;p&gt;So the n D representation outlined above is the same as the 2 D polar coordinate representation outlined above. But there's more. This 2 D representation is in turn identical to the 1 D representation based on a usual straight timeline with which we are all familiar. The proof is trivial as one can easily partition a straight line into as many divisions as there are on a clock for the hours and minutes marks. Then one can simply make a one-to-one mapping for each of the markers on the straight line with those on the clock. For a more visual proof, imagine, draw or animate a circular clock wet with ink along its circumference wherever you find marking for the hours and minutes in the clock. Now wheeling or rotating the clock on top of a paper sheet in a straight line can map each of those 12 hour markers and 60 minute markers on the clock to the corresponding markers on the straight line. The straight line will have hour markers equal distances apart and will have the same number of equidistant minute markers between them. &lt;/p&gt;

&lt;p&gt;One key insight from this mental mathematical athletics, &lt;a href="https://www.mathletics.com/en/"&gt;mathletics&lt;/a&gt; if you will, is that the number of axes for representations do not matter much if they contain the same amount of information. A corollary insight would be that you can extend one dimensional linear time to any number of dimensions if you have a proper mapping or transformation mechanism. &lt;/p&gt;

&lt;p&gt;There is a powerful concept of the 2 D '&lt;a href="https://en.wikipedia.org/wiki/Complex_number"&gt;imaginary&lt;/a&gt; time' in different areas of physics like cosmology, special relativity and quantum statistical mechanics. It can also be shown that Euclidean &lt;a href="https://en.wikipedia.org/wiki/Quantum_field_theory"&gt;QFT&lt;/a&gt; in n dimensions is identical to quantum statistical mechanics in n-1 dimensions. The proof for this and the construction of 2D imaginary numbers both use a mapping mechanism called &lt;a href="https://en.wikipedia.org/wiki/Wick_rotation"&gt;Wick rotation&lt;/a&gt; and are quite involved. Although we cannot use simple coordinate system transformation like before to prove this, we can see from the above exercise how one can map down or up to a lower or upper dimension. We can use a simpler tool than Wick rotation called a metric for better understanding the justification behind imaginary time.&lt;/p&gt;

&lt;p&gt;A metric is just a name we give for the generalization of the idea of distances between points in any given mathematical space. A mathematical space, often formed using a polar coordinate system or a Cartesian coordinate system, is an abstraction detached from physics and does not always get used to represent the physical notion of space. The metric or distance of a mathematical space is also detached from any physical units of distance. In a two dimensional Euclidean space, also known as a Euclidean plane, the metric is simply given by the famous Pythagorean theorem. For instance the distance of a point from origin is the square root of the sum of the x coordinate squared and the y coordinate squared. In a three dimensional Euclidean space, the metric involves the square root of the sum of x coordinate squared, y coordinate squared and z coordinate squared. This trend for the metric continues for higher dimensional Euclidean spaces. Even in the infinite dimensional generalizations of Euclidean space, also known as Hilbert spaces, there are exact Pythagorean theorem analogs. &lt;/p&gt;

&lt;p&gt;The mathematical space that represents the relativistic notion of space-time needs to be 4 dimensional but is not exactly just a 4 D Euclidean space. These 4 dimensions are minimal unlike the 3 D and n D Euclidean spaces that we constructed above because we do need a bare minimum of 4 different axes to house our 4-&lt;a href="https://en.wikipedia.org/wiki/Tuple"&gt;tuple&lt;/a&gt; or, more accurately, a &lt;a href="https://en.wikipedia.org/wiki/Four-vector"&gt;4 vector&lt;/a&gt; representing the 3 D Euclidean space with length, breadth and height, and an additional dimension for time, which is treated differently from the other 3 dimensions. Minkowski had found that his student Einstein’s postulates of special relativity also needed his 4 D mathematical construction, which he had originally developed for Maxwell’s equations of electromagnetism. The metric for this mathematical space is also called an interval and is given by the usual Pythagorean formula but with negated time:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yFxsBANA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://wikimedia.org/api/rest_v1/media/math/render/svg/d0a14afba1e45aded6ef14e5ab259c7458a15b35" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yFxsBANA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://wikimedia.org/api/rest_v1/media/math/render/svg/d0a14afba1e45aded6ef14e5ab259c7458a15b35" alt="d0a14afba1e45aded6ef14e5ab259c7458a15b35.svg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Poincare had presented a simpler form of this expression when introducing complex Minkowski spaces:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jC3qVcLi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://wikimedia.org/api/rest_v1/media/math/render/svg/cb20b5e5603c23c9c37f357ba305a5c993e88902" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jC3qVcLi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://wikimedia.org/api/rest_v1/media/math/render/svg/cb20b5e5603c23c9c37f357ba305a5c993e88902" alt="cb20b5e5603c23c9c37f357ba305a5c993e88902.svg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The imaginary number i has the special feature, by definition, that multiplying any real number with its square negates that number. Note the we had a negative square of time in the metric in the first place because of how space and time interact with each other in our universe. So it makes sense to allow for the time dimension's values to be placed on the imaginary axis so that we have the more elegant and Pythagorean looking metric expression:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AAjHg88z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://wikimedia.org/api/rest_v1/media/math/render/svg/dc1d6de73455ed8ba0433832d3706cdd0f1b8ff5" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AAjHg88z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://wikimedia.org/api/rest_v1/media/math/render/svg/dc1d6de73455ed8ba0433832d3706cdd0f1b8ff5" alt="dc1d6de73455ed8ba0433832d3706cdd0f1b8ff5.svg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you have it. Time is useful not just as a real but also as a complex or imaginary number when it makes our mathematical models simpler.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Higher Dimensions of Time and The C series
&lt;/h2&gt;

&lt;p&gt;Since we already came across imaginary time, it would be natural to question if further generalizations like quaternionic time, octonionic time or n-onionic time also make sense. In the next post in this series, we will evaluate the usefulness of these representations and see what, if any problems, they solve or what predictions they can make. We have seen so far that abstractions and mental constructs, even complex ones like a complex Minkowski space have usefulness in reality and are no less ‘real’ just because they are abstract. The mathematical models we have looked at so far are quite powerful in solving real world problems and predicting aspects of our reality. One can say that as long as we are able to do all that, and create GPS, cell phones, internet, spaceships etc, do we really need to understand time any better? &lt;/p&gt;

&lt;p&gt;I would say that it is all the more reason to understand time, one of our most profound mathematical models of reality. &lt;/p&gt;

&lt;p&gt;To this end, in a true Hegelian fashion, McTaggart reached the C series of time via dialectics. A series was the incumbent thesis. B series was the antithesis and C series was supposed to be the synthesis. McTaggart also employed modern metaphysics and analytic philosophy in defense of his neo-Hegelian view in the C series. We are about to reach the C series by understanding his arguments through parallels in the scientific community’s evolution of thoughts and ideas. The next two posts will be dedicated towards explaining this position and using it to dive further into the phenomenology and physics of time. We will also have a look at some more definitions of time and imaginary time from various scholars in the field and see if they too are fundamentally noumenal or mere abstractions for aiding calculations and without a physical meaning. We will see further uses of the ABCs and 123s and more explanations of the C in the upcoming discussions, which I hope will be very rewarding to the few of you who have read this far. &lt;/p&gt;

&lt;p&gt;[&lt;em&gt;In this series, I am trying to compress multiple millennia of thought evolution and probably an entire semester of academic work on the philosophy of time, which I would have loved to take. So I am probably being hasty, incomplete and incorrect at times. I have tried to link to further readings whenever I skip detailed explanations of the fundamentals. I would love to find corrections, links to resources and feedback, especially for these last two posts in this series as I am writing these also to inform myself better on these topics. I am not shy regarding invoking Cunningham’s law to this end.&lt;/em&gt;]&lt;/p&gt;

</description>
      <category>physics</category>
      <category>metaphysics</category>
      <category>einstein</category>
      <category>minkowski</category>
    </item>
    <item>
      <title>Time - I</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Wed, 25 Mar 2020 13:35:25 +0000</pubDate>
      <link>https://dev.to/risavkarna/time-i-1k5i</link>
      <guid>https://dev.to/risavkarna/time-i-1k5i</guid>
      <description>&lt;h1&gt;
  
  
  The Unreality of Time
&lt;/h1&gt;

&lt;p&gt;Time is in a semantic crisis. Physics and metaphysics should have resolved this by now. However it is hard to find a consensus when both disagree even on the fundamentals, let alone a rigorous definition. The closest that physics has come to metaphysics of time in recent times was probably when Einstein developed his theories of relativity, the first of which came out in 1905 and the second in 1915. He changed our classical view of time as an absolute, linear, monotonic and laminar flow, usually understood as a progression towards higher entropy or towards later events. &lt;/p&gt;

&lt;p&gt;This conception of time is highly problematic. Flow of time is provably not absolute, linear, monotonic or laminar. Furthermore, instances of time are not bound to any particular absolute ordering, especially if not linked by a direct causal chain. And even when a subsystem is moving towards lower entropy, time is still moving ‘forward’ instead of ever reversing. &lt;/p&gt;

&lt;p&gt;Cambridge idealist philosopher J.M.E McTaggart published his seminal treatment '&lt;em&gt;The Unreality of Time&lt;/em&gt;' in 1908. Its slightly different, more mature defense appeared in his 1927 work '&lt;em&gt;The Nature of Existence&lt;/em&gt;'. Especially in Vol II of the latter, his proof of unreality of time builds upon a seemingly careful Hegelian analysis of the foundational requirements of a metaphysical system like time or space. As a teacher and friend to Russell and Moore, the two other members of the 'The Mad Tea Party of Trinity', and a member of the Cambridge Apostles and the Bloomsbury set, he had overwhelming influence on his contemporary and later generations of thinkers and writers. Hegel himself was an important source of origin for most of the great 19th century philosophical ideas ‘from the philosophies of Marx and Nietzsche, phenomenology, German existentialism, and psychoanalysis’ according to Maurice Merleau-Ponty, a philosopher I admire more than most others and to whom we will come back to towards the end.&lt;/p&gt;

&lt;p&gt;Before we look deeper into it, it would help to note that the underlying subtext in these bodies of work, a triumph of neo-Hegelian idealism and modern physics, is that our knowledge of time is indistinguishable from our conception of time or our ‘modes of representation’ of  time. Time and space may not even be features of the phenomenal universe - the universe in itself without anyone to perceive or observe it - but rather just of the noumenal universe - the one that exists only as reality's map in our minds. This map of reality has grown to be almost as large as reality itself.&lt;/p&gt;

&lt;p&gt;The pre-relativistic term ‘timeline’, as opposed to ‘worldline’, still pervasively permeates the zeitgeist thanks to the common sense assumptions about time's linearity. Some of our most used interfaces have timelines, something akin to the general concept of linearly ordered events. Subverting such linearity that we are getting accustomed to on a daily basis is a popular trope in movies and story-telling in general, even when they are not about time travel or alternative histories or possible futures. Thus it is not hard to see why relativity, curvature and dilations of time do not fall under our general understanding of time but rather under sci fi, even after a century. &lt;/p&gt;

&lt;p&gt;In this series we will use the theories of relativity, quantum physics, McTaggart, Hegel, Lacan and Merleau-Ponty to arrive at where time stands currently. We will then move further towards the future of semantics of time partly by going all the way back to Aristotle's &lt;em&gt;Physics&lt;/em&gt; and Vedic literature and partly by going, ahem, back to the future with Prosser, Shuler and MJT. &lt;/p&gt;

</description>
      <category>time</category>
      <category>physics</category>
      <category>metaphysics</category>
      <category>semantics</category>
    </item>
    <item>
      <title>COVID-19 Simulation for Nepal: A Call for Collaboration</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Wed, 25 Mar 2020 13:29:43 +0000</pubDate>
      <link>https://dev.to/risavkarna/covid-19-simulation-for-nepal-a-call-for-collaboration-19n8</link>
      <guid>https://dev.to/risavkarna/covid-19-simulation-for-nepal-a-call-for-collaboration-19n8</guid>
      <description>&lt;p&gt;We are a group of national and international experts and scientists in the area of public health research, quantum statistical modeling, artificial intelligence, big data analysis and semantification. Our current goal is to enhance our &lt;strong&gt;powerful predictive models and simulation for the spread of COVID-19 in the Nepali population&lt;/strong&gt; given different scenarios and high level decisions, including the best and worst cases.&lt;/p&gt;

&lt;p&gt;Models and simulations based on our current approaches have many proven benefits including helping governments and relevant authorities make informed decisions. With large amounts of real world data and latest advancements in information technologies, we can discover previously unseen patterns and conclusions that cannot be attained through classical statistics and methods. We have a rare but highly prescient and state-of-the-art tool to potentially save many Nepali lives and livelihoods. &lt;/p&gt;

&lt;p&gt;The core algorithm and the central model for this simulation was developed by Manish J. Thapa, a quantum physicist at ETH Zürich, one of the most historically significant research institutions in the world. His own research and some other leading research in this field from his peers and contemporaries, especially regarding responding to cascading disaster spreadings and frameworks for intelligent network adaptation, have been used to construct this simulation, which  brings these findings together via an intelligent many-model approach. This simulation  also includes the standard SEIR model in epidemiology. However, we have focused on building upon the existing established knowledge and taking it a few steps further instead of wholly depending on one single model. We believe this research, when combined with further real-time data from various sources will be a substantially helpful tool in Nepal and even at a global scale. However, we certainly need to focus first on Nepal given our lack of national scale technical collaboration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Teams That Formed This Team
&lt;/h2&gt;

&lt;p&gt;The aforementioned 'we' represents a growing collaboration. Manish and I have reached out to multiple organizations and individuals after he first shared his research. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.naamii.com.np/"&gt;NAAMII&lt;/a&gt;&lt;/strong&gt;, an applied maths and AI based research non-profit, is the central body coordinating this entire effort. It has been instrumental in bringing together its network of experts in Nepal, US, UK, and Switzerland and has effectively created the platform Nepal has lacked for a national and international scale collaboration in this area.&lt;/p&gt;

&lt;p&gt;Previously introduced &lt;a href="https://risav.dev/introducing-nepwork-ck5294zz401bvmus1p2oskup0"&gt;nep.work&lt;/a&gt; group in EU/US along with our partner company in Nepal, &lt;a href="https://merakinepal.co/"&gt;Meraki Corp&lt;/a&gt;, is providing its advanced and secure data platform and coordinating with various current and potential data providers. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Our group takes privacy concerns and data anonymization very seriously. It has protocols and technologies in place for assuring the data providers and Nepali citizens about a transparent and careful handling of their data.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Recently, we were joined by &lt;a href="http://hamshospital.com/doctor/dr-kiran-raj-pandey-md-ms/"&gt;Dr. Kiran Raj Pandey&lt;/a&gt;, who is a prominent figure in this field and has also been in touch with government officials regarding his ongoing SEIR modelling efforts for Kathmandu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lftechnology.com/nepal/"&gt;Leapfrog&lt;/a&gt;, which is one of the supporters and close partner of NAAMII and their sister company &lt;a href="https://www.machnetinc.com/"&gt;Machnet&lt;/a&gt;, which provides guidance and support to nep.work group especially in its fintech efforts, are providing their support in bringing in further invaluable resources and organizations to this collaboration. &lt;/p&gt;

&lt;h2&gt;
  
  
  Please Join Us
&lt;/h2&gt;

&lt;p&gt;We would like to call upon you and all organizations, businesses, and individuals who are in a position to provide us reliable data regarding Nepal’s health infrastructure, road traffic flow and human mobility. It is of critical importance that we as a nation track human movements and hospital infrastructure to be fully informed and prepared for what's coming ahead.&lt;/p&gt;

&lt;p&gt;We would like to also highlight &lt;a href="https://covidnepal.org/"&gt;CovidNepal.org&lt;/a&gt;, another independent and noteworthy effort for this cause, that will be of help especially in aggregating hospital related data. Please contribute reliable data to it and/or promote it to hospitals and organizations in possession of relevant data.&lt;/p&gt;

&lt;p&gt;Here are some topics and examples regarding how data aggregation, especially from telecommunication service providers, can help:&lt;/p&gt;

&lt;h3&gt;
  
  
  Crowd Densities Analysis
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Finding out lots of phone GPS and cell phone tower pings near a large vegetable market every evening would be a sure sign that we need to decentralize grocery supply.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finding out that the crowd densities change more during the day than at night will further substantiate our findings based on data from a leading Nepali ISP that not enough people have been staying at home during the day&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Human Movements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Finding out how many cell phones previously pinging Kathmandu's cell towers are now pinging towers elsewhere will give us an approximation of how many people have left Kathmandu valley or how they are moving from and to different places in the last few weeks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GPS location reports, if possible to aggregate, will be even more precise and may provide us real-time data for the simulation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are more possibilities than these regarding improving the models behind our simulation. Please let us know if you have further ideas or if you have already made efforts similar to ours.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contact Us:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;NAAMII: &lt;a href="mailto:info@naamii.org.np"&gt;info@naamii.org.np&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Manish J Thapa: &lt;a href="mailto:manish.thapa@phys.chem.ethz.ch"&gt;manish.thapa@phys.chem.ethz.ch&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Risav Karna: &lt;a href="mailto:risav@merakinepal.co"&gt;risav@merakinepal.co&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>covid19</category>
      <category>simulation</category>
      <category>models</category>
      <category>ai</category>
    </item>
    <item>
      <title>A Recipe for making a Developer - I</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Tue, 25 Feb 2020 17:33:28 +0000</pubDate>
      <link>https://dev.to/risavkarna/a-recipe-for-making-a-developer-i-om4</link>
      <guid>https://dev.to/risavkarna/a-recipe-for-making-a-developer-i-om4</guid>
      <description>&lt;h1&gt;
  
  
  Amusing our Devs to Death
&lt;/h1&gt;

&lt;p&gt;Let’s make a developer. I obviously do not have a literal kitchen recipe for you because although a sizeable portion of developers likes getting baked, putting mathematical minds in ovens had disastrous results last century. We now have less brutal ways to prepare and dispose this brave new world’s modern labor force, with or without indentured servitude. Both Huxleyan and Orwellian dystopias can create efficient developers for your latest visionary tech sweatshop. The question is what pedigree of a developer you need, how much they should feel like they should get paid and how easily replaceable you want them to be. Hint: you need to set your story straight for the first two and, as for the last, the most easily replaceable ones are either the better ones or the worst of them. &lt;/p&gt;

&lt;h2&gt;
  
  
  Two Ingredients
&lt;/h2&gt;

&lt;p&gt;One secret sauce in all variations of this recipe is to use tech to make them feel better or even smug about themselves be it after a mere JavaScript boot camp, a CS degree or a Ph.D. in category theory. They each need to find pleasure in explaining to themselves and to you how &lt;a href="https://coryrylan.com/blog/tree-shakeable-providers-and-services-in-angular"&gt;the latest tree-shaking optimizations&lt;/a&gt; allow them to be free of &lt;a href="https://bundlephobia.com/"&gt;npm bundle phobia&lt;/a&gt; or how they can optimally &lt;a href="https://twitter.com/mxcl/status/608682016205344768?lang=en"&gt;invert a binary tree&lt;/a&gt; in their sleep or why their fancy &lt;a href="https://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/"&gt;burrito&lt;/a&gt; is just &lt;a href="http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html"&gt;a monoid in the category of endofunctors&lt;/a&gt;, respectively. &lt;/p&gt;

&lt;p&gt;As important as this pungent ingredient is, an even more important restriction is that you should never - never ever - let us question the fact that we are no more than just the modern equivalents of craftsmen, smiths, and laborers that build structures like houses and churches without much say in the big picture. Instead, we must be made to feel as if we are geniuses doing our own Manhattan projects or at the very least, ‘making the world a better place’. This is unquestionably achievable for us through ‘digital transformation and automation’. It squarely fits within our little domain of expertise making us feel good as your messiah or one of the apostles – in cases where the team leader is the actual one true visionary, the second coming of Lord Steve Jobs himself. &lt;/p&gt;

&lt;p&gt;With just these two things in mind, you are already half set for making a bonafide instant hire. Within a fortnight or two, you will have a fresh batch of JavaScript engineers ready to forever change the world. Add a week and they may even become scrum-certified, project-managing, medium-blogging, self-important, &lt;a href="https://github.com/RockstarLang/rockstar/blob/master/README.md"&gt;rockstar developers&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You will notice that those who actually understand our place in the corporate hierarchy are most likely humbled by &lt;a href="https://www.ted.com/talks/mike_cannon_brookes_how_you_can_use_impostor_syndrome_to_your_benefit?language=en"&gt;imposter syndrome&lt;/a&gt; and office politics and, more often than not, functionally depressed or about to be. These will soon become your 'problem employees' asking for more say in what they do or more pay or both or – God forbid – resignation. If you have candidates of this nature, I would suggest the Huxleyan recipe. &lt;/p&gt;

&lt;h2&gt;
  
  
  Father &amp;amp; Son
&lt;/h2&gt;

&lt;p&gt;As a developer currently being brain-damaged by JavaScript and co., I would like to introduce this concept to you via NgRx several levels of indirections and digression. Andrew Postman, Neil Postman’s son, reiterates the core of his father’s work that dissects Huxley and Orwell in his &lt;a href="https://www.theguardian.com/media/2017/feb/02/amusing-ourselves-to-death-neil-postman-trump-orwell-huxley"&gt;Guardian piece&lt;/a&gt; as follows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The central argument of Amusing Ourselves [to Death] is simple: there were two landmark dystopian novels written by brilliant British cultural critics – &lt;a href="https://en.wikipedia.org/wiki/Brave_New_World"&gt;Brave New World by Aldous Huxley&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Nineteen_Eighty-Four"&gt;Nineteen Eighty-Four by George Orwell&lt;/a&gt; – and we Americans had mistakenly feared and obsessed over the vision portrayed in the latter book (an information-censoring, movement-restricting, individuality-emaciating state) rather than the former (a technology-sedating, consumption-engorging, instant-gratifying bubble).”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is still a very American narrative regarding our sociopolitical climate. Most of our world including highly developed nations like the US with high concentrations of developers did &lt;a href="https://youtu.be/O-vLPvFskkg"&gt;enter the cliched brave new world but never really left 1984 either&lt;/a&gt;. The former is more about our social order and the latter is about our political order. Countries like the US, China and many of the rich cities in middle-east have managed to concurrently pull off both exceedingly well. Many other nation-states are soon to follow this trend of a liberal-but-Huxleyan social identity and a conservative-and-Orwellian political identity. Any economic entity like your new tech sweatshop or revolutionary startup (or both) tautologically falls under this regime too.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Huxleyan variant
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C0Kuq-G9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1582650289750/F2SalUhNG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C0Kuq-G9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1582650289750/F2SalUhNG.png" alt="6083617.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you go by the Huxleyan recipe, for the morale and motivation problem mentioned above you would need to up your game in using seductive tech privileges, access, and gifts here and there as Pavlovian carrots and sticks. You might have noticed how pimps in movies also play the role of a drug-dealer or have one around. They have known what Huxley always suspected governments and those in power choose to do with narcotics and pleasure-seeking human nature even before the posturing of ‘war against drugs’ and the epidemic of the ‘opioid crisis’ became a thing. The 'soma' drug of our brave new world is not a pill. It is the dopamine hit of social media approval and digitally-crafted personalized and addictive nonsense. It is delivered through the devices many of us are going to queue up for with our credit cards and savings right after this year’s product launch keynote. &lt;/p&gt;

&lt;p&gt;Your developers need this instant gratification themselves too to be able to whole-heartedly participate in pushing the soma to others around them. You have to construct distorted views of reality where they think (iff they manage to think beyond technology at all) that they are doing God’s work, without which society would fall apart. At the very least, you have to keep them inside a confined garden or a well, if you will, where they do not have to think much about the world beyond their code or of the socioeconomic ramifications of the features in their next release. This could take the form of secluded housings and transportations. It could mean antipodal distances from the assembly sweatshops. It also helps if you lead them to surmise how AI, and tech in general, will relieve us all of our mundane works and philosophize how pipe-dreams like Universal Basic Income will save us all from the developers’ jobs cannibalizing all human jobs. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Orwellian-Huxleyan hybrids
&lt;/h2&gt;

&lt;p&gt;Since the primary goal of Huxleyan citizens is to ‘find happiness’ and to be happy, the very purpose of tech entrepreneurship is to help them find it from their screens and devices. If you happen to be in an economy that is servient to bigger Huxleyan economies, your political order has to be Orwellian, the essential Huxleyan dual. &lt;/p&gt;

&lt;p&gt;You have to have high-tech sweatshops for scaling up the aforementioned ‘consumption-engorging’ supply chain. You should thus make and preserve developers using the Orwellian recipe in this case. You have to hide information about what your developers are building and often who they are building it for. You have to remind them often about how lucky they are to have the job coveted and desperately needed by hordes of unemployed or over-qualified junior developers in the country. You can never allow them contracts that secure their place at your organization for anything more than half a year. Actually, it helps if you further outsource and do not hire them directly at all. You cannot be responsible for individuals. You only need to talk to the company serving them on a platter or à la carte for you.&lt;/p&gt;

&lt;p&gt;(Disclosure: This author is currently rolling out a platform primarily for these kinds of workers.)&lt;/p&gt;

&lt;p&gt;In practice, there is no purely Orwellian or Huxleyan company. Most companies are a good mixture of the two these days. You will find it more likely to find secure, well-treated developers living comfortably in London, New York and most of SF Bay area and Western Europe. These are predominantly Huxleyan communities fueled and placated by coffee, alcohol, weed, micro-dosing or even Burning Man-like festivals. They will be mostly addicted to technology more than any drug though, thereby confined to a self-centered growth focus and destined to see the rest of the world as just a set of problems curable by software and technology. I have listened and guiltily participated when they would wax poetic on topics like &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how their weekend hackathon was for helping teen developers make the world a better place &lt;/li&gt;
&lt;li&gt;which meditation apps are the best&lt;/li&gt;
&lt;li&gt;how cryptocurrencies will solve the problems inherent in late-capitalism - while, ironically, speculating which unregulated coins are worth investing in &lt;/li&gt;
&lt;li&gt;how Facebook providing Facebook-branded internet to the not-yet-connected billions is great for those countries. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Orwell feared those who would deprive us of information. Huxley feared those who would give us so much that we would be reduced to passivity and egoism. Orwell feared that the truth would be concealed from us. Huxley feared the truth would be drowned in a sea of irrelevance. Orwell feared we would become a captive culture. Huxley feared we would become a trivial culture.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Having a Cake and Eating it Too
&lt;/h2&gt;

&lt;p&gt;I also used to interact with Asian/Indian developers living in the US or India who were constantly looking for their next job or a better one as they would be working as temps or externs from some outsourcing firm operating in the US or EU but originating in their home country. &lt;/p&gt;

&lt;p&gt;After almost a decade in Germany, I recently started living and working from Nepal as well. I have started noticing more than before how my region of the world is producing prolific developers albeit putting them under certain different incentives and priorities. It is convenient for companies like Boeing or British Airways to be able to simply push the narrative in the news that the so-called  &lt;a href="https://www.bloomberg.com/news/articles/2019-06-28/boeing-s-737-max-software-outsourced-to-9-an-hour-engineers"&gt;$9-an-hour developers crashed their $100+ million Max planes&lt;/a&gt; or cost them  &lt;a href="https://www.forbes.com/sites/jwebb/2017/05/29/british-airways-flights-and-it-failure-cue-furious-debate-around-outsourcing/#6b9a56f37839"&gt;£100+ million due to a flights control system changeover disaster&lt;/a&gt;. They still have to face the music but they can still claim to be a sound company with a good internal engineering culture. Or alternately, if questioned about bad outsourcing practices, claim that the technological problems are ‘local’ to the company exploiting the ambiguity of &lt;em&gt;localness&lt;/em&gt; in a globalized corporate Möbius strip. &lt;/p&gt;

&lt;p&gt;These ‘$9 developers’ are probably ethical and mindful in other areas of their lives. Since they are still making almost twice the regional average, I would guess they are probably also among the better developers from their universities and companies. I find it hard to believe that their mistakes are personal and not actually structural due to wrong contractual priorities (e.g. fast shipment and emphasis on bare minimum fulfillment of requirements) and bad supervision (e.g. doing a system changeover without coordinating well with the rest of the developers and technical personnel). This is a problem in how developers are made and less about their proficiency, which is traditionally improved by the company. &lt;/p&gt;

&lt;p&gt;All of these musings so far cover just the secret ingredients and the underlying kitchen chemistry for our recipe. How could we do the whole process of manufacturing, packaging, freezing, defrosting and preparing a proper developer? &lt;/p&gt;

&lt;p&gt;I would like to continue exploring this increasingly uncomfortable metaphor in the next title in this series since I have previously had complaints about my awfully long articles.&lt;/p&gt;

</description>
      <category>outsourcing</category>
      <category>dystopia</category>
      <category>orwell</category>
      <category>huxley</category>
    </item>
    <item>
      <title>Wau Ϝ Wow</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Tue, 25 Feb 2020 17:29:11 +0000</pubDate>
      <link>https://dev.to/risavkarna/wau-wow-mih</link>
      <guid>https://dev.to/risavkarna/wau-wow-mih</guid>
      <description>&lt;p&gt;Let me introduce you to Wau,&lt;br&gt;
Your new favorite of all numbers&lt;br&gt;
For many a different reason&lt;br&gt;
But here's only some for now&lt;br&gt;
I could keep going on&lt;br&gt;
But dev.to post limit encumbers&lt;/p&gt;

&lt;p&gt;Here's one:&lt;br&gt;
One is wau choose wau&lt;br&gt;
And another:&lt;br&gt;
One is wau factorial&lt;br&gt;
Zero over one's infinite sum tower&lt;br&gt;
Is really just a wau memorial&lt;/p&gt;

&lt;p&gt;If I've compounded your interest,&lt;br&gt;
e to the two i pi is wau.&lt;br&gt;
But it gets better,&lt;br&gt;
e to i to the e i o&lt;br&gt;
Finds its shelter in e to the wau &lt;br&gt;
To the tau wau wau&lt;/p&gt;

&lt;p&gt;If you're dumb-founded, just reinvest&lt;br&gt;
First, throw away your calculator,&lt;br&gt;
As a log of a wow base breaks it&lt;br&gt;
Next, buy a fractal exponentiator&lt;br&gt;
And let's say the wau takes a hit&lt;br&gt;
Then it still gives just another wow -&lt;/p&gt;

&lt;p&gt;Makes no more sense than Brexit&lt;/p&gt;

&lt;p&gt;A wow spiral definitely curls into its lone shelf&lt;br&gt;
Allow trials infinitely, it unfurls its own self&lt;br&gt;
It's not just maths, even physics gets wow help&lt;br&gt;
Einstein's E to the wow over MC squared&lt;br&gt;
Is wow to the two, but this news never aired&lt;br&gt;
Maybe since its a con split personality 0 and 1 shared&lt;/p&gt;

&lt;p&gt;Yet it's so uber cool no math lover hates it.&lt;/p&gt;




&lt;p&gt;Vi Hart's con that inspired this wau wau wow poem:&lt;/p&gt;

&lt;p&gt;&lt;a href="//youtu.be/GFLkou8NvJo"&gt;youtu.be/GFLkou8NvJo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>one</category>
      <category>wau</category>
      <category>math</category>
      <category>dihydrogenmonoxide</category>
    </item>
    <item>
      <title>Mathematics' Anarchitecture &amp; Processes for Programmers</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Tue, 21 Jan 2020 03:02:42 +0000</pubDate>
      <link>https://dev.to/risavkarna/mathematics-anarchitecture-processes-2e30</link>
      <guid>https://dev.to/risavkarna/mathematics-anarchitecture-processes-2e30</guid>
      <description>&lt;h2&gt;
  
  
  MAP for Programmers
&lt;/h2&gt;

&lt;p&gt;In the  &lt;a href="https://risav.dev/mathematics-architecture-and-processes-ck5ic92qa03jzqks1l2gv7lob"&gt;previous post&lt;/a&gt;  in this series, we made an outline of mathematical areas of programmer interests that we will explore together in 2020. &lt;/p&gt;

&lt;p&gt;A major portion of the post was about how first-order and/or propositional logic is isomorphic with categories and types. Since  &lt;a href="https://youtu.be/IOiZatlZtGU"&gt;propositions are types&lt;/a&gt;, you can have such constructs as constraint types or process types and perhaps a protocol for interacting with other types. A simple way forward would be to simply use the commonly held concept of mathematical operators and the fact that these operators will always be 'operating' on n - tuples with elements of various types. It is fun to work on the operators themselves rather than with numbers.&lt;/p&gt;

&lt;p&gt;Operators that preserve structure or map to a specific one are more interesting than the stochastic ones for now. At this point in the realm of what we call transformers and mutators. You will see that these are generalized nicknames for natural transformations and functors. We will be using these to build our basic data structures like multi-dimensional matrices, preferably in  &lt;a href="http://www.rasdaman.org/"&gt;rasdaman&lt;/a&gt;  on  &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;. These matrices encode graphs and hypergraphs which we will be using in our collaborative system ( &lt;a href="https://github.com/risavkarna/cosys/blob/master/README.md"&gt;CoSys&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;We have introduced the co-planetary platform and nep.work in a separate post. We end the series on a more abstract note by talking about our internal and external language and about the sinks, links &amp;amp; sources.&lt;/p&gt;

&lt;p&gt;The whole point is to make a map. And then to make a smaller map to navigate the previous map, ad infinitum. This structure is 12 tiered, 6 tiered, 4 tiered, 3 tiered, 2 tiered and 1 tiered in a 1D plane. In 2D, it is 12x6, 12x7, 12x7x2 and 6x6. In 3D, it is 3x3x3 and 3n+-1 x 3n+-1 x 3n+-1 dimensional. All kinds of data can be mapped on to this single monolithic immutable structure. The projection of such data, however, requires specialized DBMS and algorithms. For example, we will be using  &lt;a href="https://druid.apache.org/"&gt;Druid&lt;/a&gt; for time series and stream data. For document storage, we will be using MongoDB or Mongo-like DB APIs. For key: value stores, we will lean towards  &lt;a href="https://memcached.org/"&gt;memcached&lt;/a&gt;  or  &lt;a href="https://redis.io/"&gt;redis&lt;/a&gt;. This is not to be confused with the  &lt;a href="https://ignite.apache.org/"&gt;Apache Ignite&lt;/a&gt;  read layer of our persistence model for mathematics, and anything else for that matter. &lt;/p&gt;

&lt;p&gt;Yes, we are still strictly only talking about mathematics and applied mathematics. We will shift focus towards 'pure' mathematics and forget the engineering concerns later when we define types and categories. We still have the responsibility to build the matrices and hypergraphs promised before. For our purpose of finding mathematical foundations and mathematical structures and founding a mathematical software based on those findings, we will need steps 7 through 12. &lt;/p&gt;

&lt;p&gt;In the next post in this series, we will cover the origin of all of these ideas and the  &lt;a href="https://lotr.fandom.com/wiki/One_Ring"&gt;one ring&lt;/a&gt;  to rule them all. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Three Rings for the Elven-kings under the sky,&lt;/p&gt;

&lt;p&gt;Seven for the Dwarf-lords in their halls of stone,&lt;/p&gt;

&lt;p&gt;Nine for Mortal Men doomed to die,&lt;/p&gt;

&lt;p&gt;One for the Dark Lord on his dark throne&lt;/p&gt;

&lt;p&gt;In the Land of Mordor where the Shadows lie.&lt;/p&gt;

&lt;p&gt;One Ring to rule them all, One Ring to find them,&lt;/p&gt;

&lt;p&gt;One Ring to bring them all and in the darkness bind them&lt;/p&gt;

&lt;p&gt;In the Land of Mordor where the Shadows lie&lt;/p&gt;

&lt;p&gt;Are the rings, dear dev, that form our API&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--usGzkVwb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2wh8fmbyt2okrvr92jdw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--usGzkVwb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2wh8fmbyt2okrvr92jdw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>complex</category>
      <category>chaotic</category>
      <category>mathematics</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Mathematics' Architecture &amp; Processes for Programmers</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Fri, 17 Jan 2020 15:52:24 +0000</pubDate>
      <link>https://dev.to/risavkarna/mathematics-architecture-processes-for-programmers-1p80</link>
      <guid>https://dev.to/risavkarna/mathematics-architecture-processes-for-programmers-1p80</guid>
      <description>&lt;p&gt;This will be the 2020's web series about the foundation, architecture and deconstruction of mathematics. We will be mainly concerned with structures on top of which all of mathematics can find its foundations. However one cannot do much with just the foundations. We are going to discuss the known and the novel constructs with which we have built our mathematics. &lt;/p&gt;

&lt;p&gt;We will start by observing an interesting shadow set of the same structure and, more interestingly, we will name the different shadows but not the structure itself. Once you have shadows from all the infinite  &lt;a href="https://en.wikipedia.org/wiki/Steradian"&gt;steradians&lt;/a&gt;, you have the complete silhouette. You can go further and map the details of the structure instead of just getting its topographical outline. &lt;/p&gt;

&lt;p&gt;When you map geological points and events in a network, you will see that it helps to have topological maps aside from geologically correct maps. Maps are concerned with distances and physicality of things. However mathematical spaces and sets are concerned with other variables such as time and arbitrarily many mathematical or physical concepts. &lt;/p&gt;

&lt;h1&gt;
  
  
  1. Logic, Categories and Types
&lt;/h1&gt;

&lt;p&gt;In this section, we will talk about how the logic side and the programming side of things are equivalent in a sense. Technically we call this an  &lt;a href="http://mathworld.wolfram.com/Isomorphism.html"&gt;isomorphism&lt;/a&gt;.  &lt;a href="https://en.wikipedia.org/wiki/Hilbert_system"&gt;Hilbert style deduction systems&lt;/a&gt;  are based on intuitionistic logic, axiom schemes and deduction or proof systems. A model of computation called  &lt;a href="https://en.wikipedia.org/wiki/Lambda_calculus"&gt;lambda calculus&lt;/a&gt;  is concerned with similar equivalent structures as well. Similar models based on  &lt;a href="https://en.wikipedia.org/wiki/Type_theory"&gt;type theory&lt;/a&gt; ,  &lt;a href="https://en.wikipedia.org/wiki/Combinatory_logic"&gt;combinatory logic&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Sequent_calculus"&gt;Gentzen's sequent calculus&lt;/a&gt;  also exist. In the so-called  &lt;a href="https://en.wikipedia.org/wiki/Brouwer%E2%80%93Heyting%E2%80%93Kolmogorov_interpretation"&gt;BHK interpretation&lt;/a&gt; , intuitionistic proofs are functions and since lambda calculus proofs form a class of function, there is a correspondence between natural deduction and lambda calculus. &lt;/p&gt;

&lt;p&gt;Going further than the Curry-Howard correspondence we have so far, there is a generalized  &lt;a href="https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence"&gt;Curry-Howard-Lambek correspondence&lt;/a&gt; . It shows that proofs of  &lt;a href="https://en.wikipedia.org/wiki/Intuitionistic_logic"&gt;intuitionistic propositional logic&lt;/a&gt;  and combinators of typed  &lt;a href="https://en.wikipedia.org/wiki/Combinatory_logic"&gt;combinatory logic&lt;/a&gt;  share an  &lt;a href="https://en.wikipedia.org/wiki/Universal_algebra"&gt;equational theory&lt;/a&gt;  and form  &lt;a href="https://en.wikipedia.org/wiki/Cartesian_closed_category"&gt;cartesian closed categories&lt;/a&gt; . &lt;/p&gt;

&lt;p&gt;We will learn about constructions that operate on these logical propositions or abstract categories or types. We will deal with pairs such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Quantifier_(logic)"&gt;quantification&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Generalization"&gt;generalization&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Coproduct"&gt;sum&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Product_(category_theory)"&gt;product&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Logical_consequence"&gt;implication&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Function_(mathematics)"&gt;function&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Logical_conjunction"&gt;conjunction&lt;/a&gt;  and product&lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Logical_disjunction"&gt;disjunction&lt;/a&gt;  and sum&lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Truth_value"&gt;truth&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Unit_type"&gt;unity&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/False_(logic)"&gt;falsehood&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Bottom_type"&gt;depth&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Abductive_reasoning"&gt;Hypotheses&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Free_variables_and_bound_variables"&gt;Free Variables&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Modus_ponens"&gt;Modus Ponens&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Apply"&gt;Application&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Conditional_proof"&gt;Conditionality&lt;/a&gt;  and  &lt;a href="https://en.wikipedia.org/wiki/Abstraction"&gt;Abstraction&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will also examine the following aspects of the correspondences and related concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hibert-style deduction and Type System for Combinatory Logic&lt;/li&gt;
&lt;li&gt;Natural Deduction and Type System for Lambda Calculus&lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Closed_monoidal_category"&gt;Closed Monoidal Categories&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Categorical_logic"&gt;Internal Language&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Substructural_type_system"&gt;Linear Type System&lt;/a&gt;  &amp;amp;  &lt;a href="https://en.wikipedia.org/wiki/Linear_logic"&gt;Linear Logic&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a href="https://en.wikipedia.org/wiki/Homotopy#Homotopy_equivalence"&gt;Homotopic Equivalence &amp;amp; Equality&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2. Propositions and Constraints
&lt;/h1&gt;

&lt;p&gt;Here we will talk about rule based knowledge bases and logical calculus for extracting knowledge from constraints, rules and propositions. Formalisms for these will also be introduced.&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Operators and n-Tuples
&lt;/h1&gt;

&lt;p&gt;We will mostly obsess with quaternions and n-dimensional tuples which may mutate to equivalent structures in other dimensions. &lt;/p&gt;

&lt;h1&gt;
  
  
  4. Transformers and Mutators
&lt;/h1&gt;

&lt;p&gt;These mutators are called transformers if they shift the tuple towards structures in the same dimensions as before.&lt;/p&gt;

&lt;h1&gt;
  
  
  5. Matrices and Hypergraphs
&lt;/h1&gt;

&lt;p&gt;We will agree upon an intuitive encoding for matrices and various kinds of graphs.&lt;/p&gt;

&lt;h1&gt;
  
  
  6. MAMBA and COSYS
&lt;/h1&gt;

&lt;p&gt;We will examine a memory arrays &amp;amp; meshes based architecture for a collaborative system for computational problem solving.&lt;/p&gt;

&lt;h1&gt;
  
  
  7. COPLA and NEP.WORK
&lt;/h1&gt;

&lt;p&gt;Based on 6, we will create a model for inter-planetary level computational collaborations and national level collaborations, named in the examples as nep.work.&lt;/p&gt;

&lt;h1&gt;
  
  
  8. Spoken and Written Lang
&lt;/h1&gt;

&lt;p&gt;We will take a step back and examine the constructors of our abstractions. We will study spoken and written language structures describing the aforementioned concepts and knowledge base.&lt;/p&gt;

&lt;h1&gt;
  
  
  9. Shared and Heard Lang
&lt;/h1&gt;

&lt;p&gt;We will continue 8 with a shifted focus towards how language is intensionally and extensionally shared and heard. Essentially we take a sharp and brief look at understanding of understanding itself.&lt;/p&gt;

&lt;h1&gt;
  
  
  X. Internal Lang and Lang
&lt;/h1&gt;

&lt;p&gt;We will continue 9 with a further shifted focus towards internal language systems and the capacity for an externally shared language. We will look unbiasedly at both Chomsky's Universal Grammar and Deutscher's Universal Relativism.&lt;/p&gt;

&lt;h1&gt;
  
  
  11. Sink and Link
&lt;/h1&gt;

&lt;p&gt;Certain nodes in our directed graphs and networks are sources or sinks or both.  The edge's representation as a line or a n-D enclosure is known as a link and it may be directional and/or contextual.&lt;/p&gt;

&lt;h1&gt;
  
  
  12. Source and Course
&lt;/h1&gt;

&lt;p&gt;After looking at sinks and links, we focus ourselves on sources. The rest of the courses will be about sources and actors prevailing in such a meta-platform for mathematics, politics, economics, physics and engineering.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EdjkZH81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/c6rnffs564ztbugo0xl7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EdjkZH81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/c6rnffs564ztbugo0xl7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mathematics</category>
      <category>logic</category>
      <category>hypergraphs</category>
      <category>calculus</category>
    </item>
    <item>
      <title>Anarchitecture</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Wed, 08 Jan 2020 09:52:13 +0000</pubDate>
      <link>https://dev.to/risavkarna/anarchitecture-4eng</link>
      <guid>https://dev.to/risavkarna/anarchitecture-4eng</guid>
      <description>&lt;h1&gt;
  
  
  Development in Post-Agile, Managerless Teams
&lt;/h1&gt;

&lt;p&gt;Software teams often need a personnel as a bridge to the world of businesses and customers. However do they really need these bridging professionals who have likely never developed any non-trivial software to also &lt;em&gt;manage&lt;/em&gt; enterprise software teams? Can a team, especially a software team, self-organize?&lt;/p&gt;

&lt;h2&gt;
  
  
  Managers of Bullshit
&lt;/h2&gt;

&lt;p&gt;Anthropologist David Graeber argues in his book aptly named &lt;em&gt;Bullshit Jobs&lt;/em&gt; about the existence and social harm of meaningless jobs. Among the five types of entirely pointless jobs, non-technical professionals managing software teams would fall into the 'box tickers' and 'taskmasters' categories. These managers use paperwork and shallow documentations as a proxy for actually needed actions. They may even create extra work, unnecessary burden, avoidable tight deadlines and management strategies unsuited for a creative and technical team. I have known and worked with brilliant project managers over the years who definitely do not belong to these categories but I have also seen first hand the enormity of harm from these managers of bullshit and their similarly bullshit management techniques.&lt;/p&gt;

&lt;p&gt;'Uncle Bob' Martin, one of the authors of the original &lt;a href="https://agilemanifesto.org/"&gt;Agile Manifesto&lt;/a&gt;, in his talk cum rant &lt;a href="https://youtu.be/ecIWPzGEbFc"&gt;'The Future of Programming'&lt;/a&gt; explains precisely why most software development teams are facing this manager invasion problem. He draws from multiple decades of living what we now learn as history of software development and pin-points that software development professionals have in the modern days come to be workers without a self managing and risk handling discipline. You can see in this writeup how his talk leads to the post-agile sentiment I am bringing forth here:&lt;/p&gt;

&lt;h2&gt;
  
  
  Businesses created this mess
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;"...business understands discipline... so business really liked scrum. They like scrum because of the discipline. They like scrum because it was simple and obvious - you could do these little sprints and you could do all these meetings and you could do these plannings and it made sense to the business and the business thought, "Yes, this certification thing is a great idea. We need to certify people." &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  ... because they do not understand our craft and disciplines
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;"But the business does not understand us - doesn't understand programmers and in particular the business does not understand our disciplines. Business understands scrum disciplines. Business does not understand pair programming, ... test driven development, ... refactoring, ... simple design. These technical disciplines are not within the expertise of business and they shouldn't be. They belong to us; they are a part of our expertise. So business cannot approve or endorse them... or evaluate the risks. The risk frankly is ours to take... so we have to take the risk as part of our normal professional operations, as professionals. And that's what a professional does." &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  ... and because they made agile movement a managerial mess
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;" ... [but then] there was the invasion of the project managers caused by certification. Certification turned into this siren song and attracted, frankly, all the wrong people. Agile was developed by technical people. It was a creation of the software industry. Programmers sat in that room and created the agile manifesto and agile principles. And then came certification and with certification, hordes and hordes of project managers started to get certified. They would sit for two days in a class and get a piece of paper and feel that that was somehow significant. And they literally took over the agile movement. The agile movement shifted dramatically towards the project management side."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  ... which paved the way for the post-agile world
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;"When you think now about the stuff going on in agile, you are thinking about kanban and, you know, lean this and, you know, lean startup that. Where's the technical discipline? Where's [sic] the programmers? Frankly, the programmers have all fled. If you go to an agile conference now, you don't see an awful lot of programmers there and you don't see lots of technical tracks there. Although they try... &lt;/p&gt;

&lt;p&gt;Kent Beck said at Snowbird, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The goal for Agile was to heal the divide between business and programming" &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and I believe that the [agile movement] has completely failed... Somebody has to take the lead... Civilization depends on us in ways it doesn't yet understand. In ways we don't yet understand."&lt;/p&gt;


&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Take the lead?
&lt;/h1&gt;

&lt;p&gt;So who should be the somebody that takes the lead? Would it be the technical XPers and craftsmen or would it be the businesses with their newfound love in a bastardized agility? Could it be both?&lt;/p&gt;

&lt;p&gt;Martin Fowler explains in his article on &lt;a href="https://martinfowler.com/bliki/FlaccidScrum.html"&gt;FlaccidScrum&lt;/a&gt; about how scrum, albeit not a technical framework, can accommodate the craftsmanship best practices and discipline of, say, XP or TDD.  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"In defense of Scrum, it's important to point out that just because it doesn't include technical activities within its scope should not lead anyone to conclude that it doesn't think they are important. Whenever I've listened to prominent Scrummers they've always emphasized that you must have good technical practices to succeed with a Scrum project. They don't mandate what those technical practices should be, but you do need them... &lt;/p&gt;

&lt;p&gt;I always like to point out that it isn't methodologies that succeed or fail, it's teams that succeed or fail... Many people are looking to Lean as the Next Big Agile Thing. But the more popular lean becomes the more it will run into the same kind of issues as Scrum is facing now. That doesn't make Lean (or Scrum) worthless, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;it just reminds us &lt;strong&gt;Individuals and Interactions are more valuable than Processes and Tools.&lt;/strong&gt;"&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  The Manifesto, XP and Failures
&lt;/h1&gt;

&lt;p&gt;The &lt;a href="https://agilemanifesto.org/"&gt;Agile Manifesto&lt;/a&gt; reads:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Individuals and interactions over processes and tools&lt;/li&gt;
&lt;li&gt;Working software over comprehensive documentation&lt;/li&gt;
&lt;li&gt;Customer collaboration over contract negotiation&lt;/li&gt;
&lt;li&gt;Responding to change over following a plan&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is, while there is value in the items on the right, we value the items on the left more.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;XP values feedback, simplicity, communication, courage and respect. Agile's original best practices include standups, stories, retrospectives, iterations, estimates, tests, refactors and continuous deployments. &lt;/p&gt;

&lt;p&gt;Most teams fail because of lack of XP values and/or the managerial world view that prioritizes shipping faster - under the guise of pragmatism- over shipping with agile discipline - under the disparaging label of ideology. Some failures are softer and, in my experience, are caused by managers who make their developers so disconnected from business problems over time that they are no different from machine or telephone operators from the days of past. Then there are those managers who promote the idea that QA tools and tests are not part of getting the job done but rather a luxury. &lt;/p&gt;

&lt;p&gt;However the biggest and most cliched failure source is viewing programmers as a species that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;does not know how to talk&lt;/li&gt;
&lt;li&gt;does not have 'social skills'&lt;/li&gt;
&lt;li&gt;cannot understand clients' complex requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hence businesses create the need to bring forth a magical middleman with their own non-technical management strategies and their greedy algorithm based product shipment strategies. These would also be the managers who will never agree to epics and tasks centered around code refactoring let alone complete overhauls and rewrites. Effectively, these are also the managers that cannot make rational risk management decisions owing to their lack of in-depth technical knowledge. &lt;/p&gt;

&lt;h1&gt;
  
  
  Developer Driven Development and *DD
&lt;/h1&gt;

&lt;p&gt;Post-agile movement is primarily about removal of these aforementioned categories of managers. We do not need business managers leading software teams certified after a few weeks of training about software development management principles. We instead need an inversion whereby software developers learn management principles suited for their domain. And yes, this applies for even the junior most developers in the team since domain specific management principles are useful to know for everybody in the domain.&lt;/p&gt;

&lt;p&gt;Another profound realization that led to Fred George's vision of the post-agile programmer anarchy is the fact that partnerships between the customer and the development team to drive the software development project is inherently flawed and cripplingly slow. Partnership with the customer should be about defining their problems and desirable features of the solutions, nothing more. Otherwise we would be in the business of building the fabled horse carriages of customer's dreams when we could be building them cars or even star ships that the customers do not yet know about. &lt;/p&gt;

&lt;p&gt;This radical departure from the classical and agile status quo is possible because development teams understand business metrics, customer oriented development and follow the supremely powerful continuous feedback-continuous deployment cycle. &lt;/p&gt;

&lt;p&gt;On a more fundamental level, it is the realization that &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;if you are going for a drive, you need to put the driver in the driver's seat&lt;/strong&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Secondly if the driver is an experienced professional whom you have told where to take you, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;the backseat drivers are not needed&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Over the decades we have identified that we need Test, Feature, Behavior, Acceptance Test, Data, Domain, Design, Model or, if you will, * Driven Development. Perhaps one or more of these apply to your team's needs but none of it will go into practice if the developers themselves cannot drive the development practices. As both of the Martins above would say, the teams fail not the tools and this responsibility of applying the correct technical tools is a technical team's responsibility not a business domain concern.&lt;/p&gt;

&lt;h1&gt;
  
  
  Developer Anarchy, Self-Organization and Anarchitecture
&lt;/h1&gt;

&lt;p&gt;As separation of concerns is a dearly held value and a common meta-design pattern among developers, developers need to use this same principle for the architecture of their software and the development team's communication structures. These two are known to be inseparable and mutually influencing according to &lt;a href="https://www.thoughtworks.com/insights/blog/applying-conways-law-improve-your-software-development"&gt;Conway's law&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anarchy: Seeds and Needs
&lt;/h2&gt;

&lt;p&gt;Businesses will always need to be lead by business managers. Software development will always need to be lead by software developers and architects. Businesses need not be concerned with the solutions and therefore should invert the control of solution design back to the developers to maintain orthogonality. Businesses can still partner with software teams in an agile way to properly define the problems and agree upon the desired features for any possible solution that may emerge in the solution space after enough iterations.&lt;/p&gt;

&lt;p&gt;This is obviously only going to work if your development team has enough senior developers with industry experience and if there is enough communication among all its members. Working as a professional is very different from actually becoming a professional. But once you are lucky to have a team of professionals and younglings eager enough to become professionals, every developer can rightfully be &lt;strong&gt;an architect&lt;/strong&gt; for their own region of the system they are building. You do not always have to go for a micro-service architecture for this to be possible. Simply let the most experienced developers create a functional core and everyone else develop their own parts of the imperative shell around it as efficient and well-integrated plugins. More trusted developers would get the responsibility of pairing up with the developers of the more important plugins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Self-Organizing Superorganisms
&lt;/h2&gt;

&lt;p&gt;This so-called 'post-agile' technique is still very much compliant with the original agile manifesto. However there are no managers of programmers whose wrongly placed formality and misplaced rules may constrain technical innovation and creativity. As these developers will like to fail as much as possible in the early iterations, the classical managers will have no reliable metrics of progress anyways. The ideal anarchic development team has team members jumping up to take responsibilities that no outsider manager could even have possibly foreseen. Such a team could democratically divide work based on the particular sub-specializations, interests and expertise of the team member instead of forcing everyone to see through a story or task's completion from top to bottom of the tech-stack owing to the assigned 'user stories'. These developers would work directly with the product owner or the customer and build more trust than what waterfall or impure agile derivatives can provide. &lt;/p&gt;

&lt;p&gt;It follows that one big change in the development team's architecture would be the fact that development can no longer be story driven. As mentioned earlier, customers should produce formal, comprehensive problem descriptions and perhaps the desired features of the solutions but never directly participate in solution designs and technical specs. Anarchic teams cannot allow for customer side stories that disconnect developers from the actual problems the customers face. &lt;strong&gt;Neither customers nor managers know enough to tell the developers what or how the solution should be. If they did, the programming part would already have been automated or made into a business manager friendly automation DSL or UI.&lt;/strong&gt; Developers who understand the problem clearly can empathize better with the end users and come up with better specs and deadlines for the solutions. They might also be able to squeeze in enough room for early failures and experimentation. Overall, such teams will behave as self-organizing superorganisms.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anarchy to Anarchitecture
&lt;/h2&gt;

&lt;p&gt;Lastly, neither Fred George nor the two Martins are advocating radical anarchy or complete departure from the lessons learned from scrum and other agile frameworks, be it managerial or technical. Even the anarchists are supposed to converse and ask each other. Anarchic teams have emergent leaderships and self-organization strategies rather than pre-ordained leadership or lack of well-suited organizational strategies. &lt;/p&gt;

&lt;p&gt;How would the architecture of a system produced by an anarchic team look like? Surely the anarchy would leak into the architecture itself. Perhaps there will be an explosion of plugin and microservice architectures. Perhaps not. But I am sure that software architecture itself will be radically affected. What kind of architecture allows for flexible micro-architectures? The best kind. Probably. Could we still call it an architecture? Once again, the solution emerges from the problem definition itself.&lt;/p&gt;

&lt;p&gt;We could call it &lt;strong&gt;&lt;em&gt;anarchitecture&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>anarchy</category>
      <category>postagile</category>
      <category>management</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Introducing nep.work</title>
      <dc:creator>Risav</dc:creator>
      <pubDate>Mon, 06 Jan 2020 13:23:48 +0000</pubDate>
      <link>https://dev.to/risavkarna/introducing-nep-work-4395</link>
      <guid>https://dev.to/risavkarna/introducing-nep-work-4395</guid>
      <description>&lt;h1&gt;
  
  
  nep.work in a nutshell
&lt;/h1&gt;

&lt;p&gt;We are a community that develops omni-channel platforms for sales and delivery of services through work contract exchanges and pre-purchases. &lt;/p&gt;

&lt;p&gt;Think of us as an ecommerce platform for trading service agreements and insurances (eg for event organization and logistics) instead of products and as a hospitality platform operational at every accessible venue instead of a particular location (eg hotel, stadium, hospital, website, app etc).&lt;/p&gt;

&lt;h2&gt;
  
  
  Omni-channel
&lt;/h2&gt;

&lt;p&gt;A single channel, physical or digital, is not always enough for modern ecommerce and high frequency transactions. Neither is a basic multichannel strategy. For every nep.work trading agreement related interactions between providers and consumers, we strive to bring together all available digital and physical real estate, payment gateways and logistical solutions. As we will have a singular (but distributed) functional core, these various interaction points for the market will always be in synchrony and harmony with each other. That said we will still have service providers with brick and mortar shops and traditional online catalog-sales style webshops and apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Platform
&lt;/h2&gt;

&lt;p&gt;Our sole product and exclusive service is the work exchange platform and its customer support program respectively. We have a foundational infrastructure for a  &lt;a href="https://plato.stanford.edu/entries/contractualism/"&gt;contractualist&lt;/a&gt;  service exchange, with or without money, backed by immutable, reliable and publicly verifiable structures such as blockchain and in-memory merkle trees. The platform also has formal and socio-technical mechanisms to verify proof of work (PoW) for a given fulfilled contract. A verified PoW can be used for adding a new block of data to our blockchain and related persistence systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sales and Delivery
&lt;/h2&gt;

&lt;p&gt;Our services can be sold as contracts, insurances and barter agreements. When money is involved, the transactions can be made using local payment channels or our on-delivery cash service. Payments in kind or barter may be included before, during and after the delivery as per the specific Trading Agreement (TAg). We also have logistics partners and will soon announce a unified access API and SDK for our TAg management, payments and delivery. &lt;/p&gt;

&lt;h2&gt;
  
  
  Work Exchange
&lt;/h2&gt;

&lt;p&gt;Our work exchange platform goes beyond a freelancer network for posting and grabbing project offers. After a service request or offer is posted, there is either an open or closed negotiation between the provider and consumer parties. Optionally, an auction of the type chosen by the author of the post may be created to bypass negotiations and find optimum pricing options without involving  &lt;a href="https://www.econlib.org/archives/2010/09/the_senile_walr.html"&gt;senile Walrasians&lt;/a&gt;.&lt;br&gt;
Work exchange also enables us to remain self-organizing and self-preserving. We have learnt from similar communities on web and throughout history and created a public reputation based trust system. Providing such services in itself is a part of our work exchange program.  For every project, the project's team may have various developers, artists, sponsors, volunteers, reviewers and even the audience itself due to our democratized innovation and feedback mechanisms. Membership in certain negative interest rate service provider communities can help offset your monthly income in case it dips below your baseline. Similar 'buffer financing' or insurance services also exist for the projects the nepwork community works on. Finally most communities and work groups have a meta group which is responsible for critical reviews and future roadmaps of the group.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTmAoGIM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/hdqkobowxubiloqsjb8n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTmAoGIM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/hdqkobowxubiloqsjb8n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>anarchitekt</category>
      <category>platform</category>
      <category>omnichannel</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
