Content deleted Content added
Adding local short description: "Event-driven programming language", overriding Wikidata description "programming language" |
|||
(14 intermediate revisions by 11 users not shown) | |||
Line 1:
{{Short description|Event-driven programming language}}
{{Infobox programming language
| name = P
| logo = P logo.png
|
| logo caption =
| paradigm =
| designer =
| developer = Ankush Desai, Vivek Gupta: not the politician, [[Ethan Jackson]], [[Shaz Qadeer]], [[Sriram Rajamani]], [[Microsoft]]
| latest release version = 2.3.5
| latest release date = {{Start date and age|
| typing =
| implementations =
Line 20:
| file ext = .p
| license = [[MIT License]]
| website = {{
}}
'''P''' is a [[programming language]] for asynchronous [[event-driven programming]] and the [[Internet of things|IoT]] that was developed by [[Microsoft]] and [[University of California, Berkeley]].<ref>[https://www.infoworld.com/article/3130998/microsoft-open-sources-p-language-for-iot.html Microsoft open-sources P language for IoT]</ref>
P enables programmers to specify systems consisting of a collection of [[
P is [[open-source model|open source]], licensed under [[MIT License]], and available on [[GitHub]].<ref>{{cite web|last1=Sergio De Simone|title=Microsoft Open-Sources P Language for Safe Async Event-Driven Programming|url=https://www.infoq.com/news/2016/10/microsoft-p-language-opensourced|website=InfoQ|access-date=20 October 2016}}</ref> == Example ==
<pre>
machine BankServer
{
var database: Database;
start state Init {
entry (initialBalance: map[int, int]){
database = new Database((server = this, initialBalance = initialBalance));
goto WaitForWithdrawRequests;
}
}
state WaitForWithdrawRequests {
on eWithDrawReq do (wReq: tWithDrawReq) {
var currentBalance: int;
var response: tWithDrawResp;
// read the current account balance from the database
currentBalance = ReadBankBalance(database, wReq.accountId);
// if there is enough money in account after withdrawal
if(currentBalance - wReq.amount >= 10)
{
UpdateBankBalance(database, wReq.accountId, currentBalance - wReq.amount);
response = (status = WITHDRAW_SUCCESS, accountId = wReq.accountId, balance = currentBalance - wReq.amount, rId = wReq.rId);
}
else // not enough money after withdraw
{
response = (status = WITHDRAW_ERROR, accountId = wReq.accountId, balance = currentBalance, rId = wReq.rId);
}
// send response to the client
send wReq.source, eWithDrawResp, response;
}
}
}
</pre>
== See also ==
Line 40 ⟶ 81:
== External links ==
* {{Official website|https:/
* {{URL|https://github.com/p-org/P|Source code on GitHub}}
* [https://www.microsoft.com/en-us/research/publication/p-safe-asynchronous-event-driven-programming/ P: Safe Asynchronous Event-Driven Programming]
* [https://www.microsoft.com/en-us/research/blog/p-programming-language-asynchrony/ P: A programming language designed for asynchrony, fault-tolerance and uncertainty]
Line 56 ⟶ 98:
[[Category:Systems programming languages]]
[[Category:2012 software]]
{{Prog-lang-stub}}
|