r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Topaz] The Topaz Language

Janko
12-Nov-2011
[234x2]
Hm.. i know now why I was looking at it this way. Because when I 
make a error in javascript now, browser shows me some line of code 
where it happened and I use that to know where to start fixing. Basically 
I usually can fix it imediatelly based on that info. 


If source lang. would be giving me for example line comments with 
source topaz code (I know it's not 1to1 but still) so I could aprox 
locate the same code in topaz it would be helpfull in this case
or if functions/var names would have some resemblance of topaz ones 
where possible instead being some hashes or random (could be related_topa_name_random_stuff) 
it would also help
Robert
12-Nov-2011
[236x3]
Geomol, interesting. I do the same. I have used a debugger 15+ years 
ago.
Only if you have real hard stuff, with multi threading, register 
stuff etc. the print statements are becoming to much work to do.
But normal stuff... no debugger needed.
Gabriele
14-Nov-2011
[239x2]
Janko, there are two cases here:

1) debugging the interpreter itself

2) debugging your own code (for eg. a web app written in Topaz)


I think that (2) is what interests you - in that case, you use the 
interpreter during development, so it's just the same as debugging 
in REBOL (well, I hope to provide a few more tools, but even without 
debugging REBOL code is not that difficult most of the time). Think 
of compilation as an optimization step, that you do only for production 
deployment etc. and only for some parts of your code (the parts where 
performance is important).
(Currently, if you look at the JS source, you'll see that names are 
kept from Topaz, so it's easy to debug; I don't think i'll keep this 
in the end for various reasons, but at that point i'll probably write 
some tools for debugging the interpreter itself and any other compiled 
code)
BrianH
19-Nov-2011
[241]
Gabriele, have you tried using Topaz with some kind of app packager 
like PhoneGap?
Gabriele
21-Nov-2011
[242]
Not yet, there's no point at this time. But, there's no reason why 
it could not work. It should also be not that difficult to get it 
to work with Appcelerator Titanium.
Pekr
22-Nov-2011
[243]
Oldes in Other languages group - "Hm.. i gave it a try and must say 
that Topaz is much more interesting." So, I would like to ask - is 
there any progress lately? Is Topaz already usable for real-life 
code? An what is an speed overhead in doing some app in Topaz in 
comparison to direct JS execution?
Gabriele
23-Nov-2011
[244]
Progress: I added the action! datatype, and am preparing to write 
the "real" compiler. i was hoping to start that this week but it's 
starting to seem very unlikely. sleep is starting to seem unlikely 
this week. :)

Being usable: no.

Speed: currently, you can use the "Fake Topaz" dialect and map 100% 
to JS; the interpreter is of course much slower. When 1.0 is ready: 
i don't think there will be reasons to worry about performance.
Pekr
23-Nov-2011
[245x2]
What's going to be a usage scenario though? I will have to compile, 
in order to get reasonable performance? I mean - I develop in Topaz, 
but client gets clean JS?
Or is that like this? : When user hits the website, Topaz "libraries" 
are being downloaded (language, compiler, actual app). When you inspect 
the source of the website, you can see real Topaz code, not a JS. 
This code is being compiled by JS engine for further usage, so the 
first run is kind of slower, but then it runs fast = compiled?
BrianH
23-Nov-2011
[247]
Can you make a compiler/interpreter written in JS that can automatically 
handle script blocks that have the right language set?
Andreas
23-Nov-2011
[248]
Brian: yes. See e.g. http://jashkenas.github.com/coffee-script/#scripts
BrianH
23-Nov-2011
[249]
Cool. Nice capability to add to Topaz... :)
Gabriele
24-Nov-2011
[250x3]
Brian: I did that in JR in 2007.
Petr: actually, you have the choice to do whichever you want. For 
a production web site precompiling the performance-critical parts 
is probably the best way.
note that in practice, you'll have a dialect that specifies the whole 
web application, and when you deploy it to production, you get html, 
css, js etc. generated. but, nobody forces you to use the dialect.
Marco
26-Nov-2011
[253]
How can I try topaz in Windows? Is the try-topaz.html page the only 
method? Is there a way to write a topaz program with a text editor 
and then execute it in some way?
BrianH
26-Nov-2011
[254]
Well, Topaz compiles to or is interpreted in JavaScript at the moment. 
There are several ways to run JS on Windows outside of web browsers 
- it is one of the ActiveScripting languages, so you can use cscript, 
for instance - or you can load the Topaz environment in a web page, 
which can be a local html file with no web server needed. None of 
this is tested yet, of course, so be sure to tell us how well that 
works for you :)
Pekr
26-Nov-2011
[255]
Could I have the option, that editing html page, I would see the 
topaz (on client), and once run, it compiles at that time?
PeterWood
26-Nov-2011
[256]
I wrote some notes on how to get and install Topaz at https://github.com/giesse/Project-SnowBall/wiki/Topaz-:-Getting-Started


There a little old but should still work. If not please let me know.
Gabriele
27-Nov-2011
[257]
Peter's how to should work. Or, just use a real operating system. 
:P
BrianH
27-Nov-2011
[258x4]
He was asking about how to run Topaz outside of a browser. All of 
the suggestions I made above apply to Linux as well, except you have 
to install your own JS interpreter instead of using the one that 
comes preinstalled on Windows. So, it's a bit harder on your "real" 
operating system.
Oh, I see, you're installing a JS interpreter on Windows as well 
instead of using the built-in one, or even one that is made for Windows. 
Makes sense.
OK, good, there's a node.js for Windows now (Cygwin doesn't count): 
http://npmjs.org/doc/README.html#Installing-on-Windows-Experimental
A proper installer too, the latest version: http://nodejs.org/dist/v0.6.3/node-v0.6.3.msi
Kaj
27-Nov-2011
[262]
My guess would be that most Linux distros have about five JS interpreters 
preinstalled by now
Gabriele
28-Nov-2011
[263]
Brian... Windows is the odd one around, all the other operating systems 
just require installing a package. But, if windows has a built in 
JS interpreter, and if it is standard (and I don't mean the 1998 
standard at that), then you can run Topaz on it.
BrianH
28-Nov-2011
[264]
It appears to be standard (it's the one in IE, so if you have IE9 
it is as standard as V8). However, it doesn't seem to have one of 
the objects or functions that Topaz's bootstrap depends on. Some 
time I'll try to do a proper port. In the meanwhile, Node just requires 
installing a package on Windows (at least as of the last couple months), 
so any Cygwin-related criticism can be ignored now :)
Gabriele
29-Nov-2011
[265]
missing object: look at the source of try-topaz.html. what you need 
is probably there.
Gabriele
1-Dec-2011
[266]
I don't have string parsing in Topaz yet, but I wanted to illustrate 
how what Endo is asking in the Parse group would be much easier:

Topaz Interpreter - (C) 2011 Gabriele Santilli - MIT License
>> b: ["bla" 1 2 "bla"]
== ["bla" 1 2 "bla"]
>> parse b [collect any [keep number! | skip]]
== [1 2]
Geomol
1-Dec-2011
[267]
Looks simple. Cool!
Pekr
2-Dec-2011
[268]
Cool, I want collect/keep in R3 too :-)
PeterWood
2-Dec-2011
[269]
>> parse b [collect any [keep number! | skip]]
== [1 2]


Very interesting. What would be returned if the parse rule was more 
complicated and "failed" (ie would have returned false in REBOL).
Gabriele
2-Dec-2011
[270x2]
If it fails, it returns none.
PARSE works in a similar way to DO, in that it returns the last "result". 
I will document this in detail before a 1.0 release. There is a slide 
in my september presentation about PARSE vs. INTERPRET which explains 
why I went this route.
PeterWood
2-Dec-2011
[272]
Thanks, Gabriele
BrianH
2-Dec-2011
[273]
Does it return the subject series at the position of the last result, 
or does it return the last recognized pattern as a value?
Gabriele
3-Dec-2011
[274]
Brian, each "rule" has two effect: it advances the series, and returns 
a result. Most rules return the matched value, but not all. Examples:

>> parse [1] [number!]
== 1
>> parse [1 2 3] [number! number! number!]
== 3
>> parse [1 2 3] [some number!]
== 3
>> parse [1 2 3] [object [a: number! b: number! c: number!]]
== object none [
==     a: 1
==     b: 2
==     c: 3
== ]

>> parse [1 2 3] [object [a: number! b: object [c: number! d: number!]]]
== object none [
==     a: 1
==     b: object none [
==         c: 2
==         d: 3
==     ]
== ]
BrianH
3-Dec-2011
[275]
Seems a bit like a cross between a destructuring matcher and regex. 
Useful.
GiuseppeC
15-Dec-2011
[276]
Hi, I am interested into building an maintaining documentation for 
those programming languages based on REBOL.
It would be nice to have a DOCBASE for them.
What I search is:
- Someone ABLE to SETUP the Linux and the Wiki Software
- Someone which would share with me the cost of hosting.
Do you like the idea ?
Write me at [giuseppe-:-chillemi-:-eu]
Gabriele
16-Dec-2011
[277]
Note, the Topaz specific wiki is on github: https://github.com/giesse/Project-SnowBall/wiki
AdrianS
7-Feb-2012
[278x2]
Gabriele, you might want to update the Getting Started page on github 
in relation to using Topaz with Windows. The situation is much improved 
now that there is an official Node installer (also includes npm).
so you don't need to mess around with Cygwin anymore
Gabriele
8-Feb-2012
[280x2]
Thanks, I don't really use Windows so it's hard for me to keep up 
to date on that front. Peter already said he's going to update the 
wiki; if anyone else wants to help, I believe github allows a fork 
approach to the wiki as well, otherwise I can add you to the main 
wiki to edit it directly.
Also, you only really need to install node etc. if you want to work 
*on* Topaz, otherwise you can use any web browser to just *use* Topaz, 
like in the try-topaz.html example.
Henrik
8-Feb-2012
[282x2]
I wonder if it makes sense to allow REBOL to call try-topaz.html, 
although it would be calling JS code? Then you could mix Topaz with 
REBOL for tests, etc.
res: topaz [1 + 2]