You must be logged in and have permission to create or edit a blog.
|
|
Author:
|
Yingle Jia
|
Created:
|
8/28/2006
|
|
|
ACF, C++, C#, .NET
|
By Yingle Jia on
3/1/2005
What is delegate?A delegate represents a callable entity. In the .NET world, a callable entity is either a static method or an instance method plus an object reference. In C++, function objects are also callable entities, e.g.:
struct Foo { void operator()() { ... }};
Foo f;f(); // calls operator()
Since function objects can contain state, they are much more useful than static functions. Thus a delegate class written for C++ must provide first class support for function objects.
.NET also supports chaining delegates via Delegate.Combine and Delegate.Remove methods. Multicast delegates are commonly used for events.
The old designIn previous versions of ACF, the delegate design is just a simple porting from the .NET framework. Here is an example:
static void F() { ... }
RefPtr > d = new Delegate0(&F);d->Invoke();
The old design has the following drawbacks:- Performance. In the old design, delegates are reference types and are allocated on heap. This leads...
Read More »
|
By Yingle Jia on
1/30/2005
Hello readers,
Recently I was a little busy and stopped blogging. Some readers mailed me asking whether I'll continue working on ACF or not. The answer is absolutely yes. However, I have to be very careful on future directions and certain technique issues before this framework is wide spread (I hope^_^). That's why I'm not going to emit many releases/documents before I spend enough time thinking and trying. Here are some thoughts on relation to the .NET framework and portability. Your feedback are always welcome.
Relation to the .NET frameworkAt the begining of this project, my initial thought was to bring the .NET framework to standard C++, so I tried hard to mimic nearly everything in the .NET framework, e.g. single inheritance, heap allocation, boxing/unboxing. However, practice proved this is not the right direction. People using C++/C# are developing very different kind of applications, a C++ framework has to be a thin wrapper around OS interfaces to give C++ developers performance and control,...
Read More »
|
By Yingle Jia on
11/28/2004
Hello guys,
Recently I got a new job (software engineer) at IBM China Software Development Lab (CSDL) located in Beijing, China. My job responsibility is development of IBM Workplace rich client (which I think is cool). I'll work on various platforms including Windows, Unix, Linux and MacOX, and use C++/Java. So I'll try to port ACF to other platforms in the future - isn't writing a portable C++ framework challenging and interesting? :-)
|
By Yingle Jia on
11/28/2004
Since I published ACF, I got a lot of feedback from C++ guys. There are positive ones, such as:
Nice job!...
...your framework looks pretty cool...
And also negative ones:
...single root inheritance, huge class tree, virtual functions everywhere... it looks like another OWL/MFC/VCL/AWT...
Great idea, but it is too simple and too hard to use...
Well, I like feedback (including criticisms), since they tell you where you can improve. So recently I spent no time working on new features, but on correcting ACF (to make it more C++ smell and easy to use).
In the past versions, I have been focusing on porting the .NET framework libraries to standard C++ (you see I tried to keep the classes, methods, etc. as close to the .NET ones as possible). However, this partly failed, because C++ and CLR are really very different models, simple porting will not work well (practice proved this).
o CLR has an unified type system, all types inherit from the single root - System.Object....
Read More »
|
By Yingle Jia on
11/9/2004
Recently I spent some time playing with GCC 3.2 on Win32 (I used Dev-C++ with Mingw port). Now ACF compiles and runs OK, which is much easier than I thought (actually only a little code was modified) :-). The upcoming release of ACF will include Dev-C++ project files (well, I don't like make files though they are not hard to make) so you can build and use it with GCC on Win32.
|
By Yingle Jia on
11/6/2004
The .NET team tried hard to make the .NET framework API consistent. They did a great job, however, there are still some design and naming inconsistency. The following items will be addressed in the next version of ACF.
- Factory vs. Constructor for parsing Most classes in the BCL use the Parse pattern for parsing.
int i = int.Parse(“35”); DateTime d = DateTime.Parse(“10/10/1999”);
However, the Guid structure does not follow this pattern:
Guid g("1234567890123456789012");
Which shall be:
Guid g = Guid.Parse("1234567890123456789012");
- Naming convention
Just list a few: ASCIIEncoding => AcsiiEncoding UTF8Encoding => Utf8Encoding System.IO => System.Io ...
|
By Yingle Jia on
11/4/2004
Recently I did some design refactoring to make ACF more C++ friendly (which means syntax, performance and control). This time let's take the Stream class as an example. In the .NET framework, the Stream class's main reading/writing methods are as follows:
class Stream{ abstract int Read(byte[] buffer, int offset, int count);
virtual int ReadByte() { byte[] buffer = new byte[1]; int n = Read(buffer, 0, 1); return (n == 0 ? -1 : buffer[0]); }
abstract void Write(byte[] buffer, int offset, int count);
virtual void WriteByte(byte value) { byte[] buffer = new byte[1] { value }; Write(buffer, 0, 1); }};
As you can see, the Stream class does not use unsafe code in order to be type-safe. However, the ReadByte/WriteByte methods have to be virtual and be overrided by subclasses, otherwise a temporary array will be created each time ReadByte or WriteByte is called. Another limitation is that you cannot directly read/write structures...
Read More »
|
By Yingle Jia on
8/13/2004
Here are the items that I'm planning to add in ACF 0.4:
- DateTime parsing & formatting
- Simple XML reading & writing
- Threading update
The only problem is that I don't have enough time to work on them. These are quite a lot of work, and I, like you, have jobs to do. Some friends of mine told me that they would like to contribute if they have time - hope they could find some spare time. :-)
Your feedback and suggestions are always welcome.
|
By Yingle Jia on
6/23/2004
How Microsoft Lost the API War. Though a little long. :-)
|
By Yingle Jia on
6/19/2004
Base types parsing and formatting are updated in ACF
0.3. For example, the following code shows how to format integer using various
formats:
Int32 n = 123456789;
Console::WriteLine(n.ToString(L"C")); // $123,456,789.00
Console::WriteLine(n.ToString(L"E")); // 1.234568E+008
Console::WriteLine(n.ToString(L"P")); // 12,345,678,900.00%
Console::WriteLine(n.ToString(L"N")); // 123,456,789.00
Console::WriteLine(n.ToString(L"F")); // 123456789.00
The following function formats file sizes as shown in
Windows Explorer (e.g. "3,012 KB"):
StringPtr FormatFileSize(int64 size) {
Int64 kb = size / 1024;
if (size % 1024 != 0)
kb++;
return kb.ToString(L"N0") + str(L" KB");
}
...
Read More »
|
|
|
|
|
|
|
|
|
|
Host your weblog here at WWWCoder.com for free. Just sign up for membership and you'll see a link on the left which will allow you to create your own weblog. We do ask that all blogs have a technical theme and be in English.
|