Announcement

Collapse
No announcement yet.

Universal compilers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Universal compilers

    Because I was instrumental in taking this thread off topic I have started this thread by way of apologizing for my unintentional misbehavior. (Does that get me off the hook?)

    In that thread I mentioned a universal language, meaning binary.

    Since we've moved on from there to 'universal compiler', which has not yet been developed.

    I will state at the outset that the biggest impediment to such is 'proprietary interest', not technology.

    A universal compiler would mean a universal operating system, sort of like the weather, that has no one direct controller and that all can access.

    Because all can access it, it must have a built in vetting system and user privileges must meet a defined standard. It would be one thing to make a phone call or send messages to some location but another thing entirely to allow a program to run.

    As well, a user identification process must be supported across the board. As a general rule, which may have declared exemptions, a user would have an isolated 'sandbox' for testing and proving and from which apply to the vetting system to allow publishing a program in the public domain. A lot of this is going on now, but under proprietary conditions, which while necessary for some genres, some aspects of this are counterproductive.

    Also, such a system must have multiple access locations for each individual.

    Thus, a universal compiler, or more likely a universal compiler suite should be available to all users, and complete with one's natural language access which means translating abilities.

    To this end, these links provide some insight:
    https://en.wikipedia.org/wiki/Natura...ge_programming
    https://en.wikipedia.org/wiki/Literate_programming
    Rod
    "To every unsung hero in the universe
    To those who roam the skies and those who roam the earth
    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

  • #2
    Transferring Brian's last comment:

    Wow.. a bit hard... I would say a compiler that can target any OS. Not Necessarily a compiler, it is already too hard to make a
    compiler for one single platform... for all platforms it would be nearly impossible. PluriBASIC uses the same syntax and uses
    external compilers to target different platforms. For example It uses PowerBASIC for windows' destop applications.

    And noting Rodney's comments...

    We certainly need to define our aim.

    If we say that a compiler has three steps - natural language, semicompiled (or whatever word I should use) and compiled program. Then it seems to me that a universal compiler is one where you can use any natural language, you always use the semicompiled step, and you can have any compiled program for whatever operating system/ machine code. I will have to think about standard interfaces too.

    So if we got a new language called New-Language, all we have to do is to write the interface to the semicompiler and the program can be compiled and ready for any platform.

    Or if we have an old language, then we have to create an interface for the semicompiler and we can then have a compiled program on any platform.

    Here is another link - which helps but is not the full answer - https://softwareengineering.stackexc...-compiler-work
    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
    Kerry Farmer

    Comment


    • #3
      I am getting clearer in my mind about 'my' definition of a universal compiler.

      My definition of a Universal Compiler

      1 You start with the programming language - eg Fortran, C, PB etc. It is not an absolute but you probably need an editor for that language. That language is either quasi English or is a list of codes (or French or German etc). The definition is that this file (and it probably is a file) can be read and understood by someone who understands programming but does not know machine code or agrees that this is a more efficient and effective way of programming - which indeed it is. One definition of a programming language is that one line creates up to many lines in the compiled program. Most lines will create more than one line.

      2 Then you need to define the interface file/s between this programming language and the 'semi-compiled stage'. (Is that the right name?? Another name is ‘Intermediate Code’). This interface will be specific to the programming language but general to the semi-compiler. This interface converts the output from the programming language into input for the semi-compiler. The output will be a file - or maybe several files.

      3 Then you need a semi-compiler. This is constant and independent of the programming language and the compiler. The semi-compiler does all the hard work. The semi-compiler almost certainly has several stages - but not absolutely necessarily. The output is a file or set of files.

      4 Then you need to define the interface file/s between the semi-compiler output and the compiler (is there a better term? The producer of the executable program???) This interface will be standard.

      5 Then you need to compile the program. The input is the semi-compiler output file/s. The output is an .exe file or equivalent executable file/s. There will be a different compiler for each operating system that the program is going to be run on.

      The Universal Compiler advantages
      1. So, if you want to implement a new language, all you have to do is write the interface into the semi-compiler - step 2 above
      2. And if you want to run on another platform, all you have to do is write the compiler ie accept the standard output from the semi-compiler and produce a different form of the executable program


      And behind all this the programs above must all run on a platform too. You could have a suite for Windows and for any other operating system - although one such platform would be enough. - maybe.

      The concept of using one system for compiling in another system is called a cross-compiler - but you know all that and I include it here only for completeness. There are also back-compilers (or de-compilers) for going from an executable to a ‘language’ and boot strap compilers where a program uses its own language to compile itself (which is what Adam is doing – is it not?).

      And is PB a good language to develop all of the above programs in? I would say a resounding 'yes'

      I think one of the confusions of history is that these stages are sometimes combined.

      Does anyone agree?
      [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
      Kerry Farmer

      Comment


      • #4
        Ism't DOTNET and the usage of an IL (Intermediate Language) just that?
        --Theo Gottwald
        ------------------------------------------------
        76706 Dettenheim * Germany * info@it-berater.org
        ------------------------------------------------
        Joses Forum * Theo's Link Site * IT-Berater.org

        Comment


        • #5
          Ism't DOTNET and the usage of an IL (Intermediate Language) just that?
          Similar, but not quite. Just a step along the road.
          Rod
          "To every unsung hero in the universe
          To those who roam the skies and those who roam the earth
          To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

          Comment


          • #6
            Long long ago there were basically scripting languages that could be configured to construct binary code but over time they were replaced by the early high level languages that we see in their more developed form today. Now the only modern successor to this that I know of is the pre-processor in various flavours of MASM. The current versions of 32 and 64 bit MASM both have the ancient pre-processor and while the pre-processor is bad mannered, buggy, badly documented and highly inconsistent, it is in fact very powerful if you are patient enough as it can construct a range from bare mnemonic code to whatever high level code is available.

            You need to have a reasonably powerful parser and design the scripting language with a usable set of primitives that include loop code, substitutions and the like but it can be done, albeit no joy to code. PB has a reasonable macro language available that is head and shoulders better than most compilers but it is missing things like loop code, variable arguments and a number of other things. A powerful enough scripting language needs to be a separate language that writes the type of output code that the design requires.

            I am not going to hold my breath waiting to see it done.
            hutch at movsd dot com
            The MASM Forum

            www.masm32.com

            Comment


            • #7
              Here is the barest bones of a REPEAT macro that is available in languages like MASM for making fixed repeats of a single block of code. It is not particularly efficient code for PB but it gives you some idea of what making even a simple macro is about.
              Code:
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
                  #compile exe "repeat.exe"
              
                  #include "\basic\include\win32api.inc"
              
                  MACRO BranchTo = goto
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
               FUNCTION PBmain as LONG
              
                  LOCAL iflag as DWORD
                  LOCAL rcnt  as DWORD
              
                  iflag = 0                               ' clear the flag
              
                  Open "test.txt" for Input as #1
              
                  Do
                    Line Input #1, a$
                    a$ = ltrim$(a$)
              
                    If iflag = 1 Then
                      If left$(a$,1) <> "'" Then          ' if not another commented line
                        disp$ = disp$ + a$+$CRLF          ' append the line
                      End If
                    End If
              
                    If left$(a$,1) = "'" Then             ' if commented line, test if its a macro
                      a$ = right$(a$,-2)
                      a$ = ltrim$(a$)
              
                      If left$(a$,6) = "repeat" Then
                        rcnt = val(trim$(right$(a$,2)))   ' get the repeat count
                        iflag = 1                         ' set the flag
                      End If
              
                      If left$(a$,4) = "endr" Then
                        iflag = 0                         ' clear the flag
                        disp$ = disp$+$CRLF
                        BranchTo loopexit
                      End If
              
                    End if
              
                  Loop while not eof(1)
              
                loopexit:
                  StdOut repeat$(rcnt,disp$);
              
                  Close #1
              
                  waitkey$
              
               End FUNCTION
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              Attached Files
              hutch at movsd dot com
              The MASM Forum

              www.masm32.com

              Comment


              • #8
                Logic is easy to code for universally (yes there are exceptions), it's the GUI that is the real problem.

                A universal compiler would require a universal set of GUI primitives to allow cross platform use. Many GUI primitives are similar but none are 100% cross platform and some may not exist on some platforms.

                Invent a standard GUI mousetrap...
                <b>George W. Bleck</b>
                <img src='http://www.blecktech.com/myemail.gif'>

                Comment


                • #9
                  Interesting stuff guys, about this i have a LOT to say... but i dont want to bore anybody.

                  Expanding macros is HARD. Really hard. However PowerBASIC MACROs are more powerful now.

                  Originally posted by Steve Hutchesson View Post
                  I am not going to hold my breath waiting to see it done.
                  You probbaly dont need to, im not sure i understand what you mean, but if i understand correctly, you can
                  breathe freely.

                  www.pluribasic.com

                  Comment


                  • #10
                    A universal compiler would require a universal set of GUI primitives to allow cross platform use.
                    Which is why I stated in post #1:
                    I will state at the outset that the biggest impediment to such is 'proprietary interest', not technology.
                    To help with this discussion, I put together an overview. When considering it, remember that what Steve pointed out in posts #6 and 7. Even the smallest aspect has to be considered and incorporated.
                    It is a tad vague, but we're in the early stages.... Work at it from top down generally, and cycle back to top for any user identity. Click image for larger version

Name:	universal_system.gif
Views:	160
Size:	51.3 KB
ID:	782516
                    Rod
                    "To every unsung hero in the universe
                    To those who roam the skies and those who roam the earth
                    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                    Comment


                    • #11
                      All,
                      1) Write code in any standardize language.
                      2) Use translator to interpret and precompile to a USL-Universal Scripting Language (could be binary or text).
                      3) Select the desired output platform/platforms that you want.
                      4) Compile for targeted platform/platforms using the precompiled USL script.

                      Sounds easy enough. I bet Watson could do that with a little training.

                      Comment


                      • #12
                        Originally posted by Rodney Hicks View Post
                        A universal compiler would mean a universal operating system [...]
                        To me, that's a wrong premise. In fact, GCC can be considered to be a universal compiler. As can Java and the .NET compilers.

                        Comment


                        • #13
                          I think Brian Alvarez has been preaching about this for a while now (years). I think he even has a working compiler, to some degree (PluriBasic).
                          Has anyone looked at that?

                          Comment


                          • #14
                            Knuth, I did say...
                            A lot of this is going on now,...
                            I suspect, but I cannot know all things about all systems, that every suggestion I made has some level of presence in the current world. While in some ways, GCC can be considered a universal compiler, and it may be the closest that we have, it is not a universal compiler simply because it does not compile all kinds of code, nor does it access all computing facilities, which would be leading to the universal computer. It seems that it might be a few steps along the way.
                            Rod
                            "To every unsung hero in the universe
                            To those who roam the skies and those who roam the earth
                            To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                            Comment


                            • #15
                              I think Brian Alvarez has been preaching about this for a while now (years). I think he even has a working compiler, to some degree (PluriBasic).
                              Shawn, I started this thread because we were taking one of Brian's threads off topic.
                              Rod
                              "To every unsung hero in the universe
                              To those who roam the skies and those who roam the earth
                              To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                              Comment


                              • #16
                                I think that with a universal OS, there would not be a need for a universal compiler. In fact, i believe multiple operating systems
                                are exactly the reason why there is a need for a universal compiler.

                                I dont want to sound cocky or like a know-it-all, so, i have not been posting much, but i follow this thread with interest!

                                I agree with many ideas here, in fact i already implemented several of them a few years ago.

                                But i would like to comment on the "standarized language" that Jim recently posted. There can be a standarized language, but not necessarily.
                                How about a universal compiler in which you can not only choose your style of programming, but also the language in which you enter code?
                                See image attached.

                                There is a world of possibilities. Certainly a standarized language would be better, but everybody would want their's to be the standard. So...

                                I for one, like PowerBASIC. Are you guys planning on something?

                                www.pluribasic.com

                                Comment


                                • #17
                                  All,
                                  I am also suggesting that the precompiled USL script be HTML; after all, that is what it was designed for. Right? So now we just need a compiler that reads HTML and has the ability to produce runnable code on multiple platforms. Adam are you listening?
                                  The IDE would produce the script and the compiler would produce the executable code. Nice

                                  Comment


                                  • #18
                                    I think that with a universal OS, there would not be a need for a universal compiler. In fact, i believe multiple operating systems
                                    are exactly the reason why there is a need for a universal compiler.
                                    In the graphic I posted, if you look closely you'll notice there is no universal compiler, which agrees with your assessment, but I suspect for different reason(s).
                                    Where I think the major change required is in the initial contact with the computer system. I think it has to be all of the spoken/written languages being manipulated into a broad serving of Steve's concept of MASM.

                                    We already have voice recognition, voice commands, voice to text(and back).
                                    I for one, like PowerBASIC. Are you guys planning on something?
                                    Not yet!
                                    I will say that we could, for these forums are rife with intelligent folk that could do the job. Just don't apply if you want instant results!
                                    Rod
                                    "To every unsung hero in the universe
                                    To those who roam the skies and those who roam the earth
                                    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                                    Comment


                                    • #19
                                      I do not think that a standardized language is a "good idea'

                                      A programming language is designed for a range of operations. FORTRAN for calculations and COBOL for data processing are a good example. Combining them would be a mish mash of complexity.

                                      So 'my' universal compiler would have many languages and multiple platforms for the executable code.
                                      [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                                      Kerry Farmer

                                      Comment


                                      • #20
                                        In a universal computing situation, 'good' ideas may have to take back seat to 'essential' ideas. This too, is already happening in the computer world.
                                        Rod
                                        "To every unsung hero in the universe
                                        To those who roam the skies and those who roam the earth
                                        To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                                        Comment

                                        Working...
                                        X