Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

What came first: A compiler or a code?

Discussion in 'General Discussion' started by elmar1028, Jan 29, 2016.

  1. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    7,524
    Is there a word for these binary option questions that don't allow any depth of thought?

    *Found it online this question is a false dilema https://en.wikipedia.org/wiki/False_dilemma

    Does anyone else dislike this type of question, in a world of possibilities with a rich history only two options are given as possible answers. Like what came first the chicken or the egg, absurdly simplistic thinking the; answer is of course velociraptor.
     
    Kiwasi likes this.
  2. CaoMengde777

    CaoMengde777

    Joined:
    Nov 5, 2013
    Posts:
    813
    people talking about mechanical computers:


    28m 30s is real cool
    mechanical boy figure that writes what u set it to
     
    Last edited: Feb 5, 2016
    Ryiah likes this.
  3. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,156
    Does the human brain count as a compiler for language? Maybe that came first.

    somewhere on topic....

    Chicken or the egg? I think chicken since the egg is the offspring. And the question feels too obvious if you ask what came first : The parent or the offspring? Obviously the parent comes before the child! But maybe I oversimplified it.
     
    Last edited: Feb 15, 2016
  4. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,313
    Reading through the thread made me wonder...

    How was the compiler compiled?
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,265
    It compiled itself*. Current version compiles next version. "compiles itself" means it compiles new compiler binary from source (same thing as with normal program), not that it changes itself while it is running or something like that. Compiler also can compile new copy of current version from source, which may be useful if you wanted to toggle some optimization flags. If you ever tried to build linux system from source, you'd need to deal with something like that at some point.

    The very first compiler was written in assembly.
    The very first assmbler was written as pure machine code.
     
    Martin_H and Ryiah like this.
  6. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    Manually of course. By human hands.

    Why repeat wiki? https://en.wikipedia.org/wiki/Self-hosting
    But it's certainly possible! There is no difference between data and code. It's not an easy task though.
     
  7. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,265
    In the name of Cthulhu/because I can.

    There is a difference, actually. now, my knowledge on the subject is a bit hazy, but.

    Data and code may be placed in different CPU segments and may have different protection. If the code segment is write protected you can't self-modify. You can modify program being debugged, though, but usually that would require elevated/admin privilegies.

    For detail google "protected mode" and "global destriptor table". Now, as far as I know, windows technically uses same segment for data and code (code is still write-protected, though), but this is not the case on linux system where code and data are separate and windows has DEP system.

    So, by default, it is reasonable to expect that code sections are read-only and cannot be changed while program is running. Also, it is reasonable to expect data segment not to have "execute" permission.
     
  8. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    During first compiler time there was no protected mode... And there were tons of tricks on self-modifying code in name of optimizations. Besides there are plenty of ways to workaround those protections. Simplest being is to run launcher, make compiler recompile itself and then launcher to launch new, recompiled code while saving context. Like Unity's hot reload. It'll be slower, but will work.
     
  9. Marionette

    Marionette

    Joined:
    Feb 3, 2013
    Posts:
    349
    You are all wrong. The answer is of course....


    42
     
  10. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,412
    But is that:

    octal 42 = 34 dec
    decimal 42 = 42 dec
    hexidecimal 42 = 66 dec
    ah = 42 when using the the DOS INT 21h function LSEEK 'seek file'

    You're really not being clear here Douglas. Adam's not going to be happy!
     
    Marionette likes this.
  11. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    16,133
    Clearly it's vigesimal. After all everything mysterious has to involve Mayans. :p
     
    larku likes this.
  12. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,156
    I thought vigesimal was a vegetarian number base :eek:
     
    Ryiah likes this.
  13. Marionette

    Marionette

    Joined:
    Feb 3, 2013
    Posts:
    349
    That's the beauty of it. When run through the quantum probability sub-snarfalator, it's still...

    42

    ;)
     
  14. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,442
    Of course the code came first otherwise there would be nothing for the compiler (human or program) to compile. And long ago it was common for code to be hand compiled. In a sense human compilers who converted BASIC and other languages into lower level machine code. The higher languages themselves were generally interpreted on the fly.

    Anyway, it was after a while of manually doing this kind of conversion that someone somewhere thought "you know we could write a program to automate this conversion process." Then compilers eventually became part of the norm for languages such as C and usually an option for BASIC as well. These days even the various BASICs are likely all compiled.

    What a sense of awe it was back then to take a section of an interpreted BASIC program and manually compile it into machine code. Most of the time it ran thousands of times faster.
     
    Ryiah likes this.
unityunity