tim-hardcastle / Charm

Source code for the Charm programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🧿 Charm

Welcome to Charm!

Welcome to Charm, a new programming language. This is version 0.4, a working prototype; you shouldn't use it in production but it's good enough at this point for you to install it and play around with it. There are batteries included; there is tooling.; there are plenty of features including some you've never heard or thought of.

Charm aims to be a delightful general-purpose language particularly suitable for rapid development of CRUD apps. With the semantics of a functional language, with syntax borrowed from mainstream productivity languages (specifically Python and Go), and with inspiration mainly from SQL and Excel — Charm is not quite like anything you've ever seen. But it is also a very practical language that exists to solve some very ordinary "white-collar" problems.

It is my hope either that Charm itself will one day be used in production, or (given my amateur status and lack of time) that this project will get enough attention that my ideas will be copied by people with more money and personnel and expertise. To this end, please add a star to the repo! Thank you!

Instructions for installing Charm can be found here, as part of a general manual/tutorial wiki that tells you everything you need to know to code in Charm. There are lots of other supporting documents, and people who want to just dive in headfirst might want to look at the tutorial document Writing an adventure game in Charm.

A little Charm

Here is some sample code: you should find it readable.

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"

Distinguishing features

Here are some of Charm's more distinctive features:

  • Charm services have a functional core, imperative shell architecture, in which a thin layer of IO sits on top of pure functional business logic.
  • All values are immutable; all comparison is by value.
  • Functions are pure and referentially transparent.
  • Local constants of functions are defined in a block at the end of the function and evaluated only if/when required. (You don't know how nice this is until you've tried it.)
  • Free order of intitialization also helps you to write your scripts top-down.
  • Abstraction is achieved by overloading and duck-typing. There is multiple dispatch.
  • Field names of structs are first-class objects. Indexing structs and maps overloads the same operator.
  • While Charm is very dynamic (as illustrated in the previous two points) it is also very strongly typed, much more so than any mainstream dynamic language. There is no truthiness; there is exactly one form of type coercion.
  • Charm is REPL-oriented, with hotcoding to make it easy to code and test incrementally.
  • The REPL is also a development environment and framework. It lets you test your code, write permanent tests, ask for help, interact with error messages, configure your services, deploy them to the web and manage access to them.
  • It is intended that often a Charm service will act as its own front end (like e.g. a SQL database does) with the end-user talking to it via the Charm REPL. For this reason Charm has an unusually flexible syntax for creating DSLs.
  • Charm comes with Go and SQL interop for all your backend needs.
  • (Also the system for embedding other languages is extensible if this does not in fact meet all your needs.)
  • Charm allows and encourages you to write your applications as microservices, giving you a natural way to encapsulate data and manage access to it.
  • Charm’s syntax is based on mainstream productivity languages, principally Python and Go. It has a shallow or indeed invisible learning curve: you can learn the simple parts of the language without knowing that the other parts exist.
  • Charm's roadmap includes a point where we freeze the core language around a small set of sufficiently powerful features and try to remain permanently in version 1.x.

Documents

Licensing

🧿 Charm is distributed under the MIT license. Please steal my code and ideas.

About

Source code for the Charm programming language

License:MIT License


Languages

Language:Go 91.1%Language:xBase 7.7%Language:Scilab 1.2%