A friendly programming language from the future.
helloWorld : '{IO, Exception} ()
helloWorld _ = printLine "Hello World"
I wouldn’t call it friendly.
Although, i would agree with it not necessarily being “friendly”, since its a drastically different syntax than many beginners would be used to, the brackets and parenthesis here are not what you think they are.
Unison is a language in the style of Haskell, F#, Purescript, Elm, etc. So that first line is actually type annotations.
In Haskell, this would just be helloWorld :: IO ()
, meaning a function named “helloWorld” with no arguments and produces what is essentally a potentially-unsafe IO action with a Void return (the empty parenthesis () ).
Here in Unison they call the bracket part “abilities” or something. Its saying the same thing as Haskell, but being more explicit in saying it can raise an exception.
Yeah sorry - that’s just unnecessarily obtuse. Programming languages just don’t need to be that convoluted. Hello world should look something like this:
print("Hello, World!")
And when you need more complexity, it can still be far simpler than Unison (or Haskel). For example this (in Swift):
func processNumbers(_ numbers: [Int]) -> [Int] {
return numbers.filter { $0 % 2 == 0 }.map { $0 * $0 }
}
let numbers = [1, 2, 3, 4, 5, 6]
let processedNumbers = processNumbers(numbers)
print(processedNumbers)
It’s not parenthesis (in the PEMDAS sense), it’s the unit type and it’s normally expressed like that. If you’re not familiar with type systems, it’s the typing equivalent of void
.
Oh, it’s weird ugly Haskell!
… I can write weird, ugly Haskell in Haskell, though.
Literally the opposite of friendly. Already in the hello world you have two imports for extremely basic functionality (why should I have to import the ability to throw exceptions??) and a completely enigmatic symbol ’ that apparently has a significant function.
A “friendly” programming language should be readable without knowing esoteric symbols.
Really got my hopes up with that headline that it’d be a python-level intuitive-to-read language with static typing.
Yes, in functional programming you want to use pure functions. Exceptions are impure, therefore it has to be declared.
Other functional languages don’t even have exceptions
Functional languages typically have type inference, so the type signatures are entirely optional. I haven’t looked that deeply at unison, but I’d be entirely unsurprised if it had global type inference and if all or most type signatures were optimal.
It’s less that you have to declare something can do IO or throw an exception, and more that you’re calling something from the standard library that does IO or throws an exception.
Most stuff does neither. There’s a type level distinction between normal, regular pure code, and impure effectful code, so it’s easy to tell from the type signature whether a function is pure or not.
This looks like the opposite of friendly to me. Is it supposed to be targeted towards cloud computing or web apps? I don’t really understand what its ideal use case is.
V disappointed upon realizing this is not, as I initially read, satirically-typed