DEV Community

Cover image for VR-coding
Ilya Chistyakov
Ilya Chistyakov

Posted on

VR-coding

In light of the release of a new Apple product, I decided to tell you about a small research project in the field of VR coding. I hope that the article will inspire readers to develop this area!

What started it all?

Digging into regular legacy code of 8k lines long for several days I gradually started to go crazy. When suddenly the idea came to me to build a call graph. And lo and behold, everything suddenly became clear! It was a breakthrough and this result was used many more times by other teams. Then I found myself reflecting. We often talk about the importance of writing documentation, sometimes we write it, but often it quickly becomes outdated. Usually these are dependency graphs or sequence diagrams, which helps a lot to understand complex processes. And I thought it would be great if these graphs could be built based on code. And that's how I got excited about creating a visual programming language called Gravis.

The main idea

The point is to come up with a programming language that will allow you to comfortably create programs in three-dimensional space using VR. It will allow you to observe in real time how the application works. I mean... flying messages here and there and generating meta code. Also, the language will allow you to beautifully illustrate algorithms. Not only programmers will be able to enjoy the beauty of the code. Such a code can be thematically designed. Most likely it will be an expensive pleasure to attract programmers. This will brighten up the development and make it possible to make wonderful code presentations. Just imagine that your work takes place in the Star Wars universe! This is not only beautiful, but also allows you to use spatial memory by making modules with different objects and memes.

Examples

There is already a successful visual language - Blueprint in Unreal Engine. But it wasn't easy to work with him. There were still files there and the interaction between them is not transparent. There are also variables that live separately from the graph, which also prevents you from quickly understanding the code. To create blocks, you still have to write a lot of text. This case is not suitable for VR.

Development

It was necessary to choose a calculation model. I wanted something simple. The code consists of notes and connections between them. Each connection transfers control and data. That's it!

My love for python is endless! So I started writing an interpreter on it. Implemented basic primitives - numbers, arithmetic, branching, recursion. And a profiler.

An example of calculating the fourth Fibonacci number (the code presented in the title of the article) An example of calculating the fourth Fibonacci number (the code presented in the title of the article)

The numbers in parentheses are the operation number, the number below is the transmitted data. The arrows transmit control and data. Dotted arrows transfer control in search of the starting point for calculating the missing data. Nodes: I - input, O - output, rhombus - condition or arithmetic, circles - numeric constants, subspaces - recursive call.

To describe the programs, I took the DOT language as a basis. Now it was necessary to visualize it. The choice fell on Unity. Since the project is open-source, it seemed that it would attract more supporters. I managed to draw the graph.

Fibonacci in 3D Fibonacci in 3D

I quickly realized that my knowledge of Unity is not enough to cut something further. The process was frozen for a couple of years. Then I decided to hire developers. They added a lot. A full-fledged editor, now you can create nodes and links. It remained to implement the last pre-release feature - grouping nodes into subspaces. Which would allow working with recursion. But it turned out to be an impossible task. So here I folded my paws.

Difficulties

  • It is still unclear how you can work with more complex data structures. I had a lot of thoughts, but I didn't come to anything concrete.
  • Text. I think it will still be necessary and a voice assistant will help us here.
  • The 3D graph turned out to be not even very visual. Therefore, in my fantasies in VR, it will be more like a wall painting. But! In 3D, it will be very visually possible to watch the execution process when subspaces are created as a separate layer.
  • Diff. What can I say. Very difficult question. Naturally, the usual CI tools will not work.

Github project, suddenly someone will be interested to dig into it.

Top comments (0)