Friday, May 28, 2010

Python and C++ Integration Tutorial

Today I am going to write for the wonderful Python community out there, beauty of open-source is the huge community and help that they provide to each other through blogs, forums, mailing lists etc. So after my struggle with Python and C++ few days ago I planned to write this post to help those who may be struggling with a similar problem.

Although Python is such a great programming language in which you can do almost anything as I mentioned in my previous post but when it comes to performance and efficiency C/C++ has no competitor. So there are times especially for large-scale systems where performance cannot be sacrificed and you have to resort to C/C++ but oh no!!! Most of your source code is already in Python.........so what now?? Well not to worry. Another great thing about Python is the concept of extending it using C/C++ and that's exactly what I did. But it's easier said than done.

Calling C from Python is relatively easy but calling C++ is the real headache so I am sharing how to do it for any programmer that needs it, I had a tough time due to lack of proper tutorials on the subject and this also motivated me to write one :)

The sample class that we use here is Employee and we will use its data members and methods in Python. You can download the complete code here.

In the Employee.cpp file there is a piece of code that does the actual work, Python can call C functions with Python C API and hence its necessary to provide C extensions by keyword extern, here is the code that does it:

extern "C" {
Employee* Employee_new(){ return new Employee(); }
void Employee_promote(Employee* emp){ emp->promote(); }
void Employee_demote(Employee* emp){ emp->demote(); }
void Employee_hire(Employee* emp){ emp->hire(); }
void Employee_fire(Employee* emp){ emp->fire(); }
void Employee_display(Employee* emp){ emp->display(); }
void Employee_setFirstName(Employee* emp,char* inFirstName){ emp->setFirstName(inFirstName); }
void Employee_setLastName(Employee* emp,char* inLastName){ emp->setLastName(inLastName); }
void Employee_setEmployeeNumber(Employee* emp,int inEmployeeNumber){ emp->setEmployeeNumber(inEmployeeNumber); }
void Employee_setSalary(Employee* emp,int inNewSalary){ emp->setSalary(inNewSalary); }
}


In the code the return type of all methods is void, the constructor must have the form ClassName*...........the tough part is when you have methods that take arguments and I had quite a tough time figuring that out due to lack of tutorials on the subject. The way to do it is like this, within the extern block write the method signature as before but after the object you should have the parameter types in the signature as shown here: void Employee_setFirstName(Employee* emp,char* inFirstName){ emp->setFirstName(inFirstName); }

Now the library generation part, here's how to do it in g++

g++ -c -fPIC Employee.cpp -o Employee.o
g++ -shared -Wl,-soname,libEmployee.so -o libEmployee.so Employee.o

This will generate the dll libEmployee.so (you can give it any name of your choice) and then it can be easily called in Python. Here is an example of Python code calling a C++ class, marvelous:

from ctypes import cdll
lib = cdll.LoadLibrary('./libEmployee.so')

class Employee(object):
def __init__(self):
self.obj = lib.Employee_new()

def EmployeeTest(self):
lib.Employee_setFirstName(self.obj,"Marni")
lib.Employee_setLastName(self.obj,"Kleper")
lib.Employee_setEmployeeNumber(self.obj,71)
lib.Employee_setSalary(self.obj,50000)
lib.Employee_promote(self.obj)
lib.Employee_promote(self.obj)
lib.Employee_hire(self.obj)
lib.Employee_display(self.obj)

emp=Employee()
emp.EmployeeTest()


So ctypes does the trick and makes it quite simple........there are also other alternatives such as Boost and Swig which I have not yet explored but will do in near future as I have to work with Python and C++ for my research work for MS thesis. So stay tuned for more.

Friday, May 14, 2010

The Python Experience

Today I will write an introductory post on Python, few days back a student said to me, "Python must be hard" and she is the main reason why I came up with this post.

In one phrase I would say that Python is the best of both worlds because it is capable of delivering the power of traditional compiled languages like C, C++ and the ease of use and simplicity of scripting, interpreted languages like Perl, Tcl. In the world of Python imagination literally becomes the limit for the programmer.

Few people know that Python is used for major tasks by companies like Google, Yahoo!, NASA, Red Hat, Pixar, Disney and Dreamworks. In fact today what we see as Yahoo! mail was the Rocketmail Web-based email service and it was designed in Python. Today many universities are planning to use Python to teach introduction to programming so that students can focus on problem-solving skills instead of being bogged down by the difficulty of the language and some including MIT have even started to do so.

So here goes for the students back in Pakistan the basic features of Python which make it so appealing and powerful:

  • Of course it is a high-level language, its beauty lies in its higher-level data structures that reduce the development time marginally.
  • Python has support for object-oriented programming, in fact it is an object-oriented language all the way down to its core.
  • With python the code is compact and that's also the beauty of it. Python is often compared to batch or Unix shell scripting languages. But with them there is little code-reusability and you are confined to small projects with shell scripts. In fact, even small projects may lead to large and unwieldy scripts. Not so with Python, where you can grow your code from project to project, add other new or existing Python elements, and reuse code at your whim.
  • Python's portability is also what makes it the most widely used programming language today, it can be found on a variety of systems. Python is written in C and due to C's portability Python is available on practically every platform that has an ANSI C compiler.
  • Python is extremely easy to learn and students can grasp it very quickly so I would certainly recommend to many students reading this post and if you need any sort of help feel free to contact me.
  • Python's code is very easy to read so much so that even a reader who has not ever seen a single line of Python will begin to understand and read the code instantaneously.
  • Python code is extremely easy to maintain and if you review a piece of code you wrote some months back you will be able to grasp it in no time.
  • Python is robust to errors. Python provides "safe and sane" exits on errors and when your Python crashes due to errors, the interpreter dumps out a "stack trace" full of useful information such as why your program crashed and where in the code (file name, line number, function call, etc.) the error took place. These errors are known as exceptions. Python even gives you the ability to monitor for errors and take an evasive course of action if such an error does occur during runtime. These exception handlers can take steps such as defusing the problem, redirecting program flow, perform cleanup or maintenance measures, shutting down the application gracefully, or just ignoring it. In any case, the debugging part of the development cycle is reduced considerably.
  • Now comes the one great thing I simply love about Python: numerous external libraries have already been developed for Python, so whatever your application is, someone may have traveled down that road before. All you need to do is "plug-and-play". There are Python modules and packages that can do practically anything from natural language processing in NLTK to scientific computing and everything you can imagine. In Python if you cannot find what you need chances are high that there is a third-party module or package that can do the job.
  • Python has its own memory manager, the thing that makes C and C++ extremely burdensome is that memory management is the responsibility of developer: the programmer has to take care of dirty tasks of memory management no matter what but with Python this headache is gone.
  • Python is classified as an interpreted language. However traditionally purely interpreted languages are almost always slower than compiled languages because execution does not take place in a system's native binary language. But like Java in reality Python is byte-compiled i.e. results in an intermediate form closer to machine language. This improves Python's performance while allowing it to retain the advantages of interpreted languages.
So dear students I would certainly recommend all of you to do give it a go at Python as in the long run it will really benefit you.

Tuesday, May 11, 2010

Is Search Really Dead??

Gone are the days when I had to go through newspaper sites or search engines to find out the result of a late night match that I could not watch the previous night.........today all I do is just login to my Facebook account and there it is it: the latest news right before me. So where are we heading towards?

This post is a little glimpse into the future of information retrieval: yes today I have decided to throw some light on my research area but not from too much of a technical standpoint but from an interesting standpoint which opens a whole new area of research. The area and concept is becoming so important that a special panel was devoted to this discussion in this year's WWW 2010 conference at Raleigh, USA. WWW Conference is the world's most renowned platform for WWW researchers and the theme was "Search is dead." The panel comprised of the following people:

Andrei Broder – Fellow and VP, Search & Computational Advertising, Yahoo! Research.

Marti Hearst – Professor, School of Information, University of California-Berkeley.

Barney Pell – Partner, Search Strategist for Bing, Microsoft.

Andrew Tomkins – Director of Engineering at Google Research.

Prabhakar Raghavan – (Co-organizer and Moderator) Head, Yahoo! Labs .

Elizabeth Churchill – (Co-organizer) Principal Research Scientist, Yahoo! Research.

If I have to sum up the discussion in one line it is "Search as we traditionally know it is already dead!!!!"

Already user expectations from search engines are changing, the traditional task of typing in a query and being offered 10 blue links in response now amounts to a failure.Completeness is the key here: users want search engines to incorporate all the incredible level of richness that is available these days as today there is much more diverse data sources and presentations than links to web pages. So with the user needs getting "weird" and the search business competition getting "fierce" we are at the doorstep of yet another information retrieval (IR) revolution after PageRank.

Well it boils down to an important question: who is a key player in all this??? Any guesses??? Yes social networks like Twitter, Facebook, MySpace and Orkut. Mark Zuckenberg's statement at Facebook's F8 Conference, "We are building a Web where the default is social" throws a lot of light into this entire phenomenon and in particular the new Facebook Platform, crucial parts of which are the Open Graph and Social Plugin. Already as statistics say Facebook has surpassed Google in Internet traffic and this may be the beginning of the new revolution.

So what's your say on it? Is the search really dead?? I will reserve my own thoughts on this for sometime :) and would love to hear from my readers.

In the end a short video to throw some more light into this social media revolution:




Saturday, April 10, 2010

Is blogging really something to brag about?

Today I was shocked at reading a debate on Facebook on whether the HP products are good or not. One argument really threw me in shock and then when I came out of that shock I landed into a worry. To some the comment may not come as a worry but if you look at it from an analytical viewpoint then it surely is a time of emergency for Computer Science in Pakistan, the comment was "I am a blogger and I write about HP!!!" Seemingly it is harmless but the authority with which it was said left me astonished.

My astonishment comes from the level of significance these bloggers are claiming for themselves, fine you blog about stuff and you do have a voice in the news arena and your blog activities may be shaping minds of some people but does that mean that every word you write is credible and warrants acceptance. Your profession is what makes you credible, if you think that just blog posts are what matter then there would not have been any such thing as research value through publications and citations.

It really bothers me to see the state of Computer Science in Pakistan and what's more disappointing is the attitude of the people in the field. They do not even realize where their ignorant and arrogant attitude is going to take the country and on being corrected they strike back with more arrogance and ignorance.

I am afraid that if this trend is carried on it will lead us to a mere consumer society which we already are, here I have my Professors working on mining and analyzing the blogosphere; and back there we just have people content in writing blogs so we are just the data for researches of the future.

Things really have to change and they have to change fast!!!

Friday, February 19, 2010

Writing a Research Paper: Important for Those Thinking about FYP

I have been approached by many students specially in their final year of BS Computer Science for some tips and basic guidelines on writing research papers. So today I decide to blog about it based on what I have gathered from my experience. These techniques are based solely on my experience and anyone having additional suggestions is welcome to contribute.

Writing a paper is not a complex task at all: the most important thing in my opinion is o love what you're doing and be really excited about it. In the words of Meeyoung Cha:

"If you fancy a career as a researcher, you'll spend tens of thousands of hours on work over the next 10 years. The only way you're ever gonna spend 10,000 hours on research is only when you truly deeply love it. If something really engages you and makes you happy, then you will put in the kind of energy and time necessary to become an expert at it." - Click for Source

So find a research topic that really fascinates you and makes you want to invest your hours and hours into it without any regrets.

Divide your activity into phases:
1) Literature Survey
2) Design Phase
3) Implementation Phase
4) Experimental and Analysis Phase
5) Writing the Paper

Literature Survey
After the initial finding of identifying your area comes the real task: narrow down the specific domain from the area in which you want to work i.e. find a problem and conduct a literature survey i.e. see what approaches the research community has proposed to deal with that particular problem for example say there's a problem coming from the web crawling domain. Search for the best conferences in that domain like SIGIR, WWW, CIKM, ICDE etc and browse through the conference proceedings and read the famous papers relevant to your problem. To further explain I take another example from the domain of Computer Networks, suppose you want to take up a problem on Network Virtualization, then go through the famous conferences NSDI, SIGCOMM, SIGMETRICS, OSDI, SOSP etc. and read papers of some of the renowned researchers of the field.
This phase is the most important and crucial for here is from where you can extract all innovation and ideas and it serves as a prelude to the next phase of design.

Design Phase
This phase is the core of your research project/work, from the literature survey that you conducted in the last phase you must have come up with some potential shortcomings of each previously proposed solution. Now is the time to gather all what you gathered and design your own effective solution to deal with the problem at hand. During this phase I would personally advise to take suggestions from researchers working in those domains, the research community works in a collaborative environment and many would love to listen to your approach of handling the problem at hand. You can even write to authors of papers you read during the literature survey phase and they might write back to you with some further suggestions.

Implementation Phase
As obvious from the name in this phase you do the programming part, you can choose any platform suited to your research needs. Best thing about the sciences is that there is no limitation on development platform but try to choose a platform that has a large support from the worldwide community of scientists and engineers so that if you get stuck somewhere finding help is easy and if you choose a platform that lacks such support then bravo, chances are you might end up being one of the pioneer researcher for implementing your idea in that platform.

Experimental and Analysis Phase
Make no mistake about it, this phase is also very crucial and is what adds the real value to your work. It is what distinguishes it from the rest of the works in the field and highlights your research contribution. In this phase you must compare your approach with existing approaches and there must be some important comparison metrics for example bandwidth, throughput, jitter etc. in case of some computer networking research. This phase also serves as a valuable part of your research paper so don't overlook its significance and concentrate your efforts on it with due care.

Writing the Paper
1- Save all related data in one folder including results, pictures or any related text of literature survey, previous reports you have written for the project (if any) etc.
2- Download the specific format of conference/journal from their website. It will be easier for u to directly write as per that format, rather than first writing in a blank word file and then struggling/fighting with word.
3- Write abstract at the end of paper, rather than in the start.
4- The easiset way is first just write all first level heading e.g. (JUST AN EXAMPLE) Introduction, System overview, Algorithm Design, Results, Conclusion, References etc etc . The next step is to write second level headings (where-ever applicable).
5- Then make tables, flow-charts, figures and paste HIGH resolution images in corresponding headindgs.
6- Now your paper needs text stuff. If you are going to copy/paste text from self written reports, do not forget to keep continiuty in your script. Because something might be clear to you (as you have worked on this research/project) whereas for others there might be some "hidden details".)
7- After you finish your paper, write short summary in the form of abstract and assign proper keywords to your paper. The abstract should be such concise that the relavant reader is forced to read your paper!
8- Read your papers yourself a number of times and then ask some of your friend (with good English grammar) to go through it for correction of a/the/an etc.
9- Remember a very important norm, you should inform and give a copy of your paper to all those Professors/Persons whose names you have mentioned in your paper. One should NOT submit any paper in any conference without notice of co-supervisor and Professor.
10- Try to submitt paper some hours (at least) before the deadline time. Because mostly just before the deadline hour, a lot of people upload and thus system/server gets jammed. If however this is the case with you, just send the organizers by email (mentioning problem and time of submission).
There are a lot of related other things which one learns from his own personal experience. Remember as I mentioned no work is worthless !! You just have to present them in a proper and systematic way and find a conference which matches the technical depth of paper. Most of conferences in Pakistan provide a good nursery to write/present your work. So do not under-estimate your work. If anyone has any query, please feel free to ask me on my personal address (arjumand_younus@yahoo.com) or I would recommend to discuss on the group:


Lastly a very important announcement from my side for the final year students, I have many research ideas and am looking for some students for research collaborations, if anyone wants to pick up any idea for his/her Final Year Project then feel free to contact me again on the email address given above or the Yahoo group.

All the very best in this venture of final year project!!!

Tuesday, February 16, 2010

Avatar Review: A Movie Relevant to Today's World

Avatar is the new talk of the town these days with most of the people highly impressed by its high-quality graphics and awesome visuals but in my opinion there's more to it than just that. I am quite disappointed by the review I got from people of it being somewhat predictable and storyline being ordinary.

On the contrary I found Avatar highly relevant to today's world: a world of war and destruction caused by the greeds of capitalist US.

Avatar depicts US as the "sky people" who portray the peaceful Navis as a threat to their security and these "sky people" claim to fight terror with terror: a propaganda well-known in the real-world too where the US portrays and propagates Muslims as following an evil ideology aiming to annihilate the world with terror. The same bundle of lies is used against the Navis that the US has been using against the Muslims: in reality they wanted something else, a precious stone found in the forest where the Navis lived peacefully. They lied, distorted facts, showed the Navis as dangerous people simply to further their evil designs: a strategy they used in Iraq, Palestine, Afghanistan. The movie takes us to how they manipulate and use lies for their benefits and do not stop from destroying peace of the world simply for their materialistic pursuits.

Jake Sully - the main character in the movie who is an ex-Marine is used by the "sky people" as an impostor to penetrate into the Navis, pretend to be one of them, get access to their secret world and then either make them negotiate on evacuating their forest or helping the "sky people" in destroying the innocent Navis. In return Jake would get back his legs, but in the course of pretending he realizes the evil designs and the truth, purity and integrity within him stops him from being a part of this evil plot. He decides to help the Navis for they were innocent and harmless unlike what was being spread by the "sky people", they had a world of their own: a beautiful world. This is what is happening today: the evil, capitalist US in pursuit of oil ran over the Muslims and is bent upon destroying them basing its war on a bundle of lies.

Below is an interpretation of Jake Sully's words in our real-world of today:

"The Sky People (US) have sent us a message(occupation). That they can take whatever(oil) they want, and no one can stop them. Well, we will send them a message(by reviving Caliphate). We ride out as fast as a wind can carry(to call people to Haq). You tell the other clans(people,influentials) to come, we will show the Sky People. That they CANNOT take whatever they want. And this..THIS IS OUR LAND!"

The movie concludes with a message, an important message to the US and its allies and to those who believe that US is invincible and Islam's return as a system is a mere dream: I say to those watch Avatar (a movie from an Canadian director himself) and get that message loud and clear!!!!

THE MESSAGE:
Wars cannot be won through technological advancements and numbers, wars can only be won through the power of truth, power of honesty, power of purity and above all power of unity!!!

Saturday, January 16, 2010

The Quranic Style and Narrative

As I said in my last post I will be describing briefly about my role in brother Khalil's conversion to Islam so here goes.

It all begin with a heated debate on the profile of my school mate Shamikh Ahmed and I was debating against a US citizen Faizan Rizvi who also happened to be my class fellow back in school but in the other section so I didn't recall about him immediately. Later on brother Faizan by the grace of Allah realized he was wrong and then began this wonderful mission of ours: the writing of articles for brother Khalil.

Brother Khalil formerly brother Michael has a Ph.D. in English Literature and he wanted to know somethings about Quran's literary style, brother Faizan knew him and wanted my help in this task. This is the paper I wrote which played a large role in his conversion Alhamdullilah:

The Quranic Style and Narrative

The article touches upon the Quran’s style of narration and its supreme literary style. No doubt Quran is a miracle given to the Prophet Muhammad (SAW) by Allah (McAuliffe). In the opening part it talks about the structure and history of preservation of the Quran. Later the article focuses on the narrations in the Quran: the unique style of conveying the Message to Mankind through stories repeating the same story and continuing it in several different Surahs, something known in literary terms as cross-referencing. This is a unique literary style found in only the Quran but it serves important purposes as mentioned in the article itself: “1) to sustain interest in the story, 2) to test the reader’s comprehension of its implications and 3) enforce the significance of the story within the text’s context.”
One example the writer has focused and picked is the story of creation which the Quran mentions in several places: Surah 41, Surah 79, Surah 15, Surah 2, Surah 7. The story is narrated in a way that leaves the reader captivated and makes him absorb the sublime message of truth. The creation of “Heavens” serves as a reminder to Mankind of the favors to those who will follow the path prescribed by Allah. Each time the reader reads the story of creation it leaves a different impact on his mind and heart, although the story is the same yet each time the underlying message is different with a unique touch. For example when talking about the unbelievers’ attitude in Surah 41 Allah admonishes them in strong words whereas in Surah 15 the style changes to a less stricter tone but Allah predicts what would unbelievers say even if they were to be taken to the Heavens.
Also the significance of the event of Satan not only stresses the importance but serves as reminder of the challenge he poses for Man, the Satan will continue to divert Man from the way of the Lord till the Judgement Day. The dialogue between the Lord and Satan is repeated many times in the Quran and each time it leaves a different impact on the reader’s mind.
This is enough evidence for a person to see that the Quran is definitely a literary masterpiece and is seen as such by both Muslims and non-Muslims. (Boullata 2000). The Qur'ān never tells a story for its own sake, but rather uses it to drive home the point it happens to be making in a sūrah or in a section of it. As a rule, considerations of the thematic unity determine which portion of a story will be narrated in which sūrah. In other words, the story told in a given sūrah is likely to be sūrah specific, the apparent disjointedness of the Qur'ān in this case concealing a carefully worked-out technique of storytelling.
The literary excellence of the Quran is unmatchable, As a gift from Allah to mankind, the Quran employs the most sublime literary art. The Qur'ān possesses a rich literary repertoire of its own. Besides making a masterful use of language on the level of words and phrases, it contains figures of speech, satire, and irony; employs a variety of narrative and dramatic techniques; and presents characters that is spite of the sparse personal detail provided about them, come across as vivid figures. This is evident from the second series of narrations touched upon in the article which constantly makes mention of the people of the Book and how they treated Moses and then Jesus. After the narrative part is the warning for their deeds and then it goes on to mention the reassurance for those who did not go astray. It so well-connected and appealing and the series of stories seem to follow a connected chain of events. At the same time within these narrations come time and again the legislative aspects of the Holy Book serving as a reminder that Quran’s actual purpose is not simple narration: its ultimate aim is to take Man out from the shackles of human slavery and give him as a sub-ordinate and slave of Allah, the Exalted and High. The challenge of Quran is to replace legislator of law by only Allah and He is the only Legislator alone and this is what is to be kept in mind. (Qutb)
The narrative aspect of Qur'an style remains one of the most creative and innovative of the Holy Book, one which has profoundly influenced and enriched the Arabic language. Whatever narrative style the language had in pre-Islamic times were relatively crude and primitive. Even though the narrative parts of the Qur'an were clearly put to the service of the main theme of the Book, i.e., religion, the narrative was so highly developed and integrated that it became a work of art in itself. The Qur'an is remarkably innovative with respect to its method of presentation, which involves four different techniques. One common technique is that if beginning a story with a short summery, followed by the details from beginning to end, as in sura 18 (al-Kahf). The second technique is that of beginning a story by presenting the conclusion first, then the lesson to be derived from it, and then the story from beginning to end, as in the story of Moses in sura 28 (al-Qasas). The third technique presents the story directly without introduction, as in that of Mary following the birth of Jesus in sura 19 (Maryam), and the story of King Solomon and the ants in sura 27 (al-Naml). The fourth, and perhaps most innovative, technique is that of presenting the story through dramatization. This technique gives only a brief introduction signalling the beginning of the scene, followed by a dramatization of the story with a dialogue among the various characters, as in the story of Abraham and Ismail in Surah 2.
The story of Joseph narrated towards the ending of the article is one of the most beautiful and touching stories found in the Quran. In fact rarely has It left an eye unwept and part of it can be attributed to the unique narrative style in which Joseph’s whole narrative is related. It has a unified plot, and that the plot is organized on (the analogy of the rhetorical device of 'involution and evolution': the first half of the story creates a series of tensions which are resolved in reverse order in the second half (Mir 1986)
One of the elements indispensable to dramatized narrative is change of scenery, which the Qur'an utilizes fully. In the story of Joseph in sura 12, the reader is presented with a succession of scenes, each of which leads to the next, picking up the main thread of the narrative. Joseph's story comprises some twenty-eight scenes, each of which leads to the next in a manner which maintains the organic unity of the entire narrative. All such scenes are presented through dialogues replete with details and ideas. The result of such a well-knit passage is that the reader finds himself drawn to the narrative, moving anxiously from one scene to another. This effect is achieved through a coherent series of events which sustain his curiosity and interest. In one scene, for example, we find one of Joseph's brothers entering the king's court in Egypt where Joseph is the keeper of the store-house. In this scene, Joseph stipulates to his brothers that they should bring their younger brother to the king's court in order to receive provisions. The next scene presents the brothers deliberating among themselves, which is followed by a scene in which they have returned to face their father, Jacob. The following scene takes the brothers back to Egypt to confront Joseph. The presentation of the narrative in dramatic form involving a succession of scenes brings home effortlessly the main theme and the lessons to be derived from the whole narrative. The use of dialogue makes the scenes more vivid and closer to life. This is an art in which the Qur'an excels, and an art in which it is remarkably innovative. It is clearly a form of literary composition which the Qur'an, the first book in Arabic, introduced to the language.
The very aspect of self-referencing in the Quran further stresses its unique literary style; the Quran was very well aware of its literary style. The Qur'ān claims to be inimitable and challenges its opponents to produce a work like it (e.g. 2:23; 11:13; 17:88; 52:33-34). The inimitability later came to be constructed essentially in literary terms, and the theologians made belief in the matchlessness of the Qur'ān part of a Muslim's faith. In its historical exposition, the doctrine of inimitability made the literary study of the Qur'ān a handmaiden to the theological aspect of the scripture. But the doctrine overlooks a crucial fact. The Qur'ānic challenge was addressed not to the believers but to the unbelievers, and was not simply denunciation of the unbelievers, but constituted an invitation to them to carefully examine the Qur'ān and see if it could have been, as they claimed it was, the product of the mind of a man possessed. Irrespective of what conclusion one reaches on the question of the Qur'ān's origins, one must agree that the underlying assumption of the challenge was that the merit and beauty of the Qur'ān could be appreciated even by those outside the fold of the faith. And if that is the case, then it would be possible to dissociate the literary study of the Qur'ān from the theological study of it.
The pagans of Mecca were bent upon proving Muhammad(SAW) as a liar. They were thirsty for his blood and who else could have wanted more to silence that man for the control of whom they were spending huge amounts of money and fought several battles. Had the Quran been the product of a human mind, they could have easily accepted the Quranic challenge to produce the likes of it but they knew in their hearts of hearts that it is a Divine scripture and the “Quran’s challenge” left them speechless. Last but not the least, one of the most fascinating aspects is the language of the Quran: You can never feel the actual literature because the words you are reading is not the word of God, its just a translation. To Feel that you have to know Arabic and its literature. For those who can read the Qur'ān in Arabic, the all-pervading rhythm which, in conjunction with the sustained use of what may be called rhymed prose, creates in many Surahs a spellbinding effect that is impossible to reproduce. There is the characteristic terseness of the Qur'ānic language which makes for some complex constructions, but which is difficult to convey in English without being awkward. The existing translations of the Qur'ān impose a further limitation, for they fall so far short of the highly nuanced original that a detailed study of the Qur'ānic language and style on their basis is well-nigh impossible (Mir 2000).



Works Cited
McAuliffe, Jane Dame. Encyclopaedia of the Quran. Brill, 2002-2004.
Boullata, Issa. Literary Structures of Religious Meaning in the Quran. Curzon Studies Int He Qur'an Series, 2000.
Qutb, Sayyed. “In the Shade of the Quran” v. 14 Islamic Foundation.
Mir, Mustansir. The Qur'ānic Story Of Joseph: Plot, Themes, And Characters, The Muslim World, 76 (1986) 1:15.
Mir, Mustansir. Islamic Awareness: The Quran as Literature, Renaissance, 2000.