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

World: r3wp

[World] For discussion of World language

Geomol
5-Dec-2011
[387]
That can be handled with system/version/variation, which I'll add.
BrianH
5-Dec-2011
[388x3]
Then you might consider having the platform be a word of just the 
platform name, but also include a platform-plus-hardware word in 
a different field. This would make specialty code that switches on 
the OS (for API stuff) or full platform (for selecting native code) 
much easier to write.
So platform: 'windows but variation: 'windows-intel-32
Or whatever your naming convention is.
Geomol
5-Dec-2011
[391x4]
I see your point. It's not easy to find a good way, that is sure 
to cover all future possibilities.
I went for strings, so it could be e.g. "Mac OS X" and not the word 
mac-os-x.
Maybe platform could be, 'macosx, 'linux and 'windows and variation 
something like 'intel-32, 'intel-64, etc. Or do we need a third variable?
So maybe no variation, but instead processor and bits.
BrianH
5-Dec-2011
[395]
Can you SWITCH on two words at once?
Andreas
5-Dec-2011
[396x2]
In fact, there's so much more than OS and bits, that it's hardly 
worth trying to come up with an all-encompassing scheme.
Others have tried, and failed.
BrianH
5-Dec-2011
[398]
One of the common situations where you need to do platform-specific 
stuff is in loading prebuilt libraries, and those depend on the platform 
and processor variant. That means that selecting one requires selecting 
both, or all 3 if you have a seperate bits field. One SWITCH is better 
than 3.
Geomol
5-Dec-2011
[399]
I would like to have platform, which is kinda the OS, I guess. And 
the consequence of what Andreas just said, then the rest should just 
go into one variable, variation.
Andreas
5-Dec-2011
[400]
case [all [linux? arm?] [...] all [linux? amd64?] [...] ...]
Geomol
5-Dec-2011
[401]
Can you SWITCH on two words at once?


Yes, SWITCH can handle that. I don't have CASE yet, but probably 
will.
BrianH
5-Dec-2011
[402x2]
Something like this?

switch [platform variation] [
	[linux intel-32] [do something]
	[linux intel-64] [do domething else]
]
(sorry, that was bad syntax, but you get the idea)
Geomol
5-Dec-2011
[404x5]
switch reduce ... and without the first blocks inside. Just e.g. 
linux intel-32 [...]
Is it correct, REBOL can't handle that?
w> platform: 'linux
== linux
w> variation: 'intel-32
== intel-32

w> switch reduce [platform variation] [linux intel-32 [print "Found 
it!"]]
Found it!
SWITCH is a mezzaning in World (see cortex.w) and just uses FIND.
*mezzanine*
Geomol
6-Dec-2011
[409x5]
New release at https://github.com/Geomol/World
- The new routine spec is implemented.
- Compiling blocks should be fixed. I also added a test for this.

- system/version changed. Should be able to handle all future platforms/bits/processors/makers/etc.

- Added libs/version.w to help with deciding platform and version.
- Other fixes.
- Now cortex_alpha.pdf is updated too.
- And new version of cortex.w , where HELP can handle routines.
Defining routines is very flexible, a bit against my simplistic philosophy 
for World, but now it's done. Having e.g. libc (OS X example):

libc: load/library %/usr/lib/libc.dylib

Defining PUTS can be as simple as:

puts: make routine! [
	libc "puts" [
		[string!] pointer
	]
	sint
]

or as full of info and features as:

puts: make routine! [
	"Writes a string to stdout followed by a newline."
	[typecheck]
	libc "puts" [
		string [string!] pointer "String to write to stdout"
	]
	sint integer!
]
Compiling blocks is not 100%. Working on it.
Mchean
6-Dec-2011
[414]
Geomol: this is such nice stuff!
Geomol
6-Dec-2011
[415x4]
:)
My first experience with LLVM.


I tried to compile World with llvm-g++ under OS X. When compiling 
with gcc, I normally use -O2 option. I compared performance with 
the Mandelbrot test. Between compilations, I deleted all .o files 
and executable, so new compile started from scratch.

Compiling with llvm-g++:

With -O2 option, file size grow to 105% and execution time extend 
to 105% (slower).

With -O3 option, file size grow to 106% and execution time is the 
same.

With -O4 option (also Link Time Optimization), file size extend to 
122% and execution time grow to 107% (slower).


Then I tried to compile with gcc and -O3 option. Now file size grow 
to 105% and execution time shortened to 85% (faster).

Has anyone had similar experience with LLVM?
(And I thought, LLVM was much better, but maybe I do something wrong 
or miss some option!?)
Porting to LLVM took less than an hour. It's mainly changes, because 
LLVM is very strict about types, when checking e.g. unsigned against 
signed values. etc.
Dockimbel
6-Dec-2011
[419]
You mean porting to "clang"?
Geomol
6-Dec-2011
[420x2]
There is a /usr/bin/llvm-g++ command under OS X. The man page say:
llvm-gcc uses gcc front-end and gcc's command line interface.

So maybe it isn't "clang"!? I'm not sure. It's my first real experience 
with LLVM.
There also is a /usr/bin/clang
Maybe I should try compile with that.
Dockimbel
6-Dec-2011
[422]
By the way, why haven't you used LLVM for building World? As it is 
VM-based, LLVM would have been a good match.
Geomol
6-Dec-2011
[423x5]
Because I had no experience with LLVM, because I started World dev. 
on older MacBook, because LLVM was many MB download, because I wasn't 
sure, I could get LLVM on Windows and Linux easily.
I tried compile with clang. More results, first with gcc, then clang:

gcc -O2 option
size: 346136
time: 0:00:00.681560

clang -O2 option
size: 349976
time: 0:00:00.736821

clang -O3 option
size: 354072
time: 0:00:00.643053

clang -O4 option
size: 382888
time: 0:00:00.734845
And I notice, at least one of my tests don't finish with the LLVM 
and clang versions, which is disturbing. :/
So it seems, I made a good choise with gcc, because 1) it was easy 
to make World compile with LLVM and clang (if I choose that path 
now) and 2) it seems, some code doesn't work as intended with LLVM 
and clang.
gcc -O3 option
size: 362304
time: 0:00:00.579858


It seems, gcc beat LLVM and clang here on performance, if I use -O3 
option.
BrianH
6-Dec-2011
[428x2]
LLVM isn't really VM-based in the sense that bytecode VMs are. The 
VM is a compiler backend, but the code it requires tends to have 
to be specialized a little for the actual machine. As the developers 
of Portable NaCl have been discovering, it's not necessarily that 
good at being a portable VM.
You might also look into LuaJIT, as it is supposedly faster than 
most VMs, and smaller too.
Geomol
6-Dec-2011
[430]
Thanks, Brian (LuaJIT). Could be later, when World is stable and 
the hunt for performance really starts.
Dockimbel
6-Dec-2011
[431]
Sure, LLVM is not a "VM", it's a framework for building compilers, 
interpreters, VMs,...But for a VM-based language implementation, 
it makes sense to strongly consider the LLVM option.
Geomol
6-Dec-2011
[432]
Yeah, I've had it in the back of my head all the way with World. 
And then I just noticed, it was installed on this Mac.
Andreas
6-Dec-2011
[433x4]
llvm-gcc support has been dropped in the most recent LLVM release 
(3.0), so definitely use clang whenever you can.
I don't think that LLVM/Clang claims to be much better in runtime 
performance over GCC, at the moment.
The resulting binaries are, at the moment, generally comparable to 
GCC-generated ones. GCC is better in some areas, LLVM/Clang in others.
However, _build_ times with Clang should be superioer, but that won't 
matter much for World, I think. Error messages from Clang should 
also be much better. Esp. for C++, but also for C.