Busy Developer's Guide to Next-Generation Languages

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."

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

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
		}
	}
}

Analysis

Why Jolie?

The Pony Programming Language

... in a nutshell

The Pony Programming Language

What is this thing?

The Pony Programming Language

Other notes

The Pony Programming Language

Producer-Consumer

The Pony Programming Language

Main

actor Main
  """
  Producer-Consumer concurrency problem.

  Pony has no blocking operations.
  The Pony standard library is structured in this way to use notifier objects,
  callbacks and promises to make programming in this style easier.
  """

  new create(env: Env) =>
    let buffer = Buffer(20, env.out)

    let producer = Producer(2, buffer, env.out)
    let consumer = Consumer(3, buffer, env.out)

    consumer.start_consuming()
    producer.start_producing()

    env.out.print("**Main** Finished.")

The Pony Programming Language

Producer

use "collections"

actor Producer
  var _quantity_to_produce: U32
  let _buffer: Buffer
  var _num: U32 = 0
  let _out: OutStream

  new create(quantity_to_produce: U32, buffer: Buffer, out: OutStream) =>
    _quantity_to_produce = quantity_to_produce
    _buffer = buffer
    _out = out

  be start_producing(count: U32 = 0) =>
    _buffer.permission_to_produce(this)
    if count < _quantity_to_produce then start_producing(count + 1) end

  be produce() =>
    _out.print("**Producer** Producing product " + _num.string())
    let prod: Product = Product(_num, "Description of product " + _num.string())
    _buffer.store_product(prod)
    _num = _num + 1

The Pony Programming Language

Consumer

use "collections"

actor Consumer
  var _quantity_to_consume: U32
  let _buffer: Buffer
  let _out: OutStream

  new create(quantity_to_consume: U32, buffer: Buffer, out: OutStream) =>
    _quantity_to_consume = quantity_to_consume
    _buffer = buffer
    _out = out

  be start_consuming(count: U32 = 0) =>
    _buffer.permission_to_consume(this)
    if count < _quantity_to_consume then start_consuming(count + 1) end

  be consuming(product: Product) =>
    _out.print("**Consumer** Consuming product " + product.id.string())
    _quantity_to_consume = _quantity_to_consume -1

The Pony Programming Language

Buffer

actor Buffer
  let capacity: USize
  var _products: Array[Product]
  var _future_products: USize = 0
  var _producers_waiting: Array[Producer] = Array[Producer]
  var _consumers_waiting: Array[Consumer] = Array[Consumer]
  let _out: OutStream
    
  new create(capacity': USize, out: OutStream) =>
    capacity = capacity'
    _products = Array[Product](capacity)
    _out = out

The Pony Programming Language

Buffer

  be permission_to_consume(cons: Consumer) =>
    let debug_string = "**Buffer** Permission_to_consume"
    _out.print(debug_string)
    try
      _out.print(debug_string + ": Calling consumer to consume")
      cons.consuming(_products.delete(0)?) // Fails if products is empty.
      try
        _out.print(debug_string + ": Calling producer to produce")
        _producers_waiting.delete(0)?.produce()
      end  // If there are no producers in waiting, do nothing.
    else
      _out.print(debug_string + ": Storing consumer in waiting")
      _consumers_waiting.push(cons)
    end
    
  be permission_to_produce(prod: Producer) =>
    let debug_string = "**Buffer** Permission_to_produce"
    _out.print(debug_string)
    if (_products.size() + _future_products) < capacity then
      _future_products = _future_products + 1
      _out.print(debug_string + ": Calling producer to produce")
      prod.produce()
    else
      _producers_waiting.push(prod)
      _out.print(debug_string + ": Storing producer in waiting")
    end

The Pony Programming Language

Buffer

  be store_product(product: Product) =>
    let debug_string = "**Buffer** Store_product"
    _out.print(debug_string)
    _future_products = _future_products - 1
    try
      _out.print(debug_string + ": Calling consumer to consume")
      _consumers_waiting.delete(0)?.consuming(product)
    else
      _out.print(debug_string + ": Storing product")
      _products.push(product)
    end

Getting Started with Pony

From 0 to HelloWorld

Getting Started with Pony

Installation

Getting Started with Pony

Hello World: helloworld/main.pony

actor Main
  new create(env: Env) =>
    env.out.print("Hello, world!")

Compile the code

cd helloworld; ponyc

Directory name is the name of the program

./helloworld

Analysis

Why Pony?

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?