10

I'm boutta make a scripting language with classes, trait generics AND two kinds of value types

Call me Mr. Dangerous 😎

Comments
  • 5
    But for real, if you design an efficient language you don't need to implement a good garbage collector
  • 1
    Let's make a GC just in case a fool like me overcomes the 2GB ram limit on x86.
  • 0
    Thats nice. Doubt anyone would use it in production though
  • 1
    So what kinds of types will there be?
    Surely you want algebraic types. You also mentioned classes, so there will be objects too. But today, functions as first-class citizen are a must-have and in a scripting language you probably also want some optimized basic data types like integers, lists, and maps, so they don't have to be defined recursively...
  • 2
    @bioDan I will be using it and that's all I really care about. If people want to embed a JavaScript VM into their application then all the power to them
  • 1
    @Oktokolo I will have a class based system with externally implemented traits instead of interfaces. Probably also some form of algebraic datatypes like Rust has. It will also be a rather static type system similar to the JVM's. Yes, a static type system in a scripting language. Why? Well, why would I deliberately design an embeddable language in a way that makes it slow and inefficient?
    The only advantage dynamic/weak typing has is it's slightly less to type (in the short term) and makes everything "simpler". Also more shallow.
    And with good type inference it's not even quicker to write.
    I'm actually kinda sick of this idea that scripting languages HAVE to be dynamic.
    If you look at Rust you already have a pretty beautiful language. If you now simplify everything a bit and strip away some of the more complex things you have a language that's as terse as JavaScript except better in every aspect. That's what I'm trying to do
  • 1
    @12bitfloat so...OCaml + scripting basically?

    Also you'll probably need to focus on a good GC anyway. It's insanely hard to statically prove memory usage (so you need heap allocation) and ownership (so you need to track objects) even with stuff like region based memory use analysis, so every heap object in your language will need at least something like a GC tag or reference count.

    I don't know of a single language that got away with a crap GC because of its type system (Erlang may be an example, but Erlang's GC is tuned for other uses and its design goals and type system are...interesting).
  • 1
    @RememberMe (replying because > 5min)
    *OCaml/SML + traits + scripting

    *insanely hard as in, impossible for anything but simple-ish cases because static program analysis can never be complete and absolutely needs to be conservative.
  • 1
  • 2
    @12bitfloat
    Static type systems are better - but only if you have type inference too.
    Then you can optimize the hell out of it, find all the mixed-type bugs at parse time - and have less to type.
  • 0
    @RememberMe
    Erlang is a bad example because of its strict value immutability. No one, but the most hard-core math nerds want that in a general purpose scripting language (it is fine for a language optimized for massive parallelity and maximum robustness though).
  • 2
    @Oktokolo my point was about making GC less relevant, not about how suitable it is for scripting.
  • 0
    @RememberMe Not really OCaml because that's a functional lang AFAIK, more like Rust in simple on top of a lightweight JVM.

    As for the GC I'm hoping that providing a few good concepts (maybe value types with move semantics?) will help a lot with short lived objects which IIRC make up a lot of the garbage in a typical Java program. Then I can maybe even get away with simple non-atomic reference counting
  • 0
    Rust also gets away with "only" having reference counting and it allows for amazingly efficient memory usage. Of course it also has a lot of semantics that don't fit well into a scripting language but the idea is there

    I think the most important thing will be supporting single ownership since that allows for virtually free memory management while making sense to the programmer
Add Comment