Embracing Language Servers for Blockchain Development
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 561 | |
Author | ||
License | CC Attribution 2.0 Belgium: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/44253 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
FOSDEM 201976 / 561
1
9
10
15
18
19
23
24
27
29
31
33
34
35
38
39
40
43
47
49
52
53
54
55
58
59
60
63
65
67
69
70
78
80
82
87
93
95
97
102
103
104
107
110
111
114
116
118
120
122
123
126
127
131
133
136
137
139
141
142
148
153
155
157
159
163
164
168
169
170
171
172
173
174
181
183
185
187
188
193
196
197
198
199
200
201
205
207
208
209
211
213
214
218
221
223
224
226
230
232
234
235
236
244
248
250
251
252
253
255
256
257
262
263
264
268
269
271
274
275
276
278
280
281
283
284
288
289
290
293
294
296
297
300
301
304
309
311
312
313
314
315
317
318
321
322
327
332
333
334
335
336
337
338
339
340
343
345
346
352
353
355
356
357
359
360
362
369
370
373
374
375
376
377
378
383
384
387
388
389
390
391
393
394
395
396
406
408
409
412
413
414
415
419
420
425
426
431
432
433
434
435
436
438
439
440
441
445
446
447
448
453
455
457
459
466
467
471
473
474
475
476
479
480
484
485
486
489
491
492
496
499
500
502
505
507
508
512
515
517
518
529
531
533
534
535
536
539
540
546
550
551
552
553
554
555
557
558
559
560
561
00:00
Programming languageServer (computing)ChainProgramming languageServer (computing)PasswordSoftware developerComputer animation
00:21
Maxima and minimaSineOpen sourceEnterprise architectureProgramming languageBuildingSoftware developerWordMetropolitan area networkBitDesign by contractChainComputing platformComputer animation
01:10
Rule of inferenceCodeComputerChainCodeDesign by contractCondition numberContext awarenessComputer animation
01:51
Computer programPlastikkarteIntegrated development environmentProgramming languageMultiplicationSolid geometryBlock (periodic table)Normal (geometry)Virtual machineDesign by contractSound effectMobile appArmCartesian coordinate systemError messageSocial classMathematical analysisFunctional programmingMusical ensembleComputer programmingPhysical systemDatabase transactionVideo gameSheaf (mathematics)BitWritingIntrusion detection systemConnected spaceLengthWordJava appletWeb 2.0Moment (mathematics)InternetworkingElement (mathematics)Complete metric spaceGoodness of fitCodeContent (media)Integrated development environmentInheritance (object-oriented programming)Extension (kinesiology)CASE <Informatik>TheoremSoftware bugPersonal digital assistant
07:35
Inclusion mapModal logicExecution unitComa BerenicesRange (statistics)Maxima and minimaProcess (computing)Hill differential equationWechselseitige InformationProgramming languageAuthoring systemSolid geometryServer (computing)Revision controlFunctional programmingCodeFluid staticsInformationDemo (music)Type theoryStatement (computer science)CompilerVideo gamePersonal digital assistantComputer animation
09:23
Server (computing)Programming languageIntelDisintegrationIntrusion detection systemVisual systemStandard deviationRemote procedure callCommunications protocolIntegrated development environmentClient (computing)Programming languageServer (computing)Communications protocolDesign by contractError messageClient (computing)Internet service providerMessage passingText editorFinite-state machineSoftware developerIntegrated development environmentSolid geometryCodeComputing platformComputer fileMathematicsVisualization (computer graphics)Personal digital assistantContent (media)Arithmetic progressionState of matterSound effectSpacetimeNumberType theoryScripting languageImplementationArmWordLink (knot theory)Intrusion detection systemWeb applicationMetropolitan area networkComputer animation
14:48
Keyboard shortcutJava appletClient (computing)Server (computing)Programming languageRule of inferenceConvex hullPlanar graphMenu (computing)Duality (mathematics)Execution unitVacuumHill differential equationComa BerenicesServer (computing)CodeProgramming languageSolid geometryCommunications protocolLibrary (computing)Formal grammarProblemorientierte ProgrammierspracheMessage passingRule of inferenceParsingIndependence (probability theory)Computer programmingProjective planeINTEGRALForm (programming)Integrated development environmentJava appletBuildingBitImplementationText editorCuboidView (database)Abstract syntaxComplete metric spaceLine (geometry)Computer fontClient (computing)Software frameworkExtension (kinesiology)Variety (linguistics)AdditionTunisElement (mathematics)Frame problemArmWordMiniDiscComputer animation
20:12
Maxima and minimaServer (computing)Programming languageComputer fileCartesian coordinate systemCodeExtension (kinesiology)Latent heatArmJava appletINTEGRALWeb browserWritingWeb 2.0Visualization (computer graphics)Text editorIntegrated development environmentComputer animation
21:48
Programming languageSolid geometryMoment (mathematics)Design by contractOrder (biology)Server (computing)Intrusion detection systemIntegrated development environmentCommunications protocolArithmetic meanComputing platformComputer animation
22:56
Programming languageServer (computing)Software frameworkSoftware developerClient (computing)Virtual machineFlow separationProcess (computing)Solid geometryFile systemCuboidScripting languageMoment (mathematics)WordVisualization (computer graphics)Interactive televisionDifferent (Kate Ryan album)Information privacyComputer fileExpert systemArmComputer animation
26:54
Computer animation
Transcript: English(auto-generated)
00:06
Thanks for joining my session. It's called Embracing Language Service for Blockchain Development. I try to put as many buzzwords as possible into the title. Let us look at what it's about.
00:21
Just one word to me. I'm Man Karsten. I'm working for a company in Germany called ITEMIS. And we're specialized on tool development. And that's actually what it's about today. Of course we want to talk a little bit about blockchains.
00:42
One blockchain platform is Ethereum. Did you hear about Ethereum already? Short words about that. Ethereum is a foundation who runs a platform
01:01
which allows you to execute smart contracts on a blockchain. So what is a smart contract? Actually a smart contract is a piece of code that you can deploy and execute on a blockchain. So somehow you have to develop these contracts.
01:21
So in these contracts you can say, okay, under which conditions do you transfer money from A to B? Or something like this. And you compile that code and deploy it to the blockchain and it's distributed over the blockchain and so it gets available for everyone and it's not infringable.
01:45
That's one of the benefits of blockchains. And to execute smart contracts you actually need to have some kind of money. It's called gas. And it has actually value. So you can buy gas and you have to use gas to execute transactions.
02:07
And what can you do with that for example? It depends on how many transactions are running at the moment on the blockchain. This determines the price of the gas. So when many people are running transactions at the same time
02:24
and try to get one transaction to one block, the gas price increases. And this leads to some strange effect. One of the most popular applications on the Ethereum blockchain
02:44
is selling and buying kittens. And when many people do this, these kittens get horribly expensive and I don't know who does this, but this was one of the use cases that increased the Ethereum gas price.
03:07
But the big question is how do we actually program something from the blockchain? That's what we need to talk a little bit about. And there are many programming languages out there but the most popular for Ethereum are called Solidity and Viper.
03:26
And I will talk now about this Solidity language. So what is Solidity? It's a complete programming language and with that programming language you can write contracts.
03:43
It's similar to a class concept. So you have values, you have functions that you can call and this programming language provides you literally everything that you know from the modern programming language like multiple inheritance and extension methods
04:05
and multiple return values and so literally I think everything is in this language. So you have a nice language to define contracts and this contract can be compiled to bytecode for the Ethereum virtual machine
04:26
and then you can deploy it to the virtual machine. And I'm a tool developer. I'm interested in providing good support for that language. There's actually an IDE provided by Ethereum which is called Remix.
04:46
And it is a web-based IDE. Let's see if I have an internet connection and I can show you live a little bit. So here it is.
05:09
So this is actually Solidity code. You can add this online and you can write simple programs and compile that code.
05:23
Actually this code is not compilable because there's some syntax error in it and this is marked here. But this is not really a good IDE. For example, this is really annoying here
05:43
and when I press, for example, Content Assist I literally see every keyword, every word that is in the program and not what makes sense here. I do not see documentation, other documentation like Java docs we are used to
06:05
or I cannot cross reference to elements that are defined somewhere else. All these things that we are used from modern IDEs is not available.
06:22
So, coming back. We have a complex language but the tooling is really crappy. And the problem is if you make errors here in contracts
06:40
then you can really lose money. There was one bug in 2017 where someone by accident called a suicide method on the contract which led to the fact that millions of dollars were locked in the blockchain
07:04
and just lost. So, it's really important that you know what your program is there and so you should see if there are errors in there if something doesn't make sense maybe do some decent analysis
07:22
and what you actually know from normal programming languages. So, what we can really do about that and this is what I want actually to talk about is a tool that we created the Yakinu Solidity tools
07:40
and in this tool we implemented the Solidity language and providing a language server. What this means, I'm telling you now about that. So, coming back to a small demo. Showing this live.
08:05
So, we see here, again, Solidity code and you see for example
08:22
here at the very beginning this is one thing that Solidity is the first statement Apacma which compiler version should be used and maybe it's not the latest one. And here we get immediately a proposal okay, you should maybe upgrade to that. You can use the quick fix here
08:41
and immediately change that. You can have content assist for example, if I press here then it only gets proposed what makes sense here to enter
09:04
or here, which functions can I call. So, we have static information about types and all what you use from one of the languages.
09:27
We take this now a step further. This is a work in progress. We are also building a tool which is called the Yakinu state chart tools and actually you can think about a contract like a state machine. So, you can model this now visually
09:43
and from that state machines we just cross-compile to Solidity code and then deploy that to a blockchain. And this can also be simulated. So, you can simulate what effect does it have if you transfer some money or whatever.
10:06
Yeah, but this is Eclipse space. And some people do not like Eclipse. I actually love Eclipse. I use it every day. But I totally understand that there are other editors outside there
10:21
and you may want to use the language not only in Eclipse but maybe for different platforms. And actually we provide the Solidity language already on four editors. Besides Eclipse, we also support Eclipse here.
10:42
I will show you that in a minute. It's a web-based editor. Visual Studio Code and ATEM. And more to come. How do we achieve this? And here we come to the language service. What is a language server? We have typically a problem when we develop languages
11:03
that there are several IDEs out there and for each language and each IDE you have to implement tooling. And if you would implement this natively for each IDE
11:21
then the language provider has plenty to do. Actually, the language provider does not want to get bothered how it is integrated into a certain IDE. On the other side, the IDE or editor developers don't want to care about languages.
11:42
There are coming languages every day and they can't support everything. And the IDEs get blown up with all the toolings that support the languages here. And here comes something in
12:01
which is called the language server protocol. When Microsoft started developing Visual Studio Code they had exactly the same problem. They developed a new IDE based on a TypeScript and they needed language support for TypeScript and C Sharp and others.
12:24
And then they thought, OK, do we re-implement the wheel again? No, they said, OK, we can define a protocol which is too agnostic and which decouples the editor from the language. So the editor is just dumb and says,
12:43
OK, I'm opening that file and editing here something. I want to press Content Assist. What can you offer me? And the language server is doing the hard stuff then for the language. So the language server knows,
13:02
OK, you're currently adding this file and at that offset you want to show Content Assist. I can show these offers. And this was a good idea and there stepped some other IDE developers up
13:22
and implemented also this standard. And so all the IDE developers are now driving this standard together with Microsoft. And so you can now provide languages independently from the IDEs.
13:42
The language server protocol is based on a JSON RPC. So basically it's sending JSON messages from tool to the server and back. And it works roughly like that. You have the tool. The user clicks on document
14:02
and it says, OK, I want to open a document and tell the server here this file is open. Then you start editing and the tool sends text changes to the server. It knows, ah, you're entering this document. I'm entering a word.
14:24
And the server on the other side can also send messages back to the tool. Say, OK, what you entered is not really valid. We have the syntax error here and this is my message.
14:41
There's a broad number of clients nowadays available that support the language server protocol. And on the other side also a broad variety of languages. And this is ongoing work. But you can expect that all editors and IDEs
15:05
will support that protocol. Actually it does only cover the typical 80% of what you actually need for the tooling. And each tool has its own tweaks which cannot be covered by a common protocol.
15:24
But the normal things that you do is done in the protocol already. And you can also extend the protocol. But then the extension must be known both by the client and the server. QuickFix is such an example
15:41
which is only provided by the Eclipse IDE. And we provide implementation for QuickFixes and yeah, you can see that in Eclipse. The protocol is language independent but there exists a binding for Java.
16:01
So when you're programming any language which are based on or implemented in Java then it's good to start with this project LSP4j. It's a framework, it's a library that implements all the messages that the protocol defines.
16:21
And of course if you program a language server in a different language then you have to use a different library. We implemented that with Java and especially with a framework called Xtext. That's actually my work, what I'm daily doing.
16:41
I'm working on that project. And Xtext is a framework to develop languages. So when you want to implement programming languages or domain specific languages then this is the way to go. With Xtext you can describe very simple language
17:03
defined by a grammar, create all the implementation and you get all the editor integration out of the box. And also you can build language server with that. So I will now dig a little bit into the code
17:22
to give you an impression what's behind that to build a language server for Solidity. And this is our development environment. It's quite a bunch of projects that we have here
17:40
but there's one project that is most important which contains the language definition. And if you're known a little bit to language design then you know that you need some kind of grammar to describe the language.
18:04
It's closely to a BNF form but we mix concrete and abstract syntax. So we also see keywords that the language supports in the grammar.
18:21
What we do from this is generate a grammar for Antler. So behind our parser technology is Antler but this grammar is much simpler than the Antler grammar. And so here's the complete definition of Solidity language.
18:43
It's not that huge. Just four lines of code that you need for all the rules. And when you have defined that you typically run a code generator
19:03
and this is when X6 comes into play and generates the infrastructure for the tooling.
19:23
So what you get is the parser, you get syntax highlighting, you get cross-linking, so scoping is implemented. We have a nice outline view here so it can... where is it?
19:43
I think it's... ah, it's here. So you can directly navigate to elements. This is what you get for free when you use X6 for any language that you develop. And Solidity is just one example that we developed with that.
20:03
Now let's have a look at the language server. So we saw already that it's working in Eclipse. And now let's look at Theor. So this is now a browser IDE. You could deploy this on the web.
20:21
And you have the same things that you're used to from the Eclipse editor. So it proposes you what you can do here. It reports when you're writing something wrong. So whatever you need.
20:41
And the server behind that is the same in Eclipse, in Theor, in Atom, in Visual Studio. You develop the language once, create an application. It's actually a runnable Java application. Then you need to provide tool-specific integration.
21:05
For Eclipse you would need to write a small Eclipse plug-in which uses LSP4E for example. In Visual Studio Code you would write a VS Code extension which is an NPM package. Same for Theor.
21:21
And it depends on the tool, how it integrates the language server. Basically what it does is it describes this is my file extension and whenever you open the file extension start the language server and communicate with that. So this is the integration work. But the language server is just written once.
21:48
So let's wrap up. We have Ethereum, which is a platform to execute smart contracts.
22:00
To execute them you need money and gas. And to write such contracts you need a programming language and one of those is Solidity. With the language server protocol we are able now to develop one language and provide it to different IDEs.
22:24
Almost all of the IDEs support that at the moment. And we just implemented a Solidity language which was an existing language with means of xText and so we got a language server for Solidity.
22:41
And so we provide good tooling now for this programming language. OK. I'm already done. I'm open now for questions. Yes?
23:06
There may be some very important thing to talk about or maybe the question. What about privacy? Does it send a file? One important thing about language servers is the word server is misleading.
23:23
It's not that you run the language server somewhere on the server and the client is on a different machine. It's usually bound to the same machine. It's just separation of concerns. You have one process which is the client, the tool and the server on the same machine also on the same file system.
23:43
And it's even bound to the user. So it interacts with the user. Yes? Is it hard to add LSP support to xText?
24:01
The answer is no. It's actually quite easy. And it's already integrated so you don't have to care about that. So the framework xText integrates language server support through LSP4j and you just don't have to care about that.
24:22
So the only thing is that you have to build your language using Maven or Gradle and you can get this out of the box that you get build scripts that produce your language server for that.
24:41
Question behind? The question is do we have experience with integrating language server in IntelliJ? Yes, but not good ones.
25:01
It's actually at the moment that IntelliJ is lacking behind. There's some plug-in developed externally that provides language server support. But it works okayish.
25:22
The best LSP support you actually get at the moment is visual studio and eclipse.
25:50
Question was how is ethereum involved here? Was it our initiative to develop this language? Yes, it was our initiative because we started to work with ethereum
26:04
and then we saw okay, the tool sucks. You can't really work with that. And we are an expert in language development so we started with that. But the ethereum foundation is a foundation
26:21
that collects money from its members and also spreads money to users and we got a grant to work on Solidity tools. So they partially funded the development now.
26:44
Okay, then no more questions. Thank you very much for your attention.