Hacker News new | ask | show | jobs
by mamcx 3233 days ago
My dream is a static-first (like with inmutable-first) language with a way to do dynamic.

The thing is not available (as far I know) is to build a dynamic object and "close it" for further modification so the compiler can optimize well. Other, that requiere good metaprograming, is to build a dynamic object AT COMPILE TIME (macro?) and close it, then the type-system work after that (F# type provider is almost this)

A use case is reflect a database/data storage like JSON or relational table. I wish, like with python, to do:

    class Customer = @build(table("Customer"))
and after this line :

    c = Customer()
    print c.name
to 'c' be a static type. If at compile time, it check the type, let say the field change to c.fullname, to mark as a type error.

If in runtime, like a interpreter, to "close" Customer and be certain that it never will mutate.

AKA: Inmutable types/clases, but the posibility to mutate it in some discret places.

Make sense?

2 comments

You may be interested in Crystal.

https://crystal-lang.org/

This sounds similar to F# type providers.