React vs Vue: What to Choose in 2022?

React and Vue are the two most popular and widely used JavaScript frontend frameworks today. These frameworks allow developers to create a wide variety of web applications with JavaScript. Choosing between the two can be confusing if you are building a new application. Each has its own use case and serves different business needs. 

Most web developers prefer to use Vue.js and React frameworks. Using React or Vue.js provides a quality approach to web development that is consistent and performant. Both Vue and React have their own best scripts and meet different kinds of business needs.

In this article, we will learn about each and explore which is best suited for your business.

What is React?

React.js combines a high degree of concentration with simplicity when it comes to user experience. It was developed by Facebook as an open-source JavaScript library to help developers build user interfaces. React follows a declarative programming style and a component-based approach. It allows for the creation of complex web applications with the highest flexibility and speed. 

React.js is the most used web framework in 2021 with 40.14% of the software developers globally using React. 

React holds the top spot for the fourth year. Popular companies that are currently using React.js are AirBnB, Netflix, Instagram, and Udemy.

Source: https://2021.stateofjs.com/en-US/libraries/front-end-frameworks

What is Vue.js?

Vue.js is a progressive JavaScript framework that developers use to build interfaces. Unlike the Angular framework, Vue is incrementally adaptable by design. It scales easily between a library and a fully-featured framework. Companies using Vue.js include GitLab, Behance, Upwork, and Grammarly.

Here are a few Vue.js statistics

Vue.js is used by 0.8% of all the websites amongst JavaScript libraries.
Vue.js is used by 1.2% of all the websites amongst the JavaScript library we know and that rank in the top 1,000,000.
In 2021, 42% of the developers admitted that they used Vue in their company. 55% of the developers are of the view that Vue will get more popular in their organization. 

What are the Similarities between React and Vue?

Before looking at the differences between the two, let us look at some similarities. Both React and Vue possess component-based architecture. Also, both the frameworks are lightweight and have an exposure to lifecycle methods. Their performance is fairly similar. Both technologies work with any existing web application, even if it’s not a Single Page Application.

Below are some similarities:

They have composable and reactive view components
They use virtual DOM
JavaScript Code and PWA support
They concentrate on a core library. They also involve handling of routing and global state management with companion libraries
Possibility of working with any existing web applications
Both React and Vue have large proactive communities and plenty of libraries and tools available.

Comparison between React and Vue

You can pick one after knowing how they differ. The most obvious distinction: React is a library, whereas Vue is a framework.

Let us compare them taking into account some essential parameters. 

Data Binding 

Vue uses two-way data binding. It means whenever you change any interface element, your model state automatically changes with it. It may look simple to read about it. However, for a large project, it is not. If you want a good data overview and want easy debugging, you may prefer React as it has one-way data binding. After the model state is updated, React then renders the change in the interface element.

Desktop and Mobile Development 

React Native is the perfect platform for you if you want to build mobile apps that work on Android or iOS. Developers can use their existing skills to get started. The biggest advantage of using React is that you can reuse 99% of code between Android and iOS.

On the other hand, Vue does not have a dedicated platform like React Native. However, it does not mean you cannot develop native applications. Vue developers can use a cross-platform UI framework or plugins and write Vue applications and compile them into native apps – iOS and Android.

Major Differentiator – Syntax

One of the major differences between them is the way the view layer is built. Vue uses HTML templates by default, and there is no option to write in JavaScript Expressions (JSX). On the other hand, React solely uses JSX. Vue is easier to use even for beginner frontend developers as it uses only HTML. React’s JavaScript Expressions combine CSS and HTML into JavaScript. The XML-like syntax allows developers to create self-contained UI components with view-rendering instructions included.

Tooling

React provides third-party tools to help developers create React apps, and it allows them to speed up app development by adding scripts. Earlier, React developers had to copy the files from previous apps and configure everything from zero. It was not only time-consuming but a boring task that no developer liked doing. 

Vue, on the other hand, uses a tool called Vue CLI. It enables the user to create any project quickly. It comes with many benefits like easy improvements, adding plugins anytime during the project, etc.

Popularity

It is not easy to pick a winner on popularity, but if you check online communities, React wins this battle. It is mainly because it is backed by Facebook. The Vue community is smaller compared to React with fewer packages and resources. However, it is maintained by the creator himself – Evan You and his team.

Template and Styling

The UI library is incomplete without templates and styles. Additionally, they’re the places where the difference between React and Vue is most apparent, since the code design is different. The approaches both Vue and React take are also quite different.

While Vue has a more declarative approach, React is more functional. Since the logic and markup are both considered as one, they are mixed. It is accomplished with JSX, which is an abstraction of React.createElement, which is used to create Virtual DOM entities. 

Templates and styles are treated separately with Vue – a more conservative approach. Here, the templates are viewed as old-fashioned HTML elements.

Performance

If you want to make the decision of choosing anyone between Vue and React based on performance, you will not be able to since both frameworks have remarkable speed. However, as mentioned at the start, you can check for specific use cases to decide which is a better option for you.

Learn more about Vue.js Best Use Cases 

Vue has to be integrated into an existing project incrementally. This means there is a per project requirement since it is a progressive framework. For example, you can use Vue.js as a lightweight library to add some interactivity to a web app. Ease of integration is one of Vue’s top assets. 

You can hire Vue js developer to easily implement Vue.js into a project – it is a lot faster. The learning curve is easy, and tools like Vue UI and CLI make it a great tool to use for quick MVP delivery and start-up ideas. It is a cost-effective solution for all small to medium applications. However, it does not mean it is not good for large web apps. It has a vast ecosystem of tools and companion libraries, allowing the framework to respond to the complex needs of enterprise-grade applications.

Learn more about React.js Best Use Cases 

React was initially created for large-scale web projects, and hence using it for a small and simple app would not justify its usage. Setting up a project using React.js is not easy, and you need some level of expertise to do it, but its architecture ultimately pays off in the long run.

JSX is powerful, and it gives developers a range of powers – flow controls and advanced IDE features such as auto-completion or listing are included in the component view templates. React does not have official packages for routing or state management like Vue. If you are developing complex apps, you have to use third-party solutions in many places. It gives a range of choices to developers. If you have experienced developers, they will know better which libraries are optimum and can be used to meet the business demands of a particular web application.

Choose a framework/library according to your needs

React is a library, and hence the users gain more control, such as the manual re-rendering control. The library heavily utilizes functional programming principles, which is evident in how it handles state and communicates between components. On the contrary, Vue is a framework that brings to the table many more built-in features and companion libraries which come from the core team. Hence, this helps in making the development experience smoother for the user.

Both Vue and React are great tools for building interactive user interfaces. You cannot pick one randomly, you will need to take into account many factors like your business needs, developers’ experience, budget, timeframe to deliver the project, and much more. Performance-wise both are at par, and you won’t be disappointed in this aspect whether you choose React or Vue.

Suggested Articles

Vue vs React: What is Easier? What is Trending? [Detailed Guide with +/-]
What is Vue?
12 Best React Admin Templates Under $100

The post React vs Vue: What to Choose in 2022? appeared first on Flatlogic Blog.

Flatlogic Admin Templates banner

ASP.NET Core updates in .NET 7 Preview 2

.NET 7 Preview 2 is now available and includes many great new improvements to ASP.NET Core.

Here’s a summary of what’s new in this preview release:

Infer API controller action parameters that come from services
Dependency injection for SignalR hub methods
Provide endpoint descriptions and summaries for minimal APIs
Binding arrays and StringValues from headers and query strings in minimal APIs
Customize the cookie consent value

For more details on the ASP.NET Core work planned for .NET 7 see the full ASP.NET Core roadmap for .NET 7 on GitHub.

Get started

To get started with ASP.NET Core in .NET 7 Preview 2, install the .NET 7 SDK.

If you’re on Windows using Visual Studio, we recommend installing the latest Visual Studio 2022 preview. Visual Studio for Mac support for .NET 7 previews isn’t available yet but is coming soon.

To install the latest .NET WebAssembly build tools, run the following command from an elevated command prompt:

dotnet workload install wasm-tools

Upgrade an existing project

To upgrade an existing ASP.NET Core app from .NET 7 Preview 1 to .NET 7 Preview 2:

Update all Microsoft.AspNetCore.* package references to 7.0.0-preview.2.*.
Update all Microsoft.Extensions.* package references to 7.0.0-preview.2.*.

See also the full list of breaking changes in ASP.NET Core for .NET 7.

Infer API controller action parameters that come from services

Parameter binding for API controller actions now binds parameters through dependency injection when the type is configured as a service. This means it’s no longer required to explicitly apply the [FromServices] attribute to a parameter.

Services.AddScoped<SomeCustomType>();

[Route(“[controller]”)]
[ApiController]
public class MyController : ControllerBase
{
// Both actions will bound the SomeCustomType from the DI container
public ActionResult GetWithAttribute([FromServices]SomeCustomType service) => Ok();
public ActionResult Get(SomeCustomType service) => Ok();
}

You can disable the feature by setting DisableImplicitFromServicesParameters:

Services.Configure<ApiBehaviorOptions>(options =>
{
options.DisableImplicitFromServicesParameters = true;
})

Dependency injection for SignalR hub methods

SignalR hub methods now support injecting services through dependency injection (DI).

Services.AddScoped<SomeCustomType>();

public class MyHub : Hub
{
// SomeCustomType comes from DI by default now
public Task Method(string text, SomeCustomType type) => Task.CompletedTask;
}

You can disable the feature by setting DisableImplicitFromServicesParameters:

services.AddSignalR(options =>
{
options.DisableImplicitFromServicesParameters = true;
});

To explicitly mark a parameter to be bound from configured services, use the [FromServices] attribute:

public class MyHub : Hub
{
public Task Method(string arguments, [FromServices] SomeCustomType type);
}

Provide endpoint descriptions and summaries for minimal APIs

Minimal APIs now support annotating operations with descriptions and summaries used for OpenAPI spec generation. You can set these descriptions and summaries for route handlers in your minimal API apps using an extension methods:

app.MapGet(“/hello”, () => …)
.WithDescription(“Sends a request to the backend HelloService to process a greeting request.”);

Or set the description or summary via attributes on the route handler delegate:

app.MapGet(“/hello”, [EndpointSummary(“Sends a Hello request to the backend”)]() => …)

Binding arrays and StringValues from headers and query strings in minimal APIs

With this release, you can now bind values from HTTPS headers and query strings to arrays of primitive types, string arrays, or StringValues:

// Bind query string values to a primitive type array
// GET /tags?q=1&q=2&q=3
app.MapGet(“/tags”, (int[] q) => $”tag1: {q[0]} , tag2: {q[1]}, tag3: {q[2]}”)

// Bind to a string array
// GET /tags?names=john&names=jack&names=jane
app.MapGet(“/tags”, (string[] names) => $”tag1: {names[0]} , tag2: {names[1]}, tag3: {names[2]}”)

// Bind to StringValues
// GET /tags?names=john&names=jack&names=jane
app.MapGet(“/tags”, (StringValues names) => $”tag1: {names[0]} , tag2: {names[1]}, tag3: {names[2]}”)

You can also bind query strings or header values to an array of a complex type as long as the type has TryParse implementation as demonstrated in the example below.

// Bind to aan array of a complex type
// GET /tags?tags=trendy&tags=hot&tags=spicy
app.MapGet(“/tags”, (Tag[] tags) =>
{
return Results.Ok(tags);
});

class Tag
{
public string? TagName { get; init; }

public static bool TryParse(string? tagName, out Tag tag)
{
if (tagName is null)
{
tag = default;
return false;
}

tag = new Tag { TagName = tagName };
return true;
}
}

Customize the cookie consent value

You can now specify the value used to track if the user consented to the cookie use policy using the new CookiePolicyOptions.ConsentCookieValue property.

Thank you @daviddesmet for contributing this improvement!

Request for feedback on shadow copying for IIS

In .NET 6 we added experimental support for shadow copying app assemblies to the ASP.NET Core Module (ANCM) for IIS. When an ASP.NET Core app is running on Windows, the binaries are locked so that they cannot be modified or replaced. You can stop the app by deploying an app offline file, but sometimes doing so is inconvenient or impossible. Shadow copying enables the app assemblies to be updated while the app is running by making a copy of the assemblies.

You can enable shadow copying by customizing the ANCM handler settings in web.config:

<?xml version=”1.0″ encoding=”utf-8″?>
<configuration>
<system.webServer>
<handlers>
<remove name=”aspNetCore”/>
<add name=”aspNetCore” path=”*” verb=”*” modules=”AspNetCoreModuleV2″ resourceType=”Unspecified”/>
</handlers>
<aspNetCore processPath=”%LAUNCHER_PATH%” arguments=”%LAUNCHER_ARGS%” stdoutLogEnabled=”false” stdoutLogFile=”.logsstdout”>
<handlerSettings>
<handlerSetting name=”experimentalEnableShadowCopy” value=”true” />
<handlerSetting name=”shadowCopyDirectory” value=”../ShadowCopyDirectory/” />
</handlerSettings>
</aspNetCore>
</system.webServer>
</configuration>

We’re investigating making shadow copying in IIS a feature of ASP.NET Core in .NET 7, and we’re seeking additional feedback on whether the feature satisfies user requirements. If you deploy ASP.NET Core to IIS, please give shadow copying a try and share with us your feedback on GitHub.

Give feedback

We hope you enjoy this preview release of ASP.NET Core in .NET 7. Let us know what you think about these new improvements by filing issues on GitHub.

Thanks for trying out ASP.NET Core!

The post ASP.NET Core updates in .NET 7 Preview 2 appeared first on .NET Blog.

Flatlogic Admin Templates banner

What is PHP?

Introduction: What is PHP

PHP (an acronym for Hypertext Pre-processor or the previous one Personal Home Pages) is a server-side open-source scripting language. It is great for dynamic content management, session tracking, databases, and has fantastic community support.

PHP is a weak dynamic typing language, meaning it auto determines a lot of implicit conversions, even though there may be a lack of precision or equivocal conversions. In 2020 PHP 8 came out. It has a JIT (just-in-time) Compilation, which sped up the work of the Preprocessor multiple times.

PHP is a popular programming language and is the foundation of such CMSs as WordPress (powers 43% of all the websites on the Internet), DRUPAL, Joomla, and the most popular E-Commerce Magento 2. Also, there are very popular PHP-based MVC Frameworks Symfony such as Yii2 (very popular in Russia) and Laravel (takes the 1st place in GitHub RANKING).

How PHP works

Let’s elaborate how the Hypertext Preprocessor works. The browser sends an HTTP request to a web server. Then the index.php file is generated, which is handled by the preprocessor. Finally, the web server receives the output and sends it back over the Internet to a user’s web browser.

Why use PHP

PHP is incredibly easy for beginners and provides multiple advanced features for professional programmers. With it, you can learn and start writing basic scripts in a short period. Here is the list of the best features:

Versatility

PHP is a server-side programming language. Therefore, you need to set up a server to work with it. This language is also platform-independent. You don’t need a specific operating system to use it because it works on any platform, whether it’s macOS, Windows, Linux. For that reason, this is why it may be deployed on various systems and platforms easily and inexpensively.  

Secure and swift

PHP used to be scolded for its ability to attack the site with SQL injection, but with the release of MVC frameworks, this is now impossible. The major advantage is that due to the wide distribution and support of the community, there are now multiple tools, frameworks, and security and cyberattack protection solutions available. The second equally major feature is speed, try to use versions 8 and up, as these versions introduced the JIT Compilation, which speeds up PHP.

Well-linked with databases

PHP provides an easy way to establish a reliable connection to almost any database. So it can instantly connect to MySQL, PostgreSQL, MongoDB, or any other database.

Testing

Among programming languages, PHP has a reputation for being stable and reliable. Its code has been tested under a wide variety of real-world and experimental conditions. If there’s a possible error or shortcoming, chances are someone in the community has found a way to deal with it. There are numerous frameworks and toolkits which are helpful for secure, efficiency and effectiveness of web development.

Community

PHP has a very responsive online community. The official documentation contains feature guides, chats and forums, so you can quickly solve your problem if you get stuck.

Low-cost open-source software

PHP is a no-cost language that can significantly help you save on your development expenses. A lot of the development tools normally used with this language are open-source and available for free, so they keep the cost of the project down even more. Numerous frameworks offer Hypertext functionalities and make the development process easier and much better, for example, the most popular and widely used is Laravel.

Conclusion

Rasmus Lerdorf is a Danish-Canadian programmer who released the first version of PHP in 1994. It continues to be a widely used and actual language in web development. It has been available for quite a long time. Major companies like Slack, Meta (Facebook), HPVM, and Wikipedia use the language extensively. Web Hosting Platforms like BlueHost, Site ground run their hosting servers using Hypertext Preprocessor.

On the Flatlogic Platform, you can also use PHP when choosing the Laravel backend framework for creating your application. Afterward, you will get in a few minutes the Laravel CRUD admin panel with DataBase models and API.

The post What is PHP? appeared first on Flatlogic Blog.

Flatlogic Admin Templates banner