r/ProgrammingLanguages • u/zweiler1 π₯ Flint • Jul 10 '26
Language announcement The Flint Programming Language
I am happy to finally announce the language I have been working on for the last 2 years, Flint!
Flint is a high-level, statically and strongly typed, compiled language which centers around transparency as its core pillar. The compiler is entirely written in C++. It originated from one simple idea and core concept:
What happens when you center the whole language on an ECS-inspired composition-based paradigm?
And so the journey began. The core idea is simple: data and functionality are separated and then composed deterministically into larger entities. This idea is not new at all, ECS exists since a long time. But a composition-based workflow can only be "emulated" in Object-Oriented languages and I find it often painful or unergonomic.
In Flint, composition is the core paradigm. I have put great effort into making it ergonomic and "just work". The result is a system which can be described as a cool mix of OOP and ECS. I gave the "new" paradigm a name, since nothing quite like it exists yet, even though the ideas it is based on are well known, the Declarative Composable Modules Paradigm (DCMP).
The combination of a high level + transparency as a core pillar is a bit unusual. I have put great effort into finding a good balance. I found out that these two things are not mutually exclusive, there is a middle way in which a design can be both high level and transparent. Flint might be best described as "middle-level" as a result: You write high level code but you can see the low level runtime and execution beneath too if you want, as this focus on transparency directly results in shallow abstractions.
Most developers are more used to OOP workflows rather than compositional workflows, it's just more mainstream. So, if you cannot live without it, Flint might not be for you and that's okay. Also, I am also sure that Flint won't be for everyone because of it's split focus on being high level and transparent. It will feel too high level for some or too low level for others. But if the core idea and mentality excites you, please give it a fair chance.
The time has come where I am confident enough in Flint to search for people to try it out and give feedback on it. Many features are still missing but the general vibe and direction of the language can already be seen. The 0.4.0 version is the 20th release so far, the first initial version was released a year ago. I am now moving into the 0.5.0 release cycle which will bring generics, type constraints, compile time code execution, the standard library and more. You can look at the entire roadmap here
Flint is available in the AUR, COPR and Winget as packages, with proper highlighting and LSP capable extensions for VSCode and Neovim. The LSP works with proper error diagnostics, hover information and goto definition / declaration / file jumping (context sensitive suggestions do not work yet). Debug symbols and debuggability are now supported too, making it able to inspect and step through code. Interoperability with C also works great through the fip-c interop module which communicates with the main compiler through a custom language-agnostic Interop Protocol. (Bindless interop doesn't fully work on Windows, though, i still have to find out why).
The Wiki is in a very good state, it is kept updated with every release made. Every example in the Wiki works and I did My at explaining it all. The language's core value is transparency, so there is nothing to hide about it.
Here is an "advanced" but hopefully still easy to understand example of Flint and its paradigm in action. Keep in mind that Flint has much more to offer than shown in the example below, but I think this just encapsulates its centerpiece quite well:
use Core.print
const data Constants:
float PI = 3.14159265358979323846;
// A shape can be drawn and its area can be calculated
func IShape:
def draw();
def area() -> f32;
data DCircle:
i32x2 pos;
i32 radius;
DCircle(pos, radius);
func FCircle requires(DCircle d):
def draw():
print($"Drawing circle at [pos={d.pos}, r={d.radius}]\n");
def area() -> f32:
return Constants.PI * f32(d.radius ** 2);
entity Circle:
data: DCircle;
func: IShape, FCircle;
link:
IShape::draw -> FCircle::draw,
IShape::area -> FCircle::area;
Circle(DCircle);
data DRectangle:
i32x2 pos;
i32x2 size;
DRectangle(pos, size);
func FRectangle requires(DRectangle d):
def draw():
print($"Drawing rectangle at [pos={d.pos}, width={d.size.x}, height={d.size.y}\n");
def area() -> f32:
return f32(d.size.x * d.size.y);
entity Rectangle:
data: DRectangle;
func: IShape, FRectangle;
link:
IShape::draw -> FRectangle::draw,
IShape::area -> FRectangle::area;
Rectangle(DRectangle);
def draw_shapes(mut IShape[] shapes):
for (_, s) in shapes:
s.draw();
def sum_areas_of_shapes(mut IShape[] shapes) -> f32:
f32 sum = 0;
for (i, s) in shapes:
f32 area = s.area();
print($"shapes[{i}].area() = {area}\n");
sum += area;
return sum;
def main():
c1 := Circle(DCircle(11, 2));
r1 := Rectangle(DRectangle((10, 20), (4, 5)))
c2 := Circle(DCircle((3, 5), 10));
r2 := Rectangle(DRectangle((0, 0), (4, 2)));
IShape[] shapes = IShape[_]{c1, r1, c2, r2};
draw_shapes(shapes);
print("\n");
i32 sum = sum_areas_of_shapes(shapes);
print($"sum of areas = {sum}\n");The project is in late beta. All implemented features work reliably, as all wiki examples compile and run as intended. There are still missging error messages and unexpected edge cases (as expected from a single developer).
If you're interested, try it out, give feedback, open issues, and feel free to join the Discord. Let's discuss Flint!
(Also, I may not be aware of some industry-standard names for some systems. If you encounter anything I gave a weird name where you think "wait something like that already exists" please let me know. I try to use industry-standard terminology as much as I am able to. I hate it when new names are made up for something which already exists.)
Edit: Thank you all for your feedback. This all led me to a journey of rethinking some parts and redesigning them. Especially the documentation needs much work still, as I realized it was unhonest in many places (mostly me thinking I invented something new while I did, in fact, not). So I will quietly work on it and maybe come around with an update in the future. Still, thanks to everyone who replied!
19
u/EggplantExtra4946 Jul 10 '26 edited Jul 10 '26
You say ECS but what do you mean by it? I went though the documentation.
When I arrived at https://flint-lang.github.io/wiki/v0.4.0-core/beginners_guide/4_functions/6_groups.html I thought: "groups" maybe a new ECS related concept, but it's just tuples.
When I arrived at https://flint-lang.github.io/wiki/v0.4.0-core/beginners_guide/5_data.html I thought that's it finally:
but looking at the examples and how they are used, it's just structs.
There is nothing about data layout when you have many "data modules"/structs, such as Struct of Arrays instead of Array of Structs.
At https://flint-lang.github.io/, from the "Key Concepts" definintions of "1) Data Modules", "2) Func Modules", "3) Entities" I don't see any difference between those concepts versus structs and classes despite you saying that the language is a distinct paradigm and that it's different from OOP. It's just OOP concepts with different concept names and different keywords. You even concede that with the title "4) Similar in use to Objects":
There are many brands of OOPs but many recent ones also focus on composition instead of inheritance. This has been like that for more than a decade in fact.
7
u/Smalltalker-80 Jul 10 '26 edited Jul 10 '26
I'm puzzled. In your example, you are piecing together '
data' (structs), functions coupled to data 'requires' and something that looks like a class combining data and functions 'entity', conforming to a base interface 'IShape'.What do you think is the advantage of doing it this way compared to 'regular' OOP?
6
u/vmcrash Jul 10 '26
Just judging from the (good) documentation: it looks interesting. Maybe, after having used Go and Lisette, I'd remove the requirement for the semicolon, too.
What I didn't find though is how memory is managed. Maybe I need to read more thoroughly.
6
u/6502zx81 Jul 10 '26
Your example looks like OOP not ECS, right?
4
u/initial-algebra Jul 11 '26
I think this is why so many people are confused, because there are a lot of instances of this.
Your "Thread Stack" is a segmented stack, combining all functions into one big CFG is called defunctionalization, and your "frame threading/tail-call flattening" is the CPS-transform. It is not really correct to say that your approach is unique, it's actually very "textbook". There's nothing wrong with that, although it's not optimal to do it all the time, so production implementations of e.g. Go, OCaml and Haskell are more sophisticated about when to apply it and when to just use native function calls. However, you can certainly think of your abstract machine as being purely continuation-passing.
I think you do have something interesting here with "DCMP", although I would not consider it to be a new paradigm. Specifically, you're using composition and delegation with structural typing to generalize inheritance. I think the ECS analogy is more baggage than it is helpful at this point, since, aside from the memory layout, you don't utilize the relational data aspect.
3
u/Imaginary-Deer4185 Jul 11 '26 edited Jul 11 '26
I'm new to ECS and had to google it. It seems to me you want to create collections of pure data objects (struct-like) and then have functionality applied to all data elements of the same type, regardless of how they are used, compositionally?
Now, assume you have a parent data object type, which contains references to some sub-type data object (by interface). Now, when you invoke a certain function on all objects of the parent type, will this allow for following pointers to sub-objects, and apply appropriate function(s) on those, or just update sub-object state, and let processing the new information be taken care of in some global iteration calling relevant functions on all objects of relevant types? Or conversely, follow pointers from sub-objects to parent objects, or the other way, reading state, to affect processing?
Regardless of which approach you use (calling functions for sub-objects directly, or just updating inner state in sub-objects, or one object reading state in another linked object), they all require both parents and sub-objects to be present in CPU cache during a single processing run.
The only way around it would be explicit message passing.
I don't understand how separating code from data matters for organizing memory, compared to OO. In an object oriented language, clearly the compiled methods are not stored alongside the data.
Your wiki may be great, but it overwhelmed me quickly.
It would be nice with a non-trivial example, not as code, but as pseudo-code, illustrating the power of ECS in your implementation, for all us non-game developers.
Apart from that: GREAT WORK!
3
u/TheAncientGeek Jul 10 '26
What's ECS?
2
u/umlcat Jul 10 '26
Good Work, Good Luck !!!
2
u/cbarrick Jul 10 '26
Looks very cool!
funcseems like an odd keyword to use like this, but I don't have a better suggestion.I'm not sure how I feel about
i32x2having implicit.xand.ymembers. I think I prefer the Rust-style.0and.1since they don't imply any specific geometric interpretation. But if CUDA does it, then it can't be that bad.The
linksection of entities seems like it could be a lot of boilerplate. Have you thought about ways to make it less heavy?2
u/FreshOldMage Jul 11 '26
Nice work! As I'm also working on a language incorporating ECS concepts as first-class features, it's super interesting to see somebody elses approach.
It does seem to me by getting rid of automatically executing systems, the ECS paradigm starts to look almost exactly like OOP with some additional restrictions. While in ECS data is restricted to components, and behavior to systems, adding a component to an entity does automatically bestow this behavior to it. In Flint, the behavior is instead composited separately per entity, in what looks like an OOP interface. On a first glance, to me this seems equivalent to multiple inheritance, where parent classes are restricted to either providing fields or methods.Β
2
u/KvThweatt Jul 14 '26
Website on gh pages is hard to use on mobile. I recommend improving the mobile experience, I canβt scroll right or left on your cards, and the page physically moves off screen when trying to slide them.
Seems AI to me, this is no negative point but if it is, it can do better, and especially with web design.
2
u/AdaScout Jul 18 '26
Daniel my coworker would be proud.
4
u/Express_Job_5731 Jul 11 '26
Wow; this is incredible work. I am super impressed, please keep it up! I love that you're exploring new frontiers.
-Chris Lattner (yes, really)
1
u/RelationshipFresh966 Jul 10 '26
Playground is returning a 404 OP
1
u/tending Jul 10 '26
Without prior familiarity with ECS it's hard for me to tell how the example works. I don't know what the difference between an entity and data is, and I don't know how the dispatch works "linking" IShape to FRectangle or FCircle.
0
u/[deleted] Jul 11 '26
[deleted] β view deleted comment
14
u/[deleted] Jul 10 '26
[removed] β view removed comment