A Guide to Next-Generation Languages for Busy Developers

busy developer s guide to next generation n.w
1 / 86
Embed
Share

Explore the world of next-generation languages, their importance, and a list of noteworthy languages including Julia, Crystal, Jolie, Pony, Wing, and Wasp. Dive into the features and capabilities of the Julia Programming Language, a dynamic and high-performance language revolutionizing development practices.

  • Next-Gen Languages
  • Developer Guide
  • Julia
  • Crystal
  • Programming

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Busy Developer's Guide to Next-Generation Languages

  2. Objectives In this presentation, we're going to explore a few languages discuss why they're "next-generation" do some speculation and futurism

  3. Objectives WHY?!? ... because all our mainstream languages are old ... because productivity gains with elevated abstractions ... because functional programming couldn't get out of its own way

  4. Objectives Our list Julia: dynamically-typed high-performance general-pupose Crystal: statically-typed Ruby-esque general- purpose Jolie: service-oriented Pony: type-safe, memory-safe, exception-safe, concurrent Wing: cloud-oriented Wasp: full-stack web app

  5. Objectives NOTE This is a "survey talk" we want to cover a bunch of languages in less than an hour hello, here it is, goodbye very happy to discuss any of these afterwards The point here is "to know what you don't know" ... and give you some signposts for exploring ... and maybe give a talk at a future conference!

  6. ... in a nutshell THE JULIA PROGRAMMING LANGUAGE

  7. The Julia Programming Language What is it? https://julialang.org/ compiled (via LLVM) complex and rational numbers object-oriented and functional via multiple dispatch dynamically-typed parallel, async, multithreaded processing implicit distribution capabilities metaprogramming (code is data is code)

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

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

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

  11. From 0 to Hello World GETTING STARTED WITH JULIA

  12. Getting Started with Julia Installation Homebrew (macOS, Linux): brew install julia Chocolatey (Windows): choco install julia Downloads: https://julialang.org/downloads/ Build from source: https://github.com/JuliaLang/julia

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

  14. Getting Started with Julia Some interesting CLI switches --project=dir: Set dir as the home project/environment -p/--procs: Launches N additional local worker processes --machine-filefile: Run processes on hosts listed in file

  15. Analysis Why Julia? type-inferencing helps keep syntax clean metaprogramming (code as data) strong math/science features/ecosystem performance of native (LLVM) interoperability across other LLVM-based platforms (GraalVM, etc) clear embedding API--viable scripting engine

  16. ... in a nutshell THE CRYSTAL PROGRAMMING LANGUAGE

  17. The Crystal Programming Language What is this? https://crystal-lang.org/ web playground: https://play.crystal- lang.org/#/cr native compilation (via LLVM) heavily Ruby-inspired syntax statically type-checked, type-inferenced non-nillable types (compile-time nil checks) macro metaprogramming system

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

  19. From 0 to HelloWorld GETTING STARTED WITH CRYSTAL

  20. Getting Started with Crystal Installation https://crystal-lang.org/install/ Online playground: https://play.crystal- lang.org/#/cr Download: https://crystal- lang.org/install/from_targz Package managers: Homebrew/Linuxbrew: brew install crystal-lang Ubuntu: curl -fsSL https://crystal-

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

  22. Analysis Why Crystal? Ruby syntax static types compiled performance

  23. What is this thing? JOLIE: AN OVERVIEW

  24. Jolie: An Overview In Brief a service-oriented programming language "it is designed to reason effectively about the key questions of (micro)service development, including the following: What are the APIs exposed by services? How can these APIs be accessed? How are APIs implemented in terms of concurrency, communication, and computation? built on top of the JVM

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

  26. What were they thinking? JOLIE: PRINCIPLES

  27. Jolie: Principles Jolie encourages/enforces key principles Contract-driven development, defined by formal APIs Structural typing instead of nominative typing Components are services Decouple access points from business logic Abstract data manipulation

  28. Jolie: Principles Contract-driven development defined by formal APIs service APIs should be defined in a formal language technology agnostic unambiguous machine readable based on well-known abstractions. ironically, WSDL wasn't wrong--just bad

  29. Jolie: Principles Structural typing instead of nominative typing since, really, the contents (structure) are what's transferred ... and any nominative information is lost

  30. Jolie: Principles Components are services service are independently executable software artifacts services should be clearly identifiable in source code scope of their definition should be clearly demarcated and delimited

  31. Jolie: Principles Decouple access points from business logic any given logic can/should be accessed via multiple media therefore coupling logic to access is an antipattern

  32. Jolie: Principles Abstract data manipulation implementation of business logic should be abstract from how data is represented on the wire

  33. ... with Jolie GETTING STARTED

  34. Getting Started Installation Jolie requires Java 11+ to run Download the Jolie installer https://www.jolie-lang.org/downloads.html currently https://github.com/jolie/jolie/releases/download/ v1.11.0/jolie-1.11.0.jar Run the installer java -jar jolie-1.11.0.jar

  35. Getting Started Installation Linux/macOS/WSL Homebrew brew install jolie Docker docker pull jolielang/jolie docker run -it -v /host:/container name CONTAINERNAME jolielang/jolie edit files in your /host, which will appear in /container

  36. Getting Started Installation Or build from source git clone https://github.com/jolie/jolie.git cd jolie mvn install binaries will be in dist folder Then (optionally) set up Jolie for the local user scripts/dev-setup.sh ~/bin

  37. Getting Started Verify Run Jolie: jolie --version currently returns Jolie 1.11.2 (C) 2006-2022 the Jolie developers

  38. Getting Started Hello World from your favorite editor, create hello.ol run the file with jolie hello.ol connect to the service: http://localhost:9000/hello?name=Fred

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

  40. Analysis Why Jolie? services as a first-class concept JVM underpining makes for easy integration built-in data types beyond typical primitives structural typing makes more sense for services

  41. ... in a nutshell THE PONY PROGRAMMING LANGUAGE

  42. The Pony Programming Language What is this thing? https://www.ponylang.io/ statically-typed, object-oriented actor-model capabilities-secure type-safe memeory-safe exception-safe data-race free deadlock-free

  43. The Pony Programming Language Other notes Pony Philosophy: "Get Stuff Done" No loadable code; everything is known to the compiler type system guarantees If your program compiles, it won't crash. There will never be an unhandled exception. There's no such thing as null. There will never be a data race. Your program will never deadlock.

  44. The Pony Programming Language Producer-Consumer a classic concurrency problem Producer: generate data (at max speed) Consumer: consume data (at max speed) producer cannot outstrip consumer (lost data) consumer cannot outstrip producer (duped data)

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

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

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

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

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

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

Related


More Related Content