This blog is subject the DISCLAIMER below.

Wednesday, January 31, 2007

Presentation Guidelines By Mr. Ayman Ezzat

DO:

  • Strict by 8 ~ 12 lines per each slide.
  • Strict to allowed presentation time,40 -- 60 seconds per slide is the standard. If you are allowed 20 minutes, prepare 20 -- 30 slides.
  • Look to presentation audience instead of continuous reading from pc screen, Knowing that
  • Looking presentation audiences .... Excellent!
  • Looking screen ..... Fine!
  • Looking PC screen .... Bad!
  • Start presentation by clear self introduction "My name is ...., today i would like to talk about ........".
  • First 2--3 slides... speak clearly and slowly, Name should be pronounced slowly. Title should be pronounced clearly.
  • Whenever you refer to previous work or used technique you must put a reference in your presentation and link to it.
  • When you specify some technique to use it is good to state merit of this techniques and purpose of usage.
  • Record and memorize every question you get during the presentation from the audience, it is better to do it immediately.
  • Always make the answers to audience questions consistent with you presentations slides.
    It is good to prepare set of questions to present in case no one has something to ask and also specially when you are chairing a session.
  • Define problem well and introduce proposed solution in a very clear way.
    Provide you presentations with simple and clear pictures.
  • Graphical notations are powerful than texture notes.
  • If you give an example about your work try to be general and don't go in very detailed things, overall summarized example is good.
  • If presentation is chapters then try to put published work of each chapter.
Avoid:

  • Low voice.
  • Confusion between a reference work and your own opinion work.
  • Emphasize your original points. Distinguish:
    General background, general explanation, your own view/approach for the problem, and your own work.
  • Using first letter capital of each word inside the content of the presentation.
  • Negative answers and poor unreasonable answers.
  • Giving a smile of impoliteness.
  • Spelling Mistakes and grammar errors.
  • Answering things that you don't hear well, If you do not understand the question, you should
  • ask to the questioner. Prepare several ways to ask the meaning of the questions.
  • Motivations cant be on general topics.
  • Contributions must not be general things and originality points must be clear and focused.
  • Long introductions are not preferred by attendees.
  • Many drawbacks in a single presentation means the thesis is weak.
  • Avoid general drawbacks that are not direct related to your work.
  • If your presentation is divided to chapters do not put related work for each chapter separately it is confusing.
  • When divide presentation to sections avoid overlapping it makes attendees lost.
  • Avoid mixing general topics and emphasized parts.
  • Font color must be Black, avoid pale colors.

Published by Mr. Ayman Ezzat: view

.. more.

Tuesday, January 30, 2007

What's New in C# 2.0 ? Part 2

In the name of ALLAH

Welcome in Part2 (Sorry it will be Long Post Coz it Will be the Final Part )
Iterators allow you to easily create enumerable classes, classes that allow you to iterate through their collection of values through a foreach loop. Classes that implement the IEnumerable interface allow you to use foreach loop.
To use IEnumerable interface we must implement GetEmumerator Method which return IEnumerator object which, this object allow foreach loop to work the way it does.
The new iterator pattern makes use of the yield keyword , from this moment we don't have to create and implement an IEnumerable object , yield does all of this.
Example : -
If we tried to Store 100 000 string in array of string then we tried to retrieve the array's values using foreach loop one by the old way and the second with the Yield Key word.
Here is the difference with Yield it will take 93 milliseconds and with the Old Way 343 milliseconds.

Syntax:-

yield keyword in foreach loop

Yield Var;

the Advantages :-


Good Running Time
Save Code and increases its readability

Nullable Types

The Nullable Type Can Represent the Range of Value for any type plus it can hold the value null

Example : -
Nullable can Hold Values in this Range from -2147483648 to 2147483647 in addition to Null Value

another Example : - Nullable can hold The Value True or False ( false set as default in the normal Bool ) in addition to Null Value .

but what is its importance ?
assume you are working in database application
a Boolean field in a database can store the values true or false, or it may be undefined.

Syntax: -
int? x = 10; or double? d = 4.108; ….. and so on

the most important Properties in nullable variables : -

The HasValue property returns true if the variable contains a value, or false if it is null.
The Value property returns a value if one is assigned, otherwise
a System.InvalidOperationException is thrown.

The last Thing to say about nullable Type that it can work on Value and Ref. Type.

Static Class

Static class was developed in c# 2.0 to prevent the problem of working with The classes which have Private constructors by using Reflection.
Use The Keyword static in the declaration of the class to prevent the class instantiation by
Reflection

Syntax :-
static class Class1

Anonymous Methods

Hint :- To understand Anonymous Methods you must understand Delegates Very Good. I will depend here that you Can use Delegates.

Earlier( in previous versions of C# ) we were handling the events like this

myButton.Click += new EventHandler(MyButton_OnClick);

public void MyButton_OnClick(object sender, EventArgs e)
{
// do something
}
Here we first added a delegate to myButton’s Click event. The delegate is made to reference the MyButton_OnClick() method which is defined earlier.

Anonymous methods allow you to define un-named methods ( any block of code )
Like this

this.myButton.Click += delegate(object sender, EventArgs e)
{
MessageBox.Show("yes");
};


The Advantages: -

Anonymous methods can be useful when we only want to use our event handler to point to only one method. It can save code size and make it more readable if used appropriately.

mmm i reached the End Of This Post .. but i will be back Soon isA with C# 3.0 .. So Keep Waiting :)

.. more.

Monday, January 29, 2007

Today Exclusive: Gates & Microsoft Launch Vista

Gates on Vista softwareJan. 29: Microsoft chairman Bill Gates talks with TODAY host Meredith Vieira about the launch of Windows Vista, the company's newest operating system, which hits stores Tuesday.


.. more.

Java Developer Conference Presentations

Java Developer Conference Presentations is available..

.. more.

Sunday, January 28, 2007

What's New in C# 2.0 ? Part 1

in the name of ALLAH

Hope all be Fine ..
as we know that Microsoft announced for C# 3.0 , So I decided to write My Articles about the enhancements in this Language, but before I begin C# 3.0 lets know first the new Adds in
C# 2.0 which was released with Visual Studio 2005 then we will speak about C# 3.0 .

First i will begin with Generics.
Generics are a new feature in version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code.
to use Generics we must use this name space System.Collections.Generic

Example ..
// Declare a list of type int
GenericList list1 = new GenericList();

If you fell that this is not clear look to this problem
Imagine you want to create a class template that supports any type. When you instantiate that class, you specify the type you want to use, and from that point on, your object is "locked in" to the type you chose. How Can you Do this ??

Generic can do this look at the following Example : -

public class ObjectList : CollectionBase
{
private ArrayList list = new ArrayList();
public int Add(ItemType value)
{
return list.Add(value);
}

public void Remove(ItemType value)
{
list.Remove(value);
}

}


Second Partial Classes
Partial classes give you the ability to split a single class into more than one source code (.cs) file. Like This
public partial class MyClass
{
public MethodA()
{...}
}

public partial class MyClass
{
public MethodB()
{...}
}

When you build the application, Visual Studio .NET tracks down each piece of MyClass and assembles it into a complete, compiled class with two methods, MethodA() and MethodB().

In my opinion partial is not Very important for Small projects but it will be great in large projects.

The Second Part Will be about
Iterators
Anonymous Methods
Nullable

.. more.

Saturday, January 27, 2007

OpenCV


OpenCV is Intel® Open Source Computer Vision Library. It is a collection of C functions and a few C++ classes that implement some popular Image Processing and Computer Vision algorithms.
If you want to gain the great performance of C without being involved in the tiny details (like creating your own data structures & customized functions, etc) in the same way you used to on Mat-lab, OpenCV is your best choice. Yet, other stuff not related to image processing & computer vision directly (like neural networks, etc) won't be provided through OpenCV (yet you can find them available on the Internet in C, also).


For example, the above image was captured by a web-cam, segmented, masked with the original image from the web-cam again, & finally saved on disk with a few lines of code.

The key features :

OpenCV has cross-platform middle-to-high level API that consists of a few hundreds (>300) C functions. It does not rely on external libraries, though it can use some when it is possible.

OpenCV is free for both non-commercial and commercial use (see the license for details).

OpenCV provides transparent interface to Intel® Integrated Performance Primitives (IPP). That is, it loads automatically IPP libraries optimized for specific processor at runtime, if they are available. That grantees even faster execution (C is already fast on modest hardware) for usually complex image processing operations, making use of the available hardware (if it's Intel®'s). More information about IPP can be retrieved @ http://www.intel.com/software/products/ipp/index.htm

For more information about OpenCV :

.. more.

Explore the java platform- part1 - what is java?


Explore the Java platform
part 1
What is java?

1.1 Introduction

This part aims at getting the reader familiar with Java as fast and simple as possible as we will see a simple overview of the Java platform to help us getting through the rest of the parts in a non complex flow.
As a personal point of view, talking about Java is endless. Java is more than a platform; you can treat Java as a person, really! Sometimes you love and miss Java, and sometimes you reach the point of no going back, sometimes you say poems about the great technology, and sometimes you call it a peace of garbage.
That what makes Java very special, when you use it you feel the human thinking in every thing, you have the chance to understand every single step you do to develop an application.

Personally, I am a great fan of Java, not to be different, but because I dealt with other technologies which are mainly from Microsoft, for example; when you learn .NET, you know the steps to accomplish some tasks without knowing why, you just click here and there and write some code (IF YOU DO SO!!!) because they told you that.
Dealing with Java is very much different, as you can get to know every single detail concerning every thing, including the Java platform source code itself.

1.2 What is Java?
Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. Java applications are often compiled to bytecode, which may be compiled to native machine code at runtime.
The language itself borrows much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities.

1.2.1 History
Java was started as a project called "Oak" by James Gosling in June 1991, the goal of this project was to build a virtual machine and a language that accomplish “Write Once Run Anywhere” (WORA) concept, where you can write an application and run it on any platform without any runtime costs.
Java as a programming language passed over many levels of enhancements, now, the standard Java language is known as ‘Java2’.


1.2.2 Philosophy

Primary Goals:
It should use the object-oriented programming methodology.
It should allow the same program to be executed on multiple operating systems.
It should contain built-in support for using computer networks.
It should be designed to execute code from remote sources securely.
It should be easy to use by selecting what was considered the good parts of other object-oriented languages.

Platform independence
One characteristic, platform independence, means that programs written in the Java language must run similarly on any supported hardware/operating-system platform. One should be able to write a program once, compile it once, and run it anywhere.
This is achieved by most Java compilers by compiling the Java language code "halfway" to bytecode (specifically Java bytecode)—simplified machine instructions specific to the Java platform. The code is then run on a virtual machine (VM), a program written in native code on the host hardware that interprets and executes generic Java bytecode

Automatic Garbage Collection
One idea behind Java's automatic memory management model is that programmers should be spared the burden of having to perform manual memory management. In some languages the programmer allocates memory to create any object stored on the heap and is responsible for later manually deallocating that memory to delete any such objects. If a programmer forgets to deallocate memory or writes code that fails to do so in a timely fashion, a memory leak can occur.
In Java, this potential problem is avoided by automatic garbage collection. The programmer determines when objects are created, and the Java runtime is responsible for managing when to remove this object from memory.

1.2.3 Syntax
Java’s syntax shares a great deal of C++ syntax, however, C++ can not be considered a fully Object Oriented language rather than a hybrid language because it combines the properties of structured, generic, and OOP. For example; In C++, the program is executing inside the main function which is not a member of any object.
Java was built from the ground up as an object oriented language. As a result, almost everything is an object and all code is written inside a class. The exceptions are the intrinsic data types (ordinal and real numbers, Boolean values, and characters), which are not classes for performance reasons.


Hello world in java

// Hello.java
Public class Hello
{
Public static void main (String[] args)
{
System.out.println ("Hello, World!");
}
}

As you can see in the hello world example, a main method is defined as a member method of the class Hello. Any class can have a main method as long as it has a signature similar to the hello world class, however, if you have an application with many classes containing main methods, only one main method will execute at runtime.

1.2.4 Criticism

Performance
Java can be perceived as significantly slower and more memory-consuming than natively compiled languages such as C or C++.
In general, interpreted languages require additional instructions to execute, and can potentially run several times slower than directly compiled machine code. There also is a significant overhead in both time and space, since many Java interpreters and runtimes take up many megabytes and take many seconds to start up. This arguably makes small Java utility programs uncompetitive with programs compiled in other compiled languages. To be fair, several tests have indicated that the Java overhead is less noticeable for sophisticated or large Java programs.
Java's performance has increased substantially since the early versions, and performance of JIT compilers relative to native compilers has in some tests been shown to be quite similar.The performance of the compilers does not necessarily indicate the performance of the compiled code; only careful testing can reveal the true performance issues in any system.

Lack of OO purity
Java's primitive types are not objects. Primitive types hold their values in the stack rather than being references to values. This was a conscious decision by Java's designers for performance reasons. Because of this, Java is not considered to be a pure object-oriented programming language. However, as of Java 5.0, autoboxing enables programmers to write as if primitive types are their wrapper classes, and freely interchange between them for improved flexibility.

1.3 Why Java?
Well, we have seen that there is a good language called java, so what? Why bothering ourselves with learning a new language as long as there are already languages that satisfy our needs and easy to use and learn?

First of all, we must confess that we as Egyptians were invaded by Microsoft from quite long time. Any normal computer user believes that the only thing that can operate a PC is of course windows; most of developers now see that the .NET is the ultimate magician that can do any thing. Unfortunately, that is not the case; the case is that we did not see any other technologies to judge the products we are using in a right way. I don’t say that we don’t use Microsoft technologies,(I use windows) but we have to move on to see the wide space full of technologies out there, we have to see and try to judge fairly, and believe me the result will be very surprising.

For example; the most popular language now in Egypt is C# which is considered to be very easy and very powerful for us as Egyptians. The reason of this is that we still have a relatively small and weak software industry. C# is a good and easy language, but at small scale projects.
Talking frankly, we can say that more than 85% of the .NET concepts are taken exactly from Java.

Java platform is a very powerful and stable language with a very wide collection of technologies utilizing the language. According to statistics stated at the JDC, java is now considered the number 1(C# as number 7!!). European SW industry is now heading towards using java especially at enterprise applications level.

Last but not least, java is an open source platform. The concept of open source applications will dominate within the next few years leaving no chance for closed source applications to exist, this concept ensures maximum efforts from providers to keep their products alive and also gaining money is ensured, but this is another topic which needs a whole article.

1.4 Summary

This article was a kind of seeing a small overview of java, in next articles we will get to talk about specific technologies of java hoping to really show the power of that platform

.. more.

Friday, January 26, 2007

Advanced C++ part 6 : Advanced Memory Management part 2 : malloc and new, what's the difference?

In the days of C, dynamic memory allocation was performed through the malloc() function. You just specify the number of bytes, and it returns a pointer to the allocated memory. If the memory allocation fails it will return NULL. malloc might not initialize the allocated memory.

As C++ introduced objects, there were different requirements for dynamic allocation. In old C, you usually allocate space for homogeneous arrays of the same primitive types. Even for arrays of structs, you would usually initialize them with default values, not values dependant a result of some sort of computations. In C++, constructors added the encapsulation of the initialization logic. malloc won't call any constructors, it just allocates plain bytes.

Operator new, has more information that available to malloc. It knows the type. Which enables that operator to know the size of a single objects, thus releasing you from the burden of calculating how many bytes per object you need to allocate; you just use the number of objects you need. It also makes new able to call the constructor of that type on the newly allocated memory.

In malloc you'd have to check every pointer returned by it against NULL to know if the allocation have succeeded. But in new, it does throw an exception (you can make it return NULL instead)[1]. Example:

try
{
MyClass* m = new MyClass();
}
catch(bad_alloc x)
{
// report an error
}
or you can simply do the following to prevent exception being thrown:
MyClass* m = new (std::nothrow) MyClass();
if(m == NULL)
// report an error
[1]: Microsoft implementation of new doesn't throw an exception as opposed to the standard. It does return NULL.

There is another thing you can do to handle failed allocations. There is a function that new calls when it fails to allocate. It's type [2] is new_handler; which is defined as a function that takes no parameters and returns void. The default new_handler is the one that throws the bad_alloc exception. (Thus you can modify that behaviour). To set your new_handler as the one used, you can set_new_hanlder( your_new_handler ). This function returns the old new_handler. Your new_handler is expected to do one of 3 things:
  1. Call abort() or exit()
  2. Throw bad_alloc or a type inherited from it
  3. Make more memory available for allocation by some means
[2]: function pointer type

Operator new and delete automatically call the constructor and the destructor, respectively. We will talk in a forthcoming article about some variants where you must call the destructor yourself or where you can prevent new from automatically calling the constructor so you can call it manually as an optimization in case of very large arrays.

Note: we will take later about details of exceptions and namespaces, just take it now "as is" or read about it in some reference.

Next article in this sub-series isA will talk about overriding new and delete and the reasons why you might need that practically.

References:
http://h30097.www3.hp.com/cplus/new_handler_3c__std.htm

.. more.

Thursday, January 25, 2007

Oracle Technology Day

Join Us for an Oracle Technology Day Focusing on Oracle¿s Content Management Solutions

Click here now to register for this FREE event.Don't miss your exclusive opportunity to network with your peers and discuss content management topics with Oracle experts.

Semiramis Intercontinental Hotel - Cleopatra Ballroom Cairo, EgyptSunday, 4 February 2007
Agenda
9:00 Registration
10:00 Welcome and Introduction
10:05 Keynote: Managing Content in the Enterprise Database
11:00 Break
11:15 Technical Session 1:
Content-Enabling Business Processes and Applications
12:15 Technical Session 2:
Integration of Secure Enterprise Search and Content
13:15 Wrap-up and Raffle

.. more.

Microsoft extends life of Windows XP

Microsoft announced on Wednesday that it was extending technical support for home Windows XP operating systems, a signal that it was not abandoning them for Vista software launching next week.

The Redmond, Washington software giant said the "support life cycle" for Windows XP Home Edition and Windows XP Media Center Edition would be stretched to April 2009.

Similar support would be provided for users of Windows XP Professional, according to Microsoft.

Microsoft's next-generation Vista operating system made its business debut in November and home-computer versions will be launched on January 30. Vista is Microsoft's first revamped operating system in five years.

the sourse : http://www.dnaindia.com/report.asp?NewsID=1076264

.. more.

Wednesday, January 24, 2007

Visual Studio 2005 Team System Basics Training






Brief Description
(200-level)A complete, self-paced training course with a VPC image containing Team System software.

Overview
Provides training on:

  • Overview
  • Licensing
  • Architecture
  • Deployment and Maintenance
  • Team Foundation Server Extensibility
  • Team Foundation Reporting
  • Team Projects and Process Template Customization
  • Team Foundation Version Control
  • Team Foundation Build
  • Team Edition for Software Architects
  • Team Edition for Software Developers
  • Team Edition for Software Testers

Read more

Download: Part1, Part2, part3, part4, part5, part6, part7, and part8

.. more.

Saturday, January 20, 2007

Advanced C++ part 6 : Advanced Memory Management part 1

This article was planned to talk only about "placement new" feature. But there is other interesting features in memory management in the C++ standard that are worth mentioning. So we will expand this article to a sub-series of articles talking about those features.

This (part 1) article will merely state the topics that will be discussed.

1. malloc and new, what's the difference?
2. Overriding new and delete (for a certain class or globally).
3. Placement new and performance tweaks.
4. Allocators.

Note: I've found some source on the net that contains some useful information: C++ Reference Guide; be sure to read the table of contents and browse through it (and you might find some information about linking too).

.. more.

Friday, January 19, 2007

Java Platform Overview

hi guys, hope you are all doing good.
I plan to post a series of articles about the Java platform, these articles aim at providing a general overview about the java platform with getting into very simple details about using Java technologies.
The main objective of these articels is to give java beginners a boost to quickly understand the java platform which is some how wide and complex in the begining. The Information in these articles can be found on the web but in a noncentralized manner which sometimes makes beginners confused.
I will use the same methodology that M.Nabil used in the C++ articles, at which the articels will then be assmebled to form one document.

The articles will contain the following topics:
1- What is java ?
- History
- Philosophy
- Criticism
- Syntax
2- Resources
- JRE ( Java Runtime Enviroment )
3- APIs
- J2ME
- J2SE
- J2EE
- Extra libraries.

As i said before, these topics can be found on the web, however, these articles are mainly directed to beginners, so they will be very simplified.

I hope people find these articles useful.

.. more.

NetBeans 6.0 Milestone 6 available

Milestone 6 of NetBeans 6.0 is now available for download from the development builds section.
Choose 6.0 Q-Build to get it.

What's new and noteworthy ?

- Most Java EE features re-added to the build
- UI Gestures Collector
- Tomcat 6.0.x support
- Ant 1.7.0
- Profiler: Memory Profiling Improvements - mainly around heap dumps
- Profiler: 1.4.2 Profiling Support Removed - it is better to use standard JDK than JFluid VM
- New Network Proxy Settings UI what can be shared all over IDE
- Unit Test Libraries Node
- Maven project support

.. more.

Thursday, January 18, 2007

AJAX Security Basics Live From Redmond

Live From Redmond Webcast SeriesProduced by Microsoft

AJAX Security Basics"The Building Blocks to Protecting Your Applications Built with ASP.NET AJAX"

This Webcast will demonstrate how ASP.NET AJAX works and provide real examples of the inner workings of an AJAX application. In addition, we will explore how Java script and Web services work and why securing them is critical.

In this Webcast the attendee will learn:
1) What are the underling technologies of AJAX
2) How these technologies cooperate to enhance the user’s experience
3) How AJAX works on a HTTP level

Presenters: Caleb Sima, Billy Hoffman, and Joe Stagner.
Register here

.. more.

Tuesday, January 16, 2007

Mono gets set to implement C# 3.0

Mono open-source framework team is preparing to support C# 3.0. C# 3.0 will largely be an incremental release, but it will be expanding significantly on aspects of C# 2.0 features, some of which are not yet widely implemented.Not surprisingly, fixing Mono flaws in C# 2.0 turns out to be a pre-requisite for C# 3.0 support. De Icaza points to some of those efforts in an on-line post. He also breifly discusses work underway to support LINQ.
Read more

.. more.

Monday, January 15, 2007

Advanced C++ part 5 : Calling Convention and Intermixing C and Assembly

[Note: as calling conventions are not standardized, most details are compiler/vendor/architecture dependent, so details might differ from what stated here and what is actually there. The essence of this article is to give an overview of the concept as far as the author knows it, so don't take the specific details mentioned here as a reference]

Parameters gets passed to function through the call stack. The call stack is a stack for each process (or thread) in the system. There is exactly one stack for each thread of execution. The stack is used to store the return address too, so a function knows where to return. Local variables are also put on the stack. Calling convention are responsible for the way the parameters are sent between functions.

If we have function W ( int x, int y ), will you push x first or y when calling W? well, it doesn't matter as long as the called function pops them in the correct order. Calling conventions sets how a function should be called. They don't only define the parameters ordering, they also define which function pops them from the stack; the caller or the callee. They also define how the return value is returned (i.e. via which register etc.). Name decoration differs from one calling convention to another (the same function decorated-name might differ using another calling convention in the same version of the same compiler). The C++ standard doesn't specify certain calling conventions.

There are typically 4 calling conventions used commonly (on 32bit x86 architecture; calling conventions are very dependent on the hardware architecture). Other calling conventions on other platforms or obsolete calling conventions on x86 architecture are beyond our scope (calling conventions on 64bit Intel architecture for example provide a greater performance using register windows and register stack, but we are not going to discuss that). The 4 calling conventions are cdecl, stdcall, thiscall, and fastcall. I am not going to mention every single detail about each of them, just the main points, because the more detailed the points is the more they can differ from one compiler to another [see this for details].

cdecl

This is the default calling convention. Parameters gets pushed from right to left, so the first parameter is the nearest one to the top of stack (the callee sees them in natural ordering : first argument = stack[0], the second = stack[1] etc.). The caller pops the parameters; this is useful when using variable length parameters where the callee don't know how many parameters are there.

stdcall

This is the one used by Win32 API. Remember "LRESULT WINAPI WndProc( HWND hWnd..."? The WINAPI macro is defined to equal "__stdcall" which is the MSVC compiler directive to set this function to stdcall calling convention. This calling convention is almost the same as cdecl except that the callee pops the arguments from the stack, thus there is no variable length parameters. The advantage is that it is a little faster than the caller popping it, becaue it uses a combined instruction that adds a certain value to the top-of-stack pointer before returning. If the caller pops it will take at least one more instruction.

thiscall

The calling convention used for the non-static member functions. There is a hidden parameter; the this pointer. In MSVC, this calling convention is exactly as stdcall except that the this pointer gets passed in some register (namely ECX).

fastcall

This calling convention is used rarely. It's main advantage is that it sends one or two of the parameters through registers not through the stack (the stack is in memory), thus making calls faster.

Brainteaser

Think of a calling convention that might be faster than fastcall :). You can implement whatever calling convention you like if you are using Assembly; you have direct access to the stack. I've implemented a calling convention for my recursive method for solving the 8 queens problem, it proved 0.7 seconds faster that MSVS fast call for number of queens = 15. That was when I was in first grade. It is simple; don't think too hard.

Intermixing C and Assembly code

In x86 Assembly there is no functions as we know it.You only have a stack and the memory address of the first instruction in that function. There is nothing called parameter or a return value. To call a function you just tell the processor to got execute that address. The only function support is that the return address is pushed in the stack so that you can reutrn using the "ret" instruction[1]. A function name is typically the same as a variable name, there is no syntax difference in it; they both are labels. To send parameters, you have to handle that yourself, using a predefined or a custom calling convention. To call Assemly code from your C code, you just implement a calling convention understood by a C compiler, in your function that is to be called from C source[2]. You are free of course in other functions to implement whichever calling convention you want as long as they are not called from another language.

To call a C method from assembly, you have to know the calling convention that this method implements (including name decoration)[also see 2]. Of course the the C file produces an object file, and your Assembly file produces another one. You will have to use the linker to link both.

[1]: That's the normal common Assembly. MASM (Microsoft Assembler or Macro Assembler) implements some higher-level constructs by giving you special syntax to call functions, which he then translates into the appropriate calling convention. For reference, see this link and search the page for "invoke". Off topic speaking: MASM also implements special "if" conditions and "for" loop syntax -similar to higher-level languages- that have nothing to do with Assembly. It even supports Object Oriented Programming in Assembly!

[2]: You also have to declare that "label" as global as they are not so by default (at least in NASM (Netwide Assembler.)) Function names are global be default in C and C++. A global symbol is to be written in the object file header along with it's address inside the file. A local symbol is not written at all, so the linker can only see global symbols.

Conclusion

Next article isA will be about something different than all this low-level stuff. We will start talking in the higher-level language features. Posts will be shorter and less complicated like this, I hope so. Next article will be about placement new. Google it if you wish. I am trying to follow the original order in which I specified the articles. Anyway don't forget this "Introduction" to the compilation process, because isA we will be referring to it a lot, and you will need it some article.

Further reading (finally a lot of links :D ):
C++ Reference Guide > Understanding Calling Conventions
The Old New Thing : The history of calling conventions, part 3
Calling conventions on the x86 platform
MSDN Calling Example: function prototype and call
CodeProject: Calling Conventions Demystefied

.. more.

development competition - MDC 2007


On the sidelines of MDC 2007, there are development competition to rasie awareness and excitment around the new Vista technology.

Please spread to your friends and teams or compete yourself to WIN A ZUNE PLAYER!

P.S the website will allow uploading soon and will remain even after MDC for gadgets sharing!!

http://www.mdcgadgetcup.com/



.. more.

Sunday, January 14, 2007

Microsoft Pre-release Software Visual Studio Code Name "Orcas" - January 2007 (CTP)

Microsoft Pre-release Software Visual Studio Code Name "Orcas" - January 2007 Community Technology Preview (CTP)

Thank you Gamal, you can download this CTP from download1 as self-extracting install or download2 as ISO

The highlights of this CTP include:

  • Extended, more powerful data APIs with the ADO.NET Entity Framework and LINQ to ADO.NET
    • With the ADO.NET Entity Framework developers will be able to model the view of the data that is appropriate for each one of the applications they are building, independently of the structure of the data in the underlying database. The use of the Entity Data Model (EDM) enables developers to design models that follow the concepts built into the application, instead of having to map them to constructs available in relational stores. Once the model is in place, the powerful ADO.NET Entity Framework API is used to access and manipulate the data as .NET classes or as rows and columns, whatever is appropriate for each application.
    • ADO.NET is fully integrated with LINQ and offers many options for using LINQ in various scenarios: LINQ to SQL provides direct access to database tables from the programming environment, LINQ to Entities enables developers to use LINQ over EDM models, and LINQ to DataSet allows the full expressivity of LINQ to be used over DataSets.
  • C# 3.0 Language Support: This CTP implements all of the C#3.0 language features from the May LINQ CTP including:
    • Query Expressions

    • Object and Collection Initializers

    • Extension Methods

    • Local Variable Type Inference and Anonymous Types

    • Lambdas bound to Delegates and Expression trees

  • VB 9.0 Language Support: This CTP implements all of the VB 9.0 language features from the May LINQ CTP including:
    • Query Expressions

    • Object Initializers

    • Extension Methods

    • Local Variable Type Inference

    • Anonymous Types

  • LINQ to Objects API
    • The LINQ to Objects API supports queries over any .NET collection, such as arrays and Generic Lists. This API is defined in the System.Linq namespaces inside System.Core.dll. Click here for more details about LINQ.
  • ClickOnce improvements
    • This CTP delivers ClickOnce improvements for the deployment of Windows Presentation Foundation applications, alternative browser support and ISV rebranding.
  • Managed classes for Elliptic Curve Diffie Hellman and Elliptic Curve Digital Signature Algorithm cryptographic functionality
    • With the addition of these classes, cryptographic developers now have managed classes for Elliptic Curve Diffie Hellman secret agreement and Elliptic Curve Digital Signature Algorithm signing. These classes are built on the new CNG cryptographic libraries in Windows Vista, but still follow the familiar patterns of the cryptographic classes in .NET Framework 2.0.
  • Runtime and design-time support for Office 2007 (including Outlook 2007)
    • Customers can build managed code add-ins with a consistent development experience, regardless of which version of Office they target, which Office application(s) they target, and which programming language they choose. Managed code add-ins enable developers to use strongly-typed class members, with the help of modern development tools, including intellisense and auto-complete. Additionally add-ins can potentially run in multiple versions of Office, enabled by abstracting version-specific code and supported by a version-resilient infrastructure.
  • Support for advanced lifetime management of add-ins and their AppDomains
    • We’ve added the helper classes that manage the lifetime of add-ins, the objects passed between the host and add-ins, and even of the AppDomains the add-ins live in. By using the ContractBase and LifetimeToken handle, pipeline developer can let the hosts and add-ins act as if everything, including the AppDomain the add-in was activated in, was controlled by the garbage collector even though .Net Remoting would normally make that impossible.
  • Client service support for Login/Logout, Role management and Profiles
    • ASP.NET 2.0 shipped with new application services for authentication, authorization and personalization. Most of these services are not tied to ASP.NET and can work in non-web applications. This CTP enables the use of these services in smart client applications for Logon/Logoff, Role management and profiles.
  • A trace listener that logs event to ETW, event tracing for Windows in Vista
    • Event tracing for windows is greatly improved in Vista and the most performant loggings facility available in Windows. The System.Diagnostics.EventProviderTraceListener allows managed tracing to provide events to the Vista’s ETW infrastructure. This is a highly performant, thread-safe listener.
  • Jscript Intellisense support
    • Jscript code formatting and Intellisense support provide developers with a richer editing experience. These improvements enable the IDE to provide statement completion, color syntax highlighting and in-place documentation to Jscript and associated script models such as ASP.NET AJAX.
  • A new numeric type that provides support for very large numbers (Beyond the range of In64)
    • All existing numeric types in the Framework have a limited range. This is the first type that supports arbitrary range and will extend to accommodate any large number as needed. This type lives in the new System.Numeric namespace where all new numeric and arithmetic features are going to reside. It supports all the basic arithmetic operations including things like Pow, DivRem and GreatestCommonDivisor. It implements the following interfaces: IFormattable, IComparable, IComparable<BigInteger> and IEquatable<BigInteger>. It is serliazable and immutable. It has implicit casts from all basic integral types and explicit casts to/from all numeric type. To learn more about this type – please visit the BCL team blog.
  • LINQ over XML (XLinq)
    • Enable further LINQ over XML feature support (in addition to the functionality available in the Oct 2006 CTP) such as the ability to apply XLST to transform into and out of XLinq trees, support for System.XML reader/writer interfaces for improved XML sharing with DOM applications and System.XML schema validation for XLinq nodes.

  • SQL Server Compact Edition (SSCE)
    • SQL Server Compact Edition (SSCE) provides a local relational data store for occasionally connected client applications from desktops to devices. SSCE is light weight, embeddable and is easy to deploy with your client applications without requiring complex administration work from users. Timestamp (row version id) data type, improved table designer, Query processor enhancements and support for local transaction scope are some of the new features you find in this version of SSCE.

.. more.

Advanced C++ part 4 : Name Decoration and Intermixing C and C++ Code

If a file has two functions, add(int,int) and add(float,float), how would the linker distinguish them if some other file wanted the "add" function ?
The symbol name generated in this case should not be equal to "add", it might be __add_i_i or __add_f_f. It won't equal "add" even if there is only one add function defined, in cases there might be another one defined in another file.
The compiler is the one who choses the symbol name, the linker is the one who uses it blindly. That's because the linker doesn't have the knowledge about the internal typing system of a language, or whether a language supports overloading or not (some linkers understands C++, but that's out of our scope). This enables the linking of several languages into the same executable. For example linking pascal with C or C with C++.
The operation of converting the function/variable name to a symbol is knows is name decoration or name mangling. There is no standard defining this operation, each compiler can do it in the way he likes; implementation specific. Even different versions of the same compiler can do it differently. So it might be hard to link with old object files or files generated from other compilers (That's not a bug it's a feature). Shared libraries compiled with one version of GNU GCC might not link with programs compiled with another version. Name mangling in C in simpler, it just adds add and underscore '_' before the function name (or in some cases puts the function name as it is). Surprisingly, C does NOT support function overloading. At least not in the standard, to do it you have to modify the compiler to apply name decoration yourself.
Name mangling in C++ specific features, like namespaces and classes, can look more cryptic. For example:


void x(float z){}
void x(int i){}
int main ()
{
x(8.0f);
x(4);
}


would give the symbols (on GCC 4.1.2):


main
_Z1xf
_Z1xi


but in this example:


namespace MyNameSpace
{
void x(float z){}
class MyClass { public:
static void x(int i){}
};
}
int main ()
{
MyNameSpace::x(8.0f);
MyNameSpace::MyClass::x(4);
}


would give the symbols:


main
_ZN11MyNameSpace1xEf
_ZN11MyNameSpace7MyClass1xEi


If some other file wants to call a function from these, he has to put the exact mangled name like above in his object file so the linker can find it.

If you have some old libraries written in C and you are using C++ and want to call them you have to declare them like that:

c++ source file:

extern "C" void x(int i );


or

extern "C" {
void x(int i );
int y (float z):
int f;
}


Note that you can overload these function if you didn't mark your overloaded version as external C. The extern "C" directive marks that these functions are to mangled in C way, not the C++ way. So the linker can find the right function.
That's how you could call a C function form C++.
Calling a C++ function from C can be done in 2 ways. Marking your C++ function as external C.

For example:

extern "C" void print() {
cin >> x;
cout << "this is C++ code"; }


This method can be applied only on global function, i.e. functions not members of any namespace or class.
The second method may allow you to be able to call functions inside a namespace or a static member function, but it is a manual way.
We have the function


_ZN11MyNameSpace1xEf


You will name it the same way in the C source, taking into count how will the C compiler mangle it further. Perhaps this method can make you call non-static member functions, but it requires you to send the this pointer yourself.

Next post will be about calling convention and intermixing C and assembly code.

Further reading:
Google "name decoration"

.. more.

Saturday, January 13, 2007

Advanced C++ part 3: Linking

This post isA will make the previous post clearer.
When the C++ compiler processes a source file, it generates an object file (.o or .obj file) for each source file it have processed.
The object file typically contains a series of symbols along with their implementation. For now, a symbol is a variable name, or a function name (including member functions, we will discuss calling convention and name decoration later). The symbol can be defined in that file, or marked as external symbol.
The linker operates on a group of files. Knowing what each file have defined and what each files needs from other files. The linker's mission is to put all the object files into one executable file (.bin or .exe for standalone file, and .so and .dll for dynamic link libraries, we won't talk about dynamic linking here); linking external symbols from one file to their implementation in other files, hence the name.
An example is better than 1000 words so:
say file a.cpp has the following symbols (for scientific honesty, these would not be the real symbol names generated):


main
count [this is an integer, not a function]
external add
external subtract


And file b.cpp has the following symbols:

subtract
external count


And file c.cpp has the following sybols:

add
external count


The linker would put the address of the add function of the b.cpp into the empty slot in a.cpp, same for subtract. And puts the address of count in the empty slots of b.cpp and c.cpp. And then put all the 3 files together. Now a.cpp can call the functions he wanted from the other files. Note that the real thing that happens will be more complicated but this is a simplifies version of what happens.

The moral of this story :D is to show you how the compiler can only worry about one file at a time. Note that producing an executable from source files, is 2-phase process, compilation and linking.

Next post will be about calling convention and name decoration (aka name mangling) (related to function signature), that will show how overloading occurs and what is the use of declaring the argument types of an external function not just it's name.


As Ramy have suggested:
Futher reading for the last post:
* I am sorry I tried to search google, but I didn't find something directly useful. My sources however was from reading solutions for the problems I've faced before. As a matter of fact, one statement every while and then is where I collected this info into my mind; i.e. it is not from one direct source. The most useful source however was when I was dreaming to make a C++ compiler and I read a lot about compilers, there were some hints here and there about the operation of a C compiler, not even C++. (You can read more about Makefiles and GNU Make, you need those to manage compiling large applications in a custom way, using makefiles will help you to deeply understand the compilation process- it's tedious at the beginning; a trial and error method, takes a lot of time to know these details)
Further reading for this post:
* Same as the above, I got it from diagnosing linking problems over MSDN. I.e. searching for one linking error after another. The other useful source was when I was working on the OS and I met a lot of problems because linking an OS is something totally different than a normal program (MS linker can't do it btw). I faced a problem once that I need to put the address of the main function in the first 4 KB of the executable so GRUB can read it, there were no way to enforce that in MS linker. I spent 2 weeks facing several linkers and there were linker scripts involved. There was another one where I needed to get the size of the kernel at the run-time, I didn't implement any File System yet, so I had to rely on some feature of placing some variable in the end of the kernel and getting it's address! That one I had to ask on the alt.os.development usenet group, something you won't find directly on some web page. (You can read about GNU LD for further reading, but that's would be useful if you are searching for a certain feature, not for common reading)
Further reading for the next post: (finally something that can be directly found)
Wikipedia: Name mangling
Google search: name decoration

.. more.

Friday, January 12, 2007

Advanced C++ part 2 : Necessary Introduction to the Compilation Process

Hello all of you out there :).
I know I am awfully late in putting this part, I apologize about that :$.
Anyway the issue was I have intended to put it in a book, I've already made the first chapter, but I found it too hard to make a whole book. So I've seen it should be better writing the series here then assembling it into a book.
Okay, let's start.
This article won't be so interesting, it just furnishes basics you need to understand how the program gets compiled; because that will make a difference in your understanding of why each feature was designed that way.
Our terminology here is :
source file
: the .cpp file.
header file: the .h file.
When using libraries, like cstdio, which has the printf function and cin and cout,
your program can't use them unless you include the cstdio header file (in C it was stdio.h, in C++ it is cstdio; yeah with no .h extension).
Unlike C# or Java, the C++ compiler never looks inside any other source file other than the one it is compiling right now. This means, it can't perfom any compile-time validations if you use an external function/class; as a matter of fact, it can't even produce a description of that function/class so the linker knows which function/class he wants (we will discuss linker later). This have many consequences. The first one is that this have introduced the need for header files. Header files gets included in the source file before the compiler processes it (#include is a preprocessor). So the compiler processes the preprocessed source file which includes the expanded header files; meaning the compiler doesn't understand what a header file means, it only knows what a source file means; also meaning if you #include <abc.tyr.eee.338.e8> it won't say anything. Also you can't compile a header file; it is only intended to be included in the source file.
So why don't we #include the other source files instead ? Well, there is a difference between a declaration and definition. The source file have definition, so if you included one source file inside the others, both will claim they have the code of that function, and the linker will not know which one have the right. The header file should have only declaration, which is declaring the type, not the implementation. So if two files includes the declaration, they only say that is the type we want to be linked to us, no collision because after all, some other file will be the only one to claim that he owns the implementation which will be then linked to the other files.
[NOTE: this is why a book is easier in some cases, you can add exmaples and pages as you like]

Next part will be about linkers. I think this is enough for one post.
IMPORTANT: I need feedback to know whether I should simplify more or any comment you want to say.

.. more.

Threads Synchronization

In this post, we will talk about threads synchronization and how to achieve it specially when they use shared variables at this, synchronization is very vital and must to be obtained, for whom knew Process Synchronization and its solutions i.e. Semaphore, Monitors and so on. Try to read this article it will present a light solution without using Semaphore or Monitor classes let’s start our example, actually I’ve two processes, they currently share a variable called ‘aNumber’ each of which increments it, my main job here is to achieve synchronization more than writing the code itself .

public Multithreading()//constructor
{
ThreadStart firstThreadStart = new ThreadStart(FirstThread);
Thread firstThread = new Thread(firstThreadStart);
firstThread.Start();

ThreadStart secondThreadStart = new ThreadStart(SecondThread);
Thread secondThread = new Thread(secondThreadStart);
secondThread.Start();
}
public void FirstThread()
{
for (int i = 0; i < 100; i++)
{
aNumber++;
Console.Write(aNumber + " " );
}
}
public void SecondThread()
{
for (int i = 0; i < 100; i++)
{
aNumber++;
Console.Write(aNumber + " " );
}
}

Output is :
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 8 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 101 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

If you’ve a strong notice you will find no synchronization at all, and as loop increased, you will gain worse result.

So, we try to synchronize our two processes (FirstThread and SecondThread) there are two approches, first is to use lock and the second is to use volatile

Lets start with lock

private int aNumber;
private object synch;
public MultithreadingLock() //constructor
{
synch = new object();
ThreadStart firstThreadStart = new ThreadStart(FirstThread);
Thread firstThread = new Thread(firstThreadStart);
firstThread.Start();

ThreadStart secondThreadStart = new ThreadStart(SecondThread);
Thread secondThread = new Thread(secondThreadStart);
secondThread.Start();

}
public void FirstThread()
{
lock (synch)
{
for (int i = 0; i < 100; i++)
{
aNumber++;
Console.Write(aNumber + " ");
}
}
}
public void SecondThread()
{
lock (synch)
{
for (int i = 0; i < 100; i++)
{
aNumber++;
Console.Write(aNumber + " ");
}
}
}

Output is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

As you see we got the sychnoronization we want, but what about if I’ll create more than two functions, should I write lock (…) { } block in each, C# presents volatile keyword that indicates, field may be accessed and modified by more than one thread and this approche guarntee this field has up-to-date value at all times and I do not have to write lock block

public volatile int aNumber = 0;
public MultithreadingVolatile() //constructor
{
ThreadStart firstThreadStart = new ThreadStart(FirstThread);
Thread firstThread = new Thread(firstThreadStart);
firstThread.Start();

ThreadStart secondThreadStart = new ThreadStart(SecondThread);
Thread secondThread = new Thread(secondThreadStart);
secondThread.Start();

}
public void FirstThread()
{
for (int i = 0; i < 100; i++)
{
++aNumber;
Console.Write(aNumber + " ");
}
}
public void SecondThread()
{
for (int i = 0; i < 100; i++)
{
++aNumber;
Console.Write(aNumber + " ");
}
}

Output is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 15 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

This keyword is useful when an external process (like the operating system or a thread in your application) can potentially modify the value of a field, and you need to ensure that you are reading the most current value.
Unfortunately, I cannot seem to get the C# compiler to generate code to demonstrate the differences between volatile and non-volatile memory reads, even with the optimization flag turned on. This is probably because of poor optimization in C#. [Said by: Marc Clifton on http://www.codeproject.com/csharp/modifierkeywords.asp ]

So, I see to get true synchronization you should use lock block

Yes, I mean to now write more than that to let you read more by yourself.
Your comments are welcome

.. more.

Java Developer Conference

.. more.

MICROSOFT MIDDLE EAST DEVELOPERS CONFERENCE 2007 MDC 07



.. more.