Questions regarding JavaScript, WebSockets, WebGL

I saw a lot of stackoverflow questions regarding other client-side scripting languages

The Internet is becoming a very busy and dynamic place. The HTML and CSS specifications are trying to take the Internet to the next level - we get WebSockets support, which is very good for full-duplex client-server communication, allowing you to create fascinating design patterns. In addition, we have a working implementation of WebGL in JavaScript, which I had a lot of fun with.

But this caused some concern, at least for me. I am a desktop programmer, C / C ++ / Objective-C - depending on the platform. In particular, the rendering of an architect. JavaScript served us all amazingly, right? We used it to get basic user interactions with 2D linear websites, respond to simple events, and combine all of this with HTML and CSS.

Given the fact that real-time doors and GPU-oriented visualization were open on the Internet, will this have any consequences for JavaScript? I saw a reaction to Dart and other attempts when I clicked JavaScript. JavaScript is weakly typed, which sounds all kinds of alarms for me (given the intense mathematical library that hangs at speed, unnecessary checking of the runtime is not a fun time).

I moved a lot of code to the GPU, but even then my internal rendering was simply CPU related (the HD6990 problem cannot be a problem, not to mention the code that supports the desktop / built-in engine).

So, here it is in front of:

  • The code is bare due to the design of the interpreter. Rendering technologies and solutions costs a lot of money. This is the only foundation of my company and pays the bills. Obfuscation does not cut it (correct me if I am wrong). I always wondered why there is no intermediate compilation process in the form of bytecode that can be processed by the VM?

  • It is weakly typed. Juggling matrices, vectors, quaternions, arrays, and all other types of data common to highly interactive applications simply handle take-offs with runtime checks. Despite the fact that he eventually switches to the GPU side, you still have to do a lot of work on the processor side, which is stuck in JavaScript.

  • The prototype-based paradigm will weaken efforts to transfer code from leading players who can promote the adoption of WebGL / WebSockets. (remember that many of them are processor controlled). Will the prototype-based paradigm persist as more and more users begin to demand high quality 2D / 3D content?

  • WebSockets turned out to be a great new addition to web games (BrowserQuest), not to mention dynamic websites, and in the future many people will be created to develop amazing content (my company works with a small closed project that implements a small MMO in a 3D environment managed by WebSockets).

So, are my problems really based on reality?

Are there any new movements regarding these issues?

If you offer any answers on this topic, could you also add a small paragraph of personal opinion? I know that this is not a “Stackexchange method”, but it is not harmful, since all other questions are legitimate and the answers can actually be based.

+6
source share
3 answers

Your problems are based on a misunderstanding of how Javascript works, and basically have no reason.

  • All JIT'ed Javascript Codes are currently an intermediate bytecode language and are not recognized as a potential hindrance to portability, which is the top virtue of the Internet. Modern scripts such as programming languages ​​such as Python, Ruby, PHP, etc., work well, even if applications are not distributed as bytecode. The bytecode step is not needed, as the JIT'ed code in the end. The more material you can provide JIT for work, the better. In fact, for Java, they turned off bytecode optimization in modern versions because it confused the JIT compiler.

  • JIT compilation can optimize dynamic typing problems, although they will never provide statically typed performance, but they are likely to provide fairly good performance. There are some problems, although http://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript , but the Javascript implementation improves the work on these problems. For example, the Mozilla Audio command (which seems more like a demo command ...) runs 3D demos just to have material to optimize Javascript runtime.

  • I don’t understand why the prototype-based approach will have anything to do with high accuracy, these are two completely different things.

  • Alternative approaches, such as Google NaCL, are currently not supported by other browser providers and are likely to never be, as Microsoft and Apple will not use Google technology, and Mozilla sees that NaCL is threatening to open a website.

To understand how modern JIT compilers work, see the PyPy blog http://morepypy.blogspot.com/ (although not Javascript). They explain in detail exactly which JIT optimizations use modern computer science for code.

For what "web design patterns can be achieved in 3D", see tQuery, which is jQuery, for example, a framework for 3D content https://github.com/jeromeetienne/tquery

Cheers, Mikko

+6
source
  • The Javascript code is bare : it seems your question is about protecting "intellectual property." I think you overestimate the protection that compilation provides. Compilation hides your algorithms only slightly better than good obfuscation; a good decompiler will show most of what you are trying to hide anyway. Compilation and obfuscation protect you from the curious not from people who are determined to steal your ideas. If you want to protect the form of your code, for what copyright. I will also point out that one of the reasons for the success of the web platform is the "source of view". This is perhaps the largest educational tool for those who want to learn how to create great websites and web applications. This is an increase in open source power (lowering the barrier to viewing and changing the source).

  • Javascript is weakly typed . True, but if you are going to perform mathematical operations on large data sets, then you will use typed arrays, which are a fixed size and have elements with fixed types / sizes. In addition, type inference (in Firefox 9) significantly increases the performance associated with a variable reference.

  • Javascript is prototype-based : prototype-based inheritance is more expressive than standard-class inheritance, and with a few sugar functions you can do pretty standard class-based inheritance in Javascript: http://www.crockford.com/javascript/inheritance. html

  • WebSockets I do not think you asked a question about WebSockets. And yes, they are a great addition to the platform, in particular the latest protocol iteration and API, which allows you to send and receive Typed Arrays and Blob data directly.

Opinion

The performance of WebGL and Javascript has not yet reached the point where you could take the latest AAA first person shooters. However, I can assume that the real money that will be made in the near future with 3D games is random web games. This has already been confirmed in the case of random 2D games on the Internet, and WebGL is becoming so widespread that it is ripe for successful random 3D games.

Also, if you have a big investment in C / C ++ 3D libraries, you can consider Emscripten , which is a compiler that targets Javascript and has surprisingly good performance.

+2
source

I think this is very interesting, especially part of the obfuscation. I myself was in the console / board game industry for many, many years before I went online, like 6-7 years ago. At first, the view source was very strange to me. But slowly I fell in love with him and thought differently about technological solutions.

True, it costs a lot of money to develop high-end technologies, and it’s true, it’s very easy to copy your ideas and solutions. It is also true that you cannot protect them with copyright or protect them in any way at the time of publication. But is this really a problem? I think this inspirational conversation ...

http://www.ted.com/talks/lang/en/johanna_blakley_lessons_from_fashion_s_free_culture.html

... about how it works in the fashion industry, really nails it - to stay successful, you need to be on your feet and continue to grow. Whatever you do, history is done, now what's next?

The advantage that you have is your tools and conveyor, which in my experience are more expensive and more complicated than the actual part of the rendering. And you already have an experienced team and a game that you hope to monetize successfully.

In addition, in fact, I believe that online experience is associated more with social aspects than with graphic ones, which are largely server-side and thus protected.

Looking forward to your game!

+1
source

Source: https://habr.com/ru/post/912594/


All Articles