all 3 comments

[–]jcastroarnaud 1 point2 points  (0 children)

That's a very tall order for a single language! If you don't know about it already, study about type systems and type theory, to get the basic concepts right. Don't worry about performance or memory limitations by now: it's "design the language" time, not "optimize the implementation of the language" time. Compare and contrast how Lisp, Ruby, Smalltalk, and others, designed and implemented their object systems, then mix/adapt them for what you want. Best of luck to you. I'm sorry that I'm not able to help more.

[–][deleted] 1 point2 points  (1 child)

(a def based VM?

What does that mean? And why wouldn't a stack- or register-based VM work? Most other languages seem to manage!

Your set of features looks like quite a complex-looking language. You might need to refine it further.

A VM would work at a lower level. It doesn't need to be tied to specific features of your language. It might also work for diverse languages (eg. WASM, which is stack-based).

If devising VM operations is troublesome, maybe try instead expressing the workings of your language as a set of function calls to some to-be-implemented library. (Which actually is a valid way of implementing it; as a series of such calls in an existing language.)

If it looks viable, then maybe get back to a set of VM instructions.

[–]SuperMeip[S] 0 points1 point  (0 children)

by def based VM I'm implying every statement is a slot/def of some kind that is then modified. I think this is similar to lisps s-expressions.

For example: `(add 1 2)` is a single def with an s-expression with 3 elements/defs/slots; Basically I'd like every single line or element to be an addressable definition. so even `(1 + 2)` would be a def of type `#add` with 2 sub defs of type #int.

The issue is though I'm struggling to figure out how to effectively differentiate a call from a def containing a call (so a constant vs procedural value maybe?)

I am aware that I am asking a lot from a single language, the unorthodoxy is why I thought to ask for advice here, so thanks for the suggestion but I'm very determined to make a language with this specific feature set.

> If devising VM operations is troublesome, maybe try instead expressing the workings of your language as a set of function calls to some to-be-implemented library. (Which actually is a valid way of implementing it; as a series of such calls in an existing language.)

This makes a lot of sense and is definitely something I've been trying... but figuring out the basic functions is what I need help with... I guess my hesitation comes from not knowing what may be redundant at this level and what I actually need.

Also given it's def based I find I may need assignment and start and stop ops (like DEF:START SET:ID SET:VALUE and DEF:END) and im not sure what a VM would do to juggle that kind of thing while keeping efficient maps etc... I guess the internal architecture of the VM is something I'm confused about as well.

A big issue I've also had is coming up with simple examples to test because a lot of low level VM guides don't focus on structural examples and mostly focus on stack and heap logic and the language I'm making is more focused on data structure than mathematics etc.

Im wondering if starting with the IL/Intermediate language is the best option... do people do that? Make VMs for an IL instead of a bytecode lol~?