World: r3wp
[Red] Red language group
older newer | first last |
Kaj 26-Aug-2011 [3085x2] | http://red.esperconsultancy.nl/Red-GTK |
It doesn't do much yet, but you can reference it for testing purposes | |
Kaj 30-Aug-2011 [3087x2] | I had to go through the Blogger registration process again to post a comment |
Anyway, there's a new commenter to the last article | |
Dockimbel 31-Aug-2011 [3089x3] | Thanks for posting an answer while I wasn't available. I will add more to it today. Btw, I guess this is one of the two young coders that contacted me on IRC to help building Red. :-) |
And thank for mentioning Red in your interview, once again, that boosted Red visibility significantly. | |
About Blogger: this platform is a real PIA in many ways. When I will have some time, I will look at how to move out, probably going to WordPress, or setting up my own blog using the script from Cheyenne's web site (I would need to integrate an anti-spam service like Akismet in such case). | |
Kaj 4-Sep-2011 [3092x5] | I am proud to present my first Red/System dialect, for GTK. Here's an example of a window with a title, an icon, a label, an input field and a button with an associated action function: |
http://red.esperconsultancy.nl/screenshots/Red-System-GTK.png | |
I demonstrated it yesterday at SylCon | |
Hello World would be: | |
gtk-begin gtk-view window [label "Hello, Red world!"] | |
Dockimbel 4-Sep-2011 [3097x2] | Wow! :-) |
I see now what you meant by making dialects in Red/System! | |
Kaj 4-Sep-2011 [3099] | I am surprised myself at how far you can get. I'm pretty certain this is now the most concise and efficient GTK binding in existence |
Dockimbel 4-Sep-2011 [3100] | That's really a smart use of 'typed function attribute. |
Kaj 4-Sep-2011 [3101] | Thanks :-) |
Dockimbel 4-Sep-2011 [3102] | Is 'fixed a function call in the dialect? |
Kaj 4-Sep-2011 [3103x2] | Yes |
So it's a sort of static dialect. Red dialects will be much more dynamic | |
Dockimbel 4-Sep-2011 [3105x2] | That's very nice work Kaj! |
What was the audience reaction about that? | |
Kaj 4-Sep-2011 [3107x2] | Thanks. I've been talking about such techniques for many years in Syllable and in general, and nobody will ever believe me. I'm very happy to now have a tool to show them |
The audience... sigh. They were friends, but there was only one programmer, formerly C++ and now Python. I asked him beforehand how long he thought his equivalent Python program would be. He didn't seem to be much into GUI programming, but he maintained it would be only ten lines... | |
Dockimbel 4-Sep-2011 [3109] | How big is the GTK dialect implemenation? |
Kaj 4-Sep-2011 [3110x3] | If that is so, it is in some mystery Python binding that is hidden very well. In the known PyGTK binding, it would be 2.5 to 3 times as long, with a lot of boilerplate code inbetween |
The binding is currently 900 lines. The dialect implementation is 300 of that, but almost half of it is not used in this example | |
It will become much bigger when you support significant parts of GTK | |
Dockimbel 4-Sep-2011 [3113] | Do you think that adding a symbol! type would be a big help for building such dialects at this point? |
Kaj 4-Sep-2011 [3114x10] | Yes, but it occurred to me a day or two ago that it can be done simpler, if you support first class constants, which I would like anyway |
The gtk-position-center is the only #define in the example, the other words are function calls | |
So it's an integer, while there are already two integers for the size. Because they can be required to be adjacent, you can detect one more integer if it's at the proper distance of the pair, but that's the limit | |
You also have to use a complicated word, because defines of simple words could mess up the program elsewhere | |
To use center instead of gtk-position-center, you'd have to do: | |
center: 1 | |
for example and then check for that code. But you'd get a manual sort of symbol table that would take space | |
If you could do | |
center: constant 1 | |
and have constants be real types that you can check for, you'd be able to stretch simple dialects a lot further | |
Dockimbel 4-Sep-2011 [3124x2] | Supporting first class constants would require to duplicate all existing types... I was thinking recently about adding a PROTECT keyword that would allow to mark any variable as immutable, so they would act as constants. But I guess that such option wouldn't help much for dialects, unless I would also add a PROTECTED? keyword to detect them. |
Also, some kind of namespace support should also help implement more cleanly Red/System-level dialects. I might need that too for Red's runtime as it will grow much bigger than initially planned, due to Red compiling to Red/System. | |
Gregg 4-Sep-2011 [3126] | Very nice Kaj! |
Henrik 4-Sep-2011 [3127] | cool, Kaj |
Kaj 4-Sep-2011 [3128x6] | Thanks |
Doc, for dialects I only need constant integers. The immutability doesn't matter much, so it's more like the symbol! you suggested, but with control over the internal value | |
Namespaces would be good, too | |
Enumerations would also help; they're sort of a namespace type for constants | |
Note that to make the dialects more powerful, I'm making use of GTK's object system, that allows you to check types. So I can distinguish between different Red structs | |
If you would want to support that in Red/System itself, you'd need some sort of user defined type | |
Dockimbel 4-Sep-2011 [3134] | I think that extending the RTTI system to distinguish different type of structs (or at least aliased structs) should be doable without that. Aliases are already a form of user-defined type. |
older newer | first last |