You are on page 1of 8

International Conference on Contemporary Issues in IT in OIC Member Countries

U: A Computer Programming Language in Urdu


A.U.Khan, Kashif Ayyub and Hafiz Farooq Khan
Department of Computer Science, COMSATS Institute of Information Technology, Wah., Pakistan.
email: auk@cuonline.net.pk

Abstract
This paper presents the design and implementation issues of a computer programming language U,
having the Urdu-like dialect in contrast to English-like dialect used by mostly available computer
programming languages. An account of basic data types supported by U like (integer),
(real/float) and (char) is presented. Arithmetic, relational, logical and bit-wise operators of U
are presented and there functionality is described. Selection statements of U and and
iterative statements such as and are described. The grammar of U language
and details of the built-in library functions provided by U is also presented.

Keywords: Urdu, Urdu Computing, Urdu programming, Computer Programming

1. INTRODUCTION
It is the age of Information Technology and the benefits from the Information Technology
(IT) revolution cannot be reaped unless masses use it, which is not possible unless computing is
possible in a language that is understood by the masses[4]. Major spoken languages of Pakistan are:
Punjabi, Sariaki, Sindhi, Pashto, Urdu, Balochi, Hindko and Brahui. Of these, only Urdu, Sindhi, and
Pashto have a standardized alphabet and for rest of the languages, there are a few written works
available. However, the alphabets of Pashto, Urdu and Sindhi, the three major languages of the
Pakistan, are fully represented in Unicode [3].
According to the Article 251(1) of the constitution: “The National Language of Pakistan is
Urdu and arrangements shall be made for its being used as official and other purposes within fifteen
years from the commencing day”. For the purpose the National Language Authority (NLA) was
constituted, which has proposed the standards for Urdu letters, Urdu Code Page and Urdu
Keyboards[7].
Most of the work under the umbrella of Urdu computing addresses the problems like
standardization and development of coding in Urdu [6][7], desktop publishing, Text-to-Speech
Systems, English-to-Urdu Translation Systems, etc. but no conceivable work can be found to
develop programming tools for Urdu which can be used to create other applications[3].
The U programming language has been developed to provide a programming tool in Urdu,
keeping in mind that Urdu is the National Language of the Pakistan and the most of the population
can read and write in Urdu and that the Nations like Japan, China, Turkey, etc. are providing the
education in their native languages.

2. THE U PROGRAMMING LANGUAGE


Like other computer programming languages, U provides all those facilities which are
mandatory to develop useful programs. For the purpose, the syntax of U has been designed as close
as possible to the C programming language. However, certain complications arise when writing
programs in U due to its right-to-left scripting nature. For example, expressions in U are to be
written and evaluated from right-to-left so, the expression has the meaning that is
subtracted from whereas in case of left-to-right scripting languages like English, it is interpreted
as is subtracted from . Similarly, the prefix in Urdu is English postfix and postfix is to be
treated as prefix. The design of U is alike the design of C programming language and its grammar is

July 26 – 27, Islamabad, Pakistan 1


International Conference on Contemporary Issues in IT in OIC Member Countries
very much similar to C grammar and is attached as annex-I . The table 1 shows the reserved
keywords of U and there C equivalent:
Table 1: Reserved Words of U and there C Equivalent
(union) (if) (asm) (for)
(struct) (case) (extern) (goto)
(continue) !" (static) (while) #" $ (sizeof)
% &' (break) ( ) (char) *+ ,) (float) - (auto)
.$ (register) (double) (do) (volatile)
/ 0 1 (enum) 20 3 (long) 4 (void) " 4 (signed)
" 4 5 (unsigned) 6$+ (typedef) 7" (short) 2 8" (int)
2, $" (const) 97 " (switch) :; (return) < (else)
< (default)

2.1 Data types


U is a typed language and facilitates to declare 2 8" (integer), *+ ,) and (float/real),
and ( )(character) data types. Table-2 shows the U’s declarators and data types that can be
defined through them.
Table 2 : Table Showing U’s Data Type Declarators
Declarator Data type Meanings
2 8" integer Declares an integer
7" or 2 8" 7" 16-bit integer Declares a short integer
20 3 or 2 8" 20 3 32-bit integer Declares a long integer
*+ ,) 32-bit float Declares a float
or *+ ,) 64-bit float Declares a double
( ) unicode character Declares a character

In order to incorporate the user defined data types, the keyword has been provided.
For example, the following program fragment declares a structure and depicts its usage:
>=! -
A @=! - 2 ?"
A C0 - BA= 7 / , ,)
D
A FG E @=! - C0 -
A: H = 7 / C0 - E = 7 / C0 -
D
2.2 Assignment and Arithmetic Operators
The U supports various types of arithmetic, and assignment operators which are shown in the
table-3.
Table 3: Table Showing Various Operators Supported By U
Op. Example Meanings
+ Adds and
- Subtracts from
* Multiplies I and
/ Divides by
- Negates
% ! Gives the remainder when ! is divided by
= " Assigns value of to
" #" Add 2 to
=- " Subtracts from
" #" Multiply by 2
" " Divides by i.e is equivalent to "
"J "J Calculates I J K and stores back result in K
++ Increment by 1 and use it
Use old value of and then increment it by 1
Decrement by 1 and use it
-- Use old value of and then decrement it by 1

July 26 – 27, Islamabad, Pakistan 2


International Conference on Contemporary Issues in IT in OIC Member Countries
2.3 Logical and Relational Operators
The language also provides logical operators like or && for “and”, L or |$ for “or”
and M & and ! for “not”. Similarly, the U also provides relational operators which are shown in the
Table-4 along with their meanings.
Table 4: Table Showing The Relational Operators
Op meanings examples
> Less than % , is less than
< greater than & , is greater than
=> Less than or equal to "% , is less or equal to
=< greater than or equal to ! "& , is greater or equal to !
== equal to "" , is equal to
<> not equal to &% , is not equal to

2.4 Arrays
U also supports arrays and the following program fragment declares a one dimensional array
of integers and initializes its elements to 0:
D
APFGO NI 2 ?"
D
SIHHAFGRIAGEIQ
AGEPIO

Similarly, the following program fragment declares three matrices , and and then
calculates the product of matrices and and stores the resultant product into matrix :
A NPTOPTOINPTOPTOKNPTOPTO , ,)
AUNVNW 2 ?"
D
D
>SWHHATRWAGEWQ
AG E
SVHH ATRVAGEVQ
SUHH AT RUAGEUQ
APVOPUOKXPUOPWO EH
BA E PVOPWOI
D
2.5 Control Statements
U provides control statements like to complement C’s “if”, < @ in contrast to “if -
else” statement and < @ < @ in place of “if-else if- else” statement. The syntax of
various forms of is listed as under:
SYZ 1Q SYZ 1Q SYZ 1Q
U [ -[ U [ -[ U [ -[
< SYZ 1Q <
U [ -[< U [ -[ [<

SYZ 1Q <
U [ -[ [<
<
U [ -[<
for the C’s equivalent of “for” statement, and having the syntax:
S< A YZ 1 A< Q
U [ -[
for the pre-condition “while” loop having the syntax of the form:
SYZ 1Q
U [ -[
The statement @ is the post-condition loop that tests the condition at the end of the body
of the loop and having the syntax:

U [ -[
SYZ 1Q

July 26 – 27, Islamabad, Pakistan 3


International Conference on Contemporary Issues in IT in OIC Member Countries
The 97 " is the equivalent of C’s switch statement and its syntax is :
S6+ Q 97 "
>
F[U D F[6+ [2, $"
\[U D \[6+ [2, $"

U[U D U[6+ [2, $"


U [ -[< D<
B

2.6 Bit wise Logical Operators


U also provides bit-wise logical operators which are listed in table 5:
Table 5: Table Showing Bit-Wise Operators Of U
Op. Meanings Example
& bit wise AND I' "
| bit wise OR $ "
~ bit wise NOT ("

2.7 Functions
Like other programming languages, U also provides built-in mathematical functions and also
allows programmers to define, their own functions. Table VI shows some of the built in functions
and the following program fragment declares two functions, one returning an integer value and the
other returning no value and there usage in a the program:
SV 2 ?"Q] " 2 ?"
>
AVXV :;
B
S 4QV ^ ; 4
>
AS`Ub a5 -V ;`Q&?_
B
SQV ;
>
AFG E K 2 ?"
ASKQ] " E I
D
ASQV ^ ;
D
Table 6: Some Mathematical Functions of U
(sin) (cos) c (tan) c SdefQ + SghdQ + SdeghdQ
i (asin) i (acos) ci (atan) ci SdefQ +i SghdQ +i SdeghdQ
i (sinh) i (cosh) i c (tanh) i c SdefQ i + SghdQ i + SdeghdQ
j (sqrt) _ (log) &+ (exp) k a" (abs)

2.7 I/O Functions


Simple I/O functions l8 for output and lm; for input have also been provided and the
development of rest of the I/O functions is underway.
3. IMPLEMENTATION
Most of the Operating Systems now a days support Unicode [2]. However, implementation
for the plain old DOS is also possible through the UNS (Urdu National Support) [1]. For the
realization of U, we have used the MS Windows XP which supports the Unicode. In order to test the
idea, a prototype U parser and a U to C translator have been developed i.e. the U code is translated to
C and then is compiled through a designated C compiler that supports unicode. In future, we are
planning the U to also support the computer programming in Pashto and Sindhi.

To provide the editing facilities in Urdu, an editor namely UrduPad has also been developed.
An integrated environment for U is also under development. Further, the U has been designed in

July 26 – 27, Islamabad, Pakistan 4


International Conference on Contemporary Issues in IT in OIC Member Countries
such a way that a person who has learnt U programming language can easily switch to the C
programming language with a very little effort The following is a sample program written in U.
SQ V ;
>
v @ sl lm; u 1 *q t 7 / o qVq V q Vi " l !r sq s lm; !r/ *q p "i " V ; oL nb
bn sl _ 8 t 7 / 2q *q w "i "

As. & Vi " !r/[*q[w "i " 2 ?"


At 7 / u 1 *, ,)
APFGOV ( )

AS` x !r/ *q p "i "`Q l?_


AS !r/ @*q @w "i "Q lm;

AG E t 7 /

SHHVi " A !r/ [*q [w "i " R Vi " AFEVi "Q


>
AS` x V q Vi "`Q l?_
ASV Q lm;

AS` x u 1 s. & `Q l?_


ASu 1 s. & Q lm;

ASu 1 n s. & Q E
A Ht 7/Et 7/
ASu 1 n s. & Q EH t 7 / sl ? &?_ & s$0 ; 3 W " Xb
bX
B
ASt 7 / ` E t 7 / 2q *q w "i " v `Q l?_
B
4. CONCLUSION
Like other programming languages, U can be used as a Urdu programming tool to develop
applications, an instructional tool to teach the concepts of computer programming to the masses who
do not know English but have the knowledge of Urdu reading and writing, and to the students of
lower classes where the medium of instruction is Urdu.

5. REFERENCES

[1] UNS Code Page for DOS


[2] Unicode Consortium website at http://unicode.org
[3] Abdul-Majid Bhurgri, “Enabling Pakistani Languages Through Unicode”, Microsoft
Corporation white paper at http://download.microsoft.com/download/1/4/2/142aef9f-1a74-
4a24-b1f4-782d48d41a6d/PakLang.pdf
[4] M. Afzal and S. Hussain, ”Urdu Computing Standards: Development of Urdu Zabta Takhti
(UZT) 1.01”, Proceeding of INMIC2001, organized by IEEE and LUMS, Lahore, December
28-30, 2001, pp:216-222.
[5] M. Afzal and S. Hussain, ”Urdu Computing Standards: Urdu Zabta Takhti (UZT) 1.01”,
Proceedings of INMIC2001, organized by IEEE and LUMS, Lahore, December 28-30, 2001,
pp:223-228.
[6] K. Zia, “Standard Code Table for Urdu”, http://www.cicc.or.jp/english/hyoujyunka/mlit4/7-
10Pakistan/Pakistan1.html
[7] National Language Authority web site: http://www.nla.gov.pk

July 26 – 27, Islamabad, Pakistan 5


International Conference on Contemporary Issues in IT in OIC Member Countries
The Grammar of U Annex-I
o @]•
(union) (if) (asm) o @ 0Xo @ •
(for) (struct) (case) o @ 0bo @ •
(extern) y (goto) (continue) o @ 0Jo @ •
!" (static) (while) #" $ (sizeof)
% &' (break) ( ) (char) *+ ,) (float) ( # @?+
- (auto) .$ (register) (double) o @ 0
(do) (volatile) / 0 1 (enum) o @]• S 6$+@ " Q
20 3 (long) 4 (void) " 4 (signed)
" 4 5 (unsigned) 6$+ (typedef) 7" (short) 3 A.
2 8" (int) 2, $" (const) 97 " (switch) o @‰! r
:; (return) < (else) < (default) o @ 0HH
o @ 0 @@
o @]• #" 4@ƒL
o @]• #" $
Do S 6$+@ " Q #" $
Szgg{|}~h}f@h•€•hgg{e}Q o @2, "
Sh•€•hgg{e}Q o 3 # D BC
Szgg{|}~h}f@h•€•hgg{e}Q o @2, " n † H Ž •
! " # $%&' #> 5EF;9
o @ ‚" o @‰
o @2, " 2" 4@2, " o @ƒL Po Oo @‰! r
S # •‘@o Qo @‰! r
! " # # $ $%&' S # •‘@o Q V @6$+@t
E„„ ERR E… E† E‡ Eb En E@ EH E V ’o @‰! r
HHo @‰! r
( # ) *+,- @@o @‰! r
o @ ,a "@ 0
o @ ‚" D o xo @ ,a "@ 0 " 5G F'9
, $"
) !( ) /%0' .
V
o @ ,a "@
o @ ,a "@ ˆˆ o @ ,a "@ 0 " HI
t! q@# 1
) !( ) /%0' 1+2
o @‰ Š" ) # DL,JK
o @‰ Š" †† o @ ,a "@ o @2, "
N # •‘@o
()3 4 5 &6 o @2, "
o @‹Œ
o @‹Œ ˆ o @‰ Š" M ) &8N
o
()3 4 789
o @ ( # # %&O
o @ …o @‹Œ 2, $"@* Œ)
2, $"@2 8"
1+2 2, $"@( )
o @‰ 2, $"@*, ,)
o @‰ †o @ 2, $"@t ,‘
:3 ) # 5,92,9 M ) )# ) $%&O &8N
o @*, r/ Y 5 ˆ “ Š”
o @*, r/ EE o @‰
o @*, r/ „R o @‰ # ! ( # # $%&O $ P
! r @2 8" 2, $"@p
) # ) % ;< ! r @2 8" 2, $"@•l
o @* , " ! r @2 8" 2, $"@•1
o @* , " R o @*, r/ –9 / /@*q@( )—
o @* , " „ o @*, r/
o @* , " ER o @*, r/ (" ) ( # # $%&O Q2 LG
o @* , " E„ o @*, r/ !4 @t 4@sq@ ˜”
2, $"@p
= ># %&'
!4
o @ r
o @ r RR o @ , " R ! # G2E 2 V+ TU ,S
o @ r „„ o @ , " F \ T ž • œ › š ™
#4 /; ! # G2E 2
o @ • G F \ T ž • œ › š ™
o @ •Ho @ r (# ) ( # # $%&O WX
o @ •@o @ r G
2, $"@•l
"3)# ) ( # 4 /9,? !4 @•l

July 26 – 27, Islamabad, Pakistan 6


International Conference on Contemporary Issues in IT in OIC Member Countries
(= (# \+,N V,%K
(# ) ! # G2E 2 WX @wZ¯@® ^ `- Q ( ) *Z q s M " ( )@‰
G F \ T ž • œ › S( )
( )@*”
= (" ) ( # # $%&O WY
G• !4 @•1 # # "
# _ F9
GŸ !4 @•1 DU
2, $"@•1 S«z h«h¡@gfzfh~h}fQ U @ •1
!4 @•1 Sh•€•hgg{e}@gfzfh~h}fQ U @o
Sde~€e©}¡@gfzfh~h}fQ U @9q "
= ( " ) ! # G2E 2 WY Sgh«hdf{e}@gfzfh~h}fQ U @* 7
G F \ T ž • œ › š ™ S{fh•zf{e}@gfzfh~h}fQ U @ ?/
z d ¡ h ¢ S¶©~€@gfzfh~h}fQ U @· &'
£ ¤ ¥ ¦ § ¨ S¡hd«z•zf{e}@gfzfh~h}fQ U @*/ 4

# ! 3>> EF;9 $ P ) ` ) # # " # _ F9 51 a&Y2


! r @2L 3 ! r @* " 4 5 U D t! q@# 1
! r @* " 4 5 ! r @2L 3 U D o @2, $" ”
U D o
3 ! 3>> EF;9 & ,FZ
© ª # # " # _ F9
Ao
3 ! 3>> EF;9 $C [
« ¬ ( " 3 # # " # _ F9 ]U,
B # •‘@*q@U >
(= (# ( # # $%&O \,N
–9 / /@*q@( )— # # " # ) # DL,JK U _ F9
U
(= (# :3 ( ]F<,< U \+,N # •‘@*q@U
( ) U
9 / /@*q@( )
( ) ) (# # # " # _ F9 9 b&I2
S{¢@gfzfh~h}fQ U @
(= (# \+,N Sg¸{fd¹@gfzfh~h}fQ U @97 "
@wZ¯@® ^ - Q ( ) *Z q s M " ( )@‰
S( ) > # # " # _ F9 ,c2
( )@*” U So Q
U o U So Q
( :3 ( \+,N
( )@t #(= # # " # _ F9 ]b&'
U So Q 97 "
" ) ( :3 ( \+,N VG L
x° ˆ ²° ˆ ° ˆ ±° ˆ U° ˆ W° ˆ V° ˆ ° ˆ °° ˆ `° ˆ –° # # # # " # _ F9 512,P<
U @ƒ
>) # ! ( # # $%&O %F%N U @y l
2, $"@‰ ‚4 o )@* " 4 ! r @*, ,) U @
9 / /@*q@ !4 o )@* " 4 ! r @*, ,)
=) # # " # _ F9 B&d
> (# ) ( # # $%&O 5,- U So Qƒ
9 / /@*q@ !4 ³ 9 / /@*q@ !4
9 / /@*q@ !4 ³ # # " # _ F9 e2,XG
ASo Q ƒ U y l
# # N &
h #" 4 9 / /@*q@ !4 > # # " # _ F9 f2,9
§ #" 4 9 / /@*q@ !4 U So Ao A o Z! @ Q

! D > # )R Fg2E&92 f2,9


H @ U @o
U @* 4
!# :3 ( ]F<,< U G2E 2
!4 h3" # # " # _ F9 iI aj
9 / /@*q@ !4 U @% &'
!4 U @‰
U @:;
>) # ! 3>> EF;9 %F%N U @y
¢ « ¨ ¬
` # # " # _ F9 BC,9
# ! )# ) $%&O V,%K A % &'
´9 / /@*q@( )@t ,‘µ
( # 3 # # " # _ F9 51
# ! (= (# :3 ( ]F<,<U \+,N V,%K A‰
( )@t ,‘
9 / /@*q@( )@t ,‘ #3 # # " # _ F9 kl2+
( )@t ,‘ Ao :;

July 26 – 27, Islamabad, Pakistan 7


International Conference on Contemporary Issues in IT in OIC Member Countries
! # # # " # _ F9 e o @2, $" E t! q@# 1
A t! q@# 1 y
( # # $%&O
() # # # " # _ F9 <I 2 Sde}¡{f{e}z«@h•€•hgg{e}Q o @ ‚"
o 4
() rC, < % ;<
() # FI 2 B# •‘@o 4 > 2, $"@t ,‘ *
# •‘@o 4 V $+ @o 4 o 4 2, $"@t ,‘ *
ºL r/@*q@2 4
“L /@*, r/ () # ) # DL,JK FI 2
o 4
() (> H Om2 FI 2 o 4 # •‘@o 4
6$+@ " V $+ @o 4
() # ) # DL,JK <I 2
() (> nOm FI 2 o Z ! @*/ 4
“L /@¼ q@»L . o Z ! @*/ 4 N # •‘@*/ 4
6$+@ "
Sf½€h¡h¢Q 6$+ # () # Fg2E&92 <I 2
o Z! */ 4
# ! () (> rC, < q U pC1 oL
Sz©feQ q ()# <I 2
S•h|{gfh•Q .$ V @* 4
Sgfzf{dQ !" Po @2, $" O*/ 4
Sh•fh•}Q *
" HI I 2
# (> nOm G2 V
V @ "@t V @*/ L 1
“L /@¼ q
“L /@*/ L 1 >3 (# > # sC,;< U $
“L /@6$+@28‚" o )@* 4 t! q@# 1 V $+ @o 4
2, $"
* >3 (# ` o )@* 4
U @9q "
" ) # " H I G2 VG L
Sf½€h¡h¢@}z~hQ V @6$+ # )R Fg2E&92
Sd¹z•Q ( ) o E
Sg¹e•fQ 7" B# •‘@o Z ! >E
S{}fQ 2 8"
S«e}|Q 2L 3 # )R ) # DL,JK Fg2E&92
Sg{|}h¡Q * " 4 o
S©}g{|}h¡Q * " 4 5 o # •‘@o Z !
S¢«ezfQ *, ,) B # •‘@o Z ! >
S¡e© «hQ
S¤ee«hz}Q * Œ) # > " H I nOm
S¾e{¡Q ‰ 4 t! q@# 1

) ` # # (> rC, < nOm $P- #> VE''U D 'Y


t! q@# 1 ¼ q@‰! q Dt! q@# 1
V @*/ L 1 nS !4 ˆ ( )Q S@ ˆ ( )Q
s o #" 4@*”
() q U 5EF U D( )@‰
[ˆvˆ‰ˆÀˆ¿ˆKˆ
D !4
™ˆšˆÀˆ\ˆFˆG
3" (> rC, < < C1 Y
B# •‘@*/ L 1 > t! q@# 1 */ L 1 3 (#3 # t2, 2
PO SQ B> D E Á
3" ) # DL,JK < C1 Y
L 1 #
N# •‘@*/ L 1 H @ n b ‡ † ˆ … Ž •
L 1 E „ R  HH @@ †† ˆˆ „„ RR
EE „R E„ ER EH E@ En Eb E‡ E†
3" # C1 Y Eˆ E… E„„ ERR
t! q@# 1

July 26 – 27, Islamabad, Pakistan 8

You might also like