Vous êtes sur la page 1sur 9

Python As First Programming Language

Haisum Bhatti Syed Abid Hasan


Computer Science SZABIST-Karachi

Abstract - This paper evaluates feasibility of using


Python, instead of C or Java, as first programming language. Language features in perspective of learnability are compared of languages to find out whether Python is a good alternate to traditional first programming languages

and the prior assumptions in context of the topic to the research title. Section II starts with the literature review conducted in order to get the basics of the topic in addition to developing better understanding in order to come up with a conclusive paper. This section also provides details regarding the research methodology and the tools of the data collection in order to make this research authentic reliable. In last, Section III deals with the primary hypothesis of the research while comparing python with traditional language on the bases of some common attributes and variables for programming languages. This section is followed up by the conclusion of the paper and acknowledgements.

I.

Introduction

C was made by Brian W. Kernighan and Dennis M. Ritchie in 1970s [1]. Since then computers have evolved much. We have much capable hardware and computers are used to perform many tasks ranging from complex scientific calculations to online shopping and gaming. C was primarily designed to address issue of instructing machine to perform tasks by writing program in easy human readable format [2]. C did and still does a good job when it comes to low level hardware control and performance critical applications [3]. C++ was an extension of C with object oriented touch made by Bjarne Stroustrup in 1970s [4]. C++ was followed another popular language Java by James Gosling in 1990 [5]. These all languages are at least 20 years old today. Furthermore all have few design constraints which make it difficult for beginner to grasp fundamental programming concepts [6]. Due to syntax full of curly brackets, semi-colons and parenthesis developer focuses more on syntax following rather than building logic. Furthermore developing games and web applications in C or Java is either obsolete or it is much difficult for a beginner [7]. To overcome this issue we recommend Python as replacement for C and Java as first programming language. With simple syntax, strong object oriented design and plenty of libraries Python is a good potential language to start with. In this research paper we discuss feasibility of Python as first programming language to learn. This paper first starts with Section I discussing the problems in this context along with the purpose of study. This sections describes, in detail, what is our motive behind the research in addition to elaborating the problems. Later, Section I, also tends to highlight the significance of study while discussing the delimitation

II.

Purpose of Study

This study tries to find an alternate to first programming languages taught to students when beginning their studies in Computer Science. A normal trend observed is that students tend to run away from programming after finding it difficult to grasp programming concepts. In this paper we study causes of lesser interest in programming by students and try to overcome this problem by introducing possibly more start-up friendly language Python.

III.

Context of the study

Study focuses on students starting their CS. For this purpose several students in CS 1 are questioned and trained in both Python and C/Java to find out which language is easier to learn. This study will help making better CS course outlines for beginners to start with programming. Currently only a few quality programmers are graduating each year than market requirement. A good programing foundation will lead to interest in programming and more and better developers.

IV.
i.

Hypothesis

Main Problem

C and Java are difficult to teach and need to be replaced with some other easy to learn language such as Python.

Our contribution in this paper is to provide an analysis of feasibility of Python language as start-up language. Python has significant advantages as compared to traditional start-up languages. Python has more readable syntax with indenting defining blocks of code. Indentation makes it similar to pseudo code. High level functional programming makes it easier to manipulate data structures such as Strings, Lists, and Dictionaries etc. Has rich modules and capability to use libraries written in other languages. Can be used for game programming, web development and GUI based applications with smaller learning curve than traditional languages.

Java relies on Swings and AWT toolkit for GUI based applications. Python supplies plenty of libraries for GUI development which are easier to start with, than Win32API and MFC.

Syntax
C based languages have syntax which is defined by semicolons, curly braces and parenthesis. Missing any of these elements causes program to halt and debugging a pain. Python syntax forces to use indents making code more readable and easier to debug.

V.

Significance Of The Study

ii.

Sub-problems Lack of student interests in traditional languages


Students beginning with programming are supposed to learn to build logic using programming languages. However in traditional languages they also have to focus upon syntax learning and handling complex data types such as strings and arrays which makes it difficult for them to grasp fundamental programming concepts and makes them loose interest.

Our study can be used to determine better CS outlines for beginners and develop interest of more students toward programming by replacing traditional languages with more friendly programming languages in terms of learning curve. Main objective off this study can be stated as: making programming easier to learn and more interesting for beginners.

VI.

Delimitations of the study

Support for web development


Though C and Java can be used to program for web using CGI and JSPs respectively, but using these technologies is too advanced as far as novice developers are concerned. With Python it is far easier to start with web development.

Delimitation of our study is that resources we have defined are almost all secondary research. Due to time constraint and work load of other subjects we are going through the semester we cannot conduct a primary research.

VII.

Assumptions

Following are the assumptions we have made about this study:


Programmers are novice and have never studied any programming language prior to CS 1. Language aimed to be taught first is general purpose programming language rather than one focused on domain specific programming.

Outdated or difficult to learn graphics libraries


Libraries offered in C, C++ and Java are either outdated or are far from easy if they are comprehensive. Python on other hand offers its own libraries and capability to use current C++ and Java libraries.

Hard to use GUI toolkits such as GTK+ and MFC classes.


GUI programming using C++ requires MFCs and C requires us to use Win32 API.

VIII.
i.

Literature Review

Introduction

fundamental programming concepts and makes them loose interest.

This section contains literature review of main areas that we discuss in this paper. Each sup problem and relevant resources are discussed.

Support

for

web

development

ii.

Python as a primary language instead of C/C++ or Java

Teaching C and Java as primary languages have been a trend for past decade. However we in this research try to find better and modern alternate to this trend. We suggest Python as a suitable language to start learning for beginner. To study feasibility of Python we quantify our study in terms of these major constraints. Programming language usability constraint: This constraint analyses how easy and readable language is. Lines of code constraint: This defines lines of code required to perform a programming task in particular language. Ease of data structures, game programming and web development features constraints: This constraint compares limitations of traditional startup languages to Python for availability of features.

Though C and Java can be used to program for web using CGI and JSPs respectively, but using these technologies is too advanced as far as novice developers are concerned. With Python it is far easier to start with web development.

Outdated or difficult to learn graphics libraries


Libraries offered in C, C++ and Java are either outdated or are far from easy if they are comprehensive. Python on other hand offers its own libraries and capability to use current C++ and Java libraries.

Hard to use GUI toolkits such as GTK+ and MFC classes


GUI programming using C++ requires MFCs and C requires us to use Win32 API. Java relies on Swings and AWT toolkit for GUI based applications. Python supplies plenty of libraries for GUI development which are easier to start with, than Win32API and MFC.

We identify four main sets of variables which have to be determined in the course of determining feasibility of Python as first language. Background of student Practical exposure of all language features Availability of knowledgeable teacher and teaching material

Syntax
C based languages have syntax which is defined by semicolons, curly braces and parenthesis. Missing any of these elements causes program to halt and debugging a pain. Python syntax forces to use indents making code more readable and easier to debug.

The problem of our study can thus be stated as: Determine what are issues due to which students tend to show lesser interest in programming subjects, and suggest better language to be taught as start up as alternate to Java and C?

IX.
i.

Research Methodology

Research methodology / paradigm

iii.

Problems In Traditional Languages Lack of student interests in traditional languages


Students beginning with programming are supposed to learn to build logic using programming languages. However in traditional languages they also have to focus upon syntax learning and handling complex data types such as strings and arrays which makes it difficult for them to grasp

Our research is based on qualitative analysis of data hence it uses empiricism research methodology. During research we follow certain steps such as making hypothesis, defining problems, collecting data, analyzing that data to determine feasibility of solution and to conclude research with final statement.

ii. Research Design The method of research we adopt in this paper is defined below:
Read different papers from renowned journals for analysis of current problems. Determine problems that are relevant to our main problems statement. Define sub-problems and literature review. Find out solutions Conclude research by summarizing findings.

subjects we are going through the semester we cannot conduct a primary research. X. Related Work

i.

Learnability a. Early Education

iii. The Research Instrument The actual instruments which we use in this research are: Interviews Interviews of students involved in studying CS 1. Articles and Publications Several research papers and publications are referred throughout study. Internet Mainly used for searching related research material. iv. Procedure for data collection Through interviews we will determine difficulties faced by students in learning to program. Further we will also find out what new programmers prefer and find interesting to learn. Articles will let us know what issues do students and teachers from other parts of world have in learning to begin programming and solutions proposed by them. If further detailed information is needed we refer to internet for blogs, articles and wikis. v. Data analysis and interpretation All data acquired by us in interviews or by reading articles and papers is analyzed all and a conclusive argument is driven from data interpreted. vi. Limitations of the study Limitation of our study is that resources we have defined are almost all secondary research. Due to time constraint and work load of other

Teaching programming has its complications in early education. On the other hand if students start to learn programming in earlier stages as its easier for them to grasp concepts, otherwise it becomes tougher to get hold of multiple concepts at once. Students usually expect a program to be written in a certain programming language which runs exactly the same way in any computer system while also being easy to understand by each and every person reading it, in the very same way. [1]

b. Initial Concepts
Initially students should not worry for other top level concepts such as classes and functions etc rather they should focus on fundamental concepts of language such as variables, constants, arrays. Even the course have been referred and developed by Fotis Georgatos, in his master thesis, which concentrates on the Imperative programming paradigm, its major ideas are the priorities to be instructed in the class. [2] The most emphasized concepts of the course include, the three major programming constructs; Sequence: a set of commands that are executed successively Iteration: a definition for repeating a command or a block of commands Conditional: a "branching" command, that modifies the flow of a program Other major concepts that are discussed are data structures, as is the case in imperative languages; Variables Constants Arrays [2]

c. Teachers
Teachers should be familiar with language that they intend to teach. As a teacher, one should select a

language that is compatible with the theoretical content of the course and attracts the minimum of errors. The syntactical and semantical aspects of a language are the greatest contributor in the amount and nature of bugs that are generated when programming. Novices are particularly vulnerable in such design influences. The errors which rise while programming in a certain happen to usually help the majority rather than just one or two students. This greatly affects the course schedule, because the same error has to be corrected for many students, even explaining it as formalism takes a lot of time. [2]

A great deal for evolutionary programming is typeless languages which facilitate prototyping by documenting only the basic idea of the program, and not what its internals should work like. Even teaching a typeless language to pupils is simpler since there is no need to explain what are the types of the language rather just need to get them familiarized with the constructs. This eases the teachers overhead by skipping the typing mechanism of languages which is not an easy topic to explain, since even students get frustrated until they thoroughly understand the internals of the typical mechanisms. [2]

b. Easiness in Learning
Language should not be dry for students learning and it should be easy to learn and understand. The languages that are easy to learn do not obstruct the problem solving process and can express the main ideas clearly and in a few symbols. [2]

d. Interactivity
Language should have interactive learning environment. Environment for such interaction include IDEs and Pythons IDLE shell. A conceptually simple notational machine Some processes of this machine should be visible to the user The system should be interactive The teaching materials employed should be harmonious with the particular implementation of language, e.g. they should use the same terms; The commentary should be at the appropriate level of detail for the task given to novices, and for their conceptual grasp, e.g. error messages [2]

c. Orthogonality
If all the language components are mutually independent and that there exist only a single way of expressing any then, this notion is termed as Orthogonality. Although, by using systematic rules, arbitrary restrictions can be over ridden and the combination of basic facilities may result in arbitrary complexity. Orthogonality is directly related to simplicity. If a language uses too many keywords (=commands) then it depicts poor orthogonality. [2] d. Subset Organization This criterion refers to the ability for incremental learning of the language. This is the concept that is not necessary to understand or refer to the total design of the language, when only a subset of it is needed to solve a particular problem. A language, which is good in this, for example, would allow you to easily calculate a mathematical expression, without requiring knowing everything about declarations, initializations, objects, libraries, etc. [2] e.

e. Implementation In Education
Language should have been previously adopted to institutions in world and positive results shall have been obtained. Fortunately python has been implemented at many places and positive results have been received. For example, Radenski in the academic year 2004/05 at Chapman University has implemented a "Python First, Java Second" CS1/CS2 course sequence [4]

ii.

Easiness a. Dynamic Typing

Simplicity

By having an option as not to declare types for variables provides ease to novice learners and eliminates an obscure concept of type declaration.

Development of Python programs, as compared to other high level languages, is far quicker. Similarly, Python programs tend to be 3-5 times short in terms of lines of code, as compared to JAVA or 5-10 time

in case of C++, due to the simplicity and elegancy of the code. Obfuscated code writing is almost impossible in Python. Indentation and outline-style indicates a proper block structure. Consistent calling structure for functions and modules makes the syntax clean and simpler. [3]

together with the interpreter from a unique place, its Internet site. Because of the languages development model that anyone can contribute and enhance its development, this will probably remain the same in the future, too. At http://www.python.org/doc/ these documents and their explanations may be found: Macintosh Library Modules Tutorial Extending and Embedding (tutorial for C/C++ programmers) Library Reference Documenting Python Global Module Index Language Reference[2]

iii.

Practical Approach

a. General Purpose Language


General Purpose Language means in terminology that a language is designed with no particular application in mind. It can equally be used to define an algorithm for doing a calculation, solving complex mathematical problems, calculating bank interests or controlling a factory process. [2]

d. Speed
Byte-compilation as well as interpretational language characteristics of Python confers the advantages of speed and creates feasibility for the programmer. [3]

b. Practical
Language should be practical. That is it should have use in practical applications. Practical languages are the ones, which have an application domain that is not strongly bound to education and can be used with advantages in other scientific or engineering- fields as well, hopefully already applied in working and popular software [2]

e. Function Library
Modularity of Python incorporated as well-crafted and small components encourages formal and informal code libraries since this approach is very easy to design and use. [3]

f. c. Generality
The encouragement to use combination of a few primitive ideas in order to allow all concepts to be the depicted should be the part of the language. Like the ability to denote both procedure and functions by use of a single command is a good example of generality. Its advantages ranges from technical ones, while building the language, to very important while using it or instructing it while providing ease to the person who tries to think in this language. [2]

Support Community

All around the world there are thousands of programmers contributing to the development of Python. The motivation comes from being paid to develop applications on Python, although they are not being paid to develop Python. Implementation and development by programmers using real world settings ensures the robustness, security, relativity, efficiency, portability, and scalability while adhering to the real world needs even answering the future needs. [3]

iv.

Help & Support

v.

Language Design a. Programming Paradigms

a. Security
Programs that violate the definition of the language should not be allowed to be able to escape detection without explicit user-friendly notification. [2] Multiple paradigms are used today in programming languages. Some of the common programming paradigms include; A program which is an ordered execution of commands (statements) is termed as Imperative.

b. Documentation
Python does not suffer from the problem of multiple dialects and its documentation is coming

Object-oriented approach is where a program is a world of objects that communicate to each other. A paradigm where a program is a set of functions is termed as Functional; it is a very postulate model. Logical is where a program is a set of logical declarations.

after this command variable a will always have the value 10. [2]

b. Readability
According to Hoare, the readability of programs is immensely important than their write-ability. The simple argument is, that programs are written for and read by people, hence programming languages should encourage clarity. The intention of the designers should be to express solution structure visibly to express the intended. [2]

Even the primary programming languages like C, C++ and Java have different paradigms. Here C implements imperative, C++ implements hybrid of imperative and object oriented and Java implements purely object oriented. While Python supports all programming paradigms including functional, object oriented and imperative. [2] Other styles must also be taken into account, in order to take the importance of multiple paradigms psychology beyond the procedural aspect of programming. [2] Computer Languages generally dont depict similar characteristics, nor are they emphasizing by their design in similar topics. Such characteristics can be; Imperative paradigm (FORTRAN, COBOL) Structured PASCAL, C) programming (ALGOL,

vi.

Market Adaptation a. Industrial Adaptation

Languages are adopted either because of educational purposes or due to their popularity in industry. Python is easy to learn and also adopted in industry, hence it enjoys both characteristics. Googles AppEngine and implicit inclusion of Python in MACOSX are concrete example of such adoption. Even students wish to learn a language that can guarantee them a prosper future and a well to do job therefore the mastery of some specic language lack and its better to get the mastery of programming concepts utilized by those languages and tools. [1]

Educational orientation (BASIC, LOGO, ABC) Object orientated paradigm (C++, Java, Smalltalk) Scripting & prototyping (Perl, Tcl, Rexx) Functional paradigm Scheme) [2] (Haskell, LISP,

b. Portability
Availability of Python on a wide range of hardware and software platforms includes Intel, Sun, IBM, Macintosh OS variants, Microsoft Windows variants and all Unices, as well as less well-known platforms, including PDAs and set-top boxes is a well of proof of the portability of the language. Integration of Python with other languages like C, C++, or Java, in addition to embedment of it in programs written in these languages clearly shows the portable nature of Pyhton. In addition to all this, Python even plays well with diverse programming standards. Pythons many high quality extensions are available supporting almost all Internet standards, form CORBA to SOAP and COM, in addition to XML, XML-RPC and so on. [3]

a. Errors
Debugging should be easier in any language to help developer. This can be achieved by making errors, and their associated messages, descriptive enough to exactly get hold of the problem. A similar case with the previous example is the most typical single error of novices in C: if (a=0) {a=10}; This statement will always be executed; because it is actually an assignment and not a comparison, and

c. Maintainability
Simplicity of the Python adds to its programs easy maintainability since clean syntax in addition to

helping other developers to understand and change programs, allows the original developers to remember what they did. This cuts down maintenance costs for Python programs. [3]

Each group was given the two hour of training with respect to the language they were assigned. Once provided with the basic knowledge, each group was given an assignment in order to test their skills in a particular language, in addition to the filling up of post experiment questionnaire. Questionnaire governed the questions regarding the problems and variables identified initially in the paper and intended to support the hypothesis of the research. The results of experiment were remarkable and astonishing. The primary question asked to both of the groups was whether or not they would like to go ahead in learning programming, and as to a surprise, the group that was assigned C was a bit reluctant to answer it however the group that was assigned Python did a remarkable job and were eager and keen to get more knowledge of it. The basic reason why the other (Pyhton) group was interested was that they found it interesting and the results were achieved then and there unlike the other language group. The experiment supported most of the points which were raised in this paper and concluded it pretty well, in addition to providing the authentic and reliable data.

d. Versatility
The versatility of Python evident from the fact that it can be used in simplest scripting applications, in addition to the development of complex websites, and can be incorporated in building complex distributed applications. [3]

e. Cost
Being FOSS software, Python also depicts the three features including; the free usage, since no license purchase is required, esurience that no vendor restrictions are imposed on the free development of software applications in addition to esurience of elimination of any enterprise dependency and creating a free software market. [3]. XI.

Our Contribution

To analyze Pythons feasibility as first programming language, we conducted a research in which we selected a sample of 10 students who didnt know programming language earlier. We selected students from different departments of SZABIST coming from different backgrounds and have no or very little knowledge of programming. The students were asked to fill in a questionnaire prior to the conduction experiment and which focused in getting the idea that how much they know about programming, specifically primary programming languages. The students were first given the basic knowledge of programming and some generic concepts so as to make sure that all of them are at the same pace before the conduction of experiment. Once after introduced with basics and introduction, students were divided into two groups of five members each and were given the tuition for one of the primary programming language, i.e. C, and Python itself. One group was introduced to C while the other group learned Python.

XII.

Future Work

First of all, other than the future industrial trends, we would like to conduct a similar but high end experiment with the programming literate sample of students in order to come up with their views regarding the hypothesis of the paper which will act as a foundation stone in proving hypothesis and replacing the primary learning language. Considering the strength of python itself, its future seems bright. Comparability with Lisp, in addition to the ease of use and accessibility of a simple language it has a promising future. Having a solid foundation with extensive and mature libraries, it is applicable in all kind of projects and applications ranging from simple software to mobile phone apps and adding to IT Support and Bio-Informatics. Looking at the recent trend of web, the dynamic web will be the talk of the town, and having a dynamic architecture and

support of Python, it is a best fit for the future web development and in many cases its better than its competitors. Dynamic and. Even in the conditions where it is required to compete with the giants like Microsoft's, Python stil has been able to make its space in the industry and the affects are far and long. Companies like Google are opening the doors to a dynamic information ecosystem, thus involving python. The extensive use of Python is being observed in the Universities which is a proof for its better and promising future. However, the corporate acceptance that Java or dot-Net enjoy is in comparable with Python, which does not have it. There are a great amount of activity that is going on in the Universities, and the Open Source side of IT, which wont be going away anytime soon.

Science, Saint Louis University, St. Louis, Missouri, Thesis 2007.

Acknowledgement
This paper acknowledges authors of all articles, papers and online resources referred to. Specially Estevez Leonardo, Jianfeng Re, Nasser Kehtarnavaz , Mohammad Rahman, Dzmitry Tsishkou and Liming Chen for their useful papers. Further paper also acknowledges Mr. Asim Riaz for his generous guidance on paper writing.

Bibliography
[1] Jorma Sajaniemi And Chenglie Hu, "Teaching Programming: Going Beyond Objects First," Computer Science, University Of Joensuu, Joensuu, Finland, 2006. [2] Fotis Georgatos, "How Applicable Is Python As First Computer Language For Teaching Programming In A Pre-University Educational Environment, From A Teachers Point Of View?," Faculty Of Science, Amstel Institute, Amsterdam, Masters Thesis 2002. [3] John Alexander Miller, "Promoting Computer Literacy Through Programming Python," The University Of Michigan, Michigan, Dissertation 2004. [4] Atanas Radenski, ""Python First": A Lab-Based Digital Introduction To Computer Science," Dept. Of Computer Science, Chapman University, Orange, Ca, Usa, Dissertation 2007. [5] Michael H. Goldwasser & David Letscher, "Teaching An Object-Oriented Cs1 With Python," Dept. Mathematics And Computer

Vous aimerez peut-être aussi