 I often hear criticism to other projects especially GNOME because they use JavaScript and as we all know JavaScript is banned as low and crushes but does KD actually use JavaScript to what extent and if so can we just get rid of it. So before we get into that I just want to say a quick thing one thank you to all the donations and be important tomorrow I'm going to try to live stream my first live stream and you can do like ask me questions regarding specific bits of the code that I can walk through you through anything you would like and you know if you want to learn about something specifically you can just come tomorrow and ask me and I'll do my best to actually show you anything that's in my power to explain. So getting back to the actual video's idea does KD use JavaScript and the answer is yes pretty much everywhere actually and this might come as a surprise and if you think about KD Plasma all of KD Plasma interface is actually written on actually it relies on JavaScript because all of the interface is written in QML and QML uses JavaScript for evaluations of properties and also all of the new applications like discover part of system settings but also calendar KD connected the actual application they're all written in Kuri Gami and Kuri Gami uses QML which again relies on JavaScript. So JavaScript is actually used throughout KD whenever we have a user interface we don't use it QML I mean when like let's say older applications so like ocular, one view those use K widgets which are different but all of the new ones and KD Plasma do use QML and JavaScript so why do we do that and the simple reason is that QML is actually pretty good in what it promises to do it's very very easy to do an interface and edit an interface in QML even for non-programmers we've got a lot of the designers and if you're not experienced with C++ don't worry you can make a big impact on KD's code just by working on QML I myself mostly do QML related stuff so why does QML use JavaScript and well you should ask that to QT but it's a good fit actually to QML personally I don't like JavaScript I don't like it as a programming language but it works really well inside of it let me actually show you an example of what QML does and how it works just give me a sec so this is QML and you can see that let's go to the beginning we've got as an example this ID is configuration area now this configuration area is a variable and probably I don't know how it's implemented under the hood but probably this is a JavaScript variable because inside of this text I can put any maybe not this one but this one the ID is a bit special but this one sorry 100 and 1000 is a JavaScript number and uncourse field is currently out is a JavaScript variable because I can put like conditions like this and the health statement like this this is a JavaScript statement and it just works inside of what is QML which is this mouse area open brackets thingy that you don't see in JavaScript because it's actually not JavaScript am I recording this right yes so you can also and we do this a lot put some score brackets and actually write full flashed hello from JavaScript in here this is JavaScript and you can do almost whatever you can do in actual JavaScript and we do that as an example on position change that is when you change the position of this element which I haven't I don't even know what's this about this just an example but when the position changes then you do if pressed then bar padding equals this is all JavaScript so you might try it fully ask wait wait wait is this going to make kitty suck and the answer is no because well we do already use QML pretty much everywhere in kd plasma and kd plasma is not slow by any mean I think if you use it on a very low end device you want to really notice that is low let's refer to everything and I'll also add that if you seem to think that kd plasma is slow especially on like a slow hardware it's usually because it takes a bit to open up pop-ups for the very first time if you open up kickoff as an example for the first time it will take a while and from the second time and on it will be faster and that is because QML requires a cake which is build when you first open up pop-up you could ship with the cake by default but there are issues with that like compiling that's called compiling QML and there are issues with that which I won't get into it but usually when one thinks that kd plasma is low it's because of that and not because of the JavaScript that runs with QML now couldn't we get rid of it and yeah technically yes but we would have to get rid of QML of course because QML does rely on JavaScript right now there is no way as far as I know to use QML without JavaScript maybe in the future there are some talks about some compiling QML you know into C++ and that could be something different but right now it relies on JavaScript and in order to get rid of JavaScript we would need to get rid of QML can we do that I mean yes we can do whatever we want but that would require years and rewriting pretty much all the user interface from scratch and that's not a good idea because I don't know if you remember the last time we like the last time kd rewrote everything from scratch well it's very hard to get it tried on the first try it's probably going to be bugger than before because when you rewrite everything from scratch you're going to introduce back that's very natural but should you even consider getting rid of JavaScript on kd plasma doesn't slow it down and it really depends on how you use JavaScript if you use JavaScript for everything everything well that's going to be an issue but if you only use it like wisely only related to the very UI things that are short and doesn't require much computer computational power that's not going to be an issue let me make an example even this function here which is looks gigantic it doesn't actually do much and is called very rarely this is actually part of the panels code and it only gets called when you move the mouse while you're dragging which is the pressed part of it when you're dragging or moving the mouse while in edit mode so it's getting called right now as I move my mouse again sorry I wasn't calling sorry as I was saying this code that I showed you before gets called here when I move my mouse and it's not really slow and that actually rarely happens edit mode is a really thingy and all it does is really to do a couple of checks a couple of ifs and then it calls stuff like add applet and add applet is a c++ function so it does a couple of checks sets a couple of UI variables that you have to set from QML and then you just call the c++ function to finish it all so it doesn't actually have a significant impact on kitty's performance because it does so little and is called not very often and if you go open a random QML file which is not I don't know let me pick a very random one just give me okay this is the main QML file of the system monitor and we can see that JavaScript is being used line 25 which is the very first lines what are we doing here we are checking if there exists a current item and if so we return the title of this current item plus the minus plus system monitor and okay it does make sense it's pretty simple but basically says do I have a page open and if so the title of this page is that the name of that page plus system monitor that's very simple it's actually the title of the application and in its entirety and this relies on JavaScript but it's so little JavaScript which is called not very often because it only changes when you change I guess the current item and it's it's not going to have a significant impact on the performance what is going to have a significant impact is the actual part of the system monitor actually monitoring things and that's c++ of course but the UI and the UI related things are in JavaScript there are very small snippets of code and they don't impact on the performance that much at all really so am I happy about the current situation like this whole QML plus JavaScript plus c++ thingy honestly I don't have much to complain about I do wish that QML had a way to have like a subset of QML which maybe you lose some as per aspect of JavaScript like this array.particle.map.call this kind of things maybe you can just give up this on certain parts of the code but then be able to compile this part of the code to c++ that might improve performance somewhat but it's not like the current situation is bad or slow really you have to wisely use and JavaScript and QML you'd have to know when to implement something on one side or the other but once you do that it's pretty good really I have nothing to complain about and the upside of that is that it's really really really easy to like change things in QML for first time contributors which is why when there is something that doesn't like isn't super slow doesn't impact performance I'm more than happy to leave it QML and plus JavaScript when possible of course trying to reduce the part of JavaScript if it does per impact performance but when it doesn't and you know I rewrote the panel's code because it was impacting performance in my opinion but now that it doesn't as far as I can tell well the fact that this QML means that it's much much easier to people to get involved with the panel maintain it and contribute to it and the maintain part is pretty important because you know if I have to maintain a bunch of c++ code and I'm not very experienced with c++ it's going to be harder whereas if it's QML I'm going to be I'm going to feel much better about maintaining it and that's actually pretty important if you do want to have a good panel like again I'm rewriting all of the panel's code and I can do that because it's QML plus JavaScript now it wasn't I think very performant before but now I think it is I think it's better hopefully and it's not like before it was that slow actually but I do think that there is an improvement and if you do want to change something in the panel or improve it well it's actually pretty easy I've showed in many videos how the panels could work um this is the main file of the panel as I'm working on this and it's rather intuitive like it even got it even has comments if you add an applet then you create a new element with that applet called a context applet I explain what's this in a previous video of mine you create a QML QT binding which is explained some more I think some more in a comment maybe I deleted the comment accidentally served by that and then you check if x and y are more than zero then you actually insert the new element at the coordinates x and y and if the applet is a plasma icon well there is a whole comment explaining why that is hard coded use case well you actually insert that item at the very middle of the panel else you just append it to the elements which is of course at the end and then you update the margins okay so this maybe it's not very clear at first like read but it's not that hard either to understand now you could argue that the C++ code would be just as easy to understand but the C++ code would be detached from the actual UI code that's related to the panel and with this thing on I can do like as an example where is it where is it in here I do use somewhere somewhere as an example I say layout manager which is this file here now the layout manager has this variable called yeah layout which is used throughout the file and this layout element is actually this UI element called current layout which is a grid layout and if all that I showed you before was C++ you wouldn't be able sorry to have the layout variable and at the same time like the same very file know what you're editing sure you can have both file open but I think that it's much easier for newcomers and for maintainers to actually deal with code as this one when it doesn't impact performance and in this case and many other it doesn't so kitty does rely on JavaScript pretty much everywhere but it's not a problem and I think that we should stop bashing other projects because they use JavaScript because it's not that JavaScript is bad per se you could argue that but it's how you use it if you use it like for the entire project your entire project is written in JavaScript okay well of course you can't expect it to be super fast but if you use it in the right places it's not going to be an issue if a project is slow it's not because of JavaScript unless it's like the entirety of the code is JavaScript but that's usually not the case that was it and see you tomorrow