Home ...

Programming languages Csharp, JS, TS and PHP

Ragavendra B.N.
Ragavendra B.N.

It might be that I already have documented about Csharp or dotnet and JS already. owever in this article I will ty to bring about pros and cons of them along with PHP.

  1. Basics - All the three languages Csharp, JS or TS have some common syntax like the ? to check if a value is null or ??= which is an assignment if the left hand value is a null. Not sure of PHP on this though.

String concatenation is similar for Csharp and JS or TS which is + sign, but for PHP one has to use the . operator.

var, let and const are used for variable types for string, numeric, [] array and {} keyvalue object in JS or TS. Csharp has var alone or the actual static type like int, long, double, string to name a few. In PHP all variables are declared without either of these, instead all variables start with dollar sign like $sdf. Types in PHP include string, int, float, index and associative array() like key values $arr = ["one" => "this is val one", 2 => "this is for 2"]

TS is more or less like a wrapper language on top of JS to help make it strictly typed with the support of some additional features likes enums and others like in csharp.

JS and PHP are loosely typed or strongly typed language whereas Csharp is strongly typed. However PHP expects ; at the end of the statements and will not interpret if there is a syntax error like missing colon.

  1. Uses - PHP was built back in the day to build web pages and websites and it can be evident from its in built methods such as $_SESSION, $_POST, $_GET, $_SERVER and similar global variables.

ASP .NET or Csharp was built to benefit both the Web development and game development with its strong object oriented programming support.

JS was mainly built to enhance user experience of the web pages. However with the development of Node, it is more or less solely used for web development along with CSS support from TailwindCSS and strict type support from TS.

JSX or TSX is a HTML templating type engine similar to PHP itself or which uses Blade or similar.

  1. Object oriented programming - Csharp is the modern strict type object oriented programming language inheriting a lot of its features from other languages as well. It supports class, interfactes, single inheritance through clasess, multiple interface inheritance, lambda's and similar.

JS supports class and is similar to Java, hence its name. Private variables in its class are prefixed with # like #gfd.

PHP seems to have a reasonable OOP support with classes, interfaces, inheritance and access modifiers like public, private and protected similar to Csharp.

  1. History and popularity - In terms of timelines, PHP with its nice features has been for a while like claiming to dominate about 70% of the web share with its popular CMS like Wordpress, Magento, Joomla or frameworks such as Laravel and similar.

Csharp is supposed to be more or less the next popular web development language with a share of about 10%. Along with C++, Csharp is the next programming language in gaming.

  1. Package managers - JS or TS use npm with them in packages.json file

PHP had similar with compose utility with packages listed in composer.json file

Csharp uses the dotnet install command to install the packages.

Summary

Irrespective of the features available in the modern programming languages, almost all of them are more less equally competitive. In terms of complexity, JS or TS seem to have loosing reputation. However, similar is heard of others as well. Csharp has a lot of features in its Blazor ASP .Net releases for support of Components and similar like from react or the ones in PHP. Date or time methods in JS can be a bit here and there. Csharp seem to have a better hold of it, I haven't tried them in PHP or did it a long time ago and I doubt much issue is there with it. Once good with one strict type OOP language, similar concepts like patterns Singleton, Factory, Facade, Remote and principles like SOLID can be easily applied. Csharp and PHP may have better support for dependency injection, like injecting them for each route or similar.

Authentication is done via middleware for Csharp and PHP which is similar in JS like in Next using next-auth npm.

Livewire is one PHP library which boasts about being better than its react counter part showcasing similar if not better results acheived in an easier way.

VSCode is a popular editor wo work on any of these programming languagesas of this writing.