《MobiDev:2023年使用node.js進行后端web開發(英文版)(14頁).pdf》由會員分享,可在線閱讀,更多相關《MobiDev:2023年使用node.js進行后端web開發(英文版)(14頁).pdf(14頁珍藏版)》請在三個皮匠報告上搜索。
1、Table of ContentsWhat is Node.js and How it WorksNode.js Frameworks/ApproachesNESTJSELECTRONDENOWhy Use Node.jsLIGHTWEIGHT,FAST APPLICATIONS WITH REAL-TIME COMMUNICATIONSERVERLESS AND MICROSERVICE ARCHITECTUREINTERNET OF THINGSAUDIO/VIDEO PROCESSINGRAPID DEVELOPMENTINTEGRATION WITH C+CODEComparing N
2、ode.js to Other Backend TechnologiesNode.js vs JavaNode.js vs PythonWhen NOT to Use Node.jsDEVELOPING FINANCIAL SOFTWAREAPPLICATION WITH COMPLEX CPU CALCULATIONSNode.js Trends in 2023 and BeyondWrap Up1Developing modern software applications is an essential undertaking for anygrowing business.Fortun
3、ately,the ongoing advancements in applicationdevelopment technology have presented business owners and project managerswith a plethora of options to choose from.However,the breadth of possibletechnologies available can be overwhelming.Its important to choose the righttech stack for your business bas
4、ed on the objectives and priorities you haveestablished.One such technology that is widely in use today is Node.js.As a modernapplication framework,Node.js has been adopted by many companies to buildtheir backend tech stack.Its usage can be seen across industries as a popularoption for server-side a
5、pplication development.The popularity of Node.js today is increasing exponentially.Node.js is currentlyin use by well-known companies like Netflix,Uber,PayPal,Twitter,and more.And among web programmers,Node.js was named the most popular webtechnology according to StackOverflows 2022 Developer Survey
6、.It was chosenby 42%of respondents.But what is Node.js?How does it work,and is it still relevant in todaystechnological and business landscape?More importantly,why are so many2big-name companies and professional developers using it?These are thequestions we will answer in this article.What is Node.j
7、s and How it WorksIn terms of application stacks,Node.js presents an interesting intersection offrontend and backend technologies.Built on JavaScript,which is traditionally afrontend,client-side web scripting language,Node.js extends the capabilities ofJavaScript to run on the backend,server-side po
8、rtion of a web applicationarchitecture,as well as for serverless architecture.Node.js does this by executing within its own runtime on the server.A goodanalogy to draw is the comparison between Node.js and Java,which also runsapplications within their own runtime.The Node.js runtime is designed to b
9、elightweight and efficient,with non-blocking I/O and a package manager to makebuilding applications in the Node.js ecosystem even easier.The package manager for Node.js is called npm.Its purpose is to serve as anindex of libraries built by the Node.js community of developers which are easilyshared a
10、nd imported by other projects.These packages provide helpfulsolutions to common functions and code that simplify scaffolding new projectsand improving old ones.3Node.js Frameworks/ApproachesEven though Node.js itself is a powerful and versatile platform,there areframeworks/approaches that have built
11、 upon Node.js to improve it even further.NESTJSNestJS is an open-source,extensible,and versatile Node.js framework whichincorporates TypeScript(a superset of JavaScript which is a strongly typedprogramming language).It is built on an abstraction of other Node.jsframeworks like Express and Fastify.Th
12、is abstraction makes it easy to learn andget up to speed when building projects.NestJS is built on the concepts of Modules,Providers,and Controllers.Modulesare logical units of code organized together.Every application will have at leastone root Module,but more can be built on top of that as the cod
13、e is organized.Providers are abstractions of code that can be injected as dependencies.Controllers handle incoming requests from the client to perform applicationlogic and return a response.4The NestJS framework is great for the advantages of TypeScript and the benefitsof other abstracted frameworks
14、.The ease of use and extensibility are good fordeveloping applications around a microservice architecture as well.Theframework provides a strict project structure and implies the teamwork ofseveral programmers,which helps set up a less buggy development process.ELECTRONJavaScript is primarily a lang
15、uage for web application development,so it makessense that most of the frameworks built on it are also intended for the web.However,Electron combines the Chromium rendering engine and the Node.jsruntime and allows the development of desktop applications using JavaScript.Electron simplifies desktop a
16、pplication development by allowing programmersto write these apps in platform-agnostic web languages like HTML5 and CSS.Italso makes the packaging and installation of these applications much easier.Electron is therefore good to consider when your business use requires adesktop application without th
17、e complexity and redundancy of developingnative applications for different platforms.The Electron frameworks usage ofweb languages speeds up the development process and reduces the time tomarket for new products.DENODeno was released by the creator of Node.js in 2018 to address many of theproblems N
18、ode.js developers and users had experienced.Specifically,theseincluded addressing issues around security,modules,and compatibility.Like Node.js,the Deno runtime executes code in its own application.However,Deno programs are more secure in that the runtime executes within a sandbox,isolated from the
19、underlying file system.This adds security that preventsattackers from“breaking out”of the executable runtime and gaining access tothe server the code is running on.5Deno also eliminates the need for a centralized package manager system likeNode.jss npm.It does this by allowing modules to be imported
20、 directly by a URLand caching those modules in case the hosting URL is unavailable.Finally,Deno supports TypeScript and strives for enhanced browsercompatibility.For these reasons,there are a number of companies who arealready expressing interest in adopting Deno for their own use cases,howeveryou s
21、hould keep in mind that it is not yet supported by the major cloudproviders,so Docker images should be used.Why Use Node.jsNode.js is an applicable solution for many different types of use cases.As aprimarily server-side framework,Node.js lends itself to applications within thebackend side of the te
22、chnology stack.Below are a few of the instances whenNode.js makes sense to use.6LIGHTWEIGHT,FAST APPLICATIONS WITH REAL-TIMECOMMUNICATIONUnderstanding the size of your product is essential for choosing the righttechnology to build it with.The flexible and efficient nature of Node.js lends itselfto b
23、uilding small,fast,and scalable applications.Real-time applications likeinstant messaging and collaboration tools are one example of this.This,coupledwith the fast synchronization abilities of Node.js also make it useful forevent-based applications.Examples of these include applications that useWebS
24、ockets and WebRTC.SERVERLESS AND MICROSERVICE ARCHITECTUREBecause of its flexibility,Node.js is very good for building both serverless andmicroservice-based applications.These design styles are both very popular forsaving resources and efficiently managing application lifecycles.Serverless architect
25、ure is popular for its ability to save computing costs by onlyrequiring the resources the application needs to run with no additionaloverhead.These applications are stateless and lightweight.This makes Node.jsintegration with serverless architecture a great combination.There are npmpackages for serv
26、erless design,and building a serverless Node.js applicationworks well with an overall microservice architecture in C2C and B2C use caseswhen the server load is volatile.INTERNET OF THINGSNode.js is very good at handling simultaneous connections.Since IoT is built onmany devices sending small message
27、s that must be handled quickly,Node.jsmakes a good backend for these kinds of applications,providing serverlessarchitecture and real-time communication support.AUDIO/VIDEO PROCESSINGNode.js handles asynchronous input and output much better than othertechnologies.So,when combined with external media
28、tools,Node.js can be usedas an option for processing and handling multimedia data.For example,astreaming setup can be easily configured using Node.js.7RAPID DEVELOPMENTThe ease of use that Node.js offers by being built on common web languagesmakes ramp-up times very minimal.New products can be built
29、 quickly andbrought to market without delay.The amount of engineering resources requiredto do so is also reduced because of this.This case study shows how Node.js helps meet strict deadlines.The product,anonline marketplace for hail damage repair contractors and clients,was set to belaunched before
30、the high season started.Choosing between PHP and Node.js,we decided to go with Node.js to meet both the functional requirements anddeadlines.Using isomorphic architecture allowed us to reduce the developmenttime.INTEGRATION WITH C+CODENode.js is able to seamlessly integrate with existing C+libraries
31、.This is becausethe Node.js runtime is essentially built on a C+server that runs on the hostnode.That allows Node.js to quickly transmit data between C+and applicationcode.Comparing Node.js to Other BackendTechnologiesIt may seem confusing that Node.js is distinct from other technologies,and thediff
32、erences between them might not be immediately apparent.After all,eachframework is designed for a purpose.Below are some of the most commoncomparisons between Node.js and similar technologies.Node.js vs JavaIt is common to compare Node.js to Java because each tool runs programswithin its own runtime
33、environment.However,that is where most of thesimilarities end.Java is a compiled,object-oriented programming language withsyntax similar to C+.Java programs are typically large and costly to develop.Incontrast,Node.js programs are lightweight and based on non-compiled weblanguages like JavaScript.It
34、 is also much more suited for I/O applications andefficient server-side handling of HTTP requests.8So,even though Java and Node.js may share similarities in their runtimeapplications,their use cases are actually quite different.Due to the event loop,Node.js is more efficient when operating with I/O
35、applications,whilst Javasthread pool is more powerful for complex computations.However,we canleverage both as microservices in one project.Node.js vs PythonPython is a widely popular programming language due to its simple syntax andeasy usability.These make building new projects in Python very easy,
36、which hasled to its popularity and explains its similarity to Node.js.However,Python isanother object-oriented language like Java.And even though it is interpreted(like JavaScript),its programs can consume large amounts of computingresources.It is however useful in big projects for areas like AI and
37、 math-heavy simulations,which are not areas that Node.js is useful for.Pythons libraries make it easier tobuild the application logic,however its architecture makes performancechallenging and requires a highly skilled programmer involvement.When NOT to Use Node.jsWhat are the cases when Node.js shou
38、ld not be used?DEVELOPING FINANCIAL SOFTWAREUnfortunately,fintech is the single sphere where Node.js is definitely notrecommended because of the specifics of work with the floating decimalpointit can lead to accumulation of errors in variables that deal with finances,which is unacceptable.There are
39、tools that allow you to build logic withhigh-precision calculations;however,all of them have drawbacks and must beused wisely.Our own good example of a financial management solution is basedon Ruby.9APPLICATION WITH COMPLEX CPU CALCULATIONSNode.js is not the best solution when it comes to work with
40、highly loadedthreads that involve CPU.A good example is when audio and video processing iswritten on the back endas opposed to the abovementioned recommendeduse of external processing tools,e.g.either ffmpeg/imagemagic or externallibraries of C+or Go.Node.js Trends in 2023 and BeyondThe domination o
41、f Node.js as a popular backend technology is well established.And with current adoption by over 20 million websites,Node.js is sure to remainin use for the foreseeable future.But when developing a Node.js project,it isworth paying attention to other innovations in this area,technologies thatexpand t
42、he capabilities of Node.js or can become a better alternative.The advent of Deno as an alternative to Node.js is one trend that looks tocontinue.The improvements to security and compatibility that Deno offers aremuch needed as more businesses expand into web technology.Along withDeno,NestJS is gaini
43、ng adoption thanks to its extensibility and modularity thatmake it flexible for growing apps.The need for scalability is boosted by a widespread shift to serverless andmicroservice application design.These small,lightweight architectural styles aremuch different from the large monoliths of tradition
44、al software design.Lightweight applications are cheaper and easier to build,and their reactivenessmakes them ideal for real-time applications and IoT.Another promising innovation is Bun.In fact,this is a new runtime for JavaScriptand TypeScript,still under development,but with great prospects.The ma
45、inadvantages of Bun are improved performance and speed due to the fact that itis written in the low-level programming language Zig,which supports manualmemory management.Amplify is a full-stack framework from AWS that has been in development for along time.It allows you to quickly create scalable fu
46、ll-stack web and mobile appson AWS.The release of the Flutter SDK has made it much easier to connect10Flutter applications to the Amplify backend,making the technology morepopular among developers.Another very promising web technology is Remix.The company recentlyannounced partnering with Shopify,wh
47、ich plans to use Remix in most of its newprojects.This technology greatly simplifies the development of web applicationsdue to special built-in features.For example,Error Boundaries allows you tohandle errors in specific components without blocking the entire page,whichgreatly facilitates error hand
48、ling.Astro is a great framework for small businesses.However,this technology is bestsuited for building websites and not web applications.The framework is knownfor its unique Astro Islands architecture which extracts your UI into smaller,isolated components and replaces unused JavaScript with lightw
49、eight HTML,providing faster page loading times.Wrap UpIn summary,the number of use cases for Node.js is already large and continuingto grow as advancements in other technical areas can apply to Node.js as well.There are no indications that this growth will slow any time soon.So with theproper resear
50、ch and the right use cases,Node.js can be an excellent choice forbuilding many different types of products now and in the future.There are no“good”or“bad”technologies as such.Each one is good for itsparticular set of tasks.Every software product owner has to identify the mostimportant criteria of choice,according to business goals and existingconstraintsand after that,the choice will be much more obvious.If you have any specific questions regarding your own project or need help withchoosing a tech stack for your future product,feel free to contact us!Image credit11