Busy Developer's Guide to Next-Generation Languages

ted.neward@newardassociates.com | Blog: http://blogs.newardassociates.com | Github: tedneward | LinkedIn: tedneward

Objectives

In this presentation, we're going to

Objectives

WHY?!?

Objectives

Our list

Objectives

NOTE

The Julia Programming Language

... in a nutshell

The Julia Programming Language

What is it?

The Julia Programming Language

Julia distributed invocations

$ julia -p 2

julia> r = remotecall(rand, 2, 2, 2)
Future(2, 1, 4, nothing)

julia> s = @spawnat 2 1 .+ fetch(r)
Future(2, 1, 5, nothing)

julia> fetch(s)
2×2 Array{Float64,2}:
 1.18526  1.50912
 1.16296  1.60607

The Julia Programming Language

With some interesting metaprogramming support

julia> ex1 = Meta.parse("1 + 1")
:(1 + 1)

julia> dump(ex1)
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol +
    2: Int64 1
    3: Int64 1

julia> ex2 = Expr(:call, :+, 1, 1)
:(1 + 1)

julia> ex1 == ex2
true

julia> 

The Julia Programming Language

Hosting Julia in native code

#include <julia.h>
JULIA_DEFINE_FAST_TLS

int main(int argc, char *argv[])
{
    jl_init();

    /* run Julia commands */
    jl_eval_string("print(sqrt(2.0))");

    jl_atexit_hook(0);
    return 0;
}
$ gcc -o test -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib 
    -Wl,-rpath,$JULIA_DIR/lib test.c -ljulia

Getting Started with Julia

From 0 to Hello World

Getting Started with Julia

Installation

Getting Started with Julia

Hello, world

println("Hello, world!")

Run

julia hello.jl

Or run interactively

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.1 (2023-06-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> print("Hello world")
Hello world
julia> 

Getting Started with Julia

Some interesting CLI switches

Analysis

Why Julia?

The Crystal Programming Language

... in a nutshell

The Crystal Programming Language

What is this?

The Crystal Programming Language

An HTTP server

require "http/server"

server = HTTP::Server.new do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world! The time is #{Time.local}"
end

address = server.bind_tcp 8080
puts "Listening on http://#{address}"
server.listen

Getting Started with Crystal

From 0 to HelloWorld

Getting Started with Crystal

Installation

Getting Started with Crystal

Create a project

crystal init app hello

Hello, world: src/hello.cr

# TODO: Write documentation for `Hello`
module Hello
  VERSION = "0.1.0"

  # TODO: Put your code here
end

Run

crystal run src/hello.cr

Compile

crystal build src/hello.cr; ./hello

Analysis

Why Crystal?

Jolie: An Overview

What is this thing?

Jolie: An Overview

In Brief

Jolie: An Overview

From the Jolie docs:

"More in general, Jolie brings a structured linguistic approach to the programming of services, including constructs for access endpoints, APIs with synchronous and asynchronous operations, communications, behavioural workflows, and multiparty sessions. Additionally, Jolie embraces that service and microservice systems are often heterogeneous and interoperability should be a first-class citizen: all data in Jolie is structured as trees that can be semi-automatically (most of the time fully automatically) converted from/to different data formats (JSON, XML, etc.) and communicated over a variety of protocols (HTTP, binary protocols, etc.). Jolie is an attempt at making the first language for microservices, in the sense that it provides primitives to deal directly with the programming of common concerns regarding microservices without relying on frameworks or external libraries."

Getting Started

... with Jolie

Getting Started

Installation

Getting Started

Installation

Getting Started

Installation

Getting Started

Verify

Getting Started

Hello World

Getting Started

Hello world

type HelloRequest {
	name:string
}

interface HelloInterface {
requestResponse:
	hello( HelloRequest )( string )
}

service HelloService {
	execution: concurrent

	inputPort HelloService {
		location: "socket://localhost:9000"
		protocol: http { format = "json" }
		interfaces: HelloInterface
	}

	main {
		hello( request )( response ) { 
			response = "Hello " + request.name
		}
	}
}

Jolie: Principles

What were they thinking?

Jolie: Principles

Jolie encourages/enforces key principles

Jolie: Principles

Contract-driven development

Jolie: Principles

Structural typing

Jolie: Principles

Components are services

Jolie: Principles

Decouple access points from business logic

Jolie: Principles

Abstract data manipulation

Analysis

Why Jolie?

The Wing Programming Language

... in a nutshell

The Wing Programming Language

What is it?

The Wing Programming Language

bring cloud;

let q = new cloud.Queue();
let b = new cloud.Bucket() as "Bucket: Last Message";

q.addConsumer(inflight (m: str) => {
    b.put("latest.txt", m);
});

new cloud.Function(inflight (s: str) => {
    log("Cloud Function was called with ${s}");
    q.push(s);
});

Getting Started with Wing

From 0 to HelloWorld

Getting Started with Wing

Installation

Getting Started with Wing

Hello... er, Cloud

bring cloud;

let bucket = new cloud.Bucket();
let queue = new cloud.Queue();

queue.setConsumer(inflight (message: str) => {
  bucket.put("wing.txt", "Hello, ${message}");
});

Test it in the Wing Console

wing it hello.w

Analysis

Why Wing?

The Wasp Programming Language

... in a nutshell

The Wasp Programming Language

What is this thing?

The Wasp Programming Language

Hello world

app todoApp {
  title: "ToDo App",  // visible in the browser tab
  auth: { // full-stack auth out-of-the-box
    userEntity: User, 
    methods: { google: {}, gitHub: {}, email: {...} }
  }
}

route RootRoute { path: "/", to: MainPage }
page MainPage {
  authRequired: true, // Limit access to logged in users.
  component: import Main from "@client/Main.tsx" // Your React code.
}

query getTasks {
  fn: import { getTasks } from "@server/tasks.js", // Your Node.js code.
  entities: [Task] // Automatic cache invalidation.
}

entity Task {=psl ... psl=} // Your Prisma data model.

Getting Started with Wasp

Getting Started with Wasp

Installation

Getting Started with Wasp

Create the project

wasp new TodoApp

Start the server

cd TodoApp; wasp start

Browse to http://localhost:3000

Analysis

Why Wasp?

The Mint Programming Language

... in a nutshell

The Mint Programming Language

What is it?

The Mint Programming Language

Hello world

component Main {
  fun render : Html {
    <button>
      "Click ME!"
    </button>
  }
}

The Mint Programming Language

Counter component

component Counter {
  state counter = 0

  fun increment { next { counter: counter + 1 } }
  fun decrement { next { counter: counter - 1 } }

  fun render {
    <div>
      <button onClick={decrement}>"Decrement"</button>

      <span><{ Number.toString(counter) }></span>

      <button onClick={increment}>"Increment"</button>
    </div>
  }
}

Getting Started with Mint

From 0 to HelloWorld

Getting Started with Mint

Installation

Getting Started with Mint

Generate a new project

Getting Started with Mint

Main (source/Main.mint)

component Main {
  style app {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    display: flex;

    background-color: #282C34;
    height: 100vh;
    width: 100vw;

    font-family: Open Sans;
    font-weight: bold;
  }

  fun render : Html {
    <div::app>
      <Logo/>

      <Info mainPath="source/Main.mint"/>

      <Link href="https://www.mint-lang.com/">
        "Learn Mint"
      </Link>
    </div>
  }
}

Getting Started with Mint

Info (source/Info.mint)

component Info {
  property mainPath : String

  style info {
    font-size: calc(10px + 2vmin);
    color: #939DB0;
  }

  style path {
    font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
    font-style: italic;
    font-weight: 100;
    color: #E06C75;
  }

  fun render : Html {
    <p::info>
      <{ "Edit " }>

      <code::path>
        <{ mainPath }>
      </code>

      <{ " and save to reload." }>
    </p>
  }
}

Getting Started with Mint

Link (source/Link.mint)

component Link {
  property children : Array(Html) = []
  property href : String

  style link {
    font-size: calc(10px + 2vmin);
    text-decoration: none;
    color: #DDDDDD;

    &:hover {
      text-decoration: underline;
    }
  }

  fun render : Html {
    <a::link
      href="#{href}"
      target="_blank">

      <{ children }>

    </a>
  }
}

Getting Started with Mint

Run the dev server

Getting Started with Mint

Hot reload

Getting Started with Mint

Mint UI Library

Analysis

Why Mint?

Summary

What have we learned?

Summary

By the way... there's more!

Summary

By the way... there's more!

Credentials

Who is this guy?