1幎ã»ã©åã Ember.jsã«ã¯å€§ããªå€æŽãå ããããŸããã LinkedInã®ãšã³ãžãã¢ãšãªãŒãã³ãœãŒã¹ã³ãã¥ããã£ã®ç·å¯ãªååã«ãããEmberã®ã¬ã³ãã©ãŒãšã³ãžã³ãæ°ããã©ã€ãã©ãªGlimmer VMã«çœ®ãæããŸãããããã«ãããããã©ãŒãã³ã¹ãåäžããã³ã³ãã€ã«ããããã³ãã¬ãŒãã®ãµã€ãºãå€§å¹ ã«åæžãããŸããã
Glimmerã¯Handlebarsãã³ãã¬ãŒããé¢æ°åããã°ã©ãã³ã°èšèªãšåŒã³ããã©ãŠã¶ãŒã§å®è¡ã§ããäžé£ã®åœä»€ã«ã³ã³ãã€ã«ããŸãã ãããã®åœä»€ããŸãã¯ãªãã³ãŒãïŒããããã®ãã©ã³ã¹ã¬ãŒã¿ãŒãªãã¬ãŒã·ã§ã³ã³ãŒãïŒã¯ãJSONã®åœ¢åŒã§ã³ã³ãã¯ããªããŒã¿æ§é ã«ãšã³ã³ãŒããããŸãã
linkedin.com Webã¢ããªã±ãŒã·ã§ã³ãGlimmerã«ç§»è¡ãããšãããŠã³ããŒãæéãå€§å¹ ã«æ¹åãããŸããã ãã¡ã€ã«ãµã€ãºã40ïŒ åæžããããšã«å ããŠãJSONã§ãã³ãã¬ãŒããã³ã³ãã€ã«ããããšã«ããããã©ãŠã¶ãŒãJavaScriptã®è§£æã«è²»ããæéãåæžããŸããã ããã«ããã®å€æŽã«ãããã±ãŒã¹ã®90ïŒ ã§èªã¿èŸŒã¿æéã1ç§ä»¥äžæ¹åãããŸããã
ãã®èšäºã§ã¯ãã³ã³ãã€ã«ããããã³ãã¬ãŒãã解æããã®ã«å¿ èŠãªæéãå®å šã«ãªããããšã§ããŒãæéãããã«æ¹åããããã®æè¿ã®å®éšã«ã€ããŠèª¬æããŸãã
Glimmer.jsã䜿çšããå®éšã®é瀺
çŽ6ãæåãEmber.jsããŒã ã¯Glimmer.jsã®ãªãªãŒã¹ãåå¥ã®ã³ã³ããŒãã³ãã©ã€ãã©ãªãšããŠçºè¡šããŸããã ãã¬ãŒã³ããŒã·ã§ã³ã¬ã€ã€ãŒãåé¢ããããšã§ãEmberãšGlimmerã®ä»®æ³ãã·ã³ãæ倧éã«æŽ»çšããæ°èåžå Žåãã®ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãSEOããŒãžãªã©ã®è»œé補åãäœæããéçºè ã«åŒãç¶ãããšãã§ããŸããã
Glimmerã®ãã¬ãŒã¯ã¹ã«ãŒã«ãããç§ãã¡ã®ããŒã ã¯æ¬¡ã®æã«å€ãã®å®éšãè¡ãããšãã§ããŸããã
ããšãã°ãæè¿ãç§ãã¡ã¯ãã€ããªããã¬ã³ããŒãæ瀺ããŸããããã®ã¬ã³ããŒã§ã¯ãhtmlããµãŒããŒã§çæããããã©ãŠã¶ãŒã§åæ°ŽåãããŸãïŒãã¡ãã®ç¿»èš³è ã®ã¡ã¢ãåç § ïŒã ããã¯ãGlimmerä»®æ³ãã·ã³ã¢ãŒããã¯ãã£ã«ãã£ãŠæäŸãããããã©ãŒãã³ã¹äžã®å©ç¹ã®ã»ãã®å§ãŸãã«éããŸããã
Webçç£æ§ã®èæ¯ã¯ããŠãŒã¶ãŒãã¢ã¯ã·ã§ã³ãå®è¡ãããšãã«ãã°ããèµ·åããããã«æŽæ°ãïŒ60 fpsã®ããã©ãŒãã³ã¹ãç¶æããïŒãããã©ã«ãã®ããã©ãŒãã³ã¹ãæäŸããããšã§ãã ã
åŸæ¥ãã€ã³ã¹ã¿ã³ãããŠã³ããŒããå®è¡ããããã«æå°éã®JavaScriptã³ãŒããæäŸããããšãšãè€éãªã¬ã¹ãã³ã·ãUIã䜿çšããèœåãšã®éã«ã¯ãžã¬ã³ãããããŸãã åºæ¬çãªãã¬ãŒããªãã¯ãã¢ããªã±ãŒã·ã§ã³ãæé·ããã«ã€ããŠçç£æ§ãšçç£æ§ãäœäžããããšã§ãã Glimmerã®ç®æšã¯ã軜éã§é«éãã€çç£çãªã¢ããªã±ãŒã·ã§ã³ãäœæããããšã§ãã ãã®ç®æšãéæããããã®éµã®1ã€ã¯ãã¢ããªã±ãŒã·ã§ã³ã«è¿œå ãããåæ°ããã³ã³ããŒãã³ãã®ã³ã¹ããåæžããããšã§ãã
ã€ã³ã¹ã¿ã³ããã³ãã¬ãŒã
JavaScriptããJSONã«åãæ¿ãããšãã³ã³ãã€ã«ããããã³ãã¬ãŒãã®è§£æã³ã¹ããåæžãããGlimmerãé«åºŠãªãã©ãŠã¶ãŒæ©èœãšçµã¿åãããŠè§£æã¹ããããå®å šã«æé€ããŸããã
ããŠã³ããŒãæéãæé©åããå Žåãã»ãšãã©ã®éçºè ã¯ããŠã³ããŒããé«éåããããã«ãã¡ã€ã«ãµã€ãºãå°ããããããšããŸãã ãã ããJavaScriptããŒã¹ã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ããã©ãŠã¶ãŒãã³ãŒããåæãã³ã³ãã€ã«ãè©äŸ¡ããæ©èœãèµ·åã®ããã©ãŒãã³ã¹ã«åœ±é¿ããŸãã ã¢ãã€ã«ããã€ã¹ã§ã¯ãJavaScriptã³ãŒãã®åæãšã³ã³ãã€ã«ããã¹ã¯ãããã³ã³ãã¥ãŒã¿ãŒã®2ã5åé ããããããã¯éèŠã§ãã ããã ããå¯äžã®ã¹ãããã¯ã¢ããªã±ãŒã·ã§ã³ã®å šäœçãªããã©ãŒãã³ã¹ã«å€§ãã圱é¿ããŸãã
ä»æ¥ãã»ãšãã©ã®ãã¬ãŒã ã¯ãŒã¯ã¯ãã¥ãŒïŒãã¥ãŒïŒãJavaScripté¢æ°ã«ã³ã³ãã€ã«ããŸãã ãã®ãããªJavaScriptã³ãŒãã®è§£æã³ã¹ãã¯ãã°ãã°é ãããæ°ããæ©èœãè¿œå ããããšãã¢ããªã±ãŒã·ã§ã³ã®å®è¡ã¯ãŸããŸãé ããªããŸãã
åè¿°ã®ãšãããGlimmerã¯ãã¿ãŒã³ãäžé£ã®ãªãã³ãŒãã«ã³ã³ãã€ã«ããJSONãšããŠãã©ãŠã¶ãŒã«æž¡ããŸãã JSONææ³ã¯JavaScriptææ³ãããã¯ããã«åçŽã§ãããããåãããŒã¿ã解æããå ŽåãJSONããŒãµãŒã¯JavaScriptããŒãµãŒããã10åéãåäœã§ããŸãã
ããããããã¯ãã¹ãŠåãã§ããããã³ãã¬ãŒãã®ãµã€ãºã倧ãããªããšè§£ææéã¯é·ããªããŸããããã§ã«é ããªã£ãŠããŸãã 解æã¹ããããåé¿ã§ãããã©ãã§ããããïŒ
è¿å¹Žããã©ãŠã¶ã¯ãã€ããªããŒã¿ãå®å šã«åŠçããããšãåŠã³ãŸããã ArrayBufferãªã©ã®äœã¬ãã«APIã䜿çšãããšãJavaScriptããã°ã©ã ã¯ãã€ãã£ãããŒã¿ãšåçã®é床ã§ãã€ããªããŒã¿ãåŠçã§ããŸãã ãããå©çšããŠãGlimmerä»®æ³ãã·ã³ãçŽæ¥å®è¡ã§ããç¬èªã®ãã€ãã³ãŒã圢åŒã«ãã³ãã¬ãŒããã³ã³ãã€ã«ããŸããã JVMãã€ãã³ãŒã圢åŒãšåæ§ã«ãGlimmerãã€ãã³ãŒãã¯ãã©ãããã©ãŒã ã«äŸåããªããã€ããªåœ¢åŒã§ãããGlimmerä»®æ³ãã·ã³ã®äžé£ã®åœä»€ããªãã³ãŒããšãã®æŒç®åã®ãã€ãã¹ããªãŒã ã«ãšã³ã³ãŒãããŸãã JSONãŸãã¯JavaScriptã®è§£æã®ããã©ãŒãã³ã¹ã«äŸåãã代ããã«ããã©ãŠã¶ãŒãããããã¯ãŒã¯ããçã®ãã€ããã³ããŒããæ©èœã«ãã£ãŠã®ã¿å¶éãããããã«ãªããŸããã
Glimmerãã€ãã³ãŒããšã³ã³ãŒãã£ã³ã°
å€ãã®ä»®æ³ãã·ã³ãšåæ§ã«ãGlimmerä»®æ³ãã·ã³ã®æ瀺ã¯æ°åã§èªèãããŸãã ãã€ãã³ãŒãã¯ããããã®æ°åã®ã³ãŒãåãããã·ãŒã±ã³ã¹ã§ãã Glimmerã®ç¬èªæ§ã¯ããã®ã³ãã³ãã»ããããã©ãŠã¶ãŒã§DOMãã¬ã³ããªã³ã°ããããã«èšèšãããŠãããšããäºå®ã«ãããŸãã
ããšãã°ããã³ãã¬ãŒã
<h1>Hello World</h1>
ãã«ãæã«æ¬¡ã®JSON圢åŒã«ã³ã³ãã€ã«ãããŸãã
[ ["open-element", "h1", []], ["text", "Hello World"], ["close-element"] ]
ãã©ãŠã¶ã§ãJSON圢åŒãã³ã³ãã€ã«ããæåŸã®ã¹ãããã§ãæ°åã®é åã«å€æããŸããåæ°åã¯ãªãã¬ãŒã·ã§ã³ã³ãŒããŸãã¯ãªãã©ã³ãã§ãã
const Program = [25, 1, 0, 0, 22, 2, 0, 0, 32, 0, 0, 0];
JSONã®æååãæŽæ°ã«çœ®ãæããããŠããããšã«æ³šæããŠãã ããã ããã¯ããããããæååã€ã³ã¿ãŒã³ãæè¡ã䜿çšããåäžè¡ã®éè€ãæé€ããããã§ããããã§ã¯ãæååã¯æååå®æ°ã®ããŒã«å ã®ãªãã»ããã«çœ®ãæããããå®éã«ã¯ãã¡ã€ã«ãµã€ãºãå€§å¹ ã«åæžããŸãïŒæååå®æ°divãäœåç¹°ãè¿ãããæ³åããŠãã ããïŒãã³ãã¬ãŒãïŒã
æåã«ããã€ãã³ãŒãã¯åæäœã4ã€ã®32ãããæŽæ°ãšããŠãšã³ã³ãŒãããŸãããæåã®32ãããã®æ°åã¯æäœã®çš®é¡ïŒãªãã³ãŒãïŒãè¡šããæ®ãã®96ãããã¯æ倧3ã€ã®åœä»€åŒæ°ïŒãªãã©ã³ãïŒãè¡šããŸãã
ãã®ã¢ãããŒãã¯ã³ãŒãã®å®è¡ã«å¹æçã§ãããšããäºå®ã«ããããããããã€ãã¹ããããŸã-ãã€ãã³ãŒããæã€ãã¡ã€ã«ã®ãµã€ãºã¯å¿ èŠä»¥äžã«å€§ãããªããŸãã ããã¯ãã»ãšãã©ã®åœä»€ããªãã©ã³ããå¿ èŠãšããªããã1ã€ã®ãªãã©ã³ãã®ã¿ãåãå ¥ããã«ãããããããåžžã«3ã€ã®ãªãã©ã³ãçšã«ã¹ããŒã¹ã確ä¿ããŠããããã§ãã ãããã£ãŠãããã°ã©ã ã¯ç©ºã®ãã€ãã§ãã£ã±ãã«ãªããŸããã空ã®ãã€ãã¯ååšããªãã¯ãã§ãã ããã«ãGlimmeråœä»€ã»ããã«ã¯80åã®ãªãã³ãŒãããå«ãŸããŠããªãããããªãã³ãŒãã®äºçŽã¹ããŒã¹ã8ãããã«æžããããšãã§ããŸãã
æçµçã«ãããã³ã³ãã¯ããªã³ãŒãã£ã³ã°ã¹ããŒã ã«æ±ºå®ããŸããããããã¯ãŸã 16ãããã§ããã æåã®8ãããã¯ãªãã³ãŒãã§ã次ã®2ãããã¯ãªãã©ã³ãã®æ°ããšã³ã³ãŒãããããã«äœ¿çšãããæåŸã®6ãããã¯å°æ¥ã®äœ¿çšã®ããã«äºçŽãããŠããŸãã åãªãã©ã³ãã¯ãããããã°ãè¿œå ã®16ãããã§ãšã³ã³ãŒããããŸãã
ãã®ãšã³ã³ãŒãã¹ããŒã ã§ã¯ãååœä»€ã¯2ã6ãã€ãã䜿çšã§ãã次ã®ããã«ãªããŸãã
/* Fixed Opcode */ /* Operand? */ /* Operand? */ /* Operand? */ [0bIIIIIIIILLRRRRRR, 0bAAAAAAAAAAAAAAAA, 0bAAAAAAAAAAAAAAAA, 0bAAAAAAAAAAAAAAAA] /* I = instruction (opcode) type L = operand length R = reserved A = operand value */ view raw
ãã®æ°ããã¹ããŒã ã«ãããã³ã³ãã€ã«ãããããã°ã©ã ã®ãµã€ãºã50ïŒ åæžãããŸãã ãã®åè·¯ã®ãã³ãŒãã«ã¯ããããããã¹ã¯ããŠã·ãããããªãã³ãŒãã®é·ããšãªãã©ã³ãã®é·ããèŠã€ããã ããªã®ã§ãå°ããªãªãŒããŒãããããããŸãã
ãã€ãã³ãŒããšJavaScriptã®ã®ã£ãããåãã
ééããåé¡ã®1ã€ã¯ãã³ã³ãã€ã«ãã§ãŒãºå šäœããããžã§ã¯ããã«ããŒã«ç§»è¡ããããšã§ããã åã«ãã¢ããªã±ãŒã·ã§ã³ã®JavaScriptã³ãŒããèªã¿èŸŒãŸãããšããã«ããã©ãŠã¶ãŒã§ãã³ãã¬ãŒããã³ã³ãã€ã«ããæåŸã®æé ãå®è¡ããŸããã ããã«ãããã³ã³ãã€ã«ããããã³ãã¬ãŒããããŠãŒã¶ãŒã¢ã¯ã·ã§ã³ãåŠçããã³ã³ããŒãã³ãã¯ã©ã¹ãªã©ã®JavaScriptãªããžã§ã¯ãã«æ¥ç¶ã§ããŸããã
æåã®ã¹ãããã¯ãNode.jsã§ãã¹ãŠã®ã¬ãã«ã®ã³ã³ãã€ã«ãæäŸããããšã§ããã ããã³ãã«ã³ã³ãã€ã©ããšåŒã°ããæ°ããã€ã³ã¿ãŒãã§ã€ã¹ãäœæããŸãããããã¯ããã¹ãŠã®ã³ã³ãã€ã«ã¬ãã«ãåäžã®APIã«ã«ãã»ã«åããã¢ã»ã³ããªããŒã«ãããã³ãã«ããã³ãã¬ãŒãããã€ãã³ãŒãã«å€æã§ããããã«ããŸããã
次ã«ãè¿œå ã®åé¡ã«çŽé¢ããŸããããã€ãã³ãŒãã«ã³ã³ãã€ã«ãããšããå®è¡æã«ãã®ãã€ãã³ãŒããæ£ããJavaScriptãªããžã§ã¯ãã«ãæ¥ç¶ãããæ¹æ³ã¯äœã§ããïŒ ãã®åé¡ã解決ããããã«ãããã³ãã«ãïŒãã³ãã©ãŒïŒã®æŠå¿µãå°å ¥ããŸããã ãã³ãã©ãŒã¯ãã³ã³ããŒãã³ãããã«ããŒãªã©ããã³ãã¬ãŒãå ã®å€éšãªããžã§ã¯ãã«é¢é£ä»ããããäžæã®æ°å€èå¥åã§ãã ã³ã³ãã€ã«æã«ãåå€éšãªããžã§ã¯ãããã€ãã³ãŒãã§ãšã³ã³ãŒãããããã³ãã©ãŒã«é¢é£ä»ããŸãã ããšãã°ã <UserProfile />ã³ã³ããŒãã³ãã®åŒã³åºããèŠã€ãã£ãå Žåããããèå¥å42ã®ãã³ãã©ãŒã«é¢é£ä»ããããšãã§ããŸãïŒ41ã®äžæã®ã³ã³ããŒãã³ããæ¢ã«åŒã³åºãããŠãããšä»®å®ããŸãïŒã
ãã®ãããªã³ã³ããŒãã³ããåŒã³åºããšãGlimmeråœä»€ã»ããã®ããã€ãã®ãªãã³ãŒãã«ã³ã³ãã€ã«ãããŸãã ãããã®åœä»€ã®1ã€ã¯ãJavaScriptã³ã³ããŒãã³ãã¯ã©ã¹ãä»®æ³ãã·ã³ïŒVMïŒã¹ã¿ãã¯ã«ããã·ã¥ãã0x003b PushComponentDefinitionã§ãã ãã€ãã³ãŒãã«ã³ã³ãã€ã«ããããšããã®åœä»€ã¯4ãã€ã0x00 0x3b 0x01 0x2AãäœæããŸãã æåã®2ãã€ãã¯ã PushComponentDefinitionãªãã³ãŒãããšã³ã³ãŒãããŸãã 2çªç®ã®2ãã€ãã¯ãªãã©ã³ãïŒãã®å Žåã¯ãã³ãã©ãŒïŒçªå·42ïŒïŒããšã³ã³ãŒãããŸãã
ããã§ã¯ããã©ãŠã¶ã§ãã€ãã³ãŒããå®è¡ãããšã©ããªããŸããïŒ æŽæ°42ãçãçããšããJavaScriptã¯ã©ã¹ã«å€æããæ¹æ³ã¯ïŒ ãã®ããªãã¯ããå€éšã¢ãžã¥ãŒã«ããŒãã«ããšåŒã³ãŸãã ããã¯ãçæãããJavaScriptã³ãŒãã®å°ããªæçã§ããã2ã€ã®äžçãçµã¿åãããŠããã³ãã©ãŒã察å¿ããJavaScriptã¯ã©ã¹ã«å¹ççã«ãããã§ããããŒã¿æ§é ãå®çŸ©ããŸãã
ãã®äŸã§ã¯ã UserProfileã42ãã³ãã©ãŒã«é¢é£ä»ãããããå€éšã¢ãžã¥ãŒã«ããŒãã«ã¯é åã§ããã UserProfileã¯ã©ã¹ã¯é åå ã®42åã®èŠçŽ ã§ãã
import UserProfile from './src/ui/components/UserProfile/component'; /* ...other component imports */ export let table = [ /* Component1 */, /* Component2 */, /* ... */, /* Component41 */, UserProfile, /* Component43 */, /* ... */ ];
ãã€ãã³ãŒãã®å®è¡äžã«ãããªãŸã«ããŒããšåŒã°ãããã«ããŒãªããžã§ã¯ãããã³ãã©ãŒãé©åãªJavaScriptãªããžã§ã¯ãã«å€æããŸãã åãã³ãã©ãŒã¯é åå ã®ãªãã»ããã§ãããããããã®ã³ãŒãã¯ç°¡åã§é«éã§ãã
resolve<U>(handle: number): U { return this.table[handle]; }
.gbx圢åŒïŒGlimmer Binary ExperienceïŒã§ãããžã§ã¯ãããã«ããããã©ãŠã¶ãŒã«è»¢éããŠããã©ãŠã¶ãŒã§ããããŒãã¬ã³ããªã³ã°ããŸãã
次ã¯äœã§ãã
ãã€ãã³ãŒãã³ã³ãã€ã©ãå éšã¢ããªã±ãŒã·ã§ã³ã«çµ±åããã ãã§ãGlimmer.jsã®æŠå¿µã蚌æããããã«æ¬çªã¢ããªã±ãŒã·ã§ã³ã§å®éã®çµæãåéã§ããããšã楜ãã¿ã«ããŠããŸãã ããã¯ãããŸããŸãªããŒããŠã§ã¢ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ããã©ãŠã¶ãããã³åž¯åå¹ ã®çµã¿åããã«å¯ŸããããŸããŸãªã¢ã¯ã¿ãŒã䜿çšããŠãçŸå®äžçã«ããããããã®å€æŽã®åœ±é¿ãè©äŸ¡ããã®ã«åœ¹ç«ã¡ãŸãã
Glimmerãã€ãã³ãŒãã¯ãã¡ã€ã«ãµã€ãºãåæžããæåŸã®ã¹ãããã®è§£æãšã³ã³ãã€ã«ã®ã³ã¹ããå®å šã«æé€ãããããç¹ã«CPUãããã«ããã¯ãšãªãããŒããŠã§ã¢æ©èœã®äœãããã€ã¹ã§ã¯ãã¢ããªã±ãŒã·ã§ã³ã®èµ·åæéã®å€§å¹ ãªæ¹åãæåŸ ãããŸãã ããã«éèŠãªããšã¯ãæ確ã«å®çŸ©ããããã€ããªåœ¢åŒã®æ¹åã«ä»®æ³ãã·ã³ã®ãã¡ã€ã«åœ¢åŒãšå éšèŠçŽ ã調æŽããããã»ã¹ã¯ãå°æ¥çã«å€ãã®èå³æ·±ãå®éšãéãããšã«ãªããŸãã ç¹ã«ãéžæãããã€ãã³ãŒã圢åŒã¯ãGlimmerä»®æ³ãã·ã³ã®äžéšãWebAssemblyãã¯ãããžãŒã«åããŠèª¿æ»ããã³å€æŽãã解æã³ã¹ããåæžããå®è¡æã®ããã©ãŒãã³ã¹ãããã«åäžãããããšãã§ãããšããæå³ã§ãã
LinkedInã®ç§ãã¡å šå¡ããªãŒãã³ãœãŒã¹ã®å€§ãã¡ã³ã§ãããäžèšã®ãã¹ãŠã®äœæ¥ã¯GitHubã§å ¬éãããŠããŸããã Glimmerãããžã§ã¯ãã«èå³ãããå Žåã¯ãGitHubã®Glimmer VMããã³Glimmer.jsãªããžããªã«æåŸ ããŸãã
è¬èŸ
LinkedInã§ãã€ãã³ãŒãã®ç·šéã«æºãã£ãChad HietalaãšTom Daleã«æè¬ããŸãã ããã«ããªãŒãã³ãœãŒã¹ã³ãã¥ããã£ã§ãã®ããžã§ã³ãå®çŸããããã«ååããŠãããYehuda KatsuãšGodfrey Chenã«æè¬ããŸãã