Announcement

Collapse
No announcement yet.

Universal compilers

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

  • #21
    Originally posted by Rodney Hicks View Post
    Knuth, I did say...

    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.
    Well, you're throwing around quite lots of "universal" Now adding a universal computer. That's the area I personally think we're closest to being universal with the PC architecture.

    And coming back to my original point: the premise of an universal OS sin't something I can get behind. There's too many different needs for an universal OS to cover them all efficiently. Look no further than "universal" office applications. All of them, Word/Writer, Excel/Calc etc. are waaaay to overloaded with features that not a single user on earth utilizes 100% of. But 100% of the features of these programs do get used. Just not be every user. So the features itself have their merit, just not to all users. But everyone has to pay the prize for those apps attempting to be universal.

    It's the same for an OS. Too many different use cases that one OS can cover them all efficiently. And while all features of that OS will be used eventually, most devices/use cases require only certain parts of the OS, leaving behind a lot of "waste".

    And to make this a broader (and controversial) topic: by now every sane person with a bit of common sense should be very well aware that knowingly wasting resources is a sure way to even further the destruction of the human habitat. With every new invention, avoiding "waste" should be a priority, if only to make it a common, second nature mindset.

    Comment


    • #22
      I'm throwing around a lot of 'universals' because once one aspect is capable of being universal, others have to fall into place and become universal to support it or it isn't going to be really universal. Not all at once of course, as you yourself pointed out with the GCC which is getting close to universal, a little here, a little there, and before you know it, we're there.

      A universal computer would be able to give features on demand, rather than the redundancy concept in the overloaded applications.

      If several operating systems can cover the broad range of computer functions, then so can one, and likely without the waste brought about by duplication of features.

      With every new invention, avoiding "waste" should be a priority, if only to make it a common, second nature mindset.
      I agree.
      With proprietary interests no longer supporting viable equipment, waste runs rampant throughout the computer industry. Most of us have several usable computers gathering dust because we can't add features that have become available but not supported on older systems, nor can the older system be adjusted to catch up to current levels.
      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


      • #23
        Here is a later toy to perform the block repeat that MASM uses. In MASM you use it to unroll loop code to try and get it faster. This one is reasonably efficient but if you were serious, it would be a very different design. The ZIP file contains the executable and a test file, a PB fastproc, that shows how the macro is used. It does what it is supposed to do in getting the start and finish notation of the REPEAT macro, duplicates it to the required count and displays it to STDOUT. I suggest you will find that its a lot easier to talk it up than to write a working version. Brian made the point that it is an enormous amount of work to get his language up and going and the discussion I have read here is a task that is magnitudes more complex.
        Code:
        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        
            #compile exe "repeat.exe"
        
            #include "\basic\include\win32api.inc"
            #include "algos.bas"
        
            MACRO Branch = ! jmp
            MACro StorIm = ! mov
        
        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        
            GLOBAL larr() as STRING
        
         FUNCTION PBmain as LONG
        
            LOCAL flen as DWORD
            LOCAL lcnt as DWORD
            LOCAL cntr as DWORD
            LOCAL flag as DWORD
            LOCAL icnt as DWORD
        
            Open "sample.txt" for Binary as #1
              flen = lof(1)                                 ' get the file length
              Get$ #1, flen,TheFile$                        ' load entire file into string memory
            Close #1
        
            lcnt = tally(TheFile$,chr$(13,10))              ' get the line count
            DIM larr(lcnt) as STRING                        ' dimension a string array of that count
            parse TheFile$, larr(), chr$(13,10)             ' parse the file into the array
        
            StorIm cntr, 0                                  ' set the counter to zero
        
          ' -------------------------------------------------
        
            While cntr < lcnt                               ' loop through the lines
              wrd1$ = firstword(larr(cntr))                 ' get first word of line
        
            ' ***********************************************
        
              If lcase$(wrd1$) = "repeat" Then
                wrd2$ = second_word(larr(cntr))
        
                lbl0:                                       ' subloop to get contents of repeat block
                  cntr = cntr + 1                           ' increment counter
                  wrd1$ = firstword(larr(cntr))             ' get each first word
                  If lcase$(wrd1$) <> "endm" Then           ' if its not endm
                    apnd$ = larr(cntr)+$CRLF
                    acum$ = acum$ + apnd$                   ' append to accumulation buffer
                    Branch lbl0                             ' then loop back
                  End If
        
                outp$ = repeat$(val(wrd2$),acum$+$CRLF)     ' repeat the content
                cntr = cntr + 1                             ' increment counter to avoid "endm"
                StdOut outp$;                               ' write each expanded macro to STANDARD OUT
        
              End If
        
            ' ***********************************************
        
              StdOut larr(cntr)                             ' display normal lines
              cntr = cntr + 1                               ' increment line counter
        
            wEnd
        
          ' -------------------------------------------------
        
            waitkey$
        
         End FUNCTION
        
        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        Attached Files
        hutch at movsd dot com
        The MASM Forum

        www.masm32.com

        Comment


        • #24
          Computer manufacturers want to sell computers so they add advanced features. OS manufacturers want to sell OSs so they add advanced features. Software manufacturers want to sell software so they add advanced features. Device manufacturers want to sell devices so they add advanced features.

          If the system is voice controlled and touch controlled then there is no need for a hardware keyboard or mouse. If the system has voice output and a wireless screen input/output then there is no need for an integrated display.

          You call that NGATS-Next Generation Automatic Test System. Fully software configurable. You want an OHM meter? Done. You want a Voltmeter? Done. You want a WATT meter? Done etc.

          At some point you just have to say "Enough is enough" pick a standard and go with it or if no adequate standard exists then create one. You will still have to upgrade to a new system every 5 - 10 years if you want to stay current. If you are not interested in staying current then the numbers change to 15 - 25 years (numbers may change with the propensity of lightning strikes).

          Comment


          • #25
            Brian made the point that it is an enormous amount of work to get his language up and going and the discussion I have read here is a task that is magnitudes more complex.
            Well, in spite of my tendency to make it seem simple, I am very much aware of the complexity of the concept, yet, if we look around and in depth, we'll find that almost all aspects have been addressed to varying degrees. And others besides Brian have poured energies beyond measure into their field of expertise. This trend can and will continue. Things will get more complex yet if everyone has a different goal and focus. After forty years of home computers, we really haven't come that far.

            Computer manufacturers want to sell computers so they add advanced features. OS manufacturers want to sell OSs so they add advanced features. Software manufacturers want to sell software so they add advanced features. Device manufacturers want to sell devices so they add advanced features....
            Precisely, and I said in the first post of this thread that proprietary interests will be the biggest stumbling block.

            At some point you just have to say "Enough is enough" pick a standard and go with it or if no adequate standard exists then create one.
            So I have picked the universal standard.

            I can see no reason why PowerBASIC users cannot lead the charge.
            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


            • #26
              So we have got this concept of a universal semicompiler with standard interfaces from the programming language and to the compiler.

              And I think I agree with George - the GUI will be fun!!!

              But you know, I think we could have a standard GUI interface. In other words the GUI aspects of the programming language are passed on to the GUI semicompiler in a standard interface and are then 'GUI semicompiled' and passed onto the compiler in a standard interface. I think that this may not be as big a problem as our first thoughts.

              So now we have the programming language having two outputs - one to the processing semi-compiler and one to the GUI semicompiler and the backend compiler having two input standard interfaces - one from the processing semi-compiler and one from the GUI semicompiler.

              Maybe we have other divisions in the semicompiler as well. But possibly not.

              Surely in this world of AI, this is one of the simpler tasks.

              And PB would certainly be in the list of possible development tools.

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

              Comment


              • #27
                And I think I agree with George - the GUI will be fun!!!
                I think it will all be fun, except when it isn't.

                We are looking at a many tentacled behemoth that no one person shall fully understand all its components and how they all fit together. In fact, even the computer may not be capable of comprehending its universal nature, what with sections handing duties to other sections according to specific needs or protocols.

                While proprietary interests may be a stumbling block to begin with, I think that within the system there will be plenty of room for interests of that nature, with attached responsibilities, of course.

                At this early stage of discussion it is interesting to note the differences, in concepts, effectiveness, acceptance(or non), etc. All must be accommodated to have a truly universal device.

                I expect that this process has already started, possibly with the GCC that Knuth pointed out, but also Brian's work, and PB itself, whether or not we are aware that this is happening.

                Integral components will start circling about each other and connecting, or being connected to without actively seeking such.
                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


                • #28
                  Rodney

                  I think I am saying..

                  'If we decide it is possible, then it is possible'

                  And I am going to add - and once we step back - it is not too formidable.

                  In my own experience, once you start to set the parameters, things start falling into place
                  [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                  Kerry Farmer

                  Comment


                  • #29
                    I think you're right, Kerry!

                    And just like that, we've begun to begin....

                    So anyone with parameters,- steps to take, targets, order of significance, etc. Let's hear them here.

                    We need the least important as much as the most important, and believe it or not, even some in jest( to help keep us humble ).

                    Some items will be moved to the forefront, some latered until our contribution begins to crystalize.

                    For the nonce, this will be by consensus.
                    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


                    • #30
                      @ All...This is possible. Of course it is possible. But you need to realize the monstruosity of project you guys are trying to take on.
                      it is not just a project of a weekend, or a 1 or 2 year project. If you really wanna do this, you need to realize you will need to sacrifice
                      A LOT of your life. Your wife may think you dont love her... Your sleep pattern will be messed... your belly fat will accumulate... your hair
                      may fall (or you may end up pulling it clean off!)... you may even begin to understand why some people deceases at only 65...

                      And... NO. I am not kidding.

                      But... if your mind is set on doing this, start with a tokenizer. Create a FAST tokenizer that splits words and labels them. For example,
                      a UDT with several members, like keytype and reserved. This will be useful for parsing the code. Instead of comparing strings,
                      many times, make the tokenizer label them ONCE, this will speed up the engine a lot. Then use the labels to parse the code like this:

                      Code:
                      IF Wrd(num).keytype = %WORD_RESERVED THEN
                          SELECT CASE Wrd(num).reserved
                              CASE %RESERVED_IF
                              CASE %RESERVED_THEN
                          END SELECT
                      END IF
                      This and using ASM where possible, are the only way to make it as fast as you are used to.

                      I suggest your tokenizer contains (at least) the following members:
                      • flags ' a quad variable for flags... you will probably need more than 64 bits over the years!
                      • address ' the address where the word begins.
                      • length ' the length of the word.
                      • keytype ' type of word, for example, equate, string, number, function, sub, bracket... etc.
                      • reserved ' ID for a reserved word, make them equates. You will need hundreds.
                      You will probably need a few more.








                      www.pluribasic.com

                      Comment


                      • #31
                        Yes, Brian, such a thing is possible and the personal aspects will test the conviction to the end result. Except, I don't see an end result, for any system will have to adapt to new knowledge, conditions, aspirations, capabilities, and needs, to name a few things for the future.

                        Computing is here to stay, even if we programmers aren't.
                        Computing has come a long way in the roughly forty years of personal computers, but there is still lots of room for improvement.

                        The current arrangement of computer facilities is approaching a pseudo universal computer, but it has too much duplication and hence, waste.

                        So the need is there for a rebuild from the ground up.

                        Strangely enough, I already have code similar to that which you posted, but probably not as much as you.
                        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


                        • #32
                          Originally posted by Rodney Hicks View Post
                          ...I already have code similar to that which you posted, but probably not as much as you.
                          Is it Open source? Im curious to see it.

                          www.pluribasic.com

                          Comment


                          • #33
                            Is it Open source? Im curious to see it.
                            No, it's not Open source, at least at the moment.
                            I have string equates and corresponding numeric equates as such.
                            Code:
                                $KW_IF      = "IF "
                                $KW_THEN    = " THEN "
                                $KW_ELSEIF  = "ELSEIF "
                                $KW_ELSE    = "ELSE "
                                $KW_ENDIF   = "END IF"
                                $KW_SELECT  = "SELECT "
                            and corresponding numeric equates.
                            %KW_IF, %KW_THEN, %KW_ELSEIF, %KW_ELSE, %KW_ENDIF, %KW_SELECT
                            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


                            • #34
                              If you want top speed, In a few years you will probably wish to:
                              • Get rid of string equates,
                              • Fill an array with all reserved words (preferrably sorted alphabetically).
                              • Refer to reserved words as its numeric index. Never comparing strings more than once.
                              Once a good tokenizer identifies a reserved word and labels it as a numeric expression, there should be
                              no need to consult the string version of it anymore unless you want to check the character case. And
                              even in those counted times, a simple macro will do the trick, for example:

                              Code:
                              RESWORD(%KW_THEN)
                              Trying to save you years worth of optimizations.
                              www.pluribasic.com

                              Comment


                              • #35
                                I understand what you are saying.
                                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


                                • #36
                                  Rod,

                                  Something that may be useful to you if you have not already used it is the vector table method for a "Select Case" block.
                                  Code:
                                        Select Case as CONST$ wrd1$                   ' use a vector table
                                  There are faster ways to do this when you have a known reserve word list but in high level code this method is no slouch. From what Brian has mentioned he is using a linear scanner which is much how a C compiler works but if you load the source code in an array of lines you can scan the first word then feed it through a vector table and branch to the appropriate processing code from there.
                                  hutch at movsd dot com
                                  The MASM Forum

                                  www.masm32.com

                                  Comment


                                  • #37
                                    I've been following quietly and do NOT want to sidetrack this thread, BUT... (famous way of negating what's been stated...)
                                    I would like to make 2 observations as food for thought. These do not require detailed responses, but perhaps high strategic level discussion might be applicable.

                                    1. When the PC first came out with hard drives, I believe you could choose to partition it to boot from either DOS or a Pascal-based OS. WHY? Because at that time, Pascal was thought to be "the way of the future". The Pascal compilers were all designed to take the output from the user interface and generate intermediate code ("P-code"). In turn, the P-code would be fed to the compiler to generate executable machine code. There was much talk about the universal nature of this approach, its extensibility, and its fundamental longevity. This was the golden solution, and it was SO compelling that Microsoft and IBM hedged their bets as to the longevity of DOS, and provided the alternative - a Pascal-based OS.
                                    Well, we can see where that went... the practicality of DOS' ease of use vs that of Pascal, and Poof! the wise but theoretical strategy of P-code disappeared (eventually).
                                    Not saying it cannot be done nowadays, but there are lessons to learn from a good study of the factors that led to the demise of the P-code approach. Maybe it was too far ahead of its time, or maybe it was simply commercial/marketing pressure, but I think it would be helpful to this discussion to learn from the history of Pascal.

                                    2. SmallTalk - marketed by Digitalk in the mid-1990's. This was a fascinating thing to behold! My first introduction to an Object-Oriented language, it featured "toolboxes" of GUI components that could be drag-and-dropped onto the work surface, then the inputs and outputs connected graphically. It was possible to create a prototype of your target program in just minutes. There is a competent history of Smalltalk on Wikipedia, and it's worth 20 minutes to read. Of interest are two aspects: OO, and bytecode.
                                    The intelligence behind the OO concept was wonderful, but it hit the dominant wall of linear (Von Neumann) programming, implemented at every level: the very structure of TTL logic chips, the BIOS, the CPU, and the matching structure of DOS and all the programming languages...
                                    What's interesting to me is that, unlike Pascal, OO has made steady progress, has gotten into more and more environments, has overcome the original limitations of interfaceing to linear data (like SQL databases), and is apparently becoming the new platform for a future OS (refer to MS' UWP).

                                    Based on this incredibly irrelevant sampling of only 2 situations, making anything further I write subject to intense logical destruction, I offer this thought as grist for the design mill of the Universal Compiler being discussed here...

                                    - Design it to run on an OO OS.
                                    - Design it to be built on the OO model.
                                    - Design it to generate code that will run in an OO environment, and interface with OO data...

                                    With all the effort that could be required, I feel it would be a shame to pour wives, bellies, and deaths into something that would be a great addition to an environment that is obsolete...

                                    OK, I'll go back to learning more about PB and the Jose Roca includes now (making good use of what is at hand), and leave the future visioning to you experts.

                                    Thanks for taking these observations into consideration, even if you ultimately decide to ignore any and all of them.

                                    But I do sincerely hope this is of some value as the thoughts are kicked around...

                                    My best regards and admiration to you all!
                                    -John




                                    Comment

                                    Working...
                                    X