Being a foss enthusiast I can configure most of my software in way too many ways. However I noticed that this is not true for most compilers. Which got me thinking: why isn’t that the case. In gcc (or your favorite compiler tool) I have a shitload of options about what are errors and warnings and how the code should be compiled and tons of other options. But not on how the code should be interpreted and what the code should look like.

Why can’t I simply add a module to a build process to make it [objective oriented | have indentation for brackets | automatically allocate memory | automatically assume types | auto forward-declarate | some other thing that differentiates one language from another]* ? Its so weird that I have a pdf reader that has an option to set the window icon, a mail client that lets me specify regex to search for a mentioned but forgotten attachment and play a game that lets me set my texture picmip resolution. But that the tool (gcc) to build these things has not even got a config file build in. We have build tools around them to supply arguments.

This could look like the following: ( oversimplified )

  1. preprocess
  2. compile
  3. assemble
  4. link

v

  1. add brackets from indentation
  2. preprocess
  3. check if objective oriented constraints are all satisfied
  4. do something else
  5. compile
  6. assemble
  7. run assembly through as an example ai for antivirus scanning
  8. link
  9. run test

There could also be a fork in this process: sending for example the source code both to a compiler and an interpreter to detect edge case behavior while compiling. Or compile with both automatic typing and your defined typing so that when rounding errors are big you can instantly compare with a dynamically typed version of your program. Or the other way around, maybe you want different parts of your code to be handled with different preprocessors.

The build process should be configured per project for things about the input like syntax and per computer for things about the output like optimizations.

There are of course some drawbacks, one being a trust issue where someone pulls in a obscure module to build malicious releases. It probably also is harder to maintain stability when you have to keep in mind that your preprocessor isn’t the first to be run. And your compiling process can take a lot longer if you have to go through multiple pre, post or even compilation phases.

If you know such a build tool, or c (: haha :) some obvious reasons that this should not exist, please let me know. Thank you for reading this lenghty post.

Thanks for the comments, based on them I think I can better explain what I want. I would like a language that has got minimal specification so its preprocessor, compiler, assembler and linker are a collection of plugins rather than one chunky program.

So the compiler reads for example a line. void main(int argc, char argv) and then all main body plugins get a event_newline. The function plugin reads this and creates a new object that contains the function main. Then sets an event_functionBody that is caught by other plugin(s) to read the contents of main and return what it has to do.

  • Redkey@programming.dev
    link
    fedilink
    arrow-up
    10
    ·
    1 year ago

    Some of the things you mentioned seem to belong more properly in the development environment (e.g. code editor), and there are plenty of those that offer all kinds of customization and extensibilty. Some other things are kind of core to the language, and you’d really be better off switching languages than trying to shoehorn something in where it doesn’t fit.

    As for the rest, GCC (and most C/C++ compilers) generates intermediate files at each of the steps that you mentioned. You can also have it perform those steps atomically. So, if you wanted to perform some extra processing at any point, you could create your own program to do so by working with those intermediate files, and automate the whole thing with a makefile.

    You could be on to something here, but few people seem to take advantage of the possibilities that already exist, and combining that with the fact that most newer languages/compilers deliberately remove these intermediate steps, this suggests to me that whatever problems this situation causes may have other, existing solutions.

    I don’t know much about them myself, but have you read about the LLVM toolchain or compiler-compilers like yacc? If you haven’t, it might answer some questions.

    • spykyvenator@programming.devOP
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      LLVM Is something I want to check out for some time now but never did. yacc I haven’t heard about. but its indeed what I’m getting at, why haven’t we got a single language that you can adapt to all needs.

      • stifle867@programming.dev
        link
        fedilink
        arrow-up
        10
        ·
        1 year ago

        The more generic you make something the worse it is at specific goals. The more use cases you support, the more complex and harder to maintain, the more it’s likely to fail. There will never be a “universal” programming language.

        Imagine if you had a programming language that did “everything”. Well there are people who want a simple programming language. Don’t these two things seem completely at odds?

        • spykyvenator@programming.devOP
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          1 year ago

          I agree, I put an example in my main post, it isn’t really a language in that it has as little as possible language specifications. It could be simple or complex syntax based on what plugins you select for your use case. Its not a universal programming language more like a universal programming language specification that most languages fit into.

          • stifle867@programming.dev
            link
            fedilink
            arrow-up
            4
            ·
            edit-2
            1 year ago

            You’re essentially describing a turing machine. I don’t mean to be facetious and I don’t have proof for this but my gut tells me by the time you make something this generic it will no longer be a “universal programming language” and will become a specification to allow for anything while failing to provide anything actually useful.

            Anything more specific and you’re essentially implementing YACC or some form of code generation that’s already been invented and is not specific enough to be useful for this purpose.

            EDIT: In my mind it’s like saying we have cars, boats, airplanes, bicycles, etc. Why isn’t there a platform where if we wanted we could add wings and jet engines and make it into a plane? Or instead add a horse and carriage? Or 4 wheels and a steering wheel?

            Maybe you could do so, but the result wouldn’t be anything actually useful because making a plane has specific design goals that aren’t shared with a bicycle.

            • spykyvenator@programming.devOP
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              1 year ago

              I don’t think that, but it could be. Variables, functions and things like loops, switches and if statements are things that many programming languages have in common. They can be specified without forcing a specific syntax and already take you far from turing machines.

              • stifle867@programming.dev
                link
                fedilink
                arrow-up
                2
                ·
                edit-2
                1 year ago

                I’m starting to understand what you’re saying. It wouldn’t be a universal programming language because even those things you list are not universal.

                So now I am imagining a system very roughly where you could say (for example):

                language.add(Variables)
                language.add(Functions)
                language.add(Loops)
                language.add(Strings)
                language.add(BracketScope)
                language.add(Regex)
                language.add(ActorConcurrency)
                

                You would add support for various features and maybe control the syntax via configuration? Is that more along the lines of what you are envisioning?

                  • stifle867@programming.dev
                    link
                    fedilink
                    arrow-up
                    3
                    ·
                    edit-2
                    1 year ago

                    Interesting. I don’t see any immediately obvious technical reasons why this wouldn’t be possible.

                    There are languages that include a variety of different programming paradigms (I’m thinking of D). I can’t think of any that support different syntaxes but I’m sure one would exist. However, a language that is configurable I feel does not exist and could be an interesting experiment.

                    I still do fear however, that any attempt would still not be practical as if you design a language feature that is generic enough to work with/without other features and with different syntaxes then it would not be specific enough to be clearly useful. In other words by trying to support everything it becomes good at nothing.

          • killeronthecorner@lemmy.world
            link
            fedilink
            English
            arrow-up
            3
            ·
            edit-2
            1 year ago

            To repeat the other person’s point a bit, what you’re describing sounds very much like LLVM, and other IR languages.

            IRs exist to allow a variety of programming languages to be specified in a way that doesn’t require direct compilation of that language to asm. This means the IR has to support some representation of the superset of all those languages’ features.

            So I guess your question could be interpreted as: why don’t we just use an IR to write code? Mostly because they require you to forego many of the modern conveniences of modern programming languages. The whole point of going higher level and more opinionated in language choice is to allow you to turn designs into code faster than you can with lower level representations.

            I don’t entirely follow what you’re trying to achieve with the plugins idea but it very much sounds like a combination of ideas that are found in LLVM combined with features from modern workbench IDEs. You might want to read about the architecture of Eclipse.

            Eclipse was a popular development “workbench” that allowed you to plug in various tools at every level and stage of development and configure them to your taste, as well as allowing you to build your own plugins to work with languages in a bespoke way.

            https://www.eclipse.org/articles/Article-Plug-in-architecture/plugin_architecture.html