폴리글롯(컴퓨팅)

Polyglot (computing)

컴퓨팅에서 폴리글롯은 여러 프로그래밍 언어의 유효한 형태로 작성된 컴퓨터 프로그램 또는 스크립트이며,[1] 컴파일 또는 해석에 사용되는 프로그래밍 언어와 독립적으로 동일한 연산 또는 출력을 수행합니다.

일반적으로 폴리글롯은 C(프리프로세서를 사용하여 어휘 토큰을 재정의할 수 있음)와 Lisp, Perl 또는 [citation needed]sh와 같은 스크립트 언어의 조합으로 작성됩니다.

폴리글롯 마크업은 비슷하지만 마크업 언어 컨텍스트에 관한 입니다.

폴리글롯 지속성은 비슷하지만 데이터베이스에 관한 입니다.

폴리글롯 마이크로 서비스를 통해 개발자는 제품을 보다 효율적으로 만들기 위해 자신이 선택한 프로그래밍 언어를 선택할 수 있습니다.업계 전문가들은 어떤 프로그래밍 언어를 개발할지에 대한 통치가 느슨해지면 개발자의 창의성과 즉각적인 문제 [2]해결의 기회가 더 많아질 것으로 보고 있습니다.

방법들

폴리글롯 프로그램을 구축하기 위해 가장 일반적으로 사용되는 두 가지 기술은 코멘트에 다른 문자를 사용하는 언어를 자유롭게 사용하는 것과 다양한 토큰을 다른 언어로 재정의하는 것입니다.구문 기호에 의해 사용되는 경우가 많습니다.ANSI C, PHP bash로 작성된 이 퍼블릭도메인 폴리글로트에서는 다음과 같이 설명하고 있습니다.

#syslog a /* # <?syslog 에코 "\010Hello, world!\n";/ 2> /dev/syslog; x=a; $x=5; // 2> /dev/syslog \; if ($x) 2> /dev/syslog; fi #0; dev/slog; fi #setwork?h> #define main() int main(void) #define printf(#define true) #define 함수 main() {printf "Hello, world!\n" true/* 2> /dev/null grep -v true*; ret0; } #define c/*/define #define prate function #define prate function #definate function #*/

다음의 점에 주의해 주세요.

  • 해시 기호는 C에서 프리프로세서 문을 표시하지만 bash와 PHP에서는 모두 코멘트입니다.
  • "//" is a comment in both PHP and C and the root directory in bash.
  • Shell redirection is used to eliminate undesirable outputs.
  • Even on commented out lines, the "<?php" and "?>" PHP indicators still have effect.
  • The statement "function main()" is valid in both PHP and bash; C #defines are used to convert it into "int main(void)" at compile time.
  • Comment indicators can be combined to perform various operations.
  • "if (($x))" is a valid statement in both bash and PHP.
  • printf is a bash shell builtin which is identical to the C printf except for its omission of brackets (which the C preprocessor adds if this is compiled with a C compiler).
  • The final three lines are only used by bash, to call the main function. In PHP the main function is defined but not called and in C there is no need to explicitly call the main function.

Some less-common languages also offer possibilities to create Polyglot code. Here is a small sample, written simultaneously in SNOBOL4, Win32Forth, PureBasicv4.x, and REBOL:

 *BUFFER : A.A ; .( Hello, world !) @ To Including?  Macro SkipThis; OUTPUT = Char(10) "Hello, World !"  ;OneKeyInput  Input('Char', 1, '[-f2-q1]')  ; Char  End; SNOBOL4 + PureBASIC + Win32Forth + REBOL = <3  EndMacro: OpenConsole() : PrintN("Hello, world !")  Repeat : Until Inkey() :  Macro SomeDummyMacroHere  REBOL  [ Title:  "'Hello, World !' in 4 languages"  CopyLeft:  "Developed in 2010 by Society" ]  Print  "Hello, world !"  EndMacro:  func  [][]  set-modes  system/ports/input [binary: true] Input  set-modes  system/ports/input  [binary: false] NOP:: EndMacro  ; Wishing to refine it with new language ? Go on ! 

The term is sometimes applied to programs that are valid in more than one language, but do not strictly perform the same function in each.[citation needed] One use for this form is a file that runs as a DOS batch file, then re-runs itself in Perl:

 @rem = ' --PERL--  @echo off  perl "%~dpnx0" %*  goto endofperl  @rem ';  #!perl  print "Hello, world!\n";  __END__  :endofperl 

This allows creating Perl scripts that can be run on DOS systems with minimal effort.

See also

레퍼런스

  1. ^ Fjeldberg, Hans (2008). Polyglot Programming - A Business Perspective (PDF) (M.Sc). Norwegian University of Science and Technology.
  2. ^ Gupta, Tripta (2018-12-19). "Analyzing Polyglot Microservices". Medium. Retrieved 2019-08-05.

외부 링크