The question everybody asks is always the same:
... which is usually just a mask for the real question:
We stand on the threshold of a Renaissance in programming languages
Meaning the next N years will be all about:
defining/exploring new concepts within them...
building them...
using them...
maybe even making money with them!
Programming language design has historically been split into two camps:
Practitioners
Academics
... want to figure out new ways of doing stuff
more efficiently
more succinctly
or doing entirely new stuff we couldn't do before!
... want to get stuff done
quickly (on time)
cheaply (under budget)
correctly
with minimal surprise
For the most part, these two groups have been uninterested in working together
In fact, they've been downright hostile towards one another
... don't get languages done enough to be useful
they lack good integration possibilities
they lack decent "commodity" features (such as GC)
... because getting those details right is hard
and has nothing to do with language design
which, remember, is the Academics' entire goal
don't get exposed
Practitioners never discover the concepts that might be useful
don't get used
Practitioners never learn how to use the new concept or tool
don't get discussed
Practitioners can't gather/provide feedback on the concept or language
which, in turn, has often left languages solely to the Academics
and if Practitioners ever think about languages, it's to
talk about new features in their current language
or argue about whose mainstream language is best
Virtualization
Language Tools
Linguistic Focus
Services/microservices
Virtualization helps programmers
abstractions mean developers don't need physical details
so these "low-level" details can be safely ignored
or "trap doors" exist to allow dropping to a lower level
... allowing programmers to focus on the problem
The same is true for language designers
Good tools are necessary for any successful endeavor
IDEs
analyzers/linters
debuggers
profilers
Same is true for language designers
parser generators
AST generators
grammar debuggers
optimizing backends
With the desire to create "no-dependencies" deployments...
... using a language-agnostic network interface (HTTP/JSON)...
... suddenly nobody cares what you write code in
This allowed several languages to challenge Java/.NET in the enterprise
... and increased the encapsulation barrier to callers
Each language seeks to conceptualize certain constructs directly within the language
Niklaus Wirth called this a "separation of concerns"
Procedural languages contained some new ideas
single entry point
well-defined parameters and return values
Object languages contain some new ideas
union of state and data (object)
relationships between types (inheritance)
encapsulation of details (access control)
Functional languages contain some new ideas
Type inference
"pure" functions, higher-order functions
partial application of functions and currying
sequential and monadic comprehensions
Nine ideas unique to Lisp:
Conditionals
recursion
dynamic typing
functions-as-types
garbage collection
programs as expressions
a symbol type
a notation for code using trees of symbols and constants (AST)
dynamic evaluation of code
Consider the Haskell concept of a list
let numbers = [ 1, 2, 3 ]
We can do a few things with a list
let headOfList = head numbers print headOfList {- 1 -} let lastNumber = last numbers print lastNumber {- 3 -} let tailOfList = tail numbers print tailOfList {- [2, 3] -} let takeSomeOfList = take 2 numbers print takeSomeOfList {- [1, 2] -}
We can create a list out of a range of values
let numberRange = [1..100] print numberRange {- [1, 2, 3, ... , 99, 100] -} let evens = [2, 4..100] print evens {- [2, 4, 6, ... , 98, 100] -}
We can create a list out of code
let otherEvens = [x | x <- [1..10]] print otherEvens let squares = [x*x | x <- [1..10]] print squares let fizzBuzz = [ if x `mod` 5 == 0 then "BUZZFIZZ" else if x `mod` 3 == 0 then "BUZZ" else if x `mod` 4 == 0 then "FIZZ" else show x | x <- [1..25]] print fizzBuzz
We can even create an infinite list
let forever = [1..] {- printing forever is a bad idea.... -} let foreverLove = cycle ["LOVE"] print $ take 3 foreverLove {- ["LOVE", "LOVE", "LOVE"] -}
What a silly idea... Infinite lists
I mean, who ever would have a collection that goes on forever?
What kind of list goes on forever?
Haskell calls these infinite lists "streams", by the way
What if we had a Java Iterator... without a Collection?
An "evens" for-comprehension, in Java
class EvensToAHundredComprehensionIterator implements Iterable<Integer> { public Iterator<Integer> iterator() { return new Iterator<Integer>() { int count = 0; public boolean hasNext() { return count <= 100; } public Integer next() { if (count % 2 == 0) return count++; else { count++; return next(); } } public void remove() { } }; } }
Using it in Java
for (int val : new EvensToAHundredComprehensionIterator()) { System.out.print(val + ".."); } System.out.println();
How about an Iterator that knows how to read a file?
class FileIterator implements Iterable<String> { BufferedReader br; private FileIterator(BufferedReader br) { this.br = br; } public static FileIterator open(String filename) throws IOException { FileReader fr = new FileReader(filename); BufferedReader br = new BufferedReader(fr); return new FileIterator(br); }
How about an Iterator that knows how to read a file?
public Iterator<String> iterator() { Iterator<String> ret = new Iterator<String>() { String line = null; public boolean hasNext() { return line != null; } public String next() { String result = line; try { line = br.readLine(); } catch (IOException ioEx) { line = null; } return result; } public void remove() { } }; ret.next(); return ret; } }
How about an Iterator that knows how to read a file?
for (String line : FileIterator.open("./ItWithoutColl.java")) { System.out.println("FOUND>>> " + line); }
Gong down this path leads you to a number of interesting things... some of which were captured in Guava
Iterables
Iterators
... and some of which were captured in Java8
java.util.stream.*
first-class functions ("lambdas"/function literals syntax)
But think about infinite streams again for a second
But think about infinite streams again for a second
... what if we think about external events as streams?
user input
push notifications from the server
timer events
... and our responses to those events as functions?
in other words, putting some code around "take"ing one incoming atom at a time, processing it, and moving on to the next (if it's available)
Congratulations
Congratulations
... for you have just taken your first steps to understanding
Functional programming
Functional reactive programming
Reactive architectures
Redux
... and a few more things
The problems we face are very different from a few years ago
concurrency and the end of the "free lunch"
"pure" object model drawbacks
application security
per-object security
distribution models
"user enablement"
user interface expression
... and a whole bunch more we haven't thought of yet
And the industry has already started to respond!
Jolie, Ballerina
Wing
Wasp
Inform7
... and a whole bunch more
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
"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."
Hello Jolie
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 } } }
https://www.winglang.io/
combines infrastructure and runtime code
cloud services as first-class citizens
local simulation (of cloud services)
deploy to any cloud
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); });
https://ganelson.github.io/inform-website/
Currently in it's 7th revision (Inform7)
"... a programming language for creating interactive fiction, using natural language syntax. Using natural language and drawing on ideas from linguistics and from literate programming, Inform is widely used as a medium for literary writing, as a prototyping tool in the games industry, and in education, both at school and university level (where Inform is often assigned material for courses on digital narrative)."
Example Inform7 code
Before taking the crate: if the player is wearing the hat: now the hat is in the crate; say "As you stoop down, your hat falls into the crate.“
the source for Inform7 is, itself, a story
this is "literate programming"
https://ganelson.github.io/inform/ and click away!
It's easier than ever to design your own
ANTLR (parser generator) generates C#/Java/Python/C++ parsers and ASTs
Several packages provide JVM or CLR bytecode generation
LLVM is a back-end compiler toolchain (Swift, Crystal, Rust, more)
and lots of other languages are open-source, for reference and instruction
You can build a toy language in a week; a substantive one, in months
Or take an existing language and mod it
formal fork of the language (easier if it's OSS, of course)
"internal" DSL
Consider... Scala
select ( "age" is smallint, "name" is clob, "salary" is int ) from ("persons" naturalJoin "employees") where ( "gender" == "M" and ("city" == "Seattle" or "city" == "Geneva")) orderBy "age"
Or... Javascript + XML (e4x)
// Use an XML literal to create an XML object var order = <order> <customer> <firstname>John</firstname> <lastname>Doe</lastname> </customer> <item> <description>Big Screen Television</description> <price>1299.99</price> <quantity>1</quantity> </item> </order> // Construct the full customer name var name = order.customer.firstname + " " + order.customer.lastname; // Calculate the total price var total = order.item.price * order.item.quantity;
Academics don't have a great record w/languages
Of course, Practitioners don't always, either....
"... but my boss won't let me!"
"... but my team won't let me!"
"... but what if I'm wrong?"
some bosses are just unshakeable
either go above them
or around them
or find a new boss
most bosses are willing to listen; make your case about them
benefits to the team
means by which you mitigate the costs
make sure there's a support structure in place
for some, demonstrate the utility after the fact
consider your team composition; will this benefit some but not others?
show them, don't tell them
create some examples
look to solve small problems quickly
get them involved in the process/R&D
Do your homework
Try to anticipate the problems
Be ready to be wrong about some parts
Remember: "Faint heart never won fair lady"
Look to language enhancements; where'd they come from?
Look to new languages coming out
what do they do
how do they do it
why'd they choose to do it that way
Explore creating your own new languages
start by reinventing the wheel
maybe build an "esoteric" language, just for fun
then turn your imagination loose a little