6 ms·
The Flix Programming Language
- Asraelite 3y ago> Unused definitions, type declarations, etc. are compile-time errors. This is disappointing. One my main grievances with Go is that it's very difficult to prototype code because it won't compile with unused variables. It massively slows down development. It annoyed me so much that I eventually forked the Go compiler and made a version where unused variables are only a warning.
- adultSwim 3y agoBeen keeping an eye on Flix. Looks like wonderful language. Wish I could use it at work.
- fithisux 3y agoSounds exteremely amazing
- linter 3y agoGreat, But \ is ugly
- subarctic 3y agoThat's just what I was thinking too haha. Honestly I really like the rest of the syntax though. (And of course, the type system features look neat but it's easier to have an opinion on syntax.)
- nikolay 3y agoAnd so are forA and forM!
- imoverclocked 3y agoYour username matches your comment! Also, I agree but I'm not sure what I would propose as a better token. Maybe another colon? def printAndInc(x: Int32): Int32 \ IO = becomes: def printAndInc(x: Int32): Int32 : IO = Or maybe, since functions need something after the \, even for pure functions, we just drop the \ and use the last argument? def printAndInc(x: Int32): Int32 IO =
- Too 3y agoWhy not something human readable? pure vs mut? Other languages already have readable keywords in the function definition; extends, raises, where, having, Optional, and so on. They don’t feel unnecessarily verbose.
- nrabulinski 3y agoBecause they’re working on algebraic effects so obviously IO won’t be the only effect out there. Also because “mut” is even more misleading as it doesn’t capture everything an “IO function” can do, in comparison to a pure function.
- Too 3y ago”mutates IO”? Anything is better than /{}. I don’t know, maybe one gets accustomed to it after a while? It would be rather verbose to write “returns Foo” everywhere. I’m just looking at this with fresh eyes and this aspect of the language is a token-soup. Other parts look neat though.
- ashton314 3y agoWoah, the effect system looks really neat at first glance. Also, “region-based local mutation” so your pure functions can use mutation under the hood for performance? Sweet!
- qsort 3y agoI'd like to see an experimental language that leans hard into the concept of controlled mutation. I always say that purely in terms of design my ideal language is high-level Haskell, low-level C. Conceptually, purely functional design is how programming "should" (note the quotes) be, but doing so down to the level of functions is both not very practical (some algorithms are just easier to express in terms pointers moving around rather than folds, reduces and the like), and makes it hard to reason about performance (especially memory, and most especially if you throw laziness in the mix). But then again, I write my own stuff in python because I'm a lazy fuck, so probably it's not meant to be :(
- jcparkyn 3y agoAnother alternative to this that seems quite promising is mutable value semantics (e.g. https://research.google/pubs/pub51426/ https://research.google/pubs/pub51426/).
- Hemospectrum 3y ago> I always say that purely in terms of design my ideal language is high-level Haskell, low-level C. That's similar to what I used to say. I was devastated to see the BitC project implode, but then Rust appeared and took up the mantle. It's not perfect by any means but it's influential enough to drag the whole field of PL development kicking and screaming in that general direction.
- qsort 3y agoI agree in re Rust. In spite of all the retarded monkeys in its fanbase, I always thought it was an interesting project. Popular languages today are much more similar than they used to be, they are basically "converging", Rust's willingness to try something new must be applauded. Still many pain points, still a bit of a "puzzle language", too much of a scatterbrain approach in the governance and design direction, but even if it had no other influence than to force people to think about the problems of low-level programming, that would be still a massive plus in my book.
- andrewstuart 3y agoI'm disappointed this is not from Netflix.
- globalnode 3y agodo functional languages mainly appeal to computer language enthusiasts/researchers? im just not seeing the benefit personally.
- michaelsbradley 3y agoDo you worry about side-effects that leak beyond the scope of the routines you're authoring? Why / why not?
- globalnode 3y agoi do, does functional programming make this a non issue? maybe im just not smart enough to wrap my head around it.
- andrewflnr 3y agoGenerally, yes. Some languages are really hardcore about it (notably Haskell), while others just strongly encourage you to write functions without side effects. Ed: that's the "purity" they're talking about in OP. The other major neat thing about functional languages is how they let you treat functions like objects, but most modern programming languages have adopted that as well, so it's not a big differentiator anymore.
- imoverclocked 3y agoFunctional languages that require calling out side-effects (eg: "\ IO" in Flix) allow you to write functions that are "pure" (aka: they can do no mutation of data or perform IO) and will always give you the same result for a given input. Writing the majority of your code as pure functions makes the code much easier to reason about, especially as the system scales. IMHO, it also makes testing simpler. It's definitely a different way of thinking and it has a lot of benefits. However, some of the downsides (which Flix seems to fix with region-based local mutation) might be implementing a sort that keeps two copies of a list in memory just to return the second list and discard the first. Depending on your list, this may not be an issue.
- 3y ago
- ww520 3y agoThis looks interesting with lots of feature packed. Looks like a promising language. One thing not clear is what's the reference vs value model, lifetime, and mutable vs immutable model.
- nextaccountic 3y ago> Region-based Local Mutation > Flix supports region-based local mutation, which makes it possible to implement pure functions that internally uses mutable state and destructive operations, as long as these operations are confined to the region. > We can use local mutation when it is more natural to write a function using mutable data and in a familiar imperative-style while still remaining pure to the outside world. > We can also use local mutation when it is more efficient to use mutable data structures, e.g. when implementing a sorting algorithm. Another language with a feature like this is F* (or FStar), but I think it uses a different kind of compile-time analysis. Haskell actually kind of lets you do it through the ST monad (there's a function called runST that turns mutable code inside the ST monad into pure code). But F* (and Flix) can do it implicitly
- mikhailfranco 3y agoI wish Erlang/Elixir would allow this. An Erlang/Elixir process is single-threaded by definition, so there is no contention and in-place mutation could be allowed.
- subarctic 3y agoLots of interesting bits in the FAQ: https://flix.dev/faq/ https://flix.dev/faq/ Particularly in the sections titled "What features are not supported" (no exceptions or panics, so e.g. indexing has to return an Option in case it's out of bounds) and "What controversial design choices are made". Some pithy remarks towards the end as well. To follow HN tradition and find the most controversial topic to discuss, my guess is it's either not allowing name shadowing, or divide by zero equals zero. Or the site not working without javascript (see the section on that near the end, but you'll need to turn on javascript to read it I guess)
- xcdzvyn 3y agoI did like seeing the FAQ become more and more deranged the further I scrolled! I'll perhaps be the first to jump on the 1/0 != 0 hate train though; they mention they designed the stdlib to avoid the partial-function pitfalls of Haskell's, but the article they linked to support their design decision of 1/0 being 0 mentions that it boils down to division being a partial function - x/0 is not a case division can handle. Would it not then be reasonable to make division return an Option?
- ben0x539 3y agoIt would probably be reasonable but a lot of people would complain because they don't want to think about the zero case all the time, so maybe it's also reasonable to not do that.
- brigandish 3y agoI also don't like "Unused definitions, type declarations, etc. are compile-time errors" as I often want to test the validity of a statement, like a type declaration, by compiling before using it. Much prefer warnings. I don't mind the disallowing name shadowing, but I really, really hate (I mean that) websites that are just good ol' text and the odd picture that require Javascript. The excuse of "we used React, it's easy" seems odd given that HTML is much easier.
- rmuratov 3y ago
- liamilan 3y agoJust a friendly UBC piggyback on Waterloo’s programming language ;) Over summer, I built my own little functional language, Crumb (https://github.com/liam-ilan/crumb https://github.com/liam-ilan/crumb). Unlike Flix, the scope is tiny, but some pretty awesome stuff has been done with it. (Checkout this pixel art editor in your terminal, 100% Crumb: https://github.com/ronilan/crumbicon https://github.com/ronilan/crumbicon). There’s a template (https://github.com/liam-ilan/crumb-template https://github.com/liam-ilan/crumb-template) and vscode highlighter (https://github.com/liam-ilan/crumb-vscode https://github.com/liam-ilan/crumb-vscode) for anyone who wants to mess around with it. Any feedback super appreciated :D
- deleted 3y ago[deleted]
- dang 3y agoRelated. Others? Flix – Safe, reliable, concise, and functional-first programming language - https://news.ycombinator.com/item?id=31448889 https://news.ycombinator.com/item?id=31448889 - May 2022 (42 comments) 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)
- paolosimone 3y agoLiterally started playing with it yesterday! Rough edges, but I'm really liking it so far. Let's see how it will handle the upcoming Advent of Code.
- thefourthchime 3y agoIn today's world, i think that English is the only programming language that people should focus on. With the rapid rise of AI, most tasks will soon involve the management of AI models rather than writing code. However, it is still important to have a basic understanding of coding. Introducing a new programming language at this point seems silly to me.
- dangerlibrary 3y agoThis reads like a take from a mid-level manager rationalizing that they never learned to code, and convincing themselves that they'll never need to.
- thefourthchime 3y agoI've been a dev for 25 years. I write code every day.
- dangerlibrary 3y agoNeat!
- rscho 3y agoSecurity-critical tasks and programming language research will involve humans coding for the foreseeable future. I don't think you'd like your surgical robot to be programmed in English.
- fuzztester 3y agoYes, because English is a cut-put language. So instead of cutting some organ (open) (to treat it), the robot might put it in the dustbin instead, due to a speech recognition bug. ;) https://news.ycombinator.com/item?id=38157851 https://news.ycombinator.com/item?id=38157851
- Kwpolska 3y agoLol. The random bullshit generators can write basic code, or make auto-complete smarter, but good luck making one solve complex problems, solve obscure problems without generating bullshit (aka hallucinations) or reason about large codebases. Random bullshit generators see far too much hype and will never replace programming languages for most things, where determinism is needed.
- IshKebab 3y agoTop marks for the website - passes all the tests: * Example at the top * Link to playground * Explanation of all the features, with examples! * Says which features are unique The only thing I was found wondering was "why datalog"? Language looks pretty good.
- alexchamberlain 3y agoDatalog is highly undervalued IMHO. You can describe quite complex relationships in your data, without telling the computer _how_ to realise them (as in imperatively). In fact, there are different strategies (forward vs backward chaining) where you may never realise the data at all.
- imoverclocked 3y agoFlix seems to be implemented in Scala 2.13. Should we expect Flix to work anywhere Scala 2.13 works? ie: if Scala 2.13 supports JDK 8, should we expect that Flix will not take advantage of later JVM features?
- jorkadeen 3y agoThe implementation language does not affect the target "machine". Also Flix is implemented in both Scala and Flix (but GitHub does not yet recognize Flix code). Flix targets Java 11, but is moving to target Java 21, and will take advantage of all features available there, including Project Loom. We are just waiting for Java 21 to become a bit more widespread. (I am one of the developers of Flix).
- ReleaseCandidat 3y agoOne problém of Flix has been the split of the world in "normal" und "graded" type classes, because of the effects as types. Is this solved now? Example see: https://github.com/Release-Candidate/flix-test https://github.com/Release-Candidate/flix-test
- jorkadeen 3y agoThe website is infrequently updated, so let me provide some information about what we are currently working on: - We are trying to make the entire compiler resilient (error-tolerant), incremental, and parallel. We have managed to make every single compiler phase (of which there are 28) parallel. This has already led to significant speed-ups. We are now trying to increase the degree of parallelism within each phase. We are also working on error resilience to provide LSP support no matter what errors a program contains (syntax, naming, type). For example, it should be possible to rename a variable even if the program currently has multiple errors. - We are adding support for algebraic effects and handlers. This will allow users to define and handle their own effects. - We are also exploring a novel way to combine type classes ("traits") and effects. - We have recently added support for package management and integration with Maven. In summary, we are already in a great spot, and useful programs can be written in Flix today. I encourage you to check out the documentation: https://doc.flix.dev/ https://doc.flix.dev/ and to try Flix! (I am one of the developers of Flix).
- pimbrouwers 3y agoYou had me until JVM
- preordained 3y agoDatalog! I especially like that in the smorgasbord of features. I'm still not convinced having a sentient AI encoded in the type system is what the doctor ordered for industry at large.
- teleforce 3y agoFrom the website "Flix is inspired by OCaml and Haskell with ideas from Rust and Scala". Inspirations and ideas from four of the arguably most complex languages of the modern world, all the best with that.
- thethimble 3y agoWhat a sad take… These languages put forth ideas that are extremely powerful. They might be unconventional from an imperative programming lens, but to call them all “complex” as a justification for discarding them entirely is pretty shallow.
- teleforce 3y agoSorry to be pessimistic, as they always said the fruit does not fall far from the tree, but I'm hoping that Flix can prove me wrong.
- airstrike 3y agoThis feels like a nice language to write a spreadsheet engine on...
- Yoric 3y agoOh, Datalog within the language? Exciting! I've been looking for such a feature for some time. Do I understand correctly that the facts can be established dynamically from, say, IO functions? Also, are you going to present at FOSDEM?
- archargelod 3y ago> The following design choices may be considered controversial by some: > Dividing by zero yields zero. https://www.hillelwayne.com/post/divide-by-zero/ https://www.hillelwayne.com/post/divide-by-zero/ That's one interesting point I would love to read any opinions on. Edit: Here's a HN discussion about the `divide by zero` article - https://news.ycombinator.com/item?id=17736046 https://news.ycombinator.com/item?id=17736046
- karmakaze 3y agoThere's a brief description of the same choice[0] made by the Pony language. [0] https://tutorial.ponylang.io/gotchas/divide-by-zero.html https://tutorial.ponylang.io/gotchas/divide-by-zero.html
- chubot 3y agoThis is notable too: In the year since I wrote this post, Pony added partial division. I still don’t know anything about the language but they’ve been getting grief over this post so I wanted to clear that up. https://tutorial.ponylang.io/expressions/arithmetic.html#partial-and-checked-arithmetic https://tutorial.ponylang.io/expressions/arithmetic.html#par... I think Hillel's post was just saying that 1/0 == 0 doesn't lead to any mathematical contradictions. Another way to think about it is that I believe 1/0 == 42 and 1/0 == 43 are just as valid. They don't lead to contradictions. [In ZF set theory] Since 0 is not in the domain of recip, we know nothing about the value of 1 / 0; it might equal √2, it might equal R, or it might equal anything else. But I don't think you want to use a language where 1/0 == 42, and likewise for 0.
- lamontcg 3y agoFWIW, I tend to write a lot of error checking code that checks for division by zero ahead of time and just returns zero instead. Found an example: public double magnitude { get { double c = max_magnitude; return c > 0 ? Math.Max(c, c * (this / c)._internal_magnitude) : 0; } } I could delete quite a few if statements in pretty hot codepaths if division by zero just returned zero.
- 3y ago
- owenbrown 3y agoIt boggles my mind that any developer of a new language wouldn’t use Python’s significant use of white space. You’re able to fit more code on a screen, and it’s less visual noise. It’s like Pareto better. I really don’t get why others don’t copy it.
- lamontcg 3y agoPlaying around with ML and being forced to use python, I find having no block termination character and selecting which context a line of code is in by how much you un-indent it, is the worst. Give me braces and rip a formatter across the whole codebase and be done with it. Furthermore, I think that the trend of compilers/interpreters caring about whitespace formatting rules should really end. You can't ever force everyone in the world to write aesthetically pleasing code in your language and someone out there will always be able to write a complete trainwreck, and everyone disagrees on what is or is not aesthetically pleasing. Leave the problem up to configurable code linters where it belongs. Let people make "mistakes" (in your eyes) if they want to.
- 3PS 3y agoI absolutely love the idea of embedding Prolog-esque rules inside a full traditional programming language for solving specific problems. The region-based local mutation is also an incredible idea that would really solve one of my core pain points with immutable languages like Haskell and Elixir. Also this part made me let out an audible "wow": > We can exploit purity reflection to selectively use lazy or parallel evaluation inside a library without changing the semantics from the point-of-view of the clients. Will definitely keep an eye on this language! The syntax seems a little odd (inferring type parameters for functions?) but I'm sure I could get used to it.