April 20, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

C# and PHP programming languages

Author : DAOUDI Samir | Context : MSc Software Engineering – Computer Structure

C#, the latest programming language developed in 2000 by a Microsoft team led by Andres Hejlsberg and Scott Wiltamuth in 2000. This programming language was designed specifically for the .Net platform and was the successor of C, C++ and Java; it took the best features of each and adds new features [1].

I developed Windows based applications with C# since the first IDE (Integrated Development Environment) proposed by Microsoft : Visual Studio 2003 with .Net 2.0.
The environment was really interesting with all the integrated features. The basics of programming were integrated with the environment. The compilation process, debugging and correcting the code was made easier thanks to the IDE.

The latest version of the IDE is Visual Studio 2010 with .Net 4.0 framework. The framework provided the necessary libraries and the predefined classes that provide an out of box methods and classes that makes things easier for developers.

During the development of software, I had not to care about how the machine executes the high-level functions or how the code I written was translated to machine language. The beauty of the high-level languages is that it allows developers focus only on software needs and thinking about the appropriate methods and classes to use.

Combining all these classes and different units in one program that solves the problems and produce a solution for the needs of application.
The integration of the syntax, semantic analysis in the IDE made things easier for me, I had not to compile, check errors, return back to code and correct them. In fact the IDE highlight the grammatical and logical (semantic) error at the same time of coding. Another interesting feature I really appreciate about it is the fact that variables were strongly typed. I had to choose the appropriate data type for my variables and the IDE indicates (and suggest) me the appropriate operations and manipulations of these variables.

C# allows also the type casting that allows coders to change data variables, for example if we need to merge a string variable with a float number we can use:
Float x= 2.34;
String S=”The value of X is:”;

S = S + x.ToString() ;

As the variable X (of type float) is considered as an object, an attached function to this object which is ToString() allows to convert x to a string. If I did not add the ToString() method, I get the last instruction highlighted with error saying that it was impossible to perform such instruction (+) between string and float.

And I think this is all the beauty of C# and the integrated development environment Visual Studio 2010.

PHP : for Personal Home Page ‘Is a server-side programming language, PHP is far and away the most popular programming language for use on web servers.’ [2]

I used PHP for dynamic web sites I developed in the past, and at that time I was also developing with C# and I noticed some differences between those programming languages that can be summarized as:
– Variables are not strongly typed, we can define a variable without specifying its type (A definition of a variable x can be $x=0 😉 here the variable contains an integer value without defining its type[3].

– If we want to use the same variable for another data type, we can simply assign it another value
($x= “Welcome” 😉 No casting needed to change the variable type.
– PHP is a scripting language that can be integrated to a web page and is executed at the server-side.
– The client use a browser to access the PHP pages that are executed by a server (Apache) and rendered to HTML content.

– I used an editor (Macromedia Dreamweaver) which made things easier, BUT I was obliged to save pages, view the pages in the browser, return back to the editor and then correct the errors.

I consider both C# and PHP good programming languages, each is better for specific situations but the compilation and execution are different. Also another important point is that PHP is open source and C# a licensed programming language.
Finally, I prefer C# not specifically for its syntax or compiler but in majority for the fantastic IDE that makes things easier for the developers.

References:

[1] Harvey M.Deitel, Paul J.Deitel, ‘C# for programmers, 2nd edition’, 2006. ISBN: 0-13-134591-5.
[2] Steven Holzner ‘PHP : The complete reference.’, 2007. ISBN : 978-0-07-150854-5.
[3] L.Atkinson, Z.Suraski ‘Core PHP programming 3rd edition’, 357 . ISBN : 0-13-046346-9

1