Web Development/Choosing the right programming language

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search
Section 5.3 — Back to Contents

Choosing the right programming language for server-side applications. (Choosing the right programming language for browser-site rollovers, animation, and validation -- CSS, JavaScript, Java, or Flash -- is discussed ... ...).

When it comes to the perfect programming language for the developent of your site, it is imperative that you understand that there is no perfect programming language. Once you understand this, it is simply a matter of choosing the language that best serves your needs. Before you decide on what language to use, you should consider the following

  • your server platform
  • the server software you run
  • your budget
  • previous experience in programming
  • the database you have chosen for your backend

The Operating system you are running on your system is your platform and your choice of OS may play a major part in the language you choose. Be aware that unforseen problems may push you to change platforms in the future, and that some language choices will make this very painful. Microsoft Windows and POSIX-compliant unix-like systems will most likely be your two main choices in technology.

Once you have chosen your OS, the next choice is your server software. On Windows systems, you have IIS which comes installed for free with windows. It has a long history of performance and security problems. Many of the web servers commonly used on POSIX-compliant unix-like systems are available for Windows too, including the very popular and well-respected Apache web server.

"POSIX-compliant unix-like systems" includes a plethora of available OSes including but not limited to Linux, Sun Solaris, BSD, and Mac OS X. Apache is by far the most common web server for these systems and for web serving in general.

While some of the available programming languages are free under the GNU Public License or other open-source licences, others are commercial products and carry a licensing fee. The commercial products do carry the advantage of commercial support and tighter integration with the companies' other products, so if you have a large amount of capital and want to get your site set up quickly with little configuration, then a commercial solution might be your better option. Some of us, however, cannot afford the high pricetag of the commercial solutions on the market and may elect to make use of the free yet still very powerful languages available. The tradeoff is the effort in properly configuring the environment which may or may not be worth the cost savings.

Contents

[edit] The More Popular Programming Languages

The following are a list of the more popular languages used in the industry today. This is by no means exhaustive or complete and it is up to you to personally research each option to choose the right language for you.

[edit] Perl

Type: Interpreted script language
website: perl.com
License: Open source [free]

insert content here

example code

#!/usr/bin/perl

print "Content-type: text/html\n\n";

print "<html><head>\n";
print "<title>Hello, world!</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
print "<h1>Hello, world!</h1>\n";
print "<a href=\"../perl/tutorial.html\"><b>Back</b></a> to the Tutorial\n";
print "</body></html>\n";

[edit] PHP

Type: Interpreted script language
website: php.net
License: Open source [free]

PHP is a recursive acronym for PHP Hypertext Processor. Unlike the other offerings listed, PHP is designed specifically for server-side programming, which means that its library is specialized for the tasks you'll be doing over and over again in the course of programming your website. PHP also has the advantage of being able to interweave code with HTML, thus allowing you to mix layout with programming. While this does simplify coding for small sites, it does carry the potential to be abused, resulting in difficult to manage or maintain code for larger projects. Proper use of a templating system such as smarty should do wonders towards preventing that. PHP is available for most operating systems including Unix and Windows and is an excellent server-side programming language for professional programming.

Example Code

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>php hello world</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php echo "hello world"; ?>
</body>
</html>

[edit] C

Type: Compiled
website:
License:

The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages. C is prized for its efficiency, and is the most popular programming language for writing system software, though it is also used for writing applications.
C is a useful language to learn since similar syntax is used by many modern languages such as Java, PHP, and JavaScript.

Example Code

#include <stdio.h>
int main() {
   printf("Content-Type: text/html\r\n\r\n");
   printf("<html> <head>\n");
   printf("<title>Hello, World!</title>\n");
   printf("</head>\n");
   printf("<body>\n");
   printf("<h1>Hello, World!</h1>\n");
   printf("</body> </html>\n");
}

More Example Code

#include<stdio.h>
main()
{   
  show();
}

int show()
{
  printf("hello");

}

[edit] C++

Type: Compiled
website: http://www.research.att.com/~bs/C++.html
License:

Originally released as "C with Classes" around 1982, C++ was designed by Bjarne Stroustrop to be a superset of C. With its compatibility with C, it became quite popular. In 1983 C with Classes was revised and renamed C++. It was summarized in the book, "The C++ Programming Language" by Stroustrop, Addison Wesley, 1985. The goal was to add programming language features that support data abstraction and object-oriented concepts to C. In 1990 the book entitled "The Annotated C++ Reference Manual," by Ellis and Stroustrop, Addison Wesley became the defining document.

Example Code

#include <iostream.h>
int main() {
   cout << "Content-Type: text/html\r\n\r\n";
   cout << "<html> <head>\n";
   cout << "<title>Hello, World!</title>\n";
   cout << "</head>\n";
   cout << "<body>\n";
   cout << "<h1>Hello, World!</h1>\n";
   cout << "</body> </html>\n";
   return 0;
}

[edit] Java/JSP

website: Sun Microsystems
License: ---------

insert content here

Example Code

class HelloTest {
  public static void main(String[] args) {
    System.out.println("Content-type: text/html\n");
    System.out.println("Hello World!"); //Display the string.   
  }
}

The Java Tutorial

JavaServer Pages (JSPs) are web pages with embedded Java code. The embedded Java code is executed on the server, then the page is returned to the browser for display.

Example Code

<html>
  <head>
    <title>A JSP Example</title>
  </head>
  <body>
    <% out.println("<p>Hello there!</p>"); %>
  </body>
</html>

details...

[edit] ColdFusion

website: Adobe
License: Multiple available [[1]]

Programming:ColdFusion

ColdFusion is a scripting language based on standard HTML that is used to write dynamic Web sites. It allows you create dynamic pages quickly and easily, including querying data from a database, use hundreds of built in tags and functions, or creating full scale object oriented enterprise level applications. ColdFusion pages can consist largely of standard HTML tags intermingled with ColdFusion Markup Language (CFML) tags, or can implement custom frameworks designed to assist the developer in separating presentation from business logic (e.g. with the MVC design pattern). ColdFusion was introduced by Allaire in 1996 and acquired by Macromedia in a merger in April 2001 and by Adobe in 2005. As an Adobe product, ColdFusion developers have the advantage of leveraging many existing Adobe technologies seamlessly. Examples of such integration can be seen in the dynamic generation of Adobe Acrobat .pdf documents, Adobe Flash forms and presentations, Adobe Flash remoting capabilities, as well as connection with Adobe Flex user interfaces.

Example Code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Cold Fusion example</title>
   </head>
<body>
 <cfoutput>
	<cfif Hour(Now())GT 18>
		Good Evening
	<cfelseif Hour(Now())GT 12>
	         Good Afternoon
	<cfelse>
        	Good Morning
        </cfif>
   #variables.FirstName#
 </cfoutput>
</body>
</html>


[edit] ASP

website: Microsoft
License: ---------

insert content here

Example Code

<html>
<body>

<%
dim name
name="Donald Duck"
response.write("My name is: " & name)
%>

</body>
</html>


[edit] C#

website: Microsoft
License: ---------

C# (pronounced "C Sharp") is a multi-paradigm programming language encompassing imperative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft within the .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming languages designed for the Common Language Infrastructure.

C# is intended to be a simple, modern, general-purpose, object-oriented programming language. Its development team is led by Anders Hejlsberg, the designer of Borland's Turbo Pascal. It has an object-oriented syntax based on C++. It was initially named Cool, which stood for "C-like Object Oriented Language".[2] However, in July 2000, when Microsoft made the project public, the name of the programming language was given as C#. The most recent version of the language is 3.0 which was released in conjunction with the .NET Framework 3.5 in 2007. The next proposed version, 4.0, is in development.

Example Code

class ExampleClass
{
    static void Main()
    {
        System.Console.WriteLine("Hello, world!");
    }
}