JS++ é uma linguagem de programação para desenvolvimento web que estende o JavaScript com Type System. Inclui recursos de programação imperativos, orientados a objetos, funcionais e genéricos.
JS++ apareceu pela primeira vez em 8 de outubro de 2011. A implementação moderna foi anunciada na DeveloperWeek 2016 e lançada em 31 de maio de 2016. A linguagem foi desenvolvida por Roger Poon e Anton Rapetov.
Segundo o criador do JS++, Roger Poon( que é engenheiro de software baseado no Vale do Silício, fundador da Onux ), há as seguintes afirmações:
TypeErrors
que ocorrem em tempo de execução.Para acessar o link completo da entrevista dele, consulte a referência ao final desse artigo.
wget https://onux.r.worldssl.net/jspp/downloads/JS++-0.9.2-linux_x64.tar.gz
tar zxvf JS++-0.9.2-linux_x64.tar.gz
cd JS++/
sudo install -v js++ /usr/local/bin/
Limpando os arquivos
cd ..
rm -rf JS++/ JS++-0.9.2-linux_x64.tar.gz
Rodando
js++ --version
js++ --help
vim hello.jspp
import System;
Console.log("Hello World!");
Rode: js++ -e hello.jspp
. A saída será:
Compiling: /home/$USER/hello.jspp
OK (0) errors and (0) warnings
Hello World!
Convertendo para JavaScript
js++ hello.jspp -o hello.js
node hello.js
Note que o código não haverá indentação correta, mas para analisar você pode usar o https://beautifier.io/ para formatar, o código ficará assim:
// Compiled with JS++ v.0.9.2
!function() {
var f = function() {
if (typeof console !== "undefined" && typeof console.log === "function") {
return (console.log);
} else if (typeof print === "function") {
return (print);
} else {
return ((function() {}));
}
}();
var g = function() {
if (typeof console !== "undefined" && typeof console.log === "function") {
return (console);
} else {
return (void 0);
}
}();
! function() {
f.apply(g, ['Hello World!']);
}();
}();
Há suporte de sintaxe para quase todos editores de textos e IDE . Para mais informações, consulte: https://www.onux.com/jspp/ide-editors
No Vim por exemplo, rode esses comandos:
sudo vim /usr/share/vim/vim[0-9][0-9]/filetype.vim
au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx setf javascript
au BufNewFile,BufRead *.jpp,*.jspp,*.js++ setf jspp
syntax
:
Substitua o XX pelo número da pasta que há no seu sistema.
sudo wget https://raw.githubusercontent.com/onux/jspp/master/Editor%20Integration/vim/jspp.vim \
-O /usr/share/vim/vimXX/syntax/jspp.vim
Exemplo de arquivo:
import System;
string frase = "Isso é JS++";
int numero = 936;
double valor = 8.04;
bool bin = true;
if( bin == true ){
Console.log( "FRASE: " + frase );
Console.log( "NÚMERO: " + numero.toString() );
Console.log( "VALOR: " + valor.toString() );
Console.log( "BIN: " + bin.toString() );
}
import System;
Dictionary<string?> dicionario = {
"Terminal": "Root",
"Oliveira": "Marcos",
};
Dictionary<bool?> bin = {
"verifica": true
};
if( bin["verifica"] ){
Console.log( dicionario["Oliveira"] + " " + dicionario["Terminal"] );
}
Utilizando com jQuery, por exemplo.
Código JS++ exemplo:
external $;
string hello = "Olá, JS++!";
$("#content").text( hello );
Compilamos:
js++ pagina.jspp -o pagina.js
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Olá, JS++!</title>
</head>
<body>
<h1 id="content"></h1>
<script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="pagina.js"></script>
</body>
</html>