C++ Ethereum and Emacs
Devcon 0 · November 2014 · 13:34
Lefteris Karapetsas presents on working with the C++ Ethereum client from the Emacs editor. The Devcon 0 session treats editor integration as part of the developer tooling around the early Ethereum clients, and touches related setup such as Vim and the el-get package manager for people building on the C++ implementation.
Speakers
Topics
From Devcon 0, hosted by Ethereum Foundation.
Transcript
[Music] I introduced myself yesterday too I leis and I will be working uh in solidity and generally C++ uh development for ethereum um this talk will be about de having a IMX development environment um for ethereum it will be quite a short talk um so even if you're not interested in IMX I guess that um it may get you interested a quick question Who except from Felix that I
know of is actually using IMX here okay good great we verus nope that's not in the no religious wor here never so uh goals of this presentation would be to familiarize with how to develop um for CPP ethereum with IMX um and also so ways that we can develop for ethereum inax like develop solidity contracts um maybe make you guys like him much more that's that's that's that's a very
ambitious goal but yeah so why why why emo right the advantage is that along with Vim it's one of the most popular editors and um as um as developers are our user base we should provide easy ways for developers to develop for ethereum using one of the most popular editors it's extremely customized and it's a tool that suits uh our needs since we want to be creating You languages IDs around um uh the contracts Etc well disadvantages uh is that you really need
to customize uh the editor it I mean anyone that has opened the vanilla emox must know that it's really difficult thing to use uh and as this um temporary computer s um it's a Memory hog um IMX for some people may mean 8 megabytes and constantly swapping uh or IMX makes a computer slow something that shows that uh it actually consumes a lot of memory uh just for your reference it actually uh the original um abbreviation was editor macros
so um how do you set up a nice environment in imox then if not using the vanilla editor there are many different uh environments that you can use um I would go with using um a package manager called lget um specify packages for C++ development set them up and get to developing um so this is elisp code it's a um the least flavor that uh Powers IMX um so only with this small um snippet here basically you have a package manager that will uh uh install
update and synchronize your packages um uh whenever you uh open your editor whenever you open your computer if you run IMX as a server which is what you should be doing um and also when you transfer your setup to a new computer it has various commands these would be the most uh important ones so you can download packages install packages delete or update all the packages and for a clean neox setup basically you would have something like a list of packages and a call to synchronize um uh the packages so whenever it would um if it's a new
computer and it reads this uh setup it would contact probably GitHub download all of these packages build them if there's a make file and um load them uh into your remarks load B so but what what is required for C++ development uh people will tell you different things uh old older developers would go with imox default which is said it I would suggest um packages that through my own experience have become um very useful uh over the years of development
and that is arxs um auto complete flight projectile and one that uh seamess advertising malinka is a packet that I have made which is a small um uh package that is glue between um the other ones so uh malinka the only thing that it does is create um uh project definitions and um so this is a project definition basically um it fits the data to all the other packages so um uh to tags uh
creators or to syntax takers because um we may need need to we we will need to know the include directories of the project the macros the defines that are used Etc and also we have um like compile command so that we can easily compile the project test command to easily run the tests um yeah artx so this this is an amazing package that's quite new it interfaces with sang It's actually not um Elis code it's it's a native code it's a made in C++ 11 and creates a
client server um that um creates a it's a I mean it's a client server um interface that has a demon running in the background of your um uh uh of your operating system and creates a memory database of all the tags of your project for CPP ethereum because we have one big make file that makes the whole thing it's over 2 gigb um which is quite a bit uh but it's uh very fast once the database is created it you can find the references of um your uh uh of functions where they are used you can get aut completion and
you can get um what is called in sang um as fix it hints so in a bit more detail now I'm pretty sure that yeah the resolution is not so nice but so there is a function and you would like to see where it's used you um you can just basically with one key combo see all the references very easily and jump around uh the references uh Auto completion for example this is from our um uh P2P library in C++ um there is
a can you guys SE there is a a boost uh basic resolver basically from the a your library of poost and um just by typing um uh are you you see the type and you get the autocom completed functions and this happens uh without any delay like it happens in other um um inferior let's say emox packages uh and a very nice um it's too small a very nice uh thing that sang has is fix it so it kind of it runs a uh in real time it runs a checker on
your code that um um does static analysis and provides hints so for example here this is from the scanner of solidity and there is the the location is valid uh method but um it's misspelled and um the sang static cheer actually um realizes that tells you that it's mispelled and it gives you a suggestion as to how to fix it um which you can um apply immediately with the basically this key combo which is a default uh but you can customize it
um another very useful package is fly check that basically runs syntax Checkers for any language that you may desire python Lis C++ for C++ it uses the sank syx Checker um least but last but not least is projectile is a must have um um package for uh NX development environment because it uh automatically uh indexes and creates projects by using the version control system so I don't really
need to say that you know CPP ethereum is a project I don't need to index any files I don't need to do anything um all I need to do is remember some key combinations and um I can easily switch between header and sources compile the project test it grap or AK or AG or whatever you have uh you can also do uh Version Control commits um and um various other interesting stuff I would refer you to the documentation of the of the project if you want to learn more so that's about C++ but
um what about ethereum uh so how can we develop contracts inside um uh IMX that's I mean solidity still under development um uh someone uh from the forums of uh ethereum actually developed a serpent mode which you can get here but uh as for solidity um over the weekend I made the solidity mode INX which is for now uh just the syntax um uh highlighter which you can see here and an indentation um so it properly intense and highlights the syntax of
solidity uh this is the the contract that I think uh Chris used in his example of online solidity compiler right the the ballot contract so as I said for now it is very simple just highlighting an indentation um but in the future we can uh provide Auto completion just like any other uh language as soon as we get the EST uh out of the solidity compiler we can fit it as the input data to any autocomplete package in image uh we can also integrate with the debugger uh when that's possible and
also with other tools that will be developed um for the for the ID for uh solidity so yeah that's it uh as I said a small presentation for IMX so any questions or um what is this thing are you thinking of doing something in bi as well no I don't even know the key binding in Co no questions okay
[Applause] thanks