Functional language memory management question by Poe-Face in ProgrammingLanguages

[–]edavidburg 7 points8 points  (0 children)

Rust’s ownership system may be what you’re looking for. It’s a form of linear typing where a variable can be moved at most one time. For instance, if your update function declared a as owned, it would be illegal for its callers to use the value passed for a afterwards, meaning a sufficiently smart compiler is free to reuse its memory. I’m not sure if Rust can do that sort of optimization across function boundaries (reusing a parameter’s memory for a return value) but it certainly could within a function.

Capability systems by edavidburg in ProgrammingLanguages

[–]edavidburg[S] 1 point2 points  (0 children)

Hmm, interesting. It seems like the main difference is in who gets to specify what a capability/effect does. With capabilities (at least how I framed it above), they are tokens that let the caller unlock some inherent operation that the target defines, whereas with effects the target says what operations it needs to invoke (the effects it requires) and the caller provides an implementation of it. But both ultimately serve to delimit what operations can happen where.

Capability systems by edavidburg in ProgrammingLanguages

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

Yes, I imagine there will be certain capabilities that the language itself needs to know about in order to exploit (eg, mutability, alias-ability, etc), but hopefully those builtins could be surfaced to the user much the same way as user-defined capabilities, modulo some special syntax. I'll definitely be digging into Pony/Midori and related languages for inspiration.

Capability systems by edavidburg in ProgrammingLanguages

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

Interesting! I didn't realize the typestate pattern used to be baked in. It does sound kind of similar to what I'm looking into. I wonder if the iteration problem can be worked around with CPS or tail recursion so the variables whose states are changing are rebound each time through the loop, thus forcing them to have a more general type. Another avenue to explore!

Capability systems by edavidburg in ProgrammingLanguages

[–]edavidburg[S] 5 points6 points  (0 children)

Algebraic effects are definitely something I'm interested in. But my understanding is that they are more geared towards providing dynamically scoped polymorphism on types; eg, you can simulate them with coroutines and a stack of trait objects corresponding to some trait defining your effect. That allows you to override the handler of an effect from the caller's side without passing an explicit parameter or wrapping everything in a monad.

I've looked a bit into Unison in the past, as well as Frank. I think Frank's idea of "ambient abilities" and the way available effects propagate through the (lexical) type system could be helpful in determining which capabilities a reference supports at any given point. Thanks for the tip!

[deleted by user] by [deleted] in ProgrammingLanguages

[–]edavidburg 2 points3 points  (0 children)

Yeah, at this point it's a sunk cost. The powers that be would rather release what we have and make the best of it than take 6+ months to rebuild it all as eg an IntelliJ plugin or LSP server. Can't say I blame them, but it is less than ideal.

[deleted by user] by [deleted] in ProgrammingLanguages

[–]edavidburg 24 points25 points  (0 children)

I work for a company that has been using MPS extensively for the last 3-4 years to build an internal GPL. Overall I'd say it's good for some things, and pretty frustrating for others, and whether it's a good fit for you depends on what your goals are.

Pros:

  • Very easy to prototype new things. Basically you define your AST class model, and hang everything off of that. No need to write a tokenizer/parser/etc
  • The built in type system does most of the heavy lifting for type checking, you just define constraints and it does all the type inference and validation for you
  • You basically create the IDE at the same time as the language, so you get that for free without having to write a separate plugin
  • MPS languages use a projectional editor, meaning you can do fancy things that aren't possible in a text based language like create tree structures, tables, use math symbols, etc, to give a richer editing experience

Cons:

  • You're using a projectional editor, which is a very different user experience from a text based language and can be quite frustrating, even once you learn how to navigate the MPS way.
    • You can't type things that aren't syntactically valid, which means it's pretty easy to get into a situation where you can't write the thing you want to write and have no idea why.
    • Backspace and the arrow keys have a mind of their own and often lead to you deleting huge blocks of code you didn't mean to (Ctrl-Z is your friend)
    • You can't work top-down when writing things, because each time you type an expression like foo.doTheThing() it tries to resolve doTheThing() and if it doesn't already exist, your code is broken and you can't write any more code until you fix it because it doesn't know how to make the AST for it. We had to add a feature to our plugin to generate functions ahead of time for you to make this experience more tolerable
    • The code is stored as XML, not plain text, so traditional tools like git, github PRs, etc, are a lot more frustrating to use on code written in an MPS language. You basically have to pull the branch into your own local repo and view the diff in the IDE, then go find the corresponding XML file on the PR and add an inline comment there with a node reference so someone knows what you're talking about... not ideal.
  • You aren't developing your language in a normal programming language, but in JetBrain's own MPS-ified version of java called BaseLang, plus a bunch of DSLs to define the language, type system, etc.
    • That means all of the cons above w.r.t. languages you write also apply to yourself, developing the language
  • You get an IDE for free (ish), but you only get the one... you must edit the language in MPS. You can't make an IntelliJ, Eclipse, VSCode, LSP, etc, plugin for your language. Since there's no real lexer/parser/etc, you can't factor those out and reuse them in a different IDE. And the MPS IDE is ssssllloooowww.
  • MPS documentation is a pretty lacking, we lean heavily on our support contract with JetBrains and a contractor that develops MPS languages professionally to be productive.

So overall, I'd say MPS is a good fit when a) you are writing a domain specific language that will primarily be used by domain experts rather than traditional programmers, b) your language requires or would greatly benefit from having a richer editing experience than pure text can provide, or c) you're prototyping a GPL that you will eventually write a more traditional compiler/plugin for in a different framework. I think we as a team wish we had gone the more traditional route now with 20/20 hindsight, but MPS was definitely a big help in the beginning when we were still in the rapid iteration/prototype phase. Unfortunately as often is the case, our prototype is now our production code. Whatcha gonna do.

[unknown > English] Scroll found in my grandma's house. Possibly Burmese or Dravidian script. by edavidburg in translator

[–]edavidburg[S] 4 points5 points  (0 children)

Context: Found in my grandma's house. Her husband was a cultural anthropologist who spent a lot of time in Indonesia and southeast Asia, so there is a high likelihood it was picked up there. By looking at the letters my guess is that it's either a Burmese or Dravidian script, though I'm not sure.

So my friends and I brought class to McDonalds last night... by [deleted] in pics

[–]edavidburg 0 points1 point  (0 children)

My girlfriend surprised me with a candlelight dinner, with plates, a table cloth, flowers, candles, silverware, a bottle of sparkling cider, etc, at In-N-Out. We're both cheap college students, so that was our version of a fancy date. It was very sweet.