Scripts Technology

Introduction

A computer communicates only with ones and zeros, everything else is a misunderstanding. For a computer, man is abstract and a human, the computer abstract.

Programmers write instructions in text editorswill source. These source codes are translated using the compilerto machine(ones and zeros) so that they are comprehensible to a computer to a so-called. object file. To translate data languageC ++ requires a C ++ - compiler. To överätta data languagePHP needed a PHP compiler etc.

& nbsp; Results of a compilation is saved as a object file. Several object files could & quot; be joined by a linker to a software.

High- and low-level

Computer Languages ​​is & quot; close & quot; the computer's way of working is sometimes called low-leveland can look like this ...

fib:
mov edx, [esp+8]
cmp edx, 0
ja @f
mov eax, 0
ret

@@:
cmp edx, 2
ja @f
mov eax, 1
ret

@@:
push ebx
mov ebx, 1
mov ecx, 1

@@:
lea eax, [ebx+ecx]
cmp edx, 3
jbe @f
mov ebx, ecx
mov ecx, eax
dec edx
jmp @b

@@:
pop ebx
ret

We can, for example read MOVE, COMPARE, Jump if Above, Return, etc.. We feel greatly of abstraction but reasonably legible.

A slightly higher language needs a little more & quot; translation & quot; Before the CPU can work with it as ones and zeros. Here is an example ...

.model small
.stack 100h

.data msg db 'Hello world!$'

.code
start:
mov ah, 09h ; Display the message
  lea dx, msg
  int 21h
  mov ax, 4C00h ; Terminate the executable
  int 21h
end start

Here I want to make it clear beyond any square brackets, commas and semicolons that it is more a human, albeit English language.

levels of abstraction

Kompilatorers efficiency

Kompilera- high and low-level

There are two translation methods...

  • Compilerstranslate the entire source code into machine code - Provides faster exekusion - need to be compiled once
  • Interpretertranslate a line at a time to maskonkod & nbsp; - Provides slower exekusion - recompilation every time (almost)

With the interpreters can create programming that are generic (general) and allow the interpreters translate to the various CPU'erna which Intel is an ARM is another. A compiler can not translate to another CPU, but high-level language can be the same.

Different CPUs have different hardware to help, talking about different platforms. In this course the following platforms current ...

PHP vs ASP.NET

  • ASP.NET (Active Server Pages .NET) - Source code is translated into CIL ( Common Intermediate Language), or MSIL & nbsp; ( Microsoft Intermidiate Language) to further translated to machine in the other compiler JIT(Just In Time).
  • PHP (Personal Home Page) later (PHP: Hypertext Preprocessor) - an interpreter Prompt

These programming language interpreters handle logic that make up the web features you planned to use. Both actually have a fairly similar way of programming but results of interpretation gives birth to different underlying services.

Let's look at how these platforms look. We imagine an algorithm on Web page asks for a name and then greets us with it.

This is PHP

<html>
<head>
 <title>PHP</title>
</head>
<body>
 <?php
 if (isset($_GET['Button1']))
 {
 $myText = $_GET['TextBox1'];
 echo "Hej " .ucfirst($myText)."!";
 } else {
 echo "<form action='index.php' method='get'>";
 echo "<input Type='Text' name='TextBox1'> ";
 echo "<input Type='Submit' Name='Button1' Value='Send'>";
 echo"</form>";
  }
?>
</body>
</html>

This is ASP.NET

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="WebApplication1.index" %>
 
<!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 runat="server">
 <title>ASP.NET</title>
</head>
<body>
 <form id="form1" runat="server">
 <div>
   <asp:Label ID="Label1" runat="server" />
   <br />
   <asp:PlaceHolder ID="PlaceHolder1" runat="server">
     <asp:TextBox ID="TextBox1" runat="server" />
     <asp:Button ID="Button1" runat="server" Text="Send" OnClick="Button1_Click" />
   </asp:PlaceHolder>
 </div>
 </form>
</body>
</html>

 

ASP.NET - Code behind

using System;
 
namespace WebApplication1
{
 public partial class index : System.Web.UI.Page
  {
   protected void Button1_Click(object sender, EventArgs e)
   {
     Label1.Text = "Hej " + TextBox1.Text + "!";
     PlaceHolder1.Visible = false;
   }
 
   protected void Page_Load(object sender, EventArgs e)
   {
     PlaceHolder1.Visible = true;
   }
 }
}

More about PHP

More about ASP.NET