‏إظهار الرسائل ذات التسميات fcis. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات fcis. إظهار كافة الرسائل

الجمعة، 9 مارس 2012

All about pointers: part 2

So now you learned pointers from part 1, right? What can we now do with them?

Well, we can use pointers in two ways:
1- As an abstraction over variables.
2- As just a memory location.

Abstraction over variables

Normal variables let us abstract over values; meaning "do something with x whatever value it has". Well, pointers let us store variables in variables, so to speak, and thus abstract over them.

For example, there is no pass by reference in C, but we can emulate it with pointers:

void readInt(int *x) {
cin >> *x;
}
main() {
int t;
readInt(&t);
}

The function main is passing the location &t (by value) to readInt. When readInt modifies *x, this means "go to the address stored in x, and in that address, store whatever comes from cin >>". This modifies the value of t; which is what we wanted.

This pass-by-value works for anything that has a memory location; not just simple variables:

main() {
Point p;
readInt(&(p.x));
}

This will take the address where p.x is stored, and pass it to readInt; so it will be the address where readInt will write.

Is there another use of 'abstraction over variables' other than pass by reference? Well, this depends on your imagination. We can do things like this:

void getAge( ) {
int x = 8;
dialog.scrollBox1.setBinding(&x);
showDialog( );
cout << x;
}

Here we can imagine the setBinding function storing a pointer to an integer (pointing to x in the example) and whenever the user slides the scroll bar, the content of the address stored in the pointer is changed. Therefore after the showDialog function ends we find the value of x automatically reflecting the scroll bar position. It is as if we passed the variable itself as an argument to the setBinding function.

Pointers as memory locations

We can also treat a pointer as just a location in memory, not associated with a named variable that already exists. This is helpful in situations like:

1- Dynamic memory.
2- Reading and writing buffers.
3- Accessing hardware devices.

Dynamic memory:

Local variables in functions are automatic variables; the size needed for each function's vars is calculated at compile time and space for all vars is allocated at function call, deallocated at function exit. This is useful for most programs but sometimes we want full control of memory allocation at runtime:
- Perhaps we have an array with non-fixed size.
- Perhaps we're using a linked list; where memory must be allocated only when we need to add to the list.
- Perhaps we're creating an interpreter for our own programming language, where the user's program will allocate memory.

In all cases, memory allocation takes a form like this
myPointer = malloc(memSize);
or
myPointer = new type;
or
myPointer = new type[numElements];

...and I can access the content of the pointer normally with *myPointer = xyz;

We are here using the pointer to store the address of a hypothetical variable that wasn't declared in the code. A 'run-time' variable if we may say. And since they need not be declared at compile time we can have as many of them as we wish and at the time we wish.

I think this has a theoretical aspect; and relates to theory of computation: think of turing machine and the infinite tape that gives them their computational power; and of finite state automatons and the finiteness of their states, as if they were 'compile time' memory :)

anyway...

Reading and writing buffers

Think of the fread function in C:

main() {
Point p1;
fread(&p1,myFile, sizeof(Point));
}

Here the fread function doesn't care if it's reading a point or not: all it needs is a memory location and the number of bytes to read, and it will fill that memory with data from the file. Here the pointer is treated purely as an address.

Accessing hardware devices.

In the good old days of DOS, you could do stuff like this:

// note: just a sample value
#define START_OF_VIDEO_MEMORY 0xA000

main() {
char *v = START_OF_VIDEO_MEMORY;
*(v + 5) = 60;
}

This would write the value 60 at five bytes after the start address of video memory. With code like this a developer could write directly to the video card; do tricks, make fast games....etc.

In modern operating systems this is impossible due to virtual memory. In a system like 32-bit Windows each program sees memory as 4GB all of it available to itself. The operating system does a lot of work to keep programs from taking each others' memory and keep each program thinking it owns all memory on the machine. This means that the address 0xA000 no longer means anything special; it's just a part of the virtual address space that could be valid or invalid for the running process (if it's valid, writing to it will change some unknown part of your program; if invalid your program will crash).

This leads to things like DirectX...etc to make game programming faster on Windows; but does that mean pointers for direct access are no longer useful?

Well, sometimes they're still useful. For example some hardware devices (sensors, robot controllers...) will take the virtual memory system to their advantage; the device's driver will map some memory on the device itself to memory in your program! This means you can use pointers to read or write directly to the device memory. It usually goes like this:

#include "sensor.h"
main() {
char * p = sensor_map_memory( "mySensorDeviceName");
// do what you want with p...
sensor_unmap_memory(p);
}

We've taken a nice journey now, and saw why C has a reputation for being suitable for low-level code; took a look into abstraction and dynamic memory, and hopefully understood pointers at a deeper level. I hope you liked the article!

الاثنين، 23 يناير 2012

الطريق المعلوم لشرح مثال مثلث النجوم

هب انك معيد في كلية الحاسبات تعلم البرمجة لطلبة مبتدئين، وتريدهم أن يكتبوا برنامجاً رسم مثلثاً مقلوباً من النجوم ارتفاعه 5:

*****
****
***
**
*

الطريقة التقليدية، التي رأيتها تتكرر كثيراً، هي الآتي:
  1. المعيد يعطي الطلبة فرصة لكتابة البرنامج بأنفسهم.
  2. الوقت ينتهي، بعض الطلبة كتبوا البرنامج والبعض لا.
  3. المعيد يري الطلبة الحل الصحيح، ويشرح لماذا يقوم هذا البرنامج بعمله وأنه يرسم بالفعل المثلث.
كما خمنتم، ارى أن هذه الطريقة خاطئة. نعم هي تجعل الطالب يفكر بنفسه في البرنامج، لكنها لا تخبره مطلقاً كيف يفكر: تخيل انني اعلم شخصاً السباحة بأن أتركه في الماء واقول له "سأعطيك نصف ساعة كي تسبح". نعم، هناك بعض من الناس سيتعلم بهذه الطريقة، لكنها بكل تأكيد ليست الأفضل!

اشعر ان هذا الاسلوب يوحي للطلبة ان البرمجة الهام مثل الإلهام الشعري: ان المبرمج هو شخص يجلس ويتأمل في المشكلة بعض الوقت، ثم فجأة يكتب الحل كاملاً مثلما يكتب الناس خطاباً. البرمجة مثل أي عملية فكرية لا تخلو من الإلهام والحلول الفجائية، لكن في كثيرها هي سلسلة من الخطوات تطبق بصورة علمية، وإن أردنا أن نحقق تقدما في تعليم البرمجة فلابد أن نبدأ في التفكير الجدي في ماهية هذه الخطوات وكيفية عرضها.

عملاً بمبدأ اظهر ولا تخبر تعالوا الآن نقدم طريقة مختلفة لشرح هذا المثال.

اولا سوف نصف المشكلة:
  • نريد كتابة برنامج يكتب مثلث نجوم ارتفاعه 5 سطور.
  • أدوات حل المشكلة لدينا هي (أ) امر cout الذي يعرض اشياء على الشاشة. (ب) امكانية الانتقال لسطر جديد بإضافة endl في امر cout وأخيراُ (ج)ادوات التحكم البرمجية التقليدية من loops، conditions، variables

الأمر إذاً مثل الفوازير على غرار "لديك حبل طوله كذا وصندوق وماعز وتريد ان تعبر من النافذة ذات ارتفاع كذا" الفرق الوحيد ان الأدوات المستخدمة هي افكار غير ملموسة وليس حبالاً (ولا ماعز من حسن الحظ).

الآن نفكر في الحل:

(من اجل التبسيط لن اكتب "طقوس" برامج السي من #include وما شابه)

من الواضح أنه مهما كان شكل الحل فإنه لابد أن يكتب سطوراً على الشاشة. ولابد أن يكون عدد هذه السطور خمسة:

main() {

for(int i=0; i<5; i++) {

draw_line();

}}

مهلاً! لا يوجد في السي++ أمر اسمه draw_line! انا تخيلت ان هذا الأمر موجود لسبب بسيط جداً هو أنني أريد ان احل المشكلة على أجزاء. سوف نفكر الآن فقط في عدد السطور المطلوبة ثم لاحقاً نفكر في شكل كل سطر.

العقل البشري يسهل على نفسه بأن يتجاهل بعض مكونات المشكلة ويركز في مكونات اخرى: هذا سلاح المفكرين في كل زمان ومكان وأحد أسباب التقدم العلمي الإنساني، وهذه العملية اسمها abstraction.

الآن نكتب الأمر المطلوب:

void draw_line() {

// ???????

}

علامات الاستفهام هذه محيرة: ما المطلوب ان نفعل هنا؟؟؟؟؟ الطبيعي اننا سنرسم عدداً معينا من النجوم، ولا ننسى الانتقال لسطر جديد لأن الاستدعاء القادم للدالة لابد أن يرسم من اول السطر التالي.

ما هو عدد النجوم المطلوب؟ اوه ألا تعرف؟ إنه n بالطبع!

void draw_line() {

for(int j=0; j<n; j++) {

cout << "*";

}

cout << endl;

}

هل تذكر الabstraction؟ لقد افترضت في الجزء السابق ان البرنامج "يعرف" كيف يرسم السطر. الآن أنا افترض انه "يعرف" كم نجمة ترسم في كل سطر. الآن نفكر: من أين سنأتي بهذه القيمة؟ نعود مرة اخرى ونتأمل الشكل:

*****
****
***
**
*

الذي نلاحظه أن العدد المطلوب يبدأ بخمسة ويتناقص مع كل سطر. التحول من سطر إلى سطر يحدث في الدالة main ، إذن هذا هو مكان المتغير المطلوب:

main() {

int n = 5;

for(int i=0; i<5;i++) {

draw_line();

n--;

}

}

الكود تبدو طبيعية جدا: طول السطر يبدأ بخمسة، ثم نرسم السطر، ثم ننقص الطول بمقدار واحد، وهكذا. لكن الدالة draw_line هي التي تحتاج لطول السطر، وليس main!

لا بأس، من أجل هذا هناك إمكانية تمرير الparameters. أولا نعدل main:

main() {

int n = 5;

for(int i=0; i<5;i++) {

draw_line(n);

n--;

}

}

وثانيا نعدل draw_line:

void draw_line(int n) {

for(int j=0; j< n; j++) {

cout << "*";

}

cout << endl;

}

وانتهى البرنامج! ماذا لو لم يكن الطالب قد اخذ الfunctions من قبل؟ مشكلة قابلة للحل: يمكن تقديم الfunctions قليلاً أو استخدام comments هكذا:

main() {

for(int i=0; i<5;i++) {

// draw line

}}

ثم التساؤل "ماذا نكتب مكان التعليق" بدلاً من "كيف نكتب الدالة المطلوبة".

الآن ما مميزات الطريقة الجديدة؟
  • لم تعد الخطوات بين المشكلة والبرنامج شيئاً غامضاً، وكسرنا قشرة البرنامج ونظرنا داخلها.
  • الآن يمكن للطالب أن يقلد نفس الطريقة حين يأتي عليه الدور ليكتب برنامجاً بنفسه (في السكشن او خارجه).
  • البرنامج الناتج منظم جداً ويتبع منهج structured programming، ليس لأننا فرضنا هذا على الطالب فرضاً ولكن لأن هذه كانت اسهل طريقة للتفكير في المشكلة.
  • لم نكتب البرنامج مرة واحدة لكن جزءاً جزءاً وهذه هي طريقة العمل في البرامج الحقيقية: البدء بكود تبدو صغيرة (لدرجة التفاهة احياناً) ثم تزويدها وتنقيحها تدريجيا لتصل للبرنامج المطلوب.
  • تعلم الطالب التفكير بطريقة top down والانتقال من مستوى اعلى من الabstraction لمستوى اقل.

ارجو أن يفيد هذا المثال من هو في موقف تعليمي.

السبت، 14 يناير 2012

Improving FCIS education: ideas and strategies

الم تتلق العلم في معاملي، وتضحك وتبكي بين جدراني؟
إذن اخبرهم كم أنا جميلة!
كم أنا ذكية!
فقط أحتاج لمن ينفض التراب عن وجهي...
من يجدد شبابي...

Architecture


There's a book called "The elements of computing systems" that attempts to go through all layers of a computer: starting from logic gates and building the hardware, assembler, compiler, operating system, and finally a Tetris game on top. The book even has prepared course material to teach with.

Will it be good? Will it be possible to give in a semester? I don't know, but seems worth examining.

Python, computer vision, and scientific computing

The problem with computer vision/image processing is that the set-up takes much longer than the fun parts. Students spend too much time learning how to load images, access pixels, do transformations,...etc

Python is a very high-level language, with very readable syntax (looks like pseudocode) and a lot of libraries. It currently has a gained a lot of users in the scientific community and got some excellent high-performance, high-quality libraries in these domains. It might be much easier to use in imaging/scientific computing than the current tools (C++, C#) and some researchers are even using it instead of Matlab.

This is a list of common Python libraries for imaging/SC. The most famous is SciPy, described as having "... modules for linear algebra, optimization, integration, special functions, signal and image processing, statistics, genetic algorithms, ODE solvers, and others. "

Another is VTK (visualization toolkit), described as "an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world."

Also, there's SimpleCV, a set of Python libraries to make computer vision easy and straightforward. You can look at their demos if you like.

Perhaps someone can have some experiments with these libraries and try to make use of them in FCIS subjects and/or projects.

Algorithm animation toolkit

I don't know how useful algorithm animation would be in teaching algorithms, but it could be quite useful (algorithm animation = drawing each step in the algorithm one after the other while showing state of variables, content of arrays, ...etc).

I suggest creating a generic algorithm animation kit: it would be an interpreter for a small language (perhaps C-like), the TA would write the algorithm in that language and the interpreter (which knows how to draw an array, a tree, graph...etc) would run each step, visualizing along the way.

It's not that hard a project for someone who knows compilers. By the way it might be even more useful in the data structures course (e.g to explain insertion in a binary search tree) than algorithms.

First year & programming

Let's be honest: there are too many 3rd year students who barely know how to code (probably a lot of 4th year too). Even worse: they haven't learned to make it easy for themselves.

What do I mean, not make it easy? I don't mean object oriented design or such, I mean the really simple things:
  • Indenting code to know where each loop or if statement ends, to have no statement in the wrong place (e. outside the if instead of outside the while).
  • Passing values as parameters instead of storing them as global variables or fields in the class.
  • Giving variables meaningful names. I can't remember how many times I've seen variables called a, a1, c, instead of pixelsPerCentimeter, nameToEmployeeMap,...etc
  • Not trying to really understand the problems, instead randomly changing things until the program seems to run.
  • Not trying to plan their work: no sketching of solutions, no equations before coding, nothing but opening the editor and typing.
These things do not even require practice or extreme intelligence, they simply need to be done.

So how do I suggest solving those problems? We could at least start by:
  • Having TAs talk about these issues.
  • Having TAs code in front of new programmers. All crafts are learned by watching: a young carpenter learns by watching older carpenters. A mechanic learns from his master. Programming might be a science but - like it or not - it's also a craft.
There is this belief among beginners that code is the final product: As if a programmer should read the problem, think real hard about it, and then write the code correctly. In such an imaginary world there is no need to indent code or give variables good names: the code is for the compiler to translate, not for a human to read.

In the real world you'll spend 10 or 20 times as much debugging the code as you wrote it. You'll ask TAs to debug the code with you. Neither you nor the TA wants to get lost in x,c,i,j or wonder where the while loop ends among those braces, or discover that the function depends on a global or member that he forgot about. Just do what you can to make life easier.

Structured programming: the subject that isn't :(

I have a feeling that structured programming has never been taught in the faculty: they always would teach loops or pointers or the like: this is not SP! this is just programming language features.

Real structured programming is about code having structure, i.e being decomposed into smaller components, being able to reason about each component separately of the others, then combining them into a larger program.

This is a sample of the stuff that should be taught in such a course:
  • Decompose programs into functions
  • Functions should be like mathematical functions: takes input from parameters and returns values. Do not call a function by first writing to a global var, calling it, and letting it read from the global.
  • Don't let the function doing the calculation open a file, let each function do a specific job.
  • Don't mix user interface (console or GUI) with the logic. This prevents reuse, among other things.
  • A function should map to a unit of meaning in the problem (e.g draw_character, determine_if_monster_is_dead). Reading code should sound - in your head - like reading the solution of a problem.
  • Think hard about the data, and also decompose it into structs, arrays,...etc. Those should also map to units of meaning in the program (car, deck_of_cards, salary).
Object oriented programming

Among the syntax, the static methods, the class definitions, public & private,...the most important concept is forgotten: objects.

Basically, the idea is that when a program runs, a lot of objects will be created in memory and will interact with each other by method calls. This simple idea - believe it or not - is virtually unknown to a large portion of students.

Don't believe me? Here are the signs:
  • It is very hard to explain to students what static is, even if it means just "Doesn't work on a particular object".
  • It's very hard to explain the 'this' keyword, even if it just means "The object on which the method is called".
  • Students try to call methods on C# forms without having a reference to the form. If compilation fails they create a new form instance instead of acquiring a reference to the active form.
  • They have difficulty getting constructors, which are ways to create objects.
Basically, the students mostly memorize certain shapes of code and write them as-is. So how to solve the problem?

You can start by making sure the basic concept is understood: forget encapsulation, forget inheritance, forget public/private. First you got to make sure they get it:
  • When the program runs, objects are created. They call methods upon each other.
  • An object is not the class; the class is simply an 'algorithm' to create similar objects. All real work is with the objects.
  • When writing a class, think about how the objects created from it will behave.

(This is similar to functions actually: a functions is separate from its activation. This is why the same function can have multiple activations in e.g recursion).

Also, before making them define their own classes, let them use existing classes in the standard library to do basic object operations: creating them, calling methods, setting them as fields in other objects, learn about references...etc

The advice that I just gave can be applied to all subjects in all years: Start with the simplest, most essential concept (structured = decomposition, OOP = objects...) & make sure they learn it before you continue.

Graduation project supervision

It pains me to think about how much knowledge is created, then destroyed all along the years in FCIS.

Think about how many times e.g Ahmed Salah supervised a GP related to computer vision: He recommends papers to students to learn imaging from, then more specialized papers related to the project's domain, then tutorials to Matlab. And then next year students come and he has to repeat the whole cycle again. The day he leaves for his Phd is the day less students will be able to work on CV projects. Why does it have to be like that??

Come on people! I'm not asking for some big, systemic change! Can't we have a Google document online for all TAs to copy & paste the names of papers that they gave to the students?

Then along the years, new students can be pointed to them to learn about the GP domain, interested people like me can use them to learn about new subjects. The information in preserved when the TA is away. New papers would be added if the existing ones get out of date. Wouldn't it be awesome?

The same can be said about code & documentation: We should sort the copyright issues then have all code and docs posted online, and enable searching for projects by name, problem domain (e.g augmented reality) or year. This would solve problems like
  • "Has my project idea been done before?"
  • "Why aren't more projects continued on and improved?"
  • "We want a list of interesting projects to tell TV reporters, to make FCIS more known to society"
What I'm proposing here is accumulated knowledge: Recording previous valuable knowledge so that it can be reused in the future. This is for example why books are such an important part of human progress.

Themes for graduation projects

In 2010/2011 I tried to introduce the idea of themes: a lot of GPs in the same general domain. The aims were:
  • Encourage multiple teams to cooperate on common problems (e.g share papers that introduce NLP).
  • Plant a seed of research groups in the faculty, when some of those students become TA. This would form research groups naturally instead of by fiat from management.
I think this idea should be revisited. Have two or three themes each year, and let TAs announce in a session 10 ideas or so for each theme (but allow students to freely work outside them).

Observation

During my last months as a TA, and in the summer training after I quit, I did something new to myself: I began observing.

I'd sit with the students during a lecture that another TA is giving and see how they react to different styles, or even when do they focus and when they're distracted. If I would do that now I'd also go to the labs and watch how they actually try to program and the things that are repeatedly not understood by different groups of people.

Perhaps as educators we need to take a more scientific approach to teaching, & base our decisions on data instead of personal opinions.

Speaking of scientific, perhaps we could look at research about the topic of teaching programming. For example there's an ACM special interest group called SigCSE (special interest group, computer science education) where relevant papers are published. Also a lot of educators have blogs on the internet, and sometimes they write gems like this for example.

Know your goals

Rarely has an FCIS student been told: what is the purpose of your faculty, and why give those subjects in particular.

To improve the situation, I created this presentation: a tour of almost all FCIS subjects and the purpose of each, both science-wise and market-wise. If you haven't seen it already, I suggest doing so.

Epilogue

I hope some of those ideas turn out to be practical and useful. I think there's much more to be said in this area, and I might write a part II of this article someday :)

الأربعاء، 31 أغسطس 2011

Graduation project themes and ideas - 2010

In 2010 I suggested the idea of having multiple graduation projects with a common topic or 'theme'. My hope from this was to:
  • Give students the feelings that their projects are part of a larger goal
  • Give opportunity for different teams to cooperate and share e.g research papers they found on the topic
  • Possibly plant the seed of 'research departments' in FCIS, where multiple MS.c or Ph.D researchers work on common topics instead of each doing an independent topic.
That year I gave a presentation outlining two themes: Arabic natural language processing and Pen computing , and giving a lot of ideas for each theme (and some outside the themes).

Here's the presentation slides, in case they might be useful: Themes for Graduation projects - 2010

الجمعة، 12 أغسطس 2011

فيديو: مواد كلية الحاسبات وأهميتها - حاسبات عين شمس نموذجاً

لا يتعدى هذا الفيديو 35 دقيقة لكنه غني جداً بالمعلومات عن المواد وأهميتها علمياً وبرمجياً وفي سوق العمل. قدمته في الكلية منذ فترة قريبة والآن هو على الإنترنت للجميع. مشاهدة ممتعة!

الslides المقدمة في الفيديو تجدها هنا

(لو أعجبك هذا البوست فقد يعجبك أيضاً هذا: حاسبات للقرن الواحد والعشرين)

الجمعة، 29 يوليو 2011

حاسبات للقرن الواحد والعشرين

قد مر حوالى خمسة عشر عاماً على إنشاء كلية الحاسبات. حان الوقت للتفكير في كيفية تجديد شبابها وتجهيزها للمرحلة القادمة. لديّ بعض الأفكار الاستراتيجية من أجل هذا الهدف: تقليل العدد، صورة الكلية لدى المجتمع، العامل البشري.

تقليل العدد

لابد أن نعترف الآن أن عدد طلبة الكلية حالياً أكثر من اللازم، وهذا يضر الطلبة أنفسهم إذ لا يأخذون الفرصة في التعليم المطلوب أو التقييم. ماذا عن سوق العمل؟ هناك نظرية أن الفرق في مستوى المبرمج يؤدي لفرق كبير جداً في إنتاجيته: أي أن مبرمجاً عبقرياً قد يقوم بعمل عشرة مبرمجين عاديين، ومبرمج مذهل قد يقوم بعمل مائة...

لذلك فأنا أرى أن دفعة صغيرة من خمسين أو مائة مبرمج يتم انتقاؤهم بحرص ويتعلمون جيداً قد تقوم بدور في السوق مثل مئات المبرمجين في الصورة الحالية للكلية.

- هؤلاء قد يرفعون مستوى الشركات التي سيعملون فيها ويطورون اسلوبها
- هؤلاء قد يتعين منهم الأساتذة الذين يرفعون مستوى التعليم والبحث العلمي
- هؤلاء قد يفتحون الشركات ويغيرون من شكل الاقتصاد

في رأيي أنه على إدارة الكلية أن تفكر في هذه النقطة جيداً وتفعل كل ما تستطيع مع المجلس الأعلى للجامعات لتقلل العدد قدر المستطاع.

صورة الكلية أمام المجتمع

مشكلة كلية الحاسبات أنه من الصعب تعريفها لدى الشخص العادي: الطبيب يعالج، المهندس يبني، ماذا يفعل المبرمج؟ لهذا يأتي كل شخص بنظريته الخاصة [المبرمج يستخدم فوتوشوب، المبرمج يبيع هارد ديسكات، المبرمج يجلس أمام الفيسبوك...الخ].

المشكلة الثانية أن الكلية لا توجد لها قصص نجاح معلنة بما يكفي (أقصد أن لها قصص نجاح كثيرة لكن المعلن منها قليل) هذا يؤدي للحوار الآتي:
  • فلان دخل هندسة بترول وتوظف في شركة باشو للبترول بمرتب 10،000 جنيه! لماذا لا تصبح مثله؟
  • فلانة دخلت طب وفتح لها أبوها عيادة، أنت لست أقل من ذلك وأنا أدخر لك ثمن العيادة من الآن!

نريد أن نكون نحن أيضاً طرفاً في الحكاية، فكيف نفعل ذلك؟ الخبر الجيد أن 95% من الحل موجود بالفعل بين أيدينا ولا يبقى سوى ال5% الباقية: إن كان الإعلام المصري لا يعرف الكثير عن البرمجة (وهذا طبيعي لأي إعلام) فهو يعرف ما هو الاختراع ويحب قصص المخترعين.

انظر مثلاً لهذا المقال في جريدة الشروق عن مشروع تخرج يسمح لمستخدم الكمبيوتر بالتحكم فيه عن طريق تحريك يده. الآن انظر إلى تعليقات القراء على المقال؛ وكيف يحتفون بالمشروع ويعتبرونه إنجازاً مصرياً كبيراً...الخ.

نحن في حاسبات كل سنة تقريباً لدينا مشروع أو أكثر مثل هذا، التحكم في الكمبيوتر بتحريك اليد، والعين، والأذرع، وبالصوت، وبجهاز رسم المخ -- حتى أنني في سنة من السنين مللت هذه النوعية من المشاريع وصرت أقول للطلبة أن يفكروا في أفكار أخرى، لكن.......المجتمع لا يعرف ذلك!

[لم أقصد انتقاد صاحب المشروع في هندسة أو شيء من هذا، المشروع محترم لكن كلامي هنا عن المستوى العلمي لكليتي أنا]

لدينا مشاريع تتعامل مع اللغة العربية، لغات برمجة جديدة، مشاريع روبوت، مشاريع علمية، لكن المجتمع لا يعرف. ويظنون البلد متخلّفة :(

ماذا يكلفنا أن نأتي بكاميرا فيديو ونصور كل هذه المشاريع التي تبدو كالخيال العلمي ونضع كتالوج بكل هذا على موقع Youtube؟ ماذا يضيرنا أن نكلم كل الصحف والمحطات التلفزيونية لتأتي أيام المشاريع وترى؟ لا أتوقع أن يكلف هذا مالاً في إعلانات، بل يكون الموضوع خبراً لا إعلاناً لأن الصحفيون أنفسهم يبحثون عن مثل هذه النوعية من الإنجازات. أتخيل الآن العناوين:
  • "مصر مازالت بخير، مشروعات تخرج في كلية الحاسبات تضاهي الاختراعات الأجنبية"
  • "المبدعون الشباب ينقلون المجتمع المصري إلى القرن الواحد والعشرين"
  • "الاختراعات تتوالى في الجامعات المصرية"

أريد أن يصير اسم حاسبات مرتبطاً بالاختراع، هذا هو التعريف الذي أريده في ذهن المجتمع.

وطالما نتحدث عن اليوتيوب، لماذا لا يكون هناك قناة على الإنترنت للطلبة والخريجين يتحدثون عن خبراتهم في حاسبات كنصائح لطلبة الثانوية العامة؛ عن مميزاتها وعيوبها وكيفية التفوق فيها لمن يدخلها؟ لا أريد إعلانات الجامعات الخاصة إياها عن المعامل والحدائق بل أريد شيئاً حقيقياً من طلبة حقيقيين عن العلم والتعلم والتخرج والتوظف. أليس هذا هو الهدف الأصلي؟

ماذا عن قصص النجاح للخريجين؟ نحن لدينا معيدون يدرسون للدكتوراة في المانيا وكندا وأمريكا..لا يكاد يكون هناك قارة في العالم إلا وهناك خريج حاسبات ذهب إليها للحصول على الدكتوراة من إحدى جامعاتها، لماذا لا يعرف أحد شيئاً عنهم؟

لدينا من الخريجين في شركة مايكروسوفت بالولايات المتحدة وكندا حتى لتظن انه هناك فرع من الكلية هناك، لمَ لا يعرف أحد شيئاً عنهم؟

ماذا عن الخريجين الذين قد أسسوا شركات؟

هناك ألف شيء آخر يمكن عمله، مثل FAQ عن الكلية تتداول الأسئلة الشائعة عن سوق العمل والنقابة والمعاهد...الخ. فكرت أصلاً في جعل هذه الوثيقة في صورة قصص مصورة comics لكي تغري الناس بقراءتها. من يبحث يجد ألف فكرة.

[تعقيب: قد أتبعت كلامي بعمل وبدأت خطوة صغيرة في هذا الاتجاه.]

العامل البشري

الكفاءات هي التي تصنع أي مؤسسة، وغياب الكفاءات هو الذي يهدمها. لا يضاهي الكفاءات في الأهمية سوى الجانب الإداري. معادلة النجاح المؤسسي هي

كفاءات عالية + بيئة إدارية مشجعة = مؤسسة ناجحة.

كان وكيل سابق في كليتنا (وأستاذ لي) يقوم بدور مهم جداً في منصبه: كان يفتش عن الكفاءات أينما كانت. في كليات الهندسة، كليات الحاسبات الأخرى، ربما الجامعة الأمريكية...في فترة من الفترات كنت لا تكاد تتحدث عن دكتور جيد في الكلية إلا ويحتمل أن يكون ذلك الوكيل هو الذي دعاه للتدريس لدينا.

نحن نحتاج إلى هذا من جديد! لابد من البحث عن الأساتذة الممتازين في كل مكان داخل وخارج مصر، ودعوتهم لتقديم المواد في الكلية. لابد من توفير المغريات المناسبة التي تجعلهم يرضون بالمجيء، ليس فقط المال لكن بيئة علمية جيدة، فرصة لتغيير المجتمع، بحث علمي حقيقي...الخ

ولابد أن تكون البيئة مهيئة لا فقط لجذبهم لكن للاحتفاظ بهم، فالشخص الكفء لديه مطلق الحرية أن يعمل في أية مكان يشاء، ولو رأى المكان لا يشجع فلا يوجد فتفوتة شيء يُكرهه على البقاء.

البحث عن الكفاءات وجذبها، توفير البيئة التي تستثمر كفاءتهم، توفير ظروف الإبقاء عليهم. هذه يجب أن تكون الأولوية القصوى لأية مؤسسة لا فقط الكليات.

هناك جوانب أخرى للمناقشة في حوار تجديد شباب الكلية؛ مثل شكل المناهج، طريقة التدريس، علاقة المواد ببعضها...وهي كلها أشياء مهمة حقاً ولا ريب جديرة بالمناقشة، لكني أرى النقاط الثلاثة السابقة نقاطاً استراتيجية لابد من الانتباه إليها، بل وأن ضبط هذه النقاط يساعد بشدة في النقاط الأخرى من مناهج وخلافه.

الأربعاء، 20 يوليو 2011

GP Ideas: 1- Sketchcode

Concept

Let users write programs by sketching; either using paper+scanner or using a tablet computer.

More info

I have an incomplete design of a sketch-based programming language that combines text and graphics elements. Data structures like linked lists or trees would be expressed by their familiar sketch notations, while functions would resemble their familiar text representation enriched by some additional notation gained from using a pen.

I can show my designs to interested teams, but I won't post pictures here on my blog for obvious reasons :)

The project will have two major subsystems and 3 major stages. The subsystems are
(a) Sketch recognizer
(b) Code generator [or interpreter].

The stages are
(a) Language design
(b) Implementing sketch recognizer
(c) Implementing code generation

Stages (b) and (c) could probably be done in parallel assuming a complete language specification was made beforehand.

I cannot officially supervises the project of course, but I am prepared to participate in the design of the full language.

Challenges and risks

The first challenge is in the design of a language that is usable for the sketch medium and expressive enough to represent complex programs without cluttering the area with complex, unclear sketches.

The second is the usual risk of pattern-based projects: The accuracy of recognition, choice of training algorithms, and so on.

Techniques needed

Patterns recognition, image processing, possibly compilers

Notes

This is related to my technology vision of Awraq

الثلاثاء، 19 أكتوبر 2010

Proposal for a new-style FCIS ACM chapter

As some of you know, I have long-term plans of creating a software company, إن شاء الله.

The question is: Where to get great programmers to work there?

What's a great programmer anyway? What types of programmers am I looking for? Think of someone who has some (not necessarily all) of those capabilities:

- Knows enough to create a basic computer vision application.
- Can write a compiler for a small but useful language in a couple of days.
- Can learn a new platform (say a mobile platform) in a short time.
- Invents his own tools to help with projects (e.g code generators, data editors such as level editors in games, verifiers...).
- Understands design trade-offs and the needs for real-world applications.
- Can mix concepts from different disciplines (e.g use techniques from AI when writing a database application).
- ...etc

The reader might now ask: Why do I want such a level of programmers? Does the market need anything like that at all? Well, my plan is to change the market a little. I have big ideas for creative hardware and software applications, many of which I hope are monetizable. Some of them are for internal markets (Egyptian, Arab...) and some for the international market. I should talk more later those projects. Some of their names may be familiar to readers who know me:
- Arwa
- Kalimat
- Awraq
- Kitty
- SketchCode
- Ideaz
- SenseWiki
- ...etc

Isn't this the dream of every computer-science student or graduate? A company where the valuable science they've learned is applied, improved and monetized? A place where you get paid for doing the things you love, and yet produce useful tools for society?

In order to have a chance at doing this, إن شاء الله , many things are needed: I need funding, good strategic planning, and more. But one of the things I'd need most is the existence of a growing number of smart, talented, capable programmers . The existence of those programmers is a major deciding factor for all of this.

How to establish a pool of talent then? Long-term I hope social changes help with this (like teaching children programming). Short-term we need to look at existing students and graduates and help them grow as programmers.

(Are you growing as a programmer?)

Now my opinion on the current FCIS ACM chapter activities. Before I go on I have to say two important things:

1- The ACMers have worked hard to organize competitions and educate students. Many of them have spent long hours of their own time helping others and expecting nothing in return. I'm not trying to discredit their hard work. I think it's clear that they deserve appreciation.

2- I'm not opposing their strategies for the sake of mere opposition. I've talked about these issues with several members of the organization. I think we all have the same goals for the faculty and society in general.

Now..criticism time :-) :-) :-)

1- The current ACM activities make students focus too much on algorithmic problem-solving and almost nothing else. Eventually there's a limit to the usefulness of repeatedly practicing the same topics over and over. After a while you learn nothing new.

2- Then there's no creation involved... The main aim of the competition is to give correct output for a given input. Real-world programming isn't like that. When creating a real product almost nothing is fixed in advance and you need to think hard about features, trade-offs, system constraints and user-interaction.

3- The training focuses almost exclusively on C++ console applications. This is a very small part of the development world. Again, real development has a very diverse ecosystem: Mobile applications, web apps, embedded systems, games, developer tools, scientific applications...etc. All these need a multitude of tools, techniques and languages.

4- The training talks a lot about "Computer science", "Math" and the like yet it only focuses on one aspect of CS and Math ignoring all other important aspects. This could give students the false idea that CS is only about algorithms.

5- ...Even then, the (few small) observations I've noticed make me think algorithms are not really taught in-depth. "Some lessons about graphs and dynamic programming" != "algorithms".

True, the ACMers make the occasional educational sessions or other activities but for me the real goal is achieved when people grow enough as programmers to reach and exceed the level I described at the beginning of this article. Success is when programmers are able to help with the kind of applications I described, for the kind of companies I described. (Yes, I said companies, I hope my own company helps set a wave of change in the local market).

I've talked with some ACM members and leaders and described a proposal for improving the organization. Here's some more details:

The new, new ACM

My proposal for the new ACM is all about changing the focus from one aspect (problem solving competitions) to other suggested aspects:

Creation
Students should train on creating real, working applications and not just idealized programming examples.

Diversity
Students should learn a variety of tools and languages, be capable of creating more than one type of application, and get good introductions to the various fields of computer science.

Depth
Students should have the opportunity of, and be helped with, getting deeper into the subjects that fit with their interests, both scientific and technical.


Activities

Here's a sample of suggested activities that could be made in the new ACM:

Events:-

Hackathons: Where students gather in labs (like in competitions) but instead have 2-3 hours to create a small, useful application. Like a game or a web tool.

Special topic weeks like "software engineering week", "game programming week", "programming language week", where several speakers interested in the same topic can all give presentations about the different sides of that topic.

Minimalist presentation days where several speakers can give sessions, but each session is very focused (say 15 or 20 minutes) so the speakers will have to really concentrate on what's important. And at the same time allow the audience to view many presentations without feeling tired.

Research days where TAs and other researchers can speak about their research and discuss their scientific interests with the audience.

Projects:-

Ongoing open-source projects where fresh members regularly join and learn from experienced members. I think the 2010 summer of code was a real important step forwards in this direction.

Dissect-a-project where a presenter takes some project (open source or developed by the presenter) and explains how it was designed and implemented, with a focus on how design decisions were made, how implementation problem were solved, techniques used, and the like.

Knowledge repositories: An online site where summaries, tutorials and example programs are regularly added and modified. Perhaps also a place to collect technical knowledge from the forum, blogs...etc. Perhaps in the long-term books could be authored that way.

Activities:-

Book rings where (say) five readers take five books, and each reader reads his book then passes it to the next 'element' in the ring.

Sessions of knowledge (مجالس علم) would be like mini-sessions where learners can exchange knowledge, discuss a book, plan for projects...etc

I'm sure that with some brainstorming more and more ideas could be found.

Moving forward

While this discussion is already going with existing ACM members/leaders, I decided to put this article on my blog for several reasons:
  • I wanted to raise awareness of the need for creation, diversity, and depth.
  • I wanted older ACMers (many of whom are outside Egypt) to know about these suggestions and join the discussion if they want.
  • I wanted a stable reference where my ideas are organized, written-down and publicly available.
If something stops improving, it stagnates. I think it's time to take FCIS programming activities (and perhaps the local software market) to the next stage.