A friendly programming language from the future.

      • @dneaves@lemmy.world
        link
        fedilink
        7
        edit-2
        1 year ago

        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.

        • @abhibeckert@lemmy.world
          link
          fedilink
          -4
          edit-2
          1 year ago

          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)
          
          • @dneaves@lemmy.world
            link
            fedilink
            21 year ago

            Hello world should look something like this: print("Hello, World"!)

            You don’t need the annotation line in Haskell-esque languages, most of the time. Without the annotation, this is Hello World in Haskell:

            main = print "Hello, World!"
            

            And when you need more complexity, it can still be far simpler than Unison (or Haskell)

            import qualified Data.List as List
            import Data.Function ((&))
            
            processNumbers numbers =
                let
                    isEven n = mod n 2 == 0
                in
                numbers
                    & List.filter isEven
                    & List.map (^2)
            
            main =
                processNumbers [1, 2, 3, 4, 5, 6]
                    & print
            
      • xigoi
        link
        11 year ago

        What do you mean by flipped? Parentheses seem to group expressions like in most languages.

      • @hansl@lemmy.world
        link
        fedilink
        11 year ago

        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.

          • @hansl@lemmy.world
            link
            fedilink
            11 year ago

            I’m not sure what you’re asking. Plenty of modern languages use the unit type; typescript, Rust, not sure you consider Haskell a modern language.

            From the look of it, this language seems to use it in a function signature declaration, which would make sense.

    • @hansl@lemmy.world
      link
      fedilink
      81 year ago

      Compiler, give me all the language extensions you have. Wait, wait. I’m worried what you just heard was, “Give me a lot of language extensions.” What I said was, “Give me all the language extensions you have.” Do you understand?

  • @christophski@feddit.uk
    link
    fedilink
    English
    36
    edit-2
    1 year ago

    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

          • @robinm@programming.dev
            link
            fedilink
            11 year ago

            I’m surprised about this statement, I would have said that exceptions are the consequence of an impure operation (that may or may not fail differently every time you call it).

            • I’m currently learning functional languages and have only limited knowledge, but from what I’ve read now you are right. Throwing exceptions is pure, but catching them is impure.

              In this case I guess the printLine function can throw an exception therefore the calling function must be declared with Exception?

              • @robinm@programming.dev
                link
                fedilink
                21 year ago

                I would even have said that both throwing and catching should be pure, just like returning an error value/handling should be pure, but the reason for the throw/returning error itself is impure. Like if you throw and ioerror it’s only after doing the impure io call, and the rest of the error reporting/handling itself can be pure.

                • @Pipoca@lemmy.world
                  link
                  fedilink
                  11 year ago

                  Pure functions should be referentially transparent; you should be able to replace them with whatever value they evaluate to without changing the semantics of your code.

                  Throwing is referentially impure: what value do you get from calling x => throw new RuntimeException()?

                  Instead, functional languages prefer to return a tagged union of the value or the error.

        • @sloppy_diffuser@sh.itjust.works
          link
          fedilink
          English
          11 year ago

          That’s one of the things I appreciate in a language/framework. Drives me nuts getting an exception from a dependency of a dependency of a dependency.

          Even better if its baked into the type system and I can’t run my code without handling it.

        • @Pipoca@lemmy.world
          link
          fedilink
          1
          edit-2
          1 year ago

          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.

  • @DrakeRichards@lemmy.world
    link
    fedilink
    141 year ago

    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.

  • Alex
    link
    fedilink
    131 year ago

    Unison stores code in a database.

    🫣🤨

  • @robinm@programming.dev
    link
    fedilink
    7
    edit-2
    1 year ago

    There take on what they call capabitilites is very interesting. Basically anything that would make a function non-pure seems to be declared explicitely.

    A computational effect or an “effectful” computation is one which relies on or changes elements that are outside of its immediate environment. Some examples of effectful actions that a function might take are:

    • writing to a database
    • throwing an exception
    • making a network call
    • getting a random number
    • altering a global variable
  • @onlinepersona@programming.dev
    link
    fedilink
    English
    6
    edit-2
    1 year ago

    The distributed computing aspect is very interesting, but the documentation is a mess. I applaud trying to use different and understandable terms than Haskell and other functional languages (monad, monoids, functors, applicative functor, etc.), but the examples are too verbose.

    Concerning distributed computing, writing code that seemingly has no boundaries would be a major step forward for web development. Having to split models between client and server, come up with an API that follows some convention, find a solution for client-library generation, and so much more, is tedious, repetitive, and error-prone. Having most of that handled and having blurred boundaries would make writing web applications pleasurable again.

    At the moment, unison looks like an iteration on the right path, but there is a lot of work to do in making it accessible and understandable.

  • @u_tamtam@programming.dev
    link
    fedilink
    51 year ago

    “Capabilities” is the new “Functional Programming” of decades prior,

    Scala is also expanding in this area via the Caprese project: https://docs.scala-lang.org/scala3/reference/experimental/cc.html and it promises Safe Exceptions, Safe Nullability, Safe Asynchronicity in direct style/without the “what color is your function” dilemma, delineation of pure vs impure functions, … even Rust’s borrow checker (and memory guarantees) becomes a special case of Capabilities.

    I believe this is a major paradigm shift, but the ergonomics have yet to be figured out and be battle-tested in the real world. Ultimately, like for Functional Programming Languages (OCaml, F#, Haskell, …) I don’t expect pionniers like Unison/Koka/Scala to ever become mainstream, but the “good parts” to be ported to ever the more complex and clunky “general purpose” programming languages (or, why I love Scala which is multiparadigm and still very thin/clean at its core).

    • Crazazy [hey hi! :D]
      link
      fedilink
      11 year ago

      I think that when it comes to functional programming with effect systems, unison is currently the closest to showing how it is actually done. Koka and languages like Effekt are of course very nice, but they don’t show much going for them besides the example nondeterminism and exception effect. Verse, that language that was going to be used as Fortnite’s scripting language, also plans on adding these effect systems a la Koka.

      Overall, I think one of 2 things will happen:

      • unison will slowly gain more and more adoption and grow out to become a formidable niche language
      • Verse will blow unison out of the water and everyone who once even considered unison will be moving to Verse instead
      • @u_tamtam@programming.dev
        link
        fedilink
        11 year ago

        unison is currently the closest to showing how it is actually done

        What makes you say that? As far as I’m aware, even the theoretical soundness of it isn’t a done deal (this is a harder nut to crack than e.g. rust’s borrow checker)

        Overall, I think one of 2 things will happen:

        In this niche, perhaps, I don’t believe any of those will gain mainstream adoption (though I hope I’m wrong)

    • @sknowmads@dormi.zone
      link
      fedilink
      11 year ago

      It’s not really fair to state that functional languages aren’t battle tested or imply they aren’t useful in real world problem solving, Erlang/Elixir prove that.

      • @u_tamtam@programming.dev
        link
        fedilink
        21 year ago

        functional languages aren’t battle tested or imply they aren’t useful in real world problem solving

        Yup, I never said that, though? What I was about was to draw a parallel between functional programming languages and explorations from several decades ago vs the new languages and explorations going into effect typing/capabilities programming now (and the long way ahead for those).

        What I find interesting is that those pioneering FP languages never came to top the popularity chart, implying that I’m not expecting Unison to be different (but the good parts might make it into Java/C#/Python/… many years from now).

  • @choroalp@programming.dev
    link
    fedilink
    3
    edit-2
    1 year ago

    I tried to get into this language about 6 months ago and lets just say it was pure pain. Trying to make anything simple for learning was just a mess. Nearly no support from editors(Apart from VSCode but that does not count). And Documentation was overwhelming. It may be useful in some cases but due to its sheer complexity(I did not even managed to create a simple calculator) i dont think it would a big language.

    Edit: typos

  • @tatterdemalion@programming.dev
    link
    fedilink
    2
    edit-2
    1 year ago

    Some of the solutions it claims to provide would be genuinely great. I can’t tell if it delivers. It definitely looks pre-alpha stage. I really hope it’s not locked-in to their cloud platform.

  • Matej
    link
    fedilink
    English
    21 year ago

    Looks intriguing, reading a bit … some concepts look like they came from Nix