DCSIMG
January 2008 - Posts - Pavel's Blog
Sign in | Join | Help

Pavel's Blog

Pavel is a software guy that is interested in almost everything
software related... way too much for too little time

January 2008 - Posts

Spec# - the successor to C#?

Published at Jan 31 2008, 02:51 PM by pavely

An interesting project from Microsoft Research called Spec# ("spec sharp"), is a programming system consisting of a an extension to the C# language that extends the CLR type system with various new features, all designed to enforce safety, hopefully resulting in "high-quality software" (at least this is the aspiration). The downloads include a plugin for VS 2005 that includes the compiler and several samples. Who knows, maybe this is the next great thing?

Natural Language Processing (NLP) Library

Published at Jan 17 2008, 03:26 PM by pavely

בעיני התחום של הבינה המלאכותית (Artificial Intelligence, AI) הוא התחום המרתק ביותר בעולם המחשבים. אחד התת-תחומים המעניינים בו הוא הנושא של עיבוד שפה אנושית (Natural Language Processing - NLP). הנושא מורכב (בגלל מורכבות והרב משמעותיות של השפה האנושית) אבל מרתק. ספרייה מעניינת המבוססת על .NET 2.0 נקראת Proxeme וניתנת להורדה כאן (לאחר רישום קצר). הספרייה מאפשרת לבצע פעולות נפוצות בעולם של NLP כגון POS tagging, semantic analysis ולבסוף parsing מלא. הספרייה מאד מרשימה, וכרגע תומכת בשפה האנגלית בלבד (בעתיד מתוכננות שפות נוספות). שווה בדיקה!

 

 

Interesting .NET Library

Published at Jan 06 2008, 06:16 PM by pavely

 An interesting library I came across a few months ago: AForge. AForge is a .NET 2.0 based library (licensed under the GNU General Public License) that includes sub-libraries, such as Imaging (various filters, image manipulations), Genetic algorithms, Artificial Neural Networks (ANNs), machine learning algorithms, Video (including some DirectShow support) and computer vision. It can help in research in various AI and image processing fields. A few articles on using the library can be found at CodeProject. A must for those who don't think that pure software technology is everything.

ThreadPool and Robotics Studio

Published at Jan 06 2008, 01:23 PM by pavely

 

בעולם של ה-CLR לא קשה לבצע פעולות אסינכרוניות. למשל, כל delegate תומך אוטומטית בהפעלה אסינכרונית ע"י BeginInvoke ו-EndInvoke. מי שצריך לעבוד ללא delegate יכול להשתמש ב-ThreadPool שלו מספר מתודות סטטיות להפעלת method בצורה אסינכרונית. הבעיה ב-ThreadPool היא שהינו יחיד. כלומר, אם יש מצב שבו יש באפליקציה שתי סוגי בקשות, אחת בעדיפות רגילה ואחת בעדיפות גבוהה, הן ייזרקו לאותו תור שמנהל את הבקשות האסינכרוניות, ואם לדוגמא, יש 100 בקשות רגילות בתור ואז צריך להעביר בקשה בעדיפות גבוהה, הבקשה תאלץ לחכות עד לטיפול של ה-100 הקודמות (כי ה-ThreadPool לא ייצר 100 Threads). מה עושים?

ב-Windows Vista קיים API חדש המאפשר לייצר Thread Pool פרטי (CreateThreadPool) ולעבוד איתו. לכן, פתרון אחד (בויסטה) יהיה לעטוף את ה-API בעטיפת דוט נט דרך P/Invoke או C++/CLI.

דרך אחרת היא שימוש בחבילת Robotics Studio. חבילה זו כוללת יכולת לבנות מודלים של רובוטים (בתוכנה בלבד אן עם חיבור לרובוט פיזי) ושליטה בכל מיני רמות - חבילה מאד מעניינת כשלעצמה.

בלי קשר לרובוטיקה, החבילה כוללת ספריה שנקראת (CCR (Concurrency and Control Runtime שהיא אוסף של טיפוסים המהווים מנגנון מתוחכם לניהול של בקשות אסינכרוניות. בין השאר קיימת האופציה לייצר Thread Pool פרטי ולפתור את בעית הבקשות עם העדיפויות השונות, ויש שם עוד הרבה דברים טובים שהם הרבה יותר מתוחכמים מאשר ThreadPool.QueueUserWorkItem. היופי הוא שניתן להשתמש ב-CCR ללא כל קשר לרובוטיקה.

מאמר התחלתי טוב ניתן למצוא ב-MSDN magazine בקישור הבא.

 

COM without registration

Published at Jan 06 2008, 09:36 AM by pavely

Those still using COM know that COM components must be registered in the Windows Registry to be workable. Sometimes this may not be acceptable. Sometimes you might want to run an application that may be using many COM DLLs, but don't want or can't (because of some policies) to register the components. Sometimes you want to run an application on some client's machine without any setup. Can this be done? Off the bat, that seems impossible. But there is actually a way.

What I've done in a project (it was done a few years back) was this: when the main executable runs, it registers itself as a COM surrogate using ::CoRegisterSurrogate. After that it walks a list of all CLSIDs that are expected, loads the corresponsing DLL using the usual ::LoadLibrary and calls ::CoRegisterClassObject with a generic class factory and the REGCLS_SURROGATE flag. this makes the generic class factory (a simple class implementing IClassFactory) the universal creator.

Now, every time some code (in the EXE or in another DLL!) calls the usual ::CoCreateInstance (or CComPtr<> equivalents, or even a VB DLL calling CreateObject or New), the generic class factory returns the correct instance based on the requested CLSID.

I have used this method successfully for my company's purpose - send demo CDs that require no installation and no registration.

If anyone is interested in the actual code, let me know and I'll post it.

Like Don Box said: "COM is Love!" , but (I add) "sometimes a surrogate is needed"

 

Upcoming .NET 3.x course

Published at Jan 01 2008, 09:09 AM by pavely

 

לכל המתעניין, אני מעביר קורס בשם Essential .NET 3.0 (מספר 4191) במכללת הייטק בתאריכים 20,21,27,28 בינואר, 3 בפברואר (יומיים WCF, יומיים WPF ויום WF) שכשמו כן הוא - היסודות של טכנולוגיות .NET 3.x. לפרטים נוספים ניתן לפנות למכללה, או לאתר (http://www.hi-tech.co.il/college).