Once upon a time libraries could be written in different languages and combined together with a magical thing called a linker.
(well except that C/Fortran array thing, and C++'s name mangling...)
Then interpreted scripting languages came along...
All of the various scripting languages can talk to C libraries, but they can't talk to each other.
As far as I can tell for one scripting language to use code written in another scripting language is something like XML-RPC, SOAP, or some other custom network layer.
I was hoping that there would be a common mutli-language bytecode interpreter that would let different scripting languages call libraries written in other languages.
For example it would be really useful to be able to use some CPAN in my python programs. (Not to mention making it easier for people to transition from one language to another.)
From http://en.wikipedia.org/wiki/.NET_Framework
.NET always uses JIT, JVM is optional "The namespaces provided in the .Net Framework closely resemble the platform packages in Java EE API Specification both in style and invocation."
http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java
(You can read that yourself)
The quick summary, is C# learned from the experience of "Java and Delphi". The wikipedia article suggested that C# is more feature-full than Java. But possibly at the expense of trying to be too trendy.
To me the big interesting difference is how Java and .NET development are handled.
Sun has a community process where people can submit proposals though Sun retains veto rights.
Microsoft handed the core portions of .NET to ECMA for standardization.
A standard made it easier for Mono.
(Or at least downloading mono)
The latest release builds are at
http://www.mono-project.com/Downloads
Unfortunately for me the OS X version doesn't come with GTK#. Also the assumption for Mono on OS X is that you'll use Gtk under X11.
http://developer.imendio.com/projects/gtk-macosx/
Has a useful little script to build all the dependencies for Gtk and then builds a native version for OS X
curl -O http://people.imendio.com/richard/gtk-osx/files/build-gtk.sh # handles XML-Parser & pkg-config ./build-gtk bootstrap ./build-gtk build
For some reason they defaulted to installing everything to /opt/gtk
It was a little bit annoying to find the page describing how to check mono components out
http://www.mono-project.com/AnonSVN svn co svn://svn.myrealbox.com/source/trunk/$MODULE_NAME
The project page is at http://gtk-sharp.sourceforge.net/ but the source is at
svn co svn://svn.myrealbox.com/source/trunk/gtk-sharp
Gtk# replaced the traditional gnome ./autogen.sh with
./bootstrap-2.10 --prefix=<destdir> make make install
I tried my little Hello.cs program to see if Gtk# was installed--
It failed.
After reading about the Global Assembly Cache
Buried deep in /opt/gtk/lib/mono/gac/gtk-sharp/2.10.0.0__35e10195dab3c99f was a magic little file, gtk-sharp.dll.config
<configuration> <dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.0.dylib"/> <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.0.dylib"/> <dllmap dll="libatk-1.0-0.dll" target="libatk-1.0.0.dylib"/> <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.0.dylib"/> </configuration>
more docs on dllmap Interop with Native Libraries
It died again, this time not finding the right library.
So why did the gtk on os x people pick /opt/gtk again?
export LD_LIBRARY_PATH=/opt/gtk/lib
I grabbed one of the snapshots from http://mono.ximian.com/daily/ and tried building.
get-monolite-latest, by hand
cd ${monosrc}/mcs/class/lib
curl -O http://mono.ximian.com/daily/monolite-latest.tar.gz
tar xzvf monolite-latest.tar.gz
mv monolite-[0-9]* monolite
cd ${monosrc}/mono
make
There's a change in the defines for the mach thread handling in the 10.4u sdk (XCode 2.4) needed for Intel 64 bit, which breaks mono.
Allan Hsu submitted a patch which fixed this
http://lists.ximian.com/pipermail/mono-devel-list/2006-October/021060.html
IronPython 1.0.1 is included in the mono distributions, but since I built from source...
http://www.codeplex.com/IronPython http://fepy.sourceforge.net/
White Text
Two solutions
Swap fgcolor and bgcolor in Mono mcs/class/corlib/SystemTermInfoDriver.cs line 74,75
--- old-mcs-1/class/corlib/System/TermInfoDriver.cs 2006-11-15 22:28:57.000000000 -0800
+++ new-mcs-1/class/corlib/System/TermInfoDriver.cs 2006-11-15 22:28:57.000000000 -0800
@@ -71,8 +71,8 @@
string origPair;
string origColors;
string cursorAddress;
- ConsoleColor fgcolor = ConsoleColor.White;
- ConsoleColor bgcolor = ConsoleColor.Black;
+ ConsoleColor fgcolor = ConsoleColor.Black;
+ ConsoleColor bgcolor = ConsoleColor.White;
string setafcolor; // TODO: use setforeground/setbackground if available for better
string setabcolor; // color mapping.
bool noGetPosition;
Console.ForegroundColor = ConsoleColor.Black at src/IronPythonConsole/SuperConsole.cs:33
--- old-ironpython/Src/IronPythonConsole/SuperConsole.cs 2006-11-15 22:31:29.000000000 -0800
+++ new-ironpython/Src/IronPythonConsole/SuperConsole.cs 2006-11-15 22:31:29.000000000 -0800
@@ -30,6 +30,7 @@
public ConsoleColor ErrorColor = Console.ForegroundColor;
public void SetupColors() {
+ Console.ForegroundColor = ConsoleColor.Black;
PromptColor = ConsoleColor.DarkGray;
OutColor = ConsoleColor.DarkBlue;
ErrorColor = ConsoleColor.DarkRed;
Once I could see what I was doing I thought I might try to explore a bit.
Until I made a mistake 6 characters in and hit backspace--and got ^? instead of an erased character.
-# On Debian GNU/Linux, `<--' (Backspace key) should send char `\177': -bindkey -k kb stuff "\177"
It works!
Since IronPython is tied to VisualStudio and uses some VisualStudio specific source code control system I eventually wanted more recent versions than 1.0.1
Each download link asks you to agree to the license, and provides a copy of the whole source tree.
Yep, no diffs.
Gtk-Sharp Project Information Gtk-Sharp Tutorial
using System;
using Gtk;
public class GtkHelloWorld {
public static void Main() {
Console.WriteLine("HelloWorld");
}
}
// build with
// mcs -pkg:gtk-sharp-2.0 helloword.cs
Mono has a heavy reliance on pkg-config, a useful tool which appears to have popped out of gnome.
The first time I tried building that C# program it failed being unable to find gtk-sharp-2.0
Until I did:
export PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig
import sys
import System
import clr
clr.AddReference("gtk-sharp")
import Gtk
def main(argv):
System.Console.WriteLine("HelloConsole")
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
Application.Init();
//Create the Window
Window myWin = new Window("Hello");
myWin.Resize(200,200);
//Create a label and put some text in it.
Label myLabel = new Label();
myLabel.Text = "Hello World!!!!";
//Add the label to the form
myWin.Add(myLabel);
myWin.ShowAll();
Application.Run();
Gtk.Application.Init()
# Create Window
win = Gtk.Window("hello")
win.Resize(200,200)
# Create Label
label = Gtk.Label("Hello!")
win.Add(label)
win.ShowAll()
Gtk.Application.Run()
def click(obj, args):
print "Goodbye"
def quit(obj, args):
Gtk.Application.Quit()
# and replacing the Label stuff
win.DeleteEvent += quit
# Create Button
button = Gtk.Button("Hello!")
button.Clicked += click

