7 ms·
Flix – Safe, reliable, concise, and functional-first programming language
- adultSwim 4y agoSo great to see a language with ML heritage. Really nice feature set. Plus I really like the code example right there on the front page.
- jitl 4y agoThe Datalog support is a very interesting feature for such a fully-featured language. From the home page: def reachable(g: List[(String, Int32, String)], minSpeed: Int32): List[(String, String)] = let facts = project g into Road; let rules = #{ Path(x, y) :- Road(x, maxSpeed, y), if maxSpeed >= minSpeed. Path(x, z) :- Path(x, y), Road(y, maxSpeed, z), if maxSpeed >= minSpeed. }; query facts, rules select (src, dst) from Path(src, dst) |> Foldable.toList Composing datalog natively like any other type – very cool.
- all2 4y ago> Composing datalog natively I'm naive. What does this mean and why is it important?
- pharmakom 4y agoJust look at any template heavy c++ library.
- Blackthorn 4y agoThat really doesn't answer the question. (I'm not sure what it really means either, it's a good question.)
- deleted 4y ago[deleted]
- jorkadeen 4y agoDatalog programs are values. You can store them in local variables, pass them as arguments, and return them. If you have two Datalog values you can combine them into one (effectively it's just the union of them). This allows you to write small "Datalog fragments" and stitch them together into a larger program. The type system ensures that this stays meaningful. (I am one of the authors of Flix.)
- machiaweliczny 4y agoIn short you work with tree (AST) and can compose instead of stiching strings (builder pattern) Good thing of having common AST in language is libs interoperability. It’s like normal lanugages had SQL support built-in (except you can’t do that easily as SQL is order dependent)
- jitl 4y agoDatalog is a logic programming language for relational data. It is much easier to express recursive relationships in Datalog compared to SQL. The most obvious application of Datalog is for working with graphs. The starter example I've usually seen is "graph reachability", which something like "given a list of edges between nodes, tell me if I can reach node X from node Y". // Given an edge x -> y, there is a path x -> y. path(x, y) :- edge(x, y). // Given an edge x -> z and a path z -> y, there is a path x -> y. path(x, y) :- edge(x, y: z), path(x: z, y). Here is the equivalent recursive SQL (SQLite syntax): WITH RECURSIVE path(x, y) AS ( SELECT edge.x AS x, edge.y AS y FROM edge UNION SELECT edge.x AS x, path.y AS y FROM edge, path WHERE edge.y = path.x ) SELECT DISTINCT * FROM path If you want to play with Datalog, https://percival.ink https://percival.ink is an online notebook with a very gentle introduction. I also published a version of percival.ink that converts simple Datalog queries to recursive SQLite queries here: https://percival.jake.tl https://percival.jake.tl (the example above is from percival.jake.tl). As jorkadeen said in their answer (I added emphasis to the last sentence): > Datalog programs are values. You can store them in local variables, pass them as arguments, and return them. If you have two Datalog values you can combine them into one (effectively it's just the union of them). This allows you to write small "Datalog fragments" and stitch them together into a larger program. The type system ensures that this stays meaningful. Why this is important: From my perspective is that a very large percent of industrial code interacts with data (in databases) by building query strings. In most languages, we throw away all the nice features of the language when it comes to data access. To regain some level of composability and safety, developers pour years into libraries like [Arel in Ruby](https://www.rubydoc.info/gems/arel https://www.rubydoc.info/gems/arel) or [Calcite in Java](https://calcite.apache.org/docs/algebra.html https://calcite.apache.org/docs/algebra.html). The most notable example of language native database access is [Language Integrated Query (LINQ)](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/ https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...) in C#. But all of these tools are hampered by the constraints of SQL. SQL is very good for flat, normalized data with one or two joins. Once you begin working with trees or graphs, tools based around SQL become cumbersome. Using datalog instead of SQL means you have a logical langauge that is inherently more accepting of composition in a theoretical way. But, most systems that speak datalog today are extremely specialized. [Souffle](https://souffle-lang.github.io/simple https://souffle-lang.github.io/simple) and [differential-datalog](https://github.com/vmware/differential-datalog https://github.com/vmware/differential-datalog) are useful ahead-of-time compilers for datalog, but you have to design your whole program around using them. The datalog variant [inside Datomic](https://docs.datomic.com/on-prem/query/query.html https://docs.datomic.com/on-prem/query/query.html) is dynamic, but is only usable for accessing data in a data store. Good luck using it for analysis of data in memory. Including datalog into the language as first-class values mean that you can access the power of datalog and actually compose it in practice. [Note: I've never used Flix – just a datalog fan.]
- hulitu 4y ago> Flix – Safe, Reliable, Concise, and Functional-First Programming Language "Ensure that you have at least Java 11 installed. " How about a compiler or an interpreter ? "Download the latest version of the Flix compiler (flix.jar) at https://github.com/flix/flix/releases/latest https://github.com/flix/flix/releases/latest. Create an empty folder (e.g. mkdir flixproject) and place the downloaded Flix JAR (flix.jar) into that folder. Enter the created directory (e.g. cd flixproject) and run java -jar flix.jar init to create an empty Flix project. Run java -jar flix.jar run to compile and run the project. Flix will compile the project and execute the main function (located in src/Main.flix). " So getting started is about running an empty project file ? How about some code examples ? I wanted to see what is a "Safe, Reliable, Concise, and Functional-First Programming Language". And all i get is an empty project ? After reading some docs it looks like a lisp without parantheses and one has to have a good understanding of lambda functions to be able to read the documentation.
- jorkadeen 4y agoBe sure to check out https://flix.dev/ https://flix.dev/ and https://github.com/flix/flix/tree/master/examples https://github.com/flix/flix/tree/master/examples for more examples. (I am one of the authors of Flix.)
- Smaug123 4y agoScroll down! The homepage shows examples of ADTs, purity tracking (yay!) and pattern matching on purity (oooooh), effect polymorphism (oooooh again), type classes, HKTs, and an embedded Datalog DSL.
- all2 4y agoI rather liked Nim's one line install of a binary. Starting and running a project is as simple as "nim c -r <file_name>.nim". I appreciate languages/toolkits that are concise in their tooling. Golang is another language like this. The tooling is simple (though Golang is more opinionated than Nim in things like testing and project layouts) and easy to reason about.
- gunshowmo 4y agoThis is an extremely strong set of features in one language. All the best in this project!
- the_duke 4y agoSadly the effects system seems to be just "pure vs impure" tracking per function. No arbitrary effects or custom handlers. Is that accurate?I was hoping for something more like Koka. Otherwise that is a very intriguing combination of features, especially first class Datalog constraints. Any plans for additional backends? (native, Webassembly)?
- kldx 4y agoIs this what I think it is? Ref. _What color is your function_
- jorkadeen 4y agoThe color of your function can be "effect polymorphic". In other words, e.g. List.map works with both pure and impure functions. You don't have to write two versions of List.map.
- nwmcsween 4y agoNo, effect systems aren't a different function type, in fact you could mitigate the whole function color mess in $lang with an effect system.
- kldx 4y agoAny resources to learn effects for a novice in Haskell?
- jorkadeen 4y agoAt the moment the effect system only distinguishes between pure and impure (and effect polymorphic) expressions, but we are working towards a richer system. For example, we will soon be able to express something like: def swap!(a: Array[a, r], i: Int32, j: Int32): Unit \ { Read(r), Write(r) } We are aware of algebraic effects and handlers, but let's just say that we prefer to underpromise and overdeliver. (I am one of the authors of Flix.)
- 4y ago
- lucas_membrane 4y agoMany languages running on JVM boast of an FFI allowing use of much existing code already written in Java. Is such, or will such be, possible in Flix? What is the overall status of the implementation, particularly for real world applications (features like talking to a network, file systems, databases and operating system, and/or FFIs for JVM or non-JVM languages)?
- mjs2600 4y agoI found this[1] section in the documentation on interoperability within the JVM. It looks fairly straightforward to work with. I'm not sure about FFI more generally. [1] https://doc.flix.dev/interoperability/ https://doc.flix.dev/interoperability/
- dang 4y agoRelated: In Defense of Programming Languages - https://news.ycombinator.com/item?id=27799063 https://news.ycombinator.com/item?id=27799063 - July 2021 (1 comment) Flix – Next-generation reliable, concise, functional-first programming language - https://news.ycombinator.com/item?id=25513397 https://news.ycombinator.com/item?id=25513397 - Dec 2020 (84 comments) The Flix Programming Language - https://news.ycombinator.com/item?id=19928153 https://news.ycombinator.com/item?id=19928153 - May 2019 (2 comments)
- mindcrime 4y agoWow, this looks pretty exciting. Like @jitl said, the idea of built-in Datalog support sounds really interesting. I don't know how I missed the earlier announcements of this, but now that I found it I'm definitely going to give it a spin.
- zinclozenge 4y agoI've had my eye on flix for a while. I really like the feature set.
- LesZedCB 4y agowow this is a really pretty language, nice work to the authors. definitely will be giving it a shot
- james-redwood 4y ago> Flix looks quite similar to Scala. How are the two languages related? > Flix borrows a lot of syntax from Scala, hence the two languages have a similar feel. We think Scala made many good design choices with respect to syntax, including: (a) the use of short keywords, (b) the x : T syntax for type annotations, (c) the List[Int32] syntax for type parameters, and (d) if, match, etc. as expressions. > Other than syntax, the two languages are very different: Scala is object-oriented, Flix is not. Scala has sub-typing, Flix does not. The Scala type system is unsound and has imperfect type inference, whereas the Flix type system is both sound and supports type inference. https://flix.dev/faq/ https://flix.dev/faq/
- rco8786 4y agoLooks interesting, will definitely dig into. Right off the bat though, I see 3 different syntaxes for typing? > case Rectangle(Int32, Int32) > def origin(): (Int32, Int32) = > def twoByFour(): {w :: Int32, h :: Int32} = case Rectangle: (Int32, Int32) def origin(): (Int32, Int32) def twoByFour(): (w: Int32, h: Int32) ?
- djur 4y agoThe first one is part of the syntax for defining a sum type, the second is a function returning a tuple, and the third is a function returning a record.
- rco8786 4y agoI get that I just don’t understand why they chose to make them all so different.
- deleted 4y ago[deleted]
- michaelcampbell 4y agoAre you asking why different things look different?
- rco8786 4y agoCome on. I’m asking why they chose such different syntaxes for type annotations when it would not have been terribly challenging to keep them consistent. I even gave examples. Parens vs curly braces. Single : vs double ::.
- djur 4y agoThe first example isn't a type annotation, it's a type definition. The curly braces are consistent with the literal syntax for records. I agree that the use of double colons in record types seems inconsistent. I assume it resolves some ambiguity.
- codeptualize 4y agoLove the FAQ page!
- sitkack 4y agoThis looks amazing! Can’t wait to try this with Graal
- deleted 4y ago[deleted]
- adultSwim 4y agoSo great to see a language with ML heritage. Really nice feature set.