Programming tutorial - Create A C++ Addon For Node js

Поделиться
HTML-код
  • Опубликовано: 30 окт 2024

Комментарии • 50

  • @wormquartet
    @wormquartet 3 года назад +21

    Node -does- compile under the scenes, so once everything's optimized as part of that compilation, I'm not shocked that the results are similar. It's just a sign that the optimization is well done, at least for simple math like this.
    The big advantage you'll get with native C++ is doing things Node doesn't support - things that specifically target the operating system, things that access memory directly, or things that are optimized for the specific hardware you're running on.
    I do wonder if there's any overhead to loading the C++ module, and when that occurs. Is it loaded dynamically or is it part of the compilation?
    I've got a ton to learn about this...thanks for the starting point!

  • @ThreeCoast
    @ThreeCoast 4 года назад +6

    This tutorial is a hidden jewel. Thank you sir!

  • @damiondreggs3500
    @damiondreggs3500 3 года назад +4

    Thank you for leaving your value typo in there. It was fun to try to spot the error before you, and that got me engaged and invested in your video.

  • @LowellBoggs
    @LowellBoggs Год назад

    i did this experiment with java years ago and got the same confusing results. Then I switched from just numbers to something that allocated a million integers and added them up, and STILL got the same answer you are seeing, but then I forced java to garbage collect the memory of the array and the run time was dramatically larger for java than for c++. The thing is, in real world applications, sometimes the interpreter is plenty fast enough -- especially if you exit before garbage collecting. You will see c++ winning when you are creating huge amounts of memory in small fragments that must be garbage collected in the interpretive application. So long as there is no garbage collection, you may ever see c++ clearly win. Choose the right language for the problem and be aware that testing is complex. Also be aware that figuring out how to fix a garbage collection problem is not easy... though modern tools may help a lot.

  • @alexandersemionov5790
    @alexandersemionov5790 4 года назад +4

    Node is kinda the type of variable in javascript(on v8/ c++ level), unless you change the type of variable oi runtime it will be really fast with numbers. Good work buddy

  • @europeanextreme3636
    @europeanextreme3636 4 года назад +2

    Man you saved my life, thank you!, it worked perfectly.

  • @ProgrammingwithPeter
    @ProgrammingwithPeter 5 лет назад +3

    This is nice!!! Advanced stuff, good job!

  • @haneenmahdin7647
    @haneenmahdin7647 2 года назад

    If anybody is using a Mac, you will need to install the necessary tools. So, you can run this command: xcode-select --install.

  • @jameswagner2882
    @jameswagner2882 5 лет назад +1

    Thank you for your great tutorial! You really helped me!

  • @dqvist
    @dqvist 2 года назад +1

    WOW! Thank you so much!

  • @korbkrys5868
    @korbkrys5868 3 года назад +3

    Can you make a c++ function that accepts js values and returns values that will later be used in node.js?

  • @jazzpayee
    @jazzpayee 4 года назад +2

    Shouldn't c++ be faster in the runtime than js?

  • @xazii
    @xazii Год назад

    please reply, does this actually run the c++ code(at c++ speeds)? or does it just convert the c++ code to javascript and then run that javascript in node? because if its the latter that would explain why they're running at equal speeds, I started using this in my project because i thought it would give me the performance boost from using c++ that I needed. have I understood this whole thing wrong?

  • @paulux5167
    @paulux5167 4 года назад

    Thank bro, you really helped me out !

  • @islamzaky8724
    @islamzaky8724 4 года назад +4

    Whenever I try to include the node.h, it gives me error saying it's not included in path. I already have all packages installed where I was working with napi.h before but encountered some problems and decided to follow your tutorial so any suggestions how to fix it?

    • @johansaltin8187
      @johansaltin8187 3 года назад +2

      Maybe a bit late. However, I guess that it is the IDE/tool telling you that it's not included in the path. Node-gyp has its own header files, ignore what your IDE/tool says and configure then build. Worked for me, thanks!

    • @dawsonhorn5290
      @dawsonhorn5290 3 года назад +1

      @@johansaltin8187 I was going crazy over this issue, thank you!

  • @basescriptnet
    @basescriptnet 2 года назад +1

    doubles are pretty performance consuming. Try to convert it to long, and you will see the huge difference.

  • @guima_dev
    @guima_dev 3 года назад +2

    Hi, Firstly thanks for your video!
    Could you explain how make the same thing but using another C++ libraries as well ?
    No native libaries, another ones like Armadillo or Eigen.

  • @wesingtogether
    @wesingtogether 3 года назад +2

    i wish you had actually showed "the install process" and not just said "i already have it installed" because i am running into problems installing the dependencies!

  • @prakharpatidar6968
    @prakharpatidar6968 4 года назад +2

    Thanks for tutorial. Btw did anyone get why C++ and js taking same time for this functionality? I am also getting same results on my mac. Is it because of window/mac or anyone tried it on ubuntu?

    • @krishankumar8720
      @krishankumar8720 2 года назад +1

      i am also confused both are taking almost same time in ubuntu

  • @xizted7608
    @xizted7608 4 года назад

    Hey, man, how you doing?
    I have a question, is there a way to return the value of the function to a variable?

  • @saeedmahmoodi7211
    @saeedmahmoodi7211 3 года назад +2

    i did the exact same thing , c++ was at least 12 time faster

  • @rashadblitz3552
    @rashadblitz3552 3 года назад

    is this possible to do with mac?

  • @collier801
    @collier801 Год назад

    In my main file (addon.cpp) I have included a header file (prova.h), located in an src folder that I created. The function that it declares is implemented in the prova.cpp file (located in the same directory). This is the content of the addon.cpp file:
    #include
    #include "src/prova.h"//

    • @collier801
      @collier801 Год назад

      I just solved my problem by deleting the build folder and rebuilding.

  • @kkm_dev
    @kkm_dev 5 лет назад +1

    nice tutorial but you should type in title with "Hello World" that is better for noob.

    • @europeanextreme3636
      @europeanextreme3636 4 года назад

      Here you got it: nodejs.org/api/addons.html#addons_hello_world

  • @Safinsdi
    @Safinsdi 3 года назад +1

    OMG what a nice voice?

  • @alisterroy4903
    @alisterroy4903 5 лет назад +2

    your video is soo good and simple ... could you please tell me which node-gyp version you used?

  • @fein7068
    @fein7068 3 года назад +1

    I think if you run c++ clean, the results will change

    • @aaa22421
      @aaa22421 Год назад

      Could you explain how to run c++ clean with c++ code in this video, please?

  • @msdmansory
    @msdmansory 3 года назад

    OOMMGG

  • @ara7546
    @ara7546 5 лет назад

    change double to long

    • @FullstackDevelopment
      @FullstackDevelopment  5 лет назад

      Wouldn’t that produce an incorrect result of the c++ algorithm compared to the result of the js algoritm? I mean due to precision differences

    • @ara7546
      @ara7546 5 лет назад

      @@FullstackDevelopment i do not know,but of changing to long ,it becomes faster