SlideShare una empresa de Scribd logo
1 de 4
Descargar para leer sin conexión
MetaJS
Knowledge-oriented programming language

Dmytro Dogadailo
October, 2013
http://metajs.coect.net
Purpose
MetaJS is knowledge-oriented programming language. MetaJS compiler can generate source code,
intentionally missed by programmer. This approach leads to loosely coupled and highly dynamic
programs. MetaJS is a dialect of Lisp and provides many of the typical Lisp features including
powerful macro system. It compiles to Javascript without runtime dependencies.

Function
Typical usage scenario: signature of a library function is changed but all arguments for new version
of the function can be found in the call context. MetaJS can adapt all calls of such function to the
new signature automatically. A programmer starts to use less nouns (local variables and function
arguments) and more verbs (function calls). MetaJS compiler finds what does the programmer mean
from semantic model of the program and surrounding context.

Motivation
Today compilers analyze only the grammar of the language and ignore the semantics of each
specific program. As a result, we get the source code with high level of redundancy. With the
increasing size of the program this naturally leads to difficulties in its support. Major changes in the
application source code become virtually impossible without causing of new bugs and regressions.

Audience
The complexity of software and user's expectations increase much faster than programmer's
productivity. MetaJS attempts to close this gap and offers to small teams and individual
programmers a tool that allows to do more for less time. Semantic-aware compiler orthogonally
combines with traditional Lisp meta-programming and provides new experience for all
programmers who value own time.

Methodology
In addition to traditional macros that transform program at read- and compile-time MetaJS uses
semantic transformations that runs after read- and compile-macros. In MetaJS functions can have
required and optional parameters. When MetaJS compiler finds a function call without a required
parameter it attempts to “resolve” it to make the valid function call.
The compiler tries to find all symbols and compound forms that can be used instead of missed
function argument. The compiler replaces missed function argument only when it finds exactly one
valid substitution. When valid substitution is not found or found more than one, compiler reports an
error that programmer need to resolve manually. The same approach is used in the version control
systems. Most of time merges of different code branches are done automatically, but if there are a
merge conflict – programmer need to resolve it manually or use different merge algorithm.
MetaJS uses two classes of semantic transformation: symbolic and entitative. During symbolic
transformations compiler uses symbols available in the lexical scope of the function call instead of
missed argument of the function. To qualify a symbol for the substitution of the missed function
argument MetaJS tries to match name and meta information of the missed argument and each
symbol available in the lexical scope of incomplete function call. Name of the argument can be
matched with meta of context symbol and vise versa forming four possible types of combinations.
Let's see an example of symbolic transformation when name of missed function argument is
matched with meta type of context symbol. On the left is MetaJS code and on the right is JavaScript
code generated from MetaJS code. Result of semantic transformation is highlighted with red color.
You can check this and next examples right inside your browser on the http://metajs.coect.net/.
(defn get-user-timeline (username)
#"$username timeline")

var getUserTimeline = (function(username) {
return ("" + username + " timeline");
});

(let* (u:username "dogada")
(get-user-timeline))

(function(u) {
return getUserTimeline(u);
})("dogada");

Required argument username of the function get-user-timeline is missed in the function call.
MetaJS uses local variable u, because it's declared with meta type username. The code
u:username defines symbol u and declares that it is related to something called username. Meta
types are not need to be defined at all. Compiler uses meta types and entities to build semantic
model of the program.
Entities are defined with (entity) macro and used solely by compiler to understand relations
between symbols. Entities are not types in statically-typed languages sense and have no
corresponding JavaScript code. Entities are main building block of semantic model of the program.
Let's see an example of an entitative transformation. Such transformations always use an explicitly
defined entity to find a valid relation between symbols available in the lexical scope of function call
and missed function argument. Entities may define simple relation like property relation, for
example (has username). Custom relation able to emit any form instead of missed argument, for
example (rel username `(. ~sym 'session ~rel)), where sym is actual symbol matched to the entity
and rel is target itself.
(entity request
"Entity of demo web request."
(has username))
(defn get-user-timeline (user-id:username)
#"$user-id timeline")

var getUserTimeline = (function(userId) {
return ("" + userId + " timeline");
});

(let* (req:request {username: "dogada"})
(get-user-timeline))

(function(req) {
return getUserTimeline(req.username);
})({username: "dogada"});

Required argument user-id of the function get-user-timeline is missed in the function call. MetaJS
uses property username of local variable req, because it's declared with meta type request and
entity request declares relation between request and username entities and user-id argument
declared with meta type username.
You can find examples of all 8 types of semantic transformations used by MetaJS in the
http://metajs.coect.net/pdf/metajs_semantic_code_transformations.pdf.

Conclusion
MetaJS is implemented in MetaJS, so even if it's still in alpha stage it's quite feature complete
already. Famous Lisp macro system allows to add more features without need to change language
itself. Anyone can try it without leaving a browser on http://metajs.coect.net/ or install as NodeJs
module.
It's easy to predict that in large programs symbols and entities with same name may have different
meaning in different source files even inside single project. When you import external libraries, you
may expect even more name conflicts. MetaJS plans to solve this problem with namespaces and
using of fully qualified names of entities inside compiler. A programmer can import and alias
entities from other modules exactly like symbols are imported between namespaces.
Next obvious area of improvement is meta types inheritance and various checks of code validity
based on semantic model of program.
The final goal is to make a compiler that can learn programmer's style at least particularly. A
programmer concentrates own efforts on domain models design and architecture of the program. A
programmer tells to MetaJS compiler what to do and teach it to understand program's entities and
relations between symbols. Computer in real-time mode analyzes semantic model of the program,
compares it with the code that programmer types and provides immediate feedback rather than
shows blinking cursor.

Más contenido relacionado

Último

Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Destacado

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destacado (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

High-level MetaJS language overview

  • 1. MetaJS Knowledge-oriented programming language Dmytro Dogadailo October, 2013 http://metajs.coect.net
  • 2. Purpose MetaJS is knowledge-oriented programming language. MetaJS compiler can generate source code, intentionally missed by programmer. This approach leads to loosely coupled and highly dynamic programs. MetaJS is a dialect of Lisp and provides many of the typical Lisp features including powerful macro system. It compiles to Javascript without runtime dependencies. Function Typical usage scenario: signature of a library function is changed but all arguments for new version of the function can be found in the call context. MetaJS can adapt all calls of such function to the new signature automatically. A programmer starts to use less nouns (local variables and function arguments) and more verbs (function calls). MetaJS compiler finds what does the programmer mean from semantic model of the program and surrounding context. Motivation Today compilers analyze only the grammar of the language and ignore the semantics of each specific program. As a result, we get the source code with high level of redundancy. With the increasing size of the program this naturally leads to difficulties in its support. Major changes in the application source code become virtually impossible without causing of new bugs and regressions. Audience The complexity of software and user's expectations increase much faster than programmer's productivity. MetaJS attempts to close this gap and offers to small teams and individual programmers a tool that allows to do more for less time. Semantic-aware compiler orthogonally combines with traditional Lisp meta-programming and provides new experience for all programmers who value own time. Methodology In addition to traditional macros that transform program at read- and compile-time MetaJS uses semantic transformations that runs after read- and compile-macros. In MetaJS functions can have required and optional parameters. When MetaJS compiler finds a function call without a required parameter it attempts to “resolve” it to make the valid function call. The compiler tries to find all symbols and compound forms that can be used instead of missed function argument. The compiler replaces missed function argument only when it finds exactly one valid substitution. When valid substitution is not found or found more than one, compiler reports an error that programmer need to resolve manually. The same approach is used in the version control systems. Most of time merges of different code branches are done automatically, but if there are a merge conflict – programmer need to resolve it manually or use different merge algorithm. MetaJS uses two classes of semantic transformation: symbolic and entitative. During symbolic transformations compiler uses symbols available in the lexical scope of the function call instead of missed argument of the function. To qualify a symbol for the substitution of the missed function argument MetaJS tries to match name and meta information of the missed argument and each symbol available in the lexical scope of incomplete function call. Name of the argument can be matched with meta of context symbol and vise versa forming four possible types of combinations.
  • 3. Let's see an example of symbolic transformation when name of missed function argument is matched with meta type of context symbol. On the left is MetaJS code and on the right is JavaScript code generated from MetaJS code. Result of semantic transformation is highlighted with red color. You can check this and next examples right inside your browser on the http://metajs.coect.net/. (defn get-user-timeline (username) #"$username timeline") var getUserTimeline = (function(username) { return ("" + username + " timeline"); }); (let* (u:username "dogada") (get-user-timeline)) (function(u) { return getUserTimeline(u); })("dogada"); Required argument username of the function get-user-timeline is missed in the function call. MetaJS uses local variable u, because it's declared with meta type username. The code u:username defines symbol u and declares that it is related to something called username. Meta types are not need to be defined at all. Compiler uses meta types and entities to build semantic model of the program. Entities are defined with (entity) macro and used solely by compiler to understand relations between symbols. Entities are not types in statically-typed languages sense and have no corresponding JavaScript code. Entities are main building block of semantic model of the program. Let's see an example of an entitative transformation. Such transformations always use an explicitly defined entity to find a valid relation between symbols available in the lexical scope of function call and missed function argument. Entities may define simple relation like property relation, for example (has username). Custom relation able to emit any form instead of missed argument, for example (rel username `(. ~sym 'session ~rel)), where sym is actual symbol matched to the entity and rel is target itself. (entity request "Entity of demo web request." (has username)) (defn get-user-timeline (user-id:username) #"$user-id timeline") var getUserTimeline = (function(userId) { return ("" + userId + " timeline"); }); (let* (req:request {username: "dogada"}) (get-user-timeline)) (function(req) { return getUserTimeline(req.username); })({username: "dogada"}); Required argument user-id of the function get-user-timeline is missed in the function call. MetaJS uses property username of local variable req, because it's declared with meta type request and entity request declares relation between request and username entities and user-id argument declared with meta type username.
  • 4. You can find examples of all 8 types of semantic transformations used by MetaJS in the http://metajs.coect.net/pdf/metajs_semantic_code_transformations.pdf. Conclusion MetaJS is implemented in MetaJS, so even if it's still in alpha stage it's quite feature complete already. Famous Lisp macro system allows to add more features without need to change language itself. Anyone can try it without leaving a browser on http://metajs.coect.net/ or install as NodeJs module. It's easy to predict that in large programs symbols and entities with same name may have different meaning in different source files even inside single project. When you import external libraries, you may expect even more name conflicts. MetaJS plans to solve this problem with namespaces and using of fully qualified names of entities inside compiler. A programmer can import and alias entities from other modules exactly like symbols are imported between namespaces. Next obvious area of improvement is meta types inheritance and various checks of code validity based on semantic model of program. The final goal is to make a compiler that can learn programmer's style at least particularly. A programmer concentrates own efforts on domain models design and architecture of the program. A programmer tells to MetaJS compiler what to do and teach it to understand program's entities and relations between symbols. Computer in real-time mode analyzes semantic model of the program, compares it with the code that programmer types and provides immediate feedback rather than shows blinking cursor.