forked from scala-js/scala-js-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
372 lines (362 loc) · 15.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
---
layout: index
permalink: /
---
<div id="headerwrap">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<img width="100" src="{{ '/assets/img/scala-js-logo.svg' | prepend: site.baseurl }}">
<div>
<h2 style="margin: 10px 0;">Scala.js</h2>
<h4 class="version">{{ site.versions.scalaJS }}</h4>
<h4>A safer way to build robust<br/> front-end web applications!</h4>
</div>
<div>
<a class="btn btn-theme" href="{{ site.baseurl }}/doc/tutorial/">Learn Scala.js</a>
<a class="btn btn-theme" href="https://scalafiddle.io/">Try Scala.js in the browser</a>
</div>
</div>
</div>
</div>
</div>
<div id="service">
<div class="container">
<div class="row centered">
<div class="col-md-4">
<div class="center-align">
<i aria-hidden="true" class="fa fa-check-square"></i>
<h4>Correctness</h4>
</div>
Strong typing guarantees your code is free of silly mistakes; no more
mixing up strings or numbers, forgetting what keys an object has, or
worrying about typos in your method names. Scala.js takes care of all this
tedious book-keeping for you, letting you focus on the actual, more interesting
problem your application is trying to solve.
</div>
<div class="col-md-4">
<div class="center-align">
<i aria-hidden="true" class="fa fa-rocket"></i>
<h4>Performance</h4>
</div>
Scala.js optimizes your Scala code into
<a href="{{ site.baseurl}}/doc/internals/performance.html">highly efficient JavaScript</a>.
Incremental compilation guarantees speedy (1-2s) turn-around times when your code changes.
The generated JavaScript is both fast and small, starting from 45kB gzipped for a full application.
</div>
<div class="col-md-4">
<div class="center-align">
<i aria-hidden="true" class="fa fa-cogs"></i>
<h4>Interoperability</h4>
</div>
Scala.js <a href="{{ site.baseurl }}/libraries/facades.html">loves JavaScript libraries</a>,
including React and AngularJS.
You can use any JavaScript library right from your Scala.js code, either in a statically or dynamically typed way.
You won't even notice you're crossing a language border!
<a href="{{ site.baseurl }}/doc/interoperability/">Learn more.</a>
</div>
</div>
</div>
</div>
<div class="container mtb">
<div class="row">
<div class="col-md-7">
<h4>Excellent editor support</h4>
<p>
With Scala.js, typos and type-errors are immediately caught and shown to you
in your editor, <i>without even needing to compile your code</i>. Refactor any field
or method with ease, with the confidence that if you mess it up the editor will tell
you immediately. Stop flipping back and forth between your editor and MDN,
because your editor will display what methods are available, what arguments they
take, what they return, and even their documentation, right in-line with your code!
</p>
</div>
<div class="col-md-5">
<img class="img-responsive" src="{{ '/assets/img/ide-screenshot.png' | prepend: site.baseurl }}">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h4>Go beyond JavaScript ES6, today</h4>
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs">
<li role="presentation" class="show-snippet-tab"><a class="show-snippet-link" data-language="es5" href="#">JavaScript/ES5</a></li>
<li role="presentation" class="show-snippet-tab active"><a class="show-snippet-link" data-language="es6" href="#">ECMAScript 6</a></li>
<li role="presentation" class="show-snippet-tab"><a class="show-snippet-link" data-language="typescript" href="#">TypeScript</a></li>
</ul>
</div>
<div class="col-md-12">
<h5>Hello World!</h5>
</div>
<div class="col-md-6 snippet snippet-es5" style="display: none;">
<h6 class="code-block-header">JavaScript</h6>
<pre><code class="javascript">console.log("Hello World!");</code></pre>
</div>
<div class="col-md-6 snippet snippet-es6">
<h6 class="code-block-header">ECMAScript 6</h6>
<pre><code class="javascript">console.log("Hello World!");</code></pre>
</div>
<div class="col-md-6 snippet snippet-typescript" style="display: none;">
<h6 class="code-block-header">TypeScript</h6>
<pre><code class="typescript">console.log("Hello World!");</code></pre>
</div>
<div class="col-md-6">
<h6 class="code-block-header">Scala.js</h6>
<pre><code class="scala">println("Hello World!")</code></pre>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h5>Classes</h5>
</div>
<div class="col-md-6 snippet snippet-es5" style="display: none;">
<h6 class="code-block-header">JavaScript</h6>
<pre><code class="javascript">var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
};
Person.prototype.fullName = function() {
return this.firstName + " " + this.lastName;
};</code></pre>
</div>
<div class="col-md-6 snippet snippet-es6">
<h6 class="code-block-header">ECMAScript 6</h6>
<pre><code class="javascript">class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
fullName() {
return `${this.firstName} ${this.lastName}`;
}
}</code></pre>
</div>
<div class="col-md-6 snippet snippet-typescript" style="display: none;">
<h6 class="code-block-header">TypeScript</h6>
<pre><code class="typescript">class Person {
constructor(public firstName: string,
public lastName: string) {
}
fullName() {
return `${this.firstName} ${this.lastName}`;
}
}</code></pre>
</div>
<div class="col-md-6">
<h6 class="code-block-header">Scala.js</h6>
<pre><code class="scala">class Person(val firstName: String, val lastName: String) {
def fullName(): String =
s"$firstName $lastName"
}</code></pre>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h5>Fat arrow functions</h5>
</div>
<div class="col-md-6 snippet snippet-es5" style="display: none;">
<h6 class="code-block-header">JavaScript</h6>
<pre><code class="javascript">var names = persons.map(function(p) {
return p.firstName;
});</code></pre>
</div>
<div class="col-md-6 snippet snippet-es6">
<h6 class="code-block-header">ECMAScript 6</h6>
<pre><code class="javascript">const names = persons.map(p => p.firstName);</code></pre>
</div>
<div class="col-md-6 snippet snippet-typescript" style="display: none;">
<h6 class="code-block-header">TypeScript</h6>
<pre><code class="typescript">const names = persons.map(p => p.firstName);</code></pre>
</div>
<div class="col-md-6">
<h6 class="code-block-header">Scala.js</h6>
<pre><code class="scala">val names = persons.map(p => p.firstName)
// or an even shorter version
val names = persons.map(_.firstName)</code></pre>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h5>Collections</h5>
</div>
<div class="col-md-6 snippet snippet-es5" style="display: none;">
<h6 class="code-block-header">JavaScript</h6>
<pre><code class="javascript">var personMap = {
"10": new Person("Roger", "Moore"),
"20": new Person("James", "Bond")
};
var names = [];
for (var key in personMap) {
if (Object.prototype.hasOwnProperty.call(personMap, key)) {
if (parseInt(key) > 15) {
names.push(key + " = " + personMap[key].firstName);
}
}
}</code></pre>
</div>
<div class="col-md-6 snippet snippet-es6">
<h6 class="code-block-header">ECMAScript 6</h6>
<pre><code class="javascript">const personMap = new Map([
[10, new Person("Roger", "Moore")],
[20, new Person("James", "Bond")]
]);
const names = [];
for (const [key, person] of personMap) {
if (key > 15) {
names.push(`${key} = ${person.firstName}`);
}
}</code></pre>
</div>
<div class="col-md-6 snippet snippet-typescript" style="display: none;">
<h6 class="code-block-header">TypeScript</h6>
<pre><code class="typescript">/// <reference path="dts/typescript/lib.es6.d.ts" />
const personMap = new Map<number, Person>([
[10, new Person("Roger", "Moore")],
[20, new Person("James", "Bond")]
]);
const names = new Array<string>();
for (const [key, person] of personMap) {
if (key > 15) {
names.push(`${key} = ${person.firstName}`);
}
}</code></pre>
</div>
<div class="col-md-6">
<h6 class="code-block-header">Scala.js</h6>
<pre><code class="scala">val personMap = Map(
10 -> new Person("Roger", "Moore"),
20 -> new Person("James", "Bond")
)
val names = for {
(key, person) <- personMap
if key > 15
} yield s"$key = ${person.firstName}"</code></pre>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p>
To find out more about what Scala.js looks like for JavaScript developers, check
out the <a href="{{ site.baseurl }}/doc/sjs-for-js/">detailed comparisons</a>. If
you want to try it out yourself, check out the
<a href="{{ site.baseurl }}/tutorial/">Tutorials!</a>
</p>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th width="54%">Feature</th>
<th width="12%">JavaScript ES5</th>
<th width="12%">JavaScript ES6</th>
<th width="12%">TypeScript</th>
<th width="12%">Scala.js</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5" class="info"><strong>Interoperability</strong></td>
</tr>
<tr>
<td>Fully EcmaScript5 compatible</td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>No compilation required</td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
</tr>
<tr>
<td>Use existing JS libraries</td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td colspan="5" class="info"><strong>Language features</strong></td>
</tr>
<tr>
<td>Classes</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Modules</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Support for types</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Strong type system</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Extensive standard libraries</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Optimizing compiler</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Macros, to extend the language</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td colspan="5" class="info"><strong>IDE support</strong></td>
</tr>
<tr>
<td>Catch most errors in IDE</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Easy and reliable refactoring</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
<tr>
<td>Reliable code completion</td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle-o"></i></td>
<td><i class="fa fa-circle"></i></td>
<td><i class="fa fa-circle"></i></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>