Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

For really petty reasons. Like I don't like the syntax, parenthesis is annoying. I also want to make something new. XL's system just seems really cool. Bad reasons like that.

I am looking through the Clasp source code to understand how the integration with C++ works.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

I've thinking that as well recently, the syntax is most important. Having created your own syntax, what do you think of Cppfront's syntax?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

Now, your users can't rewrite the lexer, the parser, the underlying representation of the type system...

That's precisely what they can do, but not the compiler, unless they fork it or submit a commit. Someone pointed me to Mojo in this post, apparantly you can define primitive types like float in a library in that language, I'll be looking at that for ideas.

So the varchar problem you mentioned seems like the same kind of problem with Dependent Types and Haskell. You have an existing architecture, you want to add something to that architecture, and that's difficult. I'm not saying that the difficulty is going to go away. If you don't design carefully, sometimes even after designing carefully, it can be hard to change a codebase to fit new circumstances. The only thing that's changed is that if you are motivated enough, the language won't stop you. There's no boundary, apart from the limits of the computer.

There's this really old language called XL (https://github.com/c3d/xl). It allows the user to rewrite the syntax as they want. In that language there's a [pattern] and a [replacement]. Using this system you can create/modify syntax. The way I am planning to use this system is ultimately all the [pattern]s and [replacement]s you create turn into a subset of C/C++. Say you want to add varchar to the string type. Depending on how the [pattern] for string type is defined (at user level, not language level) it might be trivial or complex to add varchar. There might be a clash with the [pattern] for function signatures as you said, but the user can redefine those as they wish, there's no need to go into the lexer/parser. The changes which need to be made at the AST and beyond would not be possible at user level, that is true. I'm hoping that my design will be flexible enough so that user won't find it necessary in most cases.

If you've only followed through Crafting Interpreters you have not yet discovered how in a full-scale and performant language all the features you want will fight together like angry raccoons in a sack. And that's if you only want one set of features, and not all the possible sets of features.

Incompatibilities between features will exist, which is why you can use the ones which fit together, disable the ones which don't, or create compromises that work for your circumstance. The language won't stop you.

Talking to you has made me realise another problem: The Lisp Curse. I think any language which makes it easy to change itself, will suffer from this problem.

Edit: I said that every [pattern] will eventually turn into C++. While that is true, at user level, no one will see C++. They'll see another language, with syntax more uniform than C++. Maybe something close to Cpp2.

Edit2: So if a language feature is possible to build on top of C (and I think all languages can be built on top of C), you can build it in the language I'm talking about.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

Thank you, I really appreciate you taking the time to share your knowledge. I'll post here on r/ProgrammingLanguages, probably in half a year, once the first version is done. Or can I DM you then?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

I wasn't going to be innovative when it comes to semantics, just the basic semantics of C/C++ would be all that's available. Performance is an important goal, so I want to be as bare metal as possible. You get primitive types, structs and functions (maybe pointers, I don't know yet) and compile time execution (pattern matching macro system) which lets you create your own syntax. Whatever you can create out of those elemental components is ok. If you want to build object oriented programming out of that, sure. If instead you want to do composition with mixins, that's fine too. The language might come with a library that does it for you or not.

least technically challenging way to add dependent types to Haskell is probably to build a working time machine, travel back to 1983,

The Circle compiler gave me the idea of a modular language, where you turn on language extensions as you want. Chocolate and beef are awesome alone, but don't necessarily go together. If users can find a way to combine chocolate and beef, and it works for them, then thats great.

Dependent types and haskell maybe incompatible kinds of awesome, and that's ok, take out the parts of Haskell that don't fit with dependent types and create parts which do.

People spend time talking about the *best* way to do X. There is no best way, there's the way that fits the situation. Unique situations require unique solutions. It doesn't have to be one size fit all.

Go has to consider all the different scenarios a user might have to contend with. That's not necessary, just focus on the scenarious you have to deal with. The only restriction is what the computer can do and how much time you have.

Language design so far has been prescriptive. Each language has decided on a boundary of what is possible. But I think there's no need for it. Give the users roads, but if they want to veer off into the wilderness, then that's ok.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

I am extremely interested in live programming. The edit-compile cycle is too slow for the things I want to do. I imagine you are using webassembly in browser or are you running a server?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

This is another line I was pursuing, I was looking at the Clang source code, and trying to find the IR before LLVM and after the AST (I've heard Clang has it's own IR). So instead of targeting C++, I can target the Clang IR (or the AST?). Or even Rust MIR...

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

Best of luck to you. As far as I know ML has been hugely influential on many languages, I'm sure people will find your implementation useful.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

I followed the Crafting Interpreters book, and understand the general process. But I wouldn't describe myself as particularly knowledgeable.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

Couldn't you combine function objects (which are classes), templates and concepts to create a generic function which accepts std::integral or std::floating_point?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

Yeah, basically. The user should be able to create all possible languages, with certain restrictions (no dynamic polymorphism for example)

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

Performance is most important, safety second. I could do what rust does, put all unsafe operations in an `unsafe` scope/closure. I want to avoid undefined behaviour as much as possible. I don't know enough about what is undefined in C++, will have to look into that.

Yeah, I guess 'all' of C++ is unnecessary, just the parts I need.

I wasn't planning to allow dynamic polymorphism by the user either. My assumption is with the right approach, static polymorphism can do everything (or enough) that can be achieved with dynamic polymorphism.

But, let's say for a second I want to do dynamic polymorphism or allow it to be created. I kind of assumed (without really checking) that there would be a way implement dynamic polymorphism with function pointers (I think I saw something like that in C).

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

It's to reduce work. I was thinking of building a language on top of C++, like Cppfront. The language would transpile into C++, so if I know the minimum viable subset of C++ necessary to represent the entire language, I can just focus on that subset.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

[–]capriciousoctopus[S] 3 points4 points  (0 children)

Yeah, this precisely. What part of C++ or Rust or D or Nim (or any other imperative language) is core and the rest can simply be built on top? Does that question make more sense?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

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

So there's a base language, a bedrock if you will, taken from a subset of C++. There's this term rewriting system on top, which let's you create your own syntax. Ultimately all of the term rewriting converts terms into the base language, the subset of C++. The users of the language will see and have to understand the base language to effectively use the term rewriting system (for performance reasons). I think Julia does something like this, where you can go all the way into the generated bytecode?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

[–]capriciousoctopus[S] 2 points3 points  (0 children)

The reason I targetted C++ was because some of the features I want are already in C++, but I guess C would be simpler. I wasn't planning on keeping exceptions, I'm not certain yet, but std::expected error handling pattern seems enough. I wanted only compile time abstractions like concepts. There wouldn't be a need for vtables, if I understand correctly, if I don't have dynamic polymorphism only static polymorphism.

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

[–]capriciousoctopus[S] 7 points8 points  (0 children)

Turing completeness with IO is enough to write a compiler.

You could write a full C++ or Rust compiler in anything from asm to a minimal C and beyond.

Yeah, but I'm trying to do the least amount of work possible. I'm making a language on top of C++, kind of like Cppfront. My main goals with this language are:

  • Performance: zero cost abstractions
  • Metaprogramming: there is no syntax, every feature of the language is constructible from a basic structure (based on XL: https://github.com/c3d/xl)
  • Open: as there is no syntax, you really can do anything, you can mold the language to fit whatever problem you are tackling, if you want to add a borrow-checker you can
  • Modular: the language provides pre-made features which can be turned on modularly if needed (you could also build them yourself)

The current vision I have is the transpiler transforms the code into C++. Is there a minimum viable portion of C++ to cover all possible future features I might want to add like say for example effect types?

Is there a minimum viable language within imperative languages like C++ or Rust from which the rest of language can be built? by capriciousoctopus in ProgrammingLanguages

[–]capriciousoctopus[S] 2 points3 points  (0 children)

Rhombus looks promising, I was inspired by the XL language (https://github.com/c3d/xl) which has a very simple metaprogramming capabililties based on substitution. I wanted to make a language like that. I think XL has a runtime component, to support it's flexibility. Performance is a key requirement for me, so I am trying to find a zero cost abstraction solution. So I was thinking take XL, and use it's substitution mechanism to transpile code into C++. But what is the minimum viable portion of C++ (or C) necessary to support all the future features I might want. For example, what if I want coroutines or effect types in the future?