A framework is a collection of code that is leveraged in the development process by providing ready-made components. Through the use of frameworks, architectural patterns and structures are created, which help speed up the development process. This Zone contains helpful resources for developers to learn about and further explore popular frameworks such as the Spring framework, Drupal, Angular, Eclipse, and more.
React is a powerful JavaScript library that has revolutionized the way developers build web applications. With its ability to create reusable UI components, improve performance with a virtual DOM, and ensure consistency with a one-way data flow, React has become a go-to choice for many developers. In this article, we will explore ways in which React can improve your web development process, from saving time and effort to making your application easier to maintain and scale and answer questions. Is it good for all situations, or there are better routes? Introduction to React React is a JavaScript library for building user interfaces that was developed by Facebook in 2011. It has since become one of the most popular libraries for building web applications and is used by companies such as Netflix, Airbnb, and Uber. React has been used to develop many successful MVPs, including: Airbnb: The popular vacation rental website was developed using React and has since become one of the most successful startups in the world. Dropbox: The cloud storage service used React to develop its MVP, which helped it to grow quickly and become a household name. Asana: The project management tool used React to create its MVP, which has since become popular with teams and businesses around the world. Uber: The ride-sharing service used React to develop its MVP, which has revolutionized the transportation industry and made it one of the most valuable companies in the world. These MVPs demonstrate the power and versatility of React and show how they can be used to create successful and scalable web applications. Here are things React can come in handy for your web development process: Improved Performance With a Virtual DOM One of the key benefits of React is its virtual DOM, which is a lightweight in-memory representation of the actual DOM. When a developer makes changes to a React application, the virtual DOM is updated instead of the actual DOM. This can improve the performance of the application, as it reduces the number of DOM manipulations that need to be made. The virtual DOM works by comparing the previous version of the virtual DOM with the new version and then only making the necessary changes to the actual DOM. This can greatly improve the performance of your application, especially if you have a lot of dynamic content or if your application is being used on a device with limited resources. Here is an example of how the virtual DOM works in React: import React from 'react'; import {render} from 'react-dom'; const App = () => { const [count, setCount] = useState(0); return ( <div> <h1>{count}</h1> <button onClick={() => setCount(count + 1)}>Increment</button> </div> ); }; render(<App/>, document.getElementById('root')); In this example, the count state variable is displayed in an h1 element, and there is a button that, when clicked, increments the count. Every time the count state variable is updated, the virtual DOM is updated with the new value. The virtual DOM then compares the previous version with the new version and only updates the actual DOM with the changes that are necessary. Using the virtual DOM can greatly improve the performance of your application and make it more responsive and user-friendly. Intuitive API and Developer Tools One of the reasons why React has become so popular is its simple, intuitive API. This makes it easy for developers to learn and use, even if they are new to web development. In addition, there are many developer tools available for React that can help improve your development process. React Developer Tools React Developer Tools is a Chrome extension that allows you to inspect the components in your React application. This can be useful for debugging and understanding how your application is structured. Create React App Create React App is a tool that makes it easy to create a new React application. It sets up a development environment with all the dependencies and configurations you need, so you can focus on writing code. Next.js Next.js is a framework for building server-rendered React applications. It allows you to easily set up a project with automatic code splitting, optimized performance, and server-side rendering. Gatsby Gatsby is a framework for building static websites using React. It allows you to create fast, secure, and SEO-friendly websites that are easy to maintain and scale. These are just a few examples of the tools and resources available for React developers. With such a strong community and ecosystem, it's easy to find support and resources to help improve your development process. Are There Alternatives Available? There are many alternatives to React for building user interfaces, including Angular, Vue.js, and Svelte. Each of these options has its own strengths and weaknesses, and the best choice will depend on your specific needs and goals. Here is a comprehensive comparison, depending on the software development team's needs: React is focused on the view layer and is easy to learn, especially for developers who are already familiar with JavaScript. React allows developers to create reusable components and provides a virtual DOM to improve performance. Angular is a comprehensive JavaScript framework that was developed by Google. It includes a range of tools and features for building web applications, including a powerful template system, dependency injection, and a CLI for creating and deploying projects. Angular has a steep learning curve and is best suited for large projects with complex requirements. Vue.js is a lightweight, easy-to-learn JavaScript framework that was created by Evan You. It has a gentle learning curve and is well-suited for building small to medium-sized projects. Vue.js has a focus on simplicity and flexibility, and it allows developers to use either a template-based syntax or a render function to define the components. Svelte is a newer JavaScript framework that was developed by Rich Harris. It offers fast performance and a small bundle size, and it compiles components to vanilla JavaScript at build time rather than relying on a runtime library. Svelte has a learning curve that is similar to React, and it is well-suited for teams that want a lightweight solution with good performance. React Sounds Good. Are There Downshifts? There are a few potential downsides to using React for web development: Steep learning curve: While easy to learn, especially for developers who are already familiar with JavaScript, it does have a steeper learning curve than some other options, such as Vue.js. This can make it less suitable for teams with less experience or for smaller projects. Requires a build step: requires a build step to convert JSX (a syntax extension for JavaScript) into regular JavaScript. This can add complexity to the development process and may not be suitable for teams that prefer a more lightweight workflow. Requires additional libraries: In order to use, you will also need to use additional libraries, such as React Router and Redux. This can add complexity to the development process and may not be suitable for teams that prefer a more lightweight stack. Whether the downsides of React are worth it, it will depend on your specific needs and goals. React is a powerful tool that is well-suited for building large, complex web applications, and it has a strong developer community and a wide range of available libraries and tools. If these benefits align with your project goals, then the downsides of React may be worth it. On the other hand, if you are building a project or are looking for a simpler development experience, then the downsides of React may outweigh the benefits. In that case, it may be worth considering an alternative option, such as Vue.js or Svelte, that has a smaller learning curve and a more lightweight development experience. Summary In conclusion, React is a powerful JavaScript library that can greatly improve your web development process. Its ability to create reusable components, improve performance with a virtual DOM, and ensure consistency with one-way data flow makes it a valuable tool for developers. In addition, its intuitive API and wide range of developer tools make it easy to learn and use. If you're looking to improve your web development skills or build better applications more efficiently, consider giving React a try. React definitely has ways to improve the software development process.
After being taken care of by the Java Community Process (JCP), Java EE is now supported by the Eclipse Foundation as Jakarta EE. This means that we can focus more on open standards for governance, open-source development, and testing for compatibility. It is also a great way to include openness to all vendors, a clear flow of intellectual property (IP), well-defined procedures for defining specifications, and a level playing field. Eclipse Starter for Jakarta EE To ensure there are more users and participants and that they have an easy path to Jakarta EE, the Eclipse Foundation has started a new project called Eclipse Starter for Jakarta EE as a new open-source initiative. The project can be found here: Start Jakarta. The issue is that it assumes the developer is already familiar with the Maven archetype. However, in today's attention economy, making it more palatable and attractive to the developer is much more crucial, mainly if they are new. It would be helpful if there were one official place where everyone could go to configure what they need, get the project structure as a ZIP file they could download, and start playing with it for Jakarta EE. User Interface for Eclipse Starter With that requirement in mind, we have started creating a UI project that is slightly better than what we already have. First, we must build a web application that takes user input through a form. Then, clicking the Submit button gives the application output as a downloadable ZIP file. The backend of the application, which is where most of the work is done, is written in Java. The form is the only client-side coding part involved in the project. We don't have any fancy requirements. The backend part of the application is already written with Java and a Servlet. As I previously stated, the requirement is relatively simple. Once we build the application through Maven, it makes a WAR file. We can throw the WAR at any web server, such as Tomcat, JBoss, Wildfly, etc. Fortunately, we have a JBoss EAP instance from the Azure App Service that we can use for this application. Thanks to Azure for sponsoring it! Improving the UI for the Eclipse Starter Then we decided to improve the UI. The simple HTML form, in fact, works. But we need validation as well. We have some drop-down input fields that will change in the future. We have new options as well. Plain HTML implies having them in two places: the backend and the front end. Duplication is wrong, we learned. For validation, client-side validation works, but it's easy to bypass. So we want to do server-side validation as well. There are a lot of JavaScript frameworks that can be used to make fancy user interfaces on the client side. Choosing one of them isn't easy. Besides, most of the time, we all work on the backend, and the programming language we’re good at is Java. Choosing React over Angular or Vue.js isn't as straightforward as choosing Spring over other frameworks. Being familiar with an ecosystem is essential when deciding on a technology. Jakarta Faces Wins After consulting with the current contributors, we decided to go with Jakarta Faces (previously called JavaServer Faces, or JSF). We looked at the learning curve and the project's complexity when evaluating JSF, and we concluded that JSF makes a lot of sense for this project. Here are a few reasons why we chose JSF over any other client-side framework: It is a component-based framework so that developers can easily reuse components and build user interfaces faster. It has powerful APIs for handling user input, the state of components, and other common tasks for web applications. It works well with other Java technologies like EJBs and JSPs. It is an open-source framework, which means it is freely available and can be used without paying license fees. Aside from these, many well-known people in the Jakarta EE community agree with this decision. Reza Rahman says about it: "I definitely vote for Faces. As Bazlur mentions, I do suspect it will ultimately result in simpler code that is easier to maintain. For a project designed to promote Jakarta usage, it also sends the correct message - we could even make Faces use apparent in the URL or an explicit mention. Lastly, I believe that for this project, it's going to be easier to get people more proficient in Java than JavaScript. Indeed, I suspect that's already true of the current committers and contributors. Kito Mann mentioned in the mailing list that- "+1 for JSF. Much faster to build with and, as Reza mentioned, familiar to developers on this team. Also, this is a relatively simple app that doesn't have any particularly complicated UI needs. Great use case." In fact, after working with JSF, I can conclude that JSF is a simpler, richer, and more mature framework that goes well with Java. Of course, the learning curve is steep for newbies, which is valid for any framework. But being familiar with the Java ecosystem makes working with JSF much easier to start with. Besides, it has great support from the Jakarta EE community and standards. And if you need to, you can easily add custom JavaScript code or any standard web technology, like Web Components. I tweeted passionately about JSF, and many others commented on it. You can read the whole thread here. While JSF has many good sides, it has some disadvantages as well. It can have a steep learning curve for developers who are new to the framework. There may be better choices for applications that require a high degree of customizability or flexibility. Overall, whether or not JSF is a good choice for a particular project depends on the project's specific requirements and goals, as well as the experience and preferences of the development team. However, we must agree that JSF is a full-fledged, mature framework. It can fit any project. Indeed, no tool is a silver bullet that suits all cases. Still, JSF deserves more love and attention than it gets now compared to other UI frameworks. This article explains why we chose JSF to build the Eclipse starter for Jakarta EE. Conclusion: The UI with JSF is still being worked on, so it might take a while to be accessible. But you can get access to the source code now: Starter UI GitHub Meanwhile, you can access the live starter application at Start Jakarta and use it to get started with Jakarta EE and generate sample Jakarta EE applications. If you would like to contribute to the Eclipse Starter for the Jakarta EE project, join us: Join the mailing list here. Clone projects from Eclipse starter. Create an account for Eclipse. Accept the Contributor Agreements. We have plenty of ideas now, and if you want to join the discussion, feel free to join us and comment below. Your thoughts would be highly appreciated. Prior knowledge of JSF or Jakarta EE isn't required to be a contributor. Last but not least, I'd like to thank Ondro Mihályi and Reza Rahman for reviewing the article and giving valuable feedback.
In one of our previous articles, Validation for Free in Scala, we discussed a validation framework by lifting validators to monad “for free”. In this article, we will discuss a validation framework with Tagless Final. Through examples, we demonstrate how the proposed validation framework can improve the quality of encoding. Validation Validation falls into two categories: Fail Fast and Error Accumulation. In Fail Fast scenario, validators return monadic validation results; a for-comprehension can be used to complete the validation. The following code returns the first error it encounters without executing the rest of the validation: Scala for { name <- UserValidator.validateName(name) phoneNumber <- UserValidator.validatePhoneNumber(phone) age <- UserValidator.validateAge(age) } yield User(name, phoneNumber, age) Note that as long as the wrapper of the validation result is monadic, this code always works. There are a number of monadic wrappers to wrap the validation result to represent the error case, for instance, None to represent the error if Option is the wrapper; Throwable to represent the error if Try is a wrapper, or customized error object to represent the error using Either. In Error Accumulation, by using applicatives instead of monads, validation is carried out, and errors are accumulated even if intermediate evaluation fails, such that all the errors can be collected in one evaluation. However, Option, Try, or Either can only hold one result; they only work in fast fail scenarios but not in error accumulation validation. Cats is a library that provides abstractions for functional programming in the Scala programming language. Cats provide a very effective wrapper called Validated for error accumulation validation. Errors can be modeled as ApplicativeError, and customized errors can be accumulated in Validated in a NonEmptyList. In many cases, we do not want to commit to a container too early. Now the question is, how can we encode a validation that is agnostic to the container of the validation result? Here comes Tagless Final. Tagless Final Tagless Final style is a method of embedding domain-specific languages (DSLs) in a typed functional host language. It is a functional pattern that allows to compose of a set of functions and ensures type safety. It is centered around interpreters; for instance, a validator of a validation framework is an interpreter in the Tagless Final context. A higher kind type F[_] is used to annotate the operators and the operands such that type checking is performed at compile time and evaluation maintains type safety at run time. F[_] is an abstraction of the wrapper in which the structure of the program is preserved. There is a rich literature on Tagless Final. In this article, we do not intend to elaborate on this coding pattern. Instead, we will discuss how Tagless Final can be used to improve our validation. Our validation framework contains the following parts: A domain to describe the problem; Validation Algebra or DSL, an abstraction of the validation rules; An interpreter that implements the validation rules; A program to execute the validation rules. Domain Suppose a User has Name, Phone, Email, and Age attributes:: Our validation is to validate each attribute and report the following errors: Scala case class Name(value:String) case class Phone(value:String) case class Email(value:String) case class Age(value:Int) case class User(name: Name, phone:Phone, email:Email, age:Age) Scala sealed trait UserError case object InvalidName extends UserError case object InvalidAge extends UserError case object InvalidPhoneNumber extends UserError case object InvalidEmail extends UserError Above, our validation is to validate each attribute and report the following errors. Algebra Our DSL has a simple operation: Scala trait UserValidator[F[_]] extends Validator[F, User] { def validate:F[User] } Where F[_] is the type constructor as a container of validation result. Interpreter The interpreter is a generic function that takes a user and returns the validation result in the container F[_]. The interpreter uses an applicative in cats that takes the result of validation results and wraps it in higher-kind type F. Scala def interpreter: User => F[User] = { user => { (User.apply _).curried.pure[F] <*> validateName(user.name) <*> validatePhone(user.phone) <*> validateEmail(user.email) <*> validateAge(user.age) } Validation errors are wrapped in F[_] and modeled as ApplicativeError to support error accumulation. The interpreter can be easily extended in the Tagless Final solution, as we demonstrated to support Option, Try, Either, and Validated (Cats) as typeclasses. Program Finally, a program that supplies the user instance to the interpreter and executes it. The interpreter typeclass is implicitly imported into the scope such that various containers are tested. For instance: Scala import com.taglessfinal.validator.userValidatorOptionInterpreter user1.validate.tap(println) import com.taglessfinal.validator.userValidatorTryInterpreter user1.validate.tap(println) import com.taglessfinal.validator.userValidatorEitherInterpreter user1.validate.tap(println) import com.taglessfinal.validator.userValidatorValidatedInterpreter user1.validate.tap(println) The implementation of validating rules is trivial. Summary Tagless Final pattern, coupled with type classes, provides an elegant solution to validation framework implementation. The solution is type-safe, extensible, and agnostic to the container of validation results; the solution works both in a fail-fast fashion and in error accumulation. It can allow the project to avoid committing to validation scenarios too early and be flexible and extensible. In this article, we discussed the specifics of the Validation and the Tagless Final pattern and discussed how Tagless Final can be used to implement an extensible validation DSL, and finally, provided an implementation of a validation framework in Tagless Final that supports four different containers.
Ruby on Rails is an open-source framework based on the Ruby programming language used for developing web applications. Though mostly associated with the backend, the framework is full stack with applications in eCommerce websites and business development. Many giants, such as Netflix, Airbnb, GitHub, etc., use the framework. Then why are we pelted with remarks like ‘Ruby is outdated’ and ‘Rails is irrelevant today'? Rails are going to be 20 years old soon. Though its popularity has declined over the years, it is nowhere going to die soon. List of 20 most popular programming languages 2022. All opinions suggesting Ruby on Rails is dead are fake rumors. Such rumors are very common in the software development field. Lots of languages and frameworks are pronounced dead, but that is always so far from the truth. So, what’s special about Ruby on Rails, and why should you consider it for your web project in 2023? Brief History of Ruby on Rails Ruby on Rails was developed by David Heinemeier Hansson in August 2004 under an MIT license and was released in 2005. It quickly revolutionized the web development industry with its innovative features, such as seamless database migration, table creation, and scaffolding of views for rapid app development. It also brought a convention-over-configuration paradigm that helps developers at many levels of software design. It is built on the Model-View-Controller framework and works on software development principles such as: Don’t Repeat Yourself: Reduces code and pattern repetitions. Active Record Pattern: Eases Object-relational mapping. Convention-Over-Configuration: Decreases the number of decisions taken by the developer. With these concepts at hand, Ruby on Rails provides quick app development and deployment processes with flexibility and ease of coding, which you may not find in any other similar framework. It helped Ruby on Rails developers in avoiding the hassles of coding and focus more on the business and logic aspects of the app. Why Do People Think That Ruby on Rails Is Dying? Ruby on Rails is a powerful framework, especially for developing a prototype application. It is also the most cost-effective. Hence, the reason why businesses flock to it. For developers, it provides a stable, flexible, quick, and simple coding experience. Why the hate, then? For sure, if the technology is not used properly or isn’t updated to the latest versions, it is bound to lose support, and the creators also will not get the crucial feedback required to further develop the framework. Two major issues developers talk about: 1. Performance Issues: Ruby on Rails does have some issues with the CPU. It also has a slower runtime speed compared to other similar frameworks, such as Node.JS. The issue is noticeable when there is a huge app with lots of traffic and user requests; the framework is bound to take up the load. Moreover, the server and database also play an important role in affecting the speed. Otherwise, programs and apps built in rails are inherently fast. Consider GitHub or Airbnb, which deal with large-scale traffic daily and have their built-in backend Rails. So what’s the issue? Well, Rails has lots of libraries and tools, and inexperienced developers tend to make wrong decisions with them while writing the code. The performance will surely hinder. Otherwise, the creators have actively been working on improving the performance with each update: Ruby 3 aimed to provide thrice the speed of Ruby 2. Rails 6.0 packs in-built features and solutions to simplify web development. Rails 7.0 included more features, such as asynchronous query loading, js bundling-rails integration, etc., to enhance performance. 2. Scalability Issues Ruby on Rails was called ‘difficult to scale up’ when Twitter decided to rewrite its backend in Scala, which was previously in Rails. This was the first instance that started the debate over this issue. But, was Rails the hindrance? Scaling up means handling more clients and users at a given time. To serve them quickly, each server-side element of the application should be configured accordingly to provide optimal performance. A middle-level or small-level application can handle traffic easily. But for large-scale applications, one of the best things to do is to build it in one language so that it becomes easier to connect and sync all the segments together. Twitter moved to Scala because it was written in JavaScript. Additionally, Scala can handle large-scale real-time messaging, so it was a better option for Twitter. But it doesn’t suggest that Ruby on Rails cannot provide scalability. Rails provide a lot of features such as service-oriented architecture, code optimization, horizontal scaling, and threat safety which allows your application to handle more traffic and to easily plug-in additional servers if required. Some large traffic companies that utilize Ruby on Rails are listed in the image below. Ruby on Rails in Comparison With Other Languages Java Java has been the most popular language since its inception. One clear distinction it has with Ruby is in the way of code execution. In Java, code is translated into a virtual machine language before execution. No such translations are required in Ruby before executing the code. Java RUBY on rails Requires More Lines Of Codes Very Few Lines Of Code Are Required For A Similar Function Slow Development Faster Development Code Needs to be Compiled, and Interpreted No Need for a Compiler Testing and Debugging is Difficult Testing, and Debugging is Easier Better Application Performance Better Flexibility And Readability Bigger Community of Experts Not as Big as Java Java Virtual Machine Can Execute Code Faster Since No Compiler, Code Gets Directly Executed Python Python and Ruby are both prominent backend languages with a plethora of libraries and powerful frameworks. They are both at the top of their games and can be utilized for cross-platform applications. However, Ruby offers more freedom in Syntax than Python. Python indulges in simplifying codes by allowing a single statement of code per line. However, this makes every Python code appear similar, hence confusing. Ruby allows flexibility through manifold statements per line. They allow programmers to indent code whenever required. Python Ruby High-Level Language General Purpose Less Object-Oriented Full Object-Oriented Supports Multiple IDEs Only Supports EclipseIDE Has More Libraries Has Fewer Libraries Has Functions Doesn’t Have functions No Modifications On Built-In Classes Can Modify Built-In Classes Multiple Inheritance Single Inheritance. PHP PHP is a general-purpose server-side scripting language like Ruby, which is used to develop almost all types of web content. Like Ruby, it is also fast, pragmatic, flexible, and object-oriented. PHP RUBY ON RAILS Faster Code Execution Slower Code Execution More Lines Of Codes for a Program Few Lines Of Codes for The Same Program Web Hosting Companies Supports PHP Apps RoR Apps Require Unix-Based Servers Testing And Debugging are Difficult Testing And Debugging are Easier Not Much Clear Structure as RoR More Clear Code Structure Requires Low Memory Space Requires High Memory Space Suitable For Any Kind Of Web Application More Suitable For Business Web Applications Perl Perl is a high-level, general-purpose, dynamic programming language. It can render a variety of paradigms, tools, and other language features. It can be used for networking, system administration, etc. One drawback is that programmers tend to work with a single paradigm; thus, the unused features sometimes create confusion. Ruby doesn’t have such issues due to its flexibility and conventions. PERL ruby on rails Less Object- Oriented More Object- Oriented Less Number of Libraries More Number of Libraries Supports More Unicode Properties Less Supportive Strings Encoding is Less Explicit Strings Encoding is More Explicit Multiple Variable Types Single Variable Types Supports Auto Conversion of Data Requires Programmers To Convert Types Explicitly Suitable For Any Kind Of Web Application More Suitable For Business Web Applications Why Choose Ruby on Rails Framework For Your Project? Ruby on Rails is a fairly mature technology with a huge community of developers. It is a developer-friendly framework with more than a million web applications and websites built on it and still counting. It provides flexibility, ease of coding, and speed that helps in building a scalable app quickly. Some More Reasons for Choosing Ruby on Rails 1. Business Logic Execution Ruby on Rails can implement complex business logic in a simple and fast process. You can use it with front-end frameworks such as React and have it developed fast. 2. Gems Ruby has a huge collection of gems in the repository. Gems are pre-written lines of codes, libraries, and tools that you can use to write codes more efficiently. They help tremendously in reducing code complexity, provide high-end features, and are reusable. 3. Rapid Development Ruby on Rails is famous for its rapid development process. Creating a project with Ruby is fairly easy, and it works best if you want to deploy your prototype quickly. Ruby utilizes fewer lines of codes and Gems which further helps in the quick development of applications. Compared to other frameworks and languages, Ruby on Rails can develop applications 40-45% more quickly. Conclusion Ruby on Rails had its best time during 2015 and has matured ever since, but its popularity and usefulness are still intact. The framework is highly utilized by startups today due to its advantages in rapid prototyping. The upcoming releases and upgrades also sound promising. With that, we cannot say that RoR has any indications of becoming obsolete anytime soon. It sure has its pros and cons and does lack performance compared to some of the other frameworks, but its advantages far outweigh the drawbacks. Hopefully, shortly we can see Ruby on Rails back at the top of the list again.
Throughout this article series, we’ve introduced you to the Flow blockchain, its smart contract language Cadence, and some of the most essential tools developers should know, all while comparing and contrasting to Ethereum. In this article, we will talk about best practices and patterns that should be followed when using the Cadence language and developing solutions on the Flow network, as well as patterns to avoid. Best Practices Use Flow Test Network and Flow Emulator One of the most important steps in developing on any blockchain is testing your projects in a simulated environment. Flow blockchain is no different. For this purpose, the Flow testnet and Flow Emulator are both crucial components to include in your development process. Not only do they allow you to understand how your dApp will perform, but they will also help you catch any critical bugs before deploying to mainnet. Use Standard Contracts Two of the most common use cases for any blockchain are digital currencies and providing proof of digital ownership through NFTs. Instead of trying to rewrite the necessary contracts from scratch, Flow developers should always import the official core contracts to ensure user safety and consistency with the rest of the network. There are currently three standard contracts you should use: Fungible Token - Used to create new tokens Non-Fungible Token - Used to create NFTs Metadata Views - Used as a metadata pattern for NFTs These contracts are essentially interfaces that force whoever is implementing them to add their variable and method declarations, enabling them to be interoperable with other smart contracts in the Flow ecosystem. They already exist on both testnet and mainnet networks, so be sure to import from the official addresses linked above when implementing them in your contract. You can find other core contracts in the Flow documentation. Create Tests for Your Smart Contracts, Transactions, and Scripts The Flow JavaScript Testing Framework is crucial for testing deployment scenarios for your contracts. However, it’s important to note that you’ll need the Flow CLI running in the background for full functionality. With these, you can test creating new accounts, sending transactions, running queries, executing scripts, and more. Additionally, it integrates with the Flow Emulator so you can create, run, and stop emulator instances. Add Your Contract to the Flow NFT Catalog The Flow NFT Catalog exists as a database to store NFT contracts and metadata. By uploading your contract, your NFTs become interoperable with the rest of the Flow ecosystem, and other developers can easily support your collection in their marketplaces or other dApps. You can add your contract to the catalog by completing a simple four-step process. Be Specific With Types Cadence is a strong and statically typed language that allows the developer to specify which types contain or return variables, interfaces, and functions. Therefore, you should be as specific as possible when making declarations; use generic types only in necessary situations. Not doing so can result in clumsy errors. Access Control Whenever possible, you should be deliberate with access control. Luckily, on the Flow blockchain, a caller cannot access objects in another user’s account storage without a reference to it. This is called reference-based security, and it means that nothing is truly public by default. However, when writing Cadence code, care must be taken when declaring variables, structs, functions, resources, and so on. There are four levels of access control a developer can include in their declarations: pub/access(all) - accessible/visible in all scopes access(account) - only accessible in the entire account where it’s defined (other contracts in the same account can access) access(contract) - only accessible in the scope of the contract in which it is defined (cannot be accessed outside of the contract) priv/access(self) - only accessible in current and inner scopes Avoid using pub/access(all) whenever possible. Check out the Flow documentation for more information on access control. Create StoragePath and PublicPath Constants Inside Your Contract The paths to your contract’s resources are extremely important and must be consistent across all transactions and scripts. To ensure uniformity, you should create constants for both PublicPath and StoragePath. pub contract BestPractices { pub let CollectionStoragePath: StoragePath pub let CollectionPublicPath: PublicPath init(){ self.CollectionStoragePath = /storage/bestPracticesCollection self.CollectionPublicPath = /public/bestPracticesCollection } } When you create a transaction that uses one of these paths, you only need to call its respective variable with the imported contract to reference the required path. //This script checks if a user has the public Collection from BestPractices contract import BestPractices from 0x... pub fun main(addr: Address): Bool { return getAccount(addr).getLinkTarget(BestPractices.CollectionPublicPath) != nil } Admin Resource It’s good practice to create an administrative resource that contains specific functions to perform actions under the contract, such as a mint function. This convention ensures that only accounts with that resource or capability can perform administrative functions. pub contract BestPractices { pub let CollectionStoragePath: StoragePath pub let CollectionPublicPath: PublicPath pub let AdminStoragePath: StoragePath pub resource AdminResource { pub fun mintNFT(){ //your mint NFT code here! } } init(){ self.CollectionStoragePath = /storage/bestPracticesCollection self.CollectionPublicPath = /public/bestPracticesCollection self.AdminStoragePath = /storage/bestPracticesAdmin //Create the adminResource and store it inside Contract Deployer account let adminResource <- create AdminResource() self.account.save(<- adminResource, to: self.AdminStoragePath) } } Create Custom Events Events are values that can be emitted during the execution of your Cadence code. For example, when defining important actions in your contracts, you can emit events to signal their completion or deliver a specific value. As a result, transactions that interact with your smart contracts can receive additional information through these events. pub contract BestPractices { pub let CollectionStoragePath: StoragePath pub let CollectionPublicPath: PublicPath pub let AdminStoragePath: StoragePath //Create your own events pub event AdminCreated() pub resource AdminResource { pub fun mintNFT(){ //your mint NFT code here! } } init(){ self.CollectionStoragePath = /storage/bestPracticesCollection self.CollectionPublicPath = /public/bestPracticesCollection self.AdminStoragePath = /storage/bestPracticesAdmin //Create the adminResource and store it inside Contract Deployer account let adminResource <- create AdminResource() self.account.save(<- adminResource, to: self.AdminStoragePath) } } Patterns on Cadence/Flow Blockchain Be Specific With Types in Type Constraints One of the most powerful features of the Cadence language is undoubtedly capabilities. Through capabilities, the scope of resource access expands. An important point when creating a capability is to specify which features of your resource should be available to others. This can be done at the time of link creation using type constraints. In this example, we use the ExampleNFT contract to create a basic functionality where any account that wants to receive an ExampleNFT must have a collection. import NonFungibleToken from 0x... import ExampleNFT from 0x... transaction{ prepare(acct: AuthAccount){ let collection <- ExampleNFT.createEmptyCollection() // Put the new collection in storage acct.save(<-collection, to: ExampleNFT.CollectionStoragePath) // Create a public Capability for the collection acct.link<&ExampleNFT.Collection{ExampleNFT.CollectionPublic}>(ExampleNFT.CollectionPublicPath, target: ExampleNFT.CollectionStoragePath) } } The "&" symbol in &ExampleNFT specifies that we are using a reference. After the reference symbol, we add the type to which the capability we are creating will have access. At this point, we need to be as specific as possible. This pattern strengthens security and limits the functionality that the user calling the borrow function of this capability can use. Omitting the {ExampleNFT.CollectionPublic} type will give you access to all the functions that exist in the ExampleNFT.Collection reference, including the withdraw function, so that anyone can access the user's collection and steal their NFTs. Use the Borrow Function To use the resource's features, you could call the Load function to remove the resource from the account, use its features, and call the Save function to save it again. However, this approach is costly and inefficient. To avoid this, use the borrow function instead. It allows you to use a reference to the resource you are calling. This method makes your transaction much more efficient and cost-effective. Use the check and getLinkTarget Functions When building applications on the Flow blockchain, you will discover the user’s account plays a vital role. Unlike other blockchains, such as Ethereum, Flow stores resources, assets, and more directly in the user's account rather than as a reference to an address on a public digital ledger. This approach requires the account to have a specific storage location, such as a collection or vault for fungible tokens. However, this also adds complexity. One must be sure that the user either does or does not have the collection in their account. Both the check() function (which checks whether a capability exists in a given path) and the getLinkTarget() function (which returns the path of a given capability) must be used when adding collections and capabilities to the user account. These functions ensure that the transaction executes without problems. Use Panic Panic is a built-in function in Cadence that allows you to terminate a program unconditionally. This can occur during the execution of your smart contract code and returns an error message, which makes it easier to understand when something does not go as expected. When declaring variables, it is possible to define them as optional; meaning, if they are not of the specified type, they have a value of nil. Thus, in Cadence, it is possible to use two question marks followed by the panic("treatment message") function when querying the value of a particular variable or function that returns an optional. let optionalAccount: AuthAccount? = //... let account = optionalAccount ?? panic("missing account") This command ??panic("treatment message") attempts to return the value with the specified type. If the returned value is the wrong type, or nil, the execution aborts, and the selected treatment message displays on the console. Anti-Patterns Although Cadence is designed to avoid many of the potential bugs and exploits found in other blockchain ecosystems, there are some anti-patterns developers should be aware of while building. Listed below are a few important ones to consider. For a complete list of anti-patterns, check out the Flow documentation. Failing to Specify the Type When Using the Borrow Function Developers should use the borrow function mentioned above to take advantage of the features available in a capability. However, it should be clear that users can store anything in their memory. Therefore, it is vital to make sure that what is borrowed is of the correct type. Not specifying the type is an anti-pattern that can end up causing errors or even breakage in your transaction and application. //Bad Practice. Should be avoided let collection = getAccount(address).getCapability(ExampleNFT.CollectionPublicPath) .borrow<&ExampleNFT.Collection>()?? panic("Could not borrow a reference to the nft collection") //Correct! let collection = getAccount(address).getCapability(ExampleNFT.CollectionPublicPath) .borrow<&ExampleNFT.Collection{NonFungibleToken.CollectionPublic}>() ?? panic("Could not borrow a reference to the nft collection") Using AuthAccount as a Function Parameter For a transaction in the preparation phase, it is possible to access the AuthAccount field of the user. This object allows access to the memory storage and all other private areas of the account for the user who provides it. Passing this field as an argument is not recommended and should be avoided, as cases where this method is necessary are extremely rare. //Bad Practice. Should be avoided transaction() { prepare(acct: AuthAccount){ //You take sensitive and important user data out of the scope of the transaction prepare phase ExampleNFT.function(acct: acct) } } Using Public Access Control on Dictionaries and Arrays By storing dictionaries and array variables in your contract with pub/access(all) scope, your smart contract becomes vulnerable, as anyone can manipulate and change these values. Creating Capabilities and References Using the Auth Keyword Creating capabilities and references with the auth keyword exposes the value to downcasting, which could provide access to functionality that was not originally intended. //AVOID THIS! signer.link<auth &ExampleNFT.CollectionPublic{NonFungibleToken.Receiver}>( /public/exampleNFT, target: /storage/exampleNFT ) Conclusion When developing on the Flow blockchain using Cadence, it helps to be aware of design patterns, anti-patterns, and best practices. By following these best practices, we can ensure a consistent level of security throughout the Flow ecosystem, thus providing the best experience for users. For a more thorough understanding, read through the Flow documentation. Have a really great day!
My talk was accepted by SpringOne in San Francisco. I never went to that conference and was really looking forward to it. This year would probably be amazing with the Spring 6.0 and Spring Boot 3.0 releases. So many groundbreaking changes. Unfortunately, my travel budget at Lightrun was cut, and I eventually left. This meant I had to cancel the trip, I would have paid for travel, but San Francisco is both far and prohibitively expensive. I’ll have to take a raincheck. This isn’t exactly a substitute, but a skeleton Spring Team is on a “world tour” that reached Tel Aviv last week, and I attended. The venue is one I’ve never attended, the Peres center for innovation. It’s on the Jaffa beach and you can literally see the waves hitting the beach from the main stage. Check out the photos below, you can literally see people on the beach in some of them. That’s a fantastic venue. The only downside is the distance from the center of Tel Aviv where I live. But that’s nothing compared to distances in the states… The event had 600+ registrations from over 80 organizations. This is the first Spring Tour outside of North America which is cool. The talks were in English which I like, but the Israeli accent is sometimes difficult to understand (yes I know). Unfortunately, I had to leave early because I had to pick up the kids. Before we proceed I want to say a couple of things about Twitter. Over the past month I moved to Mastodon and it's pretty great. There's even the Java Bubble which lists prominent community members on Mastodon. Foojay added its own instance and interest is high. I see no reason to stay on Twitter. It's toxic and getting more-so by the second. I still have my account and I have a bridge that tweets my Mastodon posts. So if you follow me there you won't miss anything. But I won't go there as often and will try not to post there. All the links in this post and future posts will refer to other networks whether LinkedIn or Mastodon. Juergen Hoeller – Introducing Spring Framework 6 Spring Framework 6 is a re-alignment of the framework. Juergen picked his works carefully, focusing on the conservative nature of Spring versions and compatibility to past versions. Spring Framework 5.3.x is very much JDK 8 based. It’s coupled to Java EE and the old javax namespace. It’s supported in open source until 2024 which means we need to make migration plans... Spring Framework 6.x changes a few things: JDK 17+ Jakarta EE instead of Java EE and javax namespace AOT Support Virtual Threads (Loom) This will be the basis for Spring Boot 3.x. The biggest challenge I foresee is the JDK 17 requirement. That might challenge some migrations. As we make those migrations, we’ll probably containerize more. Ideally, that will make future migrations much easier. JDK 17 has some fantastic features though. Juergen focused a lot on the language features but there are some great GC improvements for containers which make the upgrade worthwhile in the enterprise. Migrating to the Jakarta API is a necessary evil since the packages for the old APIs are no longer updated. This is going to be a migration pain, but it’s unavoidable. This will require anyone who has a dependency on those APIs to move that code. The entire Java ecosystem switched to fast release cycles and updates to frameworks like Tomcat happen at a much faster rate. Juergen recommends skipping Jakarta EE 9 and going directly to 10. Spring Framework 6.1 will still support JDK 17, but it will also add support for JDK 21 which should be available by then. Jakarta EE 10 will be the preferred framework for that version. AOT is a tradeoff: extra build setup and less flexibility at runtime. Reduces startup time and memory footprint in production. GraalVM is the de-facto standard for native executables. It has a strong closed-world assumption, no runtime adaptations. Build time is very long. Personally, I don’t think it’s that long as a guy who built an AOT JVM. OpenJDK static images (Project Leyden). Spring’s AOT strategy is aligning with Leyden’s JVM strategy. Starting from a warmed-up JVM image (CRaC) is also a promising option for fast Spring application bootstrap. First-class support for CRaC is expected in Spring Framework 6.1. Project Loom is a preview feature in JDK 19 that enables high throughput for Java threads. They expect significant scalability benefit for database-driven web apps. It’s also a perfect fit for messaging and scheduling applications. This means WebFlux and reactive style is no longer primarily for scalability as Loom would provide that for “free”. Other features include fast bean property determination. Complete CGLIB fork with support for capturing generated classes. NIO based classpath scanning. First-class module scanning and further module system support (possibly) in 6.1. HTTP interface clients based on @HttpExchange service. JDK HttpClient integration with WebClient but to me most interesting is the micrometer-based observability for RestTemplate and WebClient. During the break, I had time to talk to Oleg Šelajev and Juergen. The talk initially covered the future of CRaC. Jurgen was very optimistic about its chances as a future capability in the JVM and the chance of integrating it into a reasonable workflow. I asked him about the uptake of GraalVM and as of now the interest around the new versions focuses on other features. There’s excitement for GraalVM but it isn’t a killer feature. Yet. I have some thoughts on it which I will share at the end of the post. DaShaun Carter – Introducing Spring Boot 3.0 DaShaun showed a live demo of building with GraalVM and contrasted the sub-second startup time enabled by the native image in GraalVM. He then showed the RAM was a third of the full-size JVM image. Another part of the demo showed the actuator works as expected which is nice since GraalVM native image doesn’t support the agent APIs in the current version. The audience asked to see the size of the image which was half the size of the original image. The demo was good, but I’ve used GraalVM on Spring Boot in the past, so it wasn’t new to me. I asked about the uptake and traction they’re seeing for GraalVM native image. A lot of developers were waiting for Spring Boot to migrate to GraalVM and I’m curious if this is something they can already see in Spring Initializer stats. I wanted to know if the guys at Spring are seeing a flood of interest. DaShaun said he wouldn’t have made the trip if it wasn’t for GraalVM. But he invited me to talk later. I ended up speaking to Juergen and got the answer I “wanted”. After that, he pointed at https://calendar.spring.io/ which I wasn’t aware of (or forgot). The scale of releases for November is amazing. Cora Iberkleid – Protect Your Microservices with Spring Cloud Gateway Cora began her talk discussing some of the many use cases for a gateway. She emphasized that traditionally there were lots of use cases for a gateway. Spring cloud gateway is a lightweight approach to introduce a gateway that’s very approachable in the Spring ecosystem. They built it on the reactive stack and as a result, it’s fast and has high throughput since it’s non-blocking. The gateway uses predicates in handler mapping and can filter requests/responses. In the filters, you can filter, apply rules, and process requests dynamically then apply filters to the response to provide flexibility to the client. Cora showed routing configuration in YAML and weighted routing to a web service. She then moved to circuit breaking using a request limiter. The request rate limiter is based on Redis and can throttle the amount of requests sent to an API with a replenish rate and burst capacity to block over-usage of an API. This is very useful to limit abuse and limit trial users. Until now everything was done with pure YAML configurations. The demo concluded with a custom route filter that changes the requests dynamically. Dr. David Syer – Running Untrusted Code in Spring Using WebAssembly There are many cases where we might want to run untrusted code. There are many ways to do that and as Dr. Syer says WebAssembly is one of the best ways to do that. Although browsers support hosting WebAssembly, the focus of the talk is about server-side hosting. WebAssembly is a polyglot environment which makes it very attractive for some cases. You can experiment with WASM directly in the Mozilla playground in MDN. In the talk he discussed the various compilers you can use to generate WASM from C compilers to AssemblyScript, etc. See https://github.com/dsyer/hello-as He provided an interesting link to a project for hosting WASM in Java: https://github.com/kawamuray/wasmtime-java. Exchanging data with WASM seems painful and a bit of a throwback to communicating and copying data back and forth. He provided two links of interest: https://github.com/dsyer/spring-wasm-demo https://github.com/dsyer/async-wasm After the talk, I had time to talk a bit with Dr. Syer who was super nice. My fundamental problem is that I never “got” WASM. How is it better than running Java in a sandbox? The two use cases he mentioned were running untrusted code in embedded and edge computing. As a guy who worked in the mobile and embedded division at Sun/Oracle, this stings a bit. I get why this is the place where we’re “at,” but we had JVMs running in very constrained environments with MVM and for Java capabilities. It’s still around, it just never got the traction that WASM is gaining. Another aspect is the Polyglot support. Being able to do that for C or Rust code. But that’s not as interesting to me and for most of the use cases I can think of. We obviously have good Polyglot options in the JVM, but mostly in higher-level GC languages and not so much in languages like Rust or C. On the other hand, we have many other capabilities such as GC, deep native integration, elaborate memory model, etc. I’ve had this discussion with many smart people who see a lot of potential in WASM on the server. Notice that this isn’t about the browser where WASM has a valid use case. It might succeed simply because of mindshare, but as it stands right now, it seems that WASM is a couple of decades behind what we have in the JVM world. Finally Unfortunately, I had to pick up my kids from school and had to leave early so I didn’t have time to see the talk by Oleg Šelajev about Test Containers or the many other interesting talks. I did read the post on Test Containers but I guess the talk would have been more interesting. I need to go to more of these things. It seems I know more people when flying abroad to a conference than when visiting a conference in my country. As I mentioned before. I have some thoughts on why GraalVM isn’t taking over everything overnight. There are a few big reasons. It’s Work Moving to GraalVM requires a lot of work from the developers. Less so as time moves on. But still a lot of things need to change. Debugging is harder. We need to generate builds in CI and we can’t run them locally on some machines. It’s a pain. Adding the slow build process to the mix makes this even more painful. Dubious Benefit As developers, the memory and storage requirements we give are a given. DevOps have cost reduction incentives that can benefit from GraalVM but they can’t just integrate it. They need developers to do the work. In a corporate environment, cloud waste is already astronomical. Sending a developer to migrate to a new VM so the DevOps team can get “cost-saving credit”. That’s not something that the R&D management can get behind. The incentives in a corporate setting are problematic. Maybe the Spring team can arrange some viral marketing by helping twitter cut its cloud bill. I’m sure some of their microservices are Spring based. Observability While Spring Boot includes some monitoring tooling even with GraalVM. The level of observability on GraalVM is lower at the moment (no agent features). That alone might have been OK but coupled with everything else it could be a problem. We Don’t Use Serverless Java developers aren’t big on serverless. Over there GraalVM makes perfect sense and is already making great strides. But serverless isn’t as common in our community (rightly so IMHO) so the value for GraalVM isn’t as clear. To be clear. I’m very bullish on GraalVM personally. I think it will eventually enjoy significant market share traction and has many things going for it. But it will be a harder chasm to cross despite the obvious benefits.
I've been using different flavors of Ubuntu for years, including its upstream parent, Debian, and derivatives like Linux Mint, but the more-recent additions like the Snap package tool and the flakiness of Network Manager led me to make the switch once and for all. It's been a great move. Though I have a Macbook for work, I've preferred Linux over Windows and macOS for my daily driver for the past 10 years. I do a mix of coding, writing, system testing, and a wide range of activities that make Linux fast and easy. When I need tools like VScode, bridge utilities for advanced network configurations, video-editing software, and plain old email, Linux is fast and comfortable. But when Ubuntu introduced the Snap package manager, I started getting less certain about my Linux environment. I grudgingly accepted the shift from managing my network with /etc/network/interfaces to /etc/netplan/50-config.yaml, but managing packages with both apt and snap made me nervous. I set up network bridges so VMs and LXCs I run using KVN have addresses on my lab subnet. Network Manager is clunky for this, and networkd is less transparent than I'd like. The openSUSE YaST tool As these issues grew, I started casting about for an alternative. I started with Debian 11, which is solid and more traditional under the covers than Ubuntu (it's also .deb-based), but I wanted still more. I used to work for SUSE and was familiar with using the enterprise server, and decided to use Leap 15.4 — the point release open-source version — instead of Tumbleweed, the rolling release version. Installing openSUSE Right from the installer, I felt more comfortable. The openSUSE live .iso install process isn't the fastest in the world, but it provides the ability to make specific system configurations before the first boot. Tasks like partitioning, assigning a static IP, enabling openssh-server, switching from Network Manager to the wicked network manager, and other capabilities are straightforward and appealed to me as a more experienced Linux user. During the installation, I was offered the choice of desktop environment, including KDE, Gnome, and server. That's a nice touch. It's hard to over-estimate the value of being able to make all these system choices and settings right out of the gate. Running openSUSE Leap On first boot, my new Linux system was stable and familiar. Gnome is a solid desktop and it works just as it did under Ubuntu — with a couple convenient differences. Gnome Tweaks is installed by default, for example. Video codecs had to be installed separately but, fortunately, they can be added (along with other features) using community-built one-click installers. All my other familiar Gnome tools were available, including the terminal, Firefox, Evolution, Libre Office, and typical packages I use without thinking about them. When it came to installing other software, though, I turned to YaST, openSUSE's system-management tool. It's much more powerful than the standard Gnome Settings tool (and Tweaks) and does a lot more than a simple package manager. For example, I typically run KVM. YaST includes a virtualization tool that installs hypervisor tools — libvirt, virt-manager and KVM or Xen — in basically one click. The same tool can configure Virt Manager and Docker. The software manager also includes patterns, which are groups of packages that can install desktop environments (a lot are offered), file servers, development environments, and much more in one step. This makes deploying more complex, multifaceted configurations quick and confident. Finally, the default install uses the btrfs file system, which makes it possible to easily take system snapshots, among other things. Yes, this is possible to use it on other Linux distros, but openSUSE makes it feel like a core capability, which it is. As someone who tests a lot of software, it's nice to be able to jump back to a snapshot of my system. Final Thoughts Making the switch from a .deb-based system to an .rpm-based system can seem intimidating, but moving from Ubuntu to openSUSE Leap was painless and brought with it a host of improvements. I feel like my system is more responsive to my way of working, offers a range of capabilities when I need some help, and generally stays out of my way. After all, that's why I choose to run Linux in the first place.
Web development is a wide field that incorporates many features you need comprehensive knowledge about. Node.js vs PHP are some of the most developed technologies that are mostly featured in web development activities. These two technologies take part in the development of the server-side. However, Node.js tend to serve the client-side and the server-side development. According to research, 34.88% of the available websites are currently hosted on PHP. In addition, PHP has been in existence for more than three decades, making it serve approximately 78% of the entire web. In terms of comparison, Node.js is relatively new in the industry compared to PHP, although it is growing significantly. This is exactly where the big question comes in! What is the best choice between Node.js and PHP for your web development project? The truth is that the two are excellent options, although there is a need to learn more about them. If you realize that you are getting stuck when it comes to choosing between the two, this article has your back covered! What Is Node.js? A lot of confusing information has emerged, spreading that Node.js is a major framework of JavaScript programming language. However, the truth is that Node.js is not a programming language or rather a JavaScript framework. This technology operates as a platform where you can tailor the JavaScript programing language to operate as server-side scripting. In addition, Node.js operates as an open-source, single-threaded platform where you can create a fast and easily scalable server-side and networking application for your technology operations. This is the ideal option if you need to facilitate real-time operations and the development of applications based on your preferred needs. The tool can also be written using C and C++ programming languages alongside JavaScript. This is mainly propelled by the fact that low-level C is an efficient and reliable programming language that can be applied when building an operating system, database engines, and any other activity closely related to system programming. On the flip side, the C++ programming language has various traits that facilitate communication between Node.js and the respective operating system creating an internal connection. The tool can freely interact with C++ enabling it to withstand the computer characteristics creating a better platform for the server-side and the client-side. Why You Should Use Node.js Web development researchers have revealed that 36.19% of people use Node.js for their web development activities. This number is expected to grow to a huge figure as time passes since many people are learning more about the tool and how it can help them mitigate their web needs. It’s now clear that Node.js has a bunch of features to offer. Below are some features that make the tool stand out and the best choice. Non-Blocking Code The non-blocking code is one of the top features that make Node.js an incredible option. Besides, Node.js is mainly propelled by events since most codes depend mostly on the callback. It has the potential to pause or even sleep when other programs and requests are still under processing. Furthermore, the tool offers nob-blocking calls mainly used to generate a performant application. The program has a leveraged time of 1/0 to satisfy the operation of other requests. Full-Stack JS Node.js can allow you to conduct coding activities both on the client-server and the side-server. This is a powerful frontend and backend development combination. Note that this is the most crucial advantage of using Node.js in web development. Besides, it can overwhelm the limitation of employing two people even though you can save as much time and resources as possible. IoT Protocol This technology does not need you to have a lot of memory and resources on your server-side. Also, web development professionals can opt to employ IoT to generate concurrency links within different devices. The tool also can support message queuing telemetry transport, also known as MQTT, which uses IoT. This feature makes Node.js easy to integrate with your preferred third-party devices. The ease of integration makes the tool the best choice for the backend level. Simplicity Simplicity is a key feature to consider when analyzing the best technology to utilize in your web development activities. Node.js is an awesome tool that you can begin with due to its simple nature. If you are a new programmer and you want to get started, Node.js is the simplest option since you can learn and master it in just a few days. Pros of Node.js Cross-Platform Functionality Web developers can easily combine the power of Node.js and electron to generate real-time cross-platform applications that won’t need you to use different codes for every platform. This is one of the things that has triggered Node.js to create ChartExpo for Google Sheets and Excel charts such as Sankey Chart and Gauge Chart, which is currently applied in a series of data processing activities. Shorten-Time-To- Market This tool is considered full-stack and easy to scramble upon when conducting your activities. If your team members have access to this tool, they are likely to save a lot of time which they can spend doing other important activities that are more profitable. As a return, you will automatically cut short marketing time. Scalability Node.js has an efficient module balancing mechanism that allows it to operate over several CPU cores. This makes it easier for you to achieve your target goals within a much shorter duration. It has a non-blocking event loop feature that makes it efficient while at work. Cons of Node.js It Has an Unstable API The Application Program Interface, also known as API, changes from time to time, making the tool unreliable at some point. Given that new codes are released regularly, developers must change their access code regularly to withstand the current situation. Cannot Process Heavy Computation The major drawback of Node.js is that it cannot process multi-threaded programming tasks. Even though it can sustain more sophisticated applications compared to Ruby, it cannot withstand calculations that are done for quite a long duration. Callback Hell Node.js depends on callbacks since it has a synchronous operating model. This makes it difficult to process tasks since the assigned tasks are presented in the queue. What Is PHP? The term PHP is an acronym that stands for Hypertext Processor. In the past, it was defined as Personal Home Pages, which changed following technological advancement. It is an object-oriented and open-source server-side scripting that mainly operates as a web development tool. In most cases, it is used in generating web servers. However, it can be modified and used within the browser and the command line. If you prefer not to showcase your code output within the browser, you can decide to portray it through the terminal. This tool utilizes the Zend engine, mostly applied in web development activities, to execute tasks based on the given requirements. Facebook is one of the social media platforms that made changes to PHP, including JPHP, the HipHop Virtual Machine, also known as HPVM, and the Parrot. Why You Should Use PHP Within the past year, approximately 22% of web developers used PHP daily, especially when running heavy programming operations. Initially, many people firmly believed that this programming language would come to an end in the near future. However, this has been disregarded since the tool is still \growing stronger to date. Many people still rely on PHP in all their web development operations. Below are the reasons why you should prefer using it. HTML-Friendly If you are comfortable using HTML, you can easily shift to PHP without experiencing any trouble. Besides, you can opt to install PHP either outside or inside HTML, depending on your preference. Also, you should keep in mind that PHP and HTML can be interchanged, and everything still runs smoothly. Web Compatibility You can easily integrate PHP with any other technologies that evolve across the industries. Almost every hosting service you use has room for PHP adoption if the need arises. It is a vers8atile and flexible option making it easy to correspond with other programming languages available. Cross-Platform This tool can fit in all the available major operating systems available. Some of these systems include Mac OS, Linux, and Windows. In addition, PHP has proved to be compatible with any primary web server such as OpenBSD, Apache, and Nginx. Also, all the cloud platforms, such as Microsoft Azure, and Amazon AWS, among others, have the option to enable PHP. Connects All Databases PHP is known to be an adaptive web development language. It has an expansive room connecting all kinds of databases such as MS SQL, Oracle Database, and MySQL. These features give developers the freedom to choose the best database that suits generated application. Pros of PHP It Requires Less Maintenance This tool has advanced features that make it to be applied in multiple sectors, thus calling for no regular maintenance to operate smoothly. It comes with the Model-view-controller, also known as MVC, which divides every application into different models, views, and even controllers. This division mitigates regular maintenance since everything is outlined properly. Relatively Cheap Using PHP in your web development activities is completely free. Also, you don’t need to pay anything to use its features and tools. The availability of multiple data processing frameworks creates a great environment for developers to conduct their operations. User-Friendly You don’t need to spend much time learning about this tool. You can easily learn and master how to use it within the shortest time possible, given that it is friendly in nature. Even if it is your first time interacting with this tool, you can still master its model of operating. Cons of PHP Security Issues PHP is one of the web development tools that are known to have a negative reputation when it comes to security matters. When inexperienced developers take over the platform, they tend to generate sites that come with lots of vulnerabilities. This makes the tool appear as the most insecure option. Framework Quality Given that the PHP framework is open-source, the quality of the generated output is not up to standard. As a result, most frameworks lack the resources and proper support to enhance quality standards. Outdated Models Technology is constantly changing day and night, thus calling for frequent updates. As Machine learning develops, new programming languages such as Python develops. You cannot compare such advancements with PHP since it has a library full of different features and technologies. Conclusion The above-outlined web development technologies have both their negative and positive sides that you can choose based on what you want to create. All the two tools play a huge role in web development activities. The choice you make at the end of the day mainly relies on your requirements and what you would like to have. Note that one tool may have all the features you need while the other lacks, thus giving you a chance to make a sound decision.
Python is one of the best frameworks available for web application development. Although other frameworks exist, Python is the most promising and offers various features required to develop ultra-modern web applications. If you are looking for a framework to launch a professional web-based application, then Python will be the right choice. This article is dedicated to the Python Web Framework, and here we have tried to cover all the related aspects. The most important and necessary part of the web development process is to develop the actual website or web application that end-users will use to serve their purpose. It does not matter what kind of platform it will be, whether it will be using Android or iOS, Windows or Mac OS X, etc. It should be developed in such a way that it suits the best end-user requirements and should provide them with all the functionality they are looking for on their website/web application. Python web framework is used to develop ultra-modern web applications, which have become the prime requirement of any business or organization to expand their business by providing the best services to their clients and customers worldwide. So before choosing the Python Web Framework, it’s important to know its features and utility and why it’s superior to other web frameworks like Ruby on Rails, NodeJS, etc. After knowing about its features and utility, you can decide why you should go with this framework and why this framework is the perfect choice for your web application development project. Reading the basic information about it would be best to understand the Python web framework deeply. What Is Python Web Framework? Python frameworks are known to provide a robust infrastructure for developing software applications. Specifically, in terms of web development, it facilitates the developers to create a web application with speed. In addition, python-based web applications remain reliable through execution and scalable for future expansion. From a programming language point of view, it is a robust, general-purpose, object-oriented, and interpreted programming language. Moreover, it is a cost-effective and time-efficient language, so a python web development company chose it for web application development. The Python Frameworks Are Categorized Into Three: 1. Full-Stack Framework As its name implies, full-stack python web frameworks are perfect and the best -fit for backend and frontend development. It offers tools for developing GUI (graphical user interface) and backend tasks like database connectivity, security mechanism development, etc. The best example is the Django framework, which is counted as one of the best Python frameworks and is popular among developer communities. 2. Micro-framework A micro-framework might offer support for routing, templating, and other features. A developer who works with a micro-framework would understand the relevant language's standard libraries and third-party package ecosystem to complete their project. Many Python websites use micro frameworks because they work with fewer resources and are lightweight. They also don't require separate tools for databases or templates, so it is easier to integrate them with other cloud services. Its main specialty is its simplicity and extensibility, which makes Python micro frameworks different from others. However, it also has some limitations compared to the full-stack Python framework. 3. Asynchronous Framework These are event-driven frameworks. The best part about Python's asynchronous framework is that instead of waiting for line-by-line handling, it does not wait for any event to be executed before starting another. An asynchronous Framework is used to develop complex web applications. It is a highly scalable tool that handles a high volume of concurrent requests without slowing down or crashing. The list of features that make it the best framework to use for web development includes: Supports several different programming languages. Aims at scalability and concurrency. It's robust, maintained, and has a helpful community. Some Facts About Python Web Framework Python - is an open-source programming language created by a Dutch programmer named Guido Van Rossum. More than 48% of developers around the world use Python frameworks. Its community size is 10 million, which connects worldwide programmers. On Google, 29.9% of search queries were placed about Python. Source: Statista Advantages of Python Web Framework The framework is a set of code written in a programming language, which provides some functionality for programmers to save time and cut down on the time it would take to write all the code from scratch. These are used by programmers when creating web applications, as these web apps often use server-side scripting. In this respect, Python has a plethora of frameworks that offer robust web development solutions for programmers for various purposes. One such framework is Django; Django is an open-source Python web application framework designed for the rapid development of dynamic websites and back-ends. Similar utilities are Flask which allows the creation of single-file scripts or small programs; Pyramid, which offers sophisticated routing capabilities with clustered configuration files; and more. One of the best things about the Python framework is that it offers all the things, utilities, and tools that a programmer needs to create fantastic software applications. When developing a product with modern methodologies, choosing Python development services from an experienced developer is the smartest choice. Source: AZQuotes Software development companies widely use the Python web framework. It is a one-of-a-kind programming language, making it a versatile choice for developing custom web applications and mobile apps. It has several advantages over other frameworks. Following are some of them: Require less code Robust Easy maintenance Open-source Rapid development Let’s expand these advantages to have a deep understanding ahead. Easy for All Python language is one of the programming languages from high -the level language family. Still, the best part is its syntax is much simple as we write some words in English like print, exit, etc. it makes the developers and others understand the code in a much easier way. Less Coding but Impactive Compared to the programming languages like Java and C++, it facilitates the developers to write less code but in an impactful way to achieve the desired outcome. Moreover, its short coding quality makes it one of the best programming languages for developing complex applications. Enhanced Productivity It is counted as one of the best programming languages any web app development company uses to create professional or business class applications. Instead of understanding the syntax, a developer can focus on writing the direct code. Creation Prototypes Seamless Python facilitates the developers to create the prototype seamlessly. That is why developers prefer python web development frameworks for web application development. Flexibility In terms of flexibility, Python programming language is the most flexible as it can be effortlessly integrated with others. You can use it for different scenarios. The integration can happen with C, Java, .Net, C#, and other languages. Top-10 Python Web Development Frameworks in 2022 In this blog section, we will read about top-10 python web development frameworks that you can consider in 2022 for creating web applications. So, let's begin with the list. 1. Django The Django framework is the top-most choice of any web development company. Developers use this framework to develop complex web and mobile apps on high-quality standards. Due to its open-source nature, Django is cost-effective but most powerful among other python web frameworks that facilitate the developers to create APIs and business class web applications. Currently, 12000 web applications have been developed, and more are yet to come. Highlights Built-in-Authentication; Assist with pattern definition; Powered URL system; Automatic admin interface; Supports multiple cache mechanisms. 2. Flask It comes under a BSD license and influences the Sinatra Ruby Framework. It utilizes WSGI Toolbox and Jinja2 template, which makes it more special than others. Flask's prime application is to support the developers in creating a robust application base. Some big brands, like LinkedIn, Pinterest, etc., use Flask Python Framework. If we compare it with Django, it is best suited for less-size projects. Highlights Complete WSGI compilant; Best choice for small projects; Built-in development server and debugger; Supports unit testing. 3. CherryPy CherryPy is another fantastic Python web development framework and one of the top choices of Python developers. It has a multi-hung server and can run with any Python-supported framework. Offerings like date access, templates, session handling, file management, and more have reserved their name in the top-10 Python web development frameworks list. Highlights HTTP/1.1 Compliant; Effortlessly runs on various HTTP servers; Multiple built-in tools; Empowered configuration system. 4. Pyramid In a very short time, Pyramid gained popularity among experienced developers. Python 3 is compatible, or in simple words, you can say that Python 3 is required to work with the Pyramid framework. Its objective is to facilitate developers to create high-quality web applications with less complexity. As a result, the pyramid framework is one of the top choices of experienced web developers. Highlights Supports flexible authentication mechanism; Allows HTML structure validation; Full documentation; Facilitates execution of large and small applications. 5. Grok If you are looking for agile development experience, then Grok is the Python framework that you are looking for. The objective behind the development of Grok framework is to speed up the application development process. While creating the applications, developers choose independent libraries available to them. Grok is a full-stack Python web development framework. Highlights Offers a strong foundation for web app development; Empowers web developers to leverage Zope3; Integrated security mechanism; Facilitates custom web app development. 6. TurboGears Turbogears is an excellent Python web framework that is designed to overcome all inadequacies of other python family frameworks. Furthermore, it facilitates software developers to create applications quickly. Turbogears offers elements such as SQLAlchemy, Repoze, WebOb, and others to create the applications fast. Highlights Multidatabase support; Accessible command-line tools; Offers Mochikit JavaScript library integration; MVC-style architecture. 7. Zope3 Zope3 is a web framework written in Python based on the Zope Toolkit. It is designed to be scalable and extensible with low latency. This framework aims to provide developers with the ability to build web applications that are easily modularized, highly maintainable, and easily plugged into other systems. or databases. Zope3 was originally developed by Zope Corporation and is now maintained as part of the Zope Foundation. Highlights Suitable for developing a content management system; Offers data storage in the form of ZODB; The default interface is ZMI, aka Zope Management Interface; Its libraries offer flexibility. 8. Bottle The bottle is Python's simple, fast, and lightweight web framework. It is a "batteries included" Python framework. It's a lightweight WSGI-based web framework that provides fast reverse-proxy servers. In addition, it supports CSV routing, HTTP file serving, templating with Jinja2 & Blueprints, URL routing with the popular Chameleon templating engine, and more. The most famous example of the Bottle framework is - Netflix, which uses it for its web interface. Highlights Built-in template engine; WSGI framework with CGI; Easy access to data, file uploads, and cookies; Speed optimization. 9. Web2py Web2Py is a Python web framework that makes it easy to create dynamic websites and powerful internet applications. It offers SQL/JDBC as its database interface, includes support for Google App Engine, and a well-documented, correct, and clear interface designed for beginners and experts. Web2py enables the user to build web applications the same way one would build an application on their computer. Highlights Facilitates quick web development; Support Model View Control Architecture; Provides web-based IDE; Web app security. 10. Tornado The Tornado Python framework has been around for over 10 years and is still used today. Tornado was originally developed by Martelli et al. in 2005 as a lightweight web framework for Python with an emphasis on extending its capabilities through plugins at the time of its adoption to the needs of modern web development. It has become more popular in recent years due to handling asynchronous event-driven I/O for web applications. Highlights Facilitates 3rd Party authentication; Offers real-time programming; Result-oriented framework; Provide web templates. Wrapping It Up! Python is a general-purpose and high-level programming language. It provides an interesting balance of simplicity and power. As a result, we can see that Python web development frameworks are storming over the web development industry. There are many reasons for this, but the most important one is that it provides an easy-to-learn, versatile toolkit with a built-in application server. Python web frameworks are now used to create the next top most popular sites on the internet, like Pinterest and YouTube. It has proven to be more robust than other programming languages, and developers are moving towards Python because of its simplicity.
There are two main ways by which microservice applications can interact with each other: REST services and messaging systems. The REST approach is the most common and will be treated in this article. We will see how Spring boot can make the development process of REST APIs fairly easy, with the use of a set of useful annotations and some implicit background behavior, like the serialization of model objects to JSON format. Another important issue is related to the documentation and sharing of APIs, and we will see that these concerns are addressed effectively with a solution named Swagger. Integrating Swagger with Spring Boot allows us to generate the documentation from the source code, as a Swagger JSON file, and even browse and manage all the exposed REST services with a web user interface. REST API Development In order to develop a REST API with Spring Boot, we need to add the following dependency in the Maven POM: XML <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> This way we are characterizing our project as a web application, with an embedded tomcat web server included by default. Then, making use of a set of specific annotations, we can define our controllers, which are meant to expose the HTTP REST services to the external world. We can define them by simply annotating a class with @RestController. The following step is to set the mappings that are required to define the correspondence between the class methods implementing our services and the URI paths needed to execute them by HTTP calls. We see an example in the following code snippet: Java @RestController @RequestMapping("/library") public class BookController { @Autowired private BookService bookService; @GetMapping("/book") public List<Book> findAll() { return bookService.findAll(); } @GetMapping("/book/{id}") public Book findById(@PathVariable("id") String id) { return bookService.findById(id); } @PostMapping("/book") public Book add(@RequestBody Book book) { return bookService.save(book); } @PutMapping("/book") public Book update(@RequestBody Book book) { return bookService.save(book); } @DeleteMapping("/book/{id}") public void deleteByTitle(@PathVariable("id") String id) { bookService.deleteById(id); } @GetMapping(value = "/book", params = {"author"}) public List<Book> findByAuthor(@RequestParam("author") String author) { return bookService.findByAuthor(author); } } Here we have annotated a class with @RestController and @RequestMapping("/library"). The @RequestMapping annotation specifies a prefix for the HTTP paths used to call our services. Then the class public methods are configured with other annotations aimed at implementing the HTTP REST classic calls: GET, POST, PUT, DELETE: @GetMapping @PostMapping @PutMapping @DeleteMapping Those annotations contain the final portion of the HTTP path plus one or more parameters, wherever required. The @PathVariable annotation is used to map parameters passed directly in the URI path, and defined inside curly braces in the corresponding method annotation. To map query parameters, that is to say, those passed after a "?" character in the URI, the @RequestParameter annotation can be used instead, as in the findByAuthor method in the snippet above. As an example, to get all the books in the database we can use the following (if the application is running on our local machine), with an HTTP GET method call: http://localhost:8080/library/book To get a book with a particular ID: http://localhost:8080/library/book/<id value> Or finally to get a list of books by the author (case of query parameter) http://localhost:8080/library/book?author=<author name> The annotations provide an easy way to "transform" an internal implementation of a Java class in a set of services that can be called from the outside world by the HTTP protocol. Another very useful feature is the serialization of the JSON data. If we consider for instance the POST Method named add in the code snippet above, we see that it takes a parameter of type Book. But we know that the call to that method is actually made by an HTTP call with a JSON body. Spring Boot automatically converts that JSON into a Book object using a library called Jackson. The features described above are a good base to facilitate micro-service development. A further step would be to have an effective way of sharing and communicating the structure of our REST services. In the following section, we will discuss this matter, introducing a solution named Swagger. API Documentation and Swagger Solution Developing a whole system in a micro-service scenario, with a number of applications interacting with REST APIs, requires keeping the consistency of the APIs involved. Swagger is a solution with a number of tools to cope with these concerns. Swagger describes the APIs by means of a JSON specification. We can define our services with the JSON format and then generate the basic code from it or generate the JSON from our code. In the integration with Spring Boot that is described here, we will use the second option. In the previous section, we have described how we can develop the REST services exposed by a Spring Boot application, with a given set of mappings and format of input and output objects. If we consider the big picture, with our single application that must interact with a number of other applications with their own REST interfaces, possibly being developed by other teams, we understand how important would be to document and communicate the structure of those interfaces. Integrating Swagger into Spring Boot in the context of a web application, we have the means to generate a JSON description of our REST services, that will be available by a specific URL path. We will have also a Swagger web UI available that allows us to browse the services definitions and also interact with them. How to Integrate Swagger in Spring Boot In order to perform the integration (we use Swagger 2 in our example) the first thing we have to do is to set the related decencies, as shown in the following Maven POM fragment: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency> Then we have to enable Swagger by the @EnableSwagger2 annotation. In the following code snippet example, we do it in a specific configuration class (marked with @Configuration) and, in the same class, we define a bean of type Docket. In the Docket bean configuration, we set a group name, a basic set of information like title, description, and a Predicate object with a regular expression to catch the URL paths in which the REST services that we want to be read by Swagger are available, in our example all the paths prefixed with "library". Java @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket postsApi() { return new Docket(DocumentationType.SWAGGER_2).groupName("mygroup") .apiInfo(apiInfo()).select().paths( regex("/library/.*")).build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder().title("REST API example") .description("A minimal REST example with H2 in memory db as persistence layer") .termsOfServiceUrl("http://codingstrain.com") .license("REST API example License") .licenseUrl("fake@gmail.com") .version("1.0") .build(); } } Due to a bug, we also need an additional piece of configuration, which we show below, supposing we are using an application.yaml file: YAML mvc: pathmatch: matching-strategy: ant_path_matcher Running a Sample Application You can find a sample application, with all the configurations described in the previous sections, at the following GitHub link: https://github.com/mcasari/codingstrain.git. You can install it as a local git repository with the following command "git clone https://github.com/mcasari/codingstrain.git", and use Maven to compile and build it from the command line or use your preferred IDE. You can run it with the following Maven command "mvn spring-boot:run". Since it is a Spring Web application it will run with an embedded web server, listening by default on the 8080 port. We can use swagger to take a quick look and even test our API. We can use the following URL to get a JSON file with the API definitions: http://localhost:8080/v2/api-docs?group=mygroup As we can see from the URL above, we pass a query parameter named group with a value corresponding with the group name we defined in the Docket bean configuration. As a result, we obtain a JSON that can have some utility but is not what we can call "user friendly". As a better alternative we can use the Swagger UI by the following address: http://localhost:8080/swagger-ui.html In the screenshot below we can see what we obtain on the screen. We can see all the REST services we have implemented in the application, and if we expand them we can even interact with them. For instance, we can post a new book by the HTTP POST service with the path "/library/book" or get a book by the author using the available GET method that takes "author" as a parameter. Swagger UI Conclusion In this article, we have seen how Spring Boot can simplify the development of REST APIs. We have also seen how integrating a solution like Swagger can improve the communication of service definitions. This is especially important in the context of micro-service systems in which we have separate independent applications that must interact with each other and the consistency of the interfaces must be preserved. There is another very useful feature of Spring Boot, available by the so-called Actuator dependency, that provides a set of HTTP endpoints to monitor, get statistics, and manage the application in a production environment. We will cover it in the following article: Spring Boot for Cloud - Actuator.
Justin Albano
Software Engineer,
IBM
Thomas Hansen
CEO,
Aista, Ltd
Hiren Dhaduk
CTO,
Simform
Tetiana Stoyko
CTO, Co-Founder,
Incora Software Development