MouthShut.com Would Like to Send You Push Notifications. Notification may includes alerts, activities & updates.

OTP Verification

Enter 4-digit code
For Business
MouthShut Logo
32 Tips
×

Upload your product photo

Supported file formats : jpg, png, and jpeg

Address



Contact Number

Cancel

I feel this review is:

Fake
Genuine

To justify genuineness of your review kindly attach purchase proof
No File Selected

A metropolitan city India (NRI)
What will you get when you do X^=Y^=X^=Y?
Jun 09, 2003 05:27 AM 3995 Views
(Updated Jun 19, 2004 08:40 AM)


  • Note:- This is mainly meant  for non-techies who want to learn the same. Techies please excuse the content as it may be a little too fundamental for you. I am planning to write some technical reviews as time permits




Tips on programming languages  



Computer Programming is an exact science, in that all the properties of a program and all the consequences of executing it can, in principle, be found out from the text of the program itself by means of purely deductive reasoning.


-C.A.R.Hoare



If you can't write it down in English, you can't code it. -Peter Halpern


INTRODUCTION


Let me have a confession first. Though I have been in this industry for quite long and have an engineering degree in CS, it is very difficult to write on this topic to meet the needs of all person alike. I shall try to be as general as possible to be fair to all. Programming as you all know is an art. Not everyone can program. To program, you need to have a strong background in logic and to certain extent in a lot of disciplines(I meant that!) such as mathematics, accounting, business acumen, construction etc. I can go on generalizing.  I shall disaggregate various types of programming and will concentrate on general tips later on.


QUICK HISTORY OF PROGRAMMING


For the benefit of those who don’t know a thing, here it goes. After the invention of the electronic computers in the mid-1940s and the need for data processing increased, initially the programming was done in 1’s and 0’s. John Von Neumann was the first to implement certain techniques such as “Shared Program technique” and “Conditional control transfer” which let hardware to be independent and not hard-wired. As the need for these 1 & 0 based coding increased, the complexity, errors and malfunctioning also increased. This led to research in development of computer programming languages that would absolve you from the machine level abstraction. Finally this led to the first generation of programming languages(Short code and all) and the first assembler compiler A-0 was written in 1951.


Later on, the first of the well-known language FORTRAN(Formula Translation)


was written(Incidentally this is the first one I learned too!) by IBM Engineers for scientific computing. COBOL was developed for Business purposes. There were quite a few that became popular after that such as C, C+, Visual Basic, Java amongst some 150 odd popular programming languages


There are many types of programming languages such as


->Low-level programming language such as Assembly language. This is more closer to the type of the processor and is a little too tedious to implement(Oh! How I used to love those Assembly lab programs to implement traffic controllers and elevator simulations!)


->High-Level programming languages those are more English like with a generic construct and structure. You got to follow certain constructs and principles to generate those. Not all programs you write can be yielding the results you anticipate but will be running if you follow these rules(These semantics and lexical analysis are taken care of by the compiler, linker et al(based on the type of language used)


======>Procedural programming – COBOL, FORTRAN, Pascal, C etc.


======>Object oriented programming(Programming in objects, evolved from Simula/Smalltalk and used widely in c+, Java & C#)


======>Declarative programming – Includes Logic programming such as Prolog and Functional Programming such as scheme and all.


Anyways, there are many ways you can write code and the most widely used languages for development these days are Java, C+, C, C#. The focus will be mainly on these


TIPS ON PROGRAMMING


Like I said, programming is like an art. When you start drawing, most of the time you have the picture of the end product in your mind. You know what are the inputs and the outputs for the end product. The program, which you may consider as an engine, gets some input and gives you an output. What you construct decides the fate of the input and gives a result based on its execution. Well, was I generic enough till now?


How do we go about doing the same?


=>We need to make sure we understand the requirements of the problem.


=>Like the quote mentioned above, if you cannot write down in English, you cannot code it.


=>Once you have done that, you will know what you are supposed to be doing.


=>Once you know the requirements, you can start constructing the types and structure of the data you are to be using.


=>Upon the completion of the same, you need to have an algorithm for solving the problem.


=>Implement the solution.


===>Test it. If there are errors, debug them and correct them


While the same simple rules can be applied for simpler problems, you can develop most of the skills you need to develop the knowledge.


Some of the steps can be out-dated in an OOP environment where you need to have the use-cases, object models, interaction/sequence/collaboration diagrams to understand the communication between programs(a.k.a Objects). Many times you have tools that can do the majority of the work for you, thus enhancing the productivity at the cost of your own effectiveness to write error-free programs.


Let us take an example: Say, how will you interchange two integers say A and B?(I got this question in a CDOT interview, which I breezed through. I am disclosing the solution I gave)


You need to give inputs say Input_A Input_B. The result should be A=Input_B and B=Input_A.


This can be done in many ways. You need to know the types of the data being passed. Then you can write a simpler or complex algorithm to implement the same.


Here you can write a program in C+ or C such as


int A, B;


A^=B^=A^=B;


Well, this would do the trick. How? If you know the Binary logic and the language constructs. How a compiler parses the code. I shall leave it at that.


You can do in a much simpler way, like


A=A+B;


B=A-B;


A=A-B;


Or use a temporary variable to swap the same(used by almost 99.99% of the programmers).




  • While there are many ways for a simple problem, the effectiveness of a program and the effectiveness of you as a programmer increases as you use some advanced features and skills you learn while developing your initial programs.




  • Also, whenever you choose a language as your choice, become well versed with its syntax and semantics. This is due to the fact that the compiler may use a certain type of grammar and lexical analyzer to compile your programs(Terms such as LR, LALR lex and yacc ring a bell?)




  • Once you develop the acumen, you can explore and do trial and error to learn the programs.




  • It is also wiser to learn and practice Data Structures and Algorithms. Though I may sound nepotistic towards this subject, it is very important to follow some of the basic concepts available to you.






Continued in Comments Section


Upload Photo

Upload Photos


Upload photo files with .jpg, .png and .gif extensions. Image size per photo cannot exceed 10 MB


Comment on this review

Read All Reviews

X