r/functionalprogramming • u/Inconstant_Moo • Nov 14 '23
FP Charm 0.4: a different kind of functional language
Charm is a language where Functional-Core/Imperative-Shell is the language paradigm and not just something you can choose to do in Python or Ruby or PHP or JS or your favorite lightweight dynamic language. Because of the sort of use-cases that this implies, it didn't seem suitable to write another Lisp or another ML, so I got to do some completely blank-slate design. This gives us Charm, a functional language which has no pattern-matching, no currying, no monads, no macros, no homoiconicity, nor a mathematically interesting type system — but which does have purity, referential transparency, immutability, multiple dispatch, a touch of lazy evaluation, REPL-oriented development, hotcoding, microservices … and SQL interop because everyone's going to want that.
I'm pretty sure you haven't seen anything like this because I've been talking about it over on r/programminglanguages for well over a year and no-one's seen much of a resemblance to anything. Charm is a new idea! It comes packaged in a fairly conventional syntax based mainly on Python and Go, as this little snippet shows.
cmd // An imperative command.
greet :
get name from Input("What's your name? ")
post "Hello " + name + "!"
def // A pure function.
factorial(n) :
n == 0 : 1
n > 0 : n * factorial n - 1
else : error "can't take the factorial of a negative number"This is version 0.4 of Charm, which I'm calling a "working prototype", as defined here. It has a complete core language, it has libraries and tooling, it has some new and awesome features of its own. One of the things that "working prototype" means is that it's good enough for you to play around with. Please do! Charm has lots of documentation. There is a language tutorial/manual here, or those of you who want to dive in headfirst could look at the tutorial document Writing an adventure game in Charm.
I'm showing you this project now because I'm at the turning point between designing the prototype and optimizing the implementation, so this would be the best time for anyone to criticize the design. Thank you for any comments! Also if you approve of this project please add a star to the repo! — I hope to at least attract enough attention to Charm that some of my better ideas will be stolen.
4
u/TankorSmash Nov 14 '23 edited Nov 14 '23
I looked over the feature list and I'm trying to understand where Charm fits in. Is it meant to replace Python et al? I love that it comes with a nice REPL and hotloading, but I also love pattern matching and currying.
Definitely curious to try the language out to see, but it's not clear yet where it really shines.
Edit found this, there's a lot of good info if you click through the links:
4
u/mesonofgib Nov 14 '23
I'm not sure what's going on here, but I Googled "charm lang" and see a Wikipedia article for The Charm programming language:
I'm guessing this isn't yours?
0
u/LPTK Nov 15 '23
I went through some of the linked documents and didn't find a single new idea in there. Can you name one?
To me it looks like a rehash of things that have been done many times before.