Re: [Vala] Hi, Is Vala what I am looking for?



On Fri, Sep 25, 2009 at 10:03:59 +0200, Orlando José Luque Moraira wrote:
Yes but not. I am looking for a system than can allow a developer to
compile, easily, for any platform or SO or device. You can force the
precompiler to generate code for linux, or windows, or a PDA just by using
libraries developed with the help of precompiler directives and precompiler
code. You can get this new code and compile it in a common compiler of the
target SO/device.

Well, the C and C++ languages themselves are pretty well standardized and
since vala generates valid C code, it should compile for any target. So it
is mainly a question of libraries providing the same APIs on all systems you
target.

Yes, there are multi-SO libraries out there (wxWidgets, glib, lua, gtk+,
sdl, allegro, etc) but if you need to port an application to another SO, one
which is not supported by one or more of the libraries, it is a mess and you
need to change the library and maintain two branches of code. (And I forgot
to say that maybe you must research which library to use, risk on developing
over a incomplete or bugged one, needing to learn how it works, etc)

My idea is to use "proxy libraries" so, the common developer sees
"Thread.Sleep", but just below this visibility is a little layer which links
the method to the real method of, (by example) pthreads for linux or to the
common threads library of windows. This will be done with precompiler code
and directives and will be done before by someone (or maybe you).

Well, GLib is such "proxy library". It provides a few utilities, but big part
of a reason it exists is to make GTK platform-independent. It's GTrhead and
GModule modules are purely "proxy libraries" -- they simply wrap native APIs
for threads and dynamic libraries respectively.

Another such "proxy library" is APR (apache portable runtime).

There will be optimizations with help of macros (“macroizing”?), generation
of code, help with aspect programming, etc.

This is getting somewhere else, though. Yes, aspect programming... First
I heard about it it was in Lisp and involved defining transformations, for
purpose of optimization, of rather big constructs. Like how to compose two
loops exchanging the order of iteration. I've seen the same thing, not called
aspect-anything in Haskell. The punny before/after/around stuff I've seen in
any other languages was nowhere near that usefull and I doubt it improves
readability (it's another place where semantics can be changed).

 There could be a lot of possible libraries, or algorithms or options for
the use/develop of a component. Tweaks enter here. Maybe you want to use a
different DHT version; if it does not exists, you could add a “tweak” for
the DHT so it could function in another way and then use it invoking the
tweaked version.

 Yes, you can get this done using abstract classes and a lot of method calls
between father class and its son, but it is contrary to maintability, it is
a mess, and maybe you cannot afford the use of so many method calls. Why use
a spoon when you can use a machinegun?

I guess you are talking about something like 'policy' template arguments
technique used in C++. There you would define a class or function template
taking a class or function template argument, that will be called to in some
key point to change the behaviour.

Since C++ substitutes template parameters at compile time, it can actually
make this pretty efficient. At the cost of taking long time to compile and
expanding the code size, because each variant is compiled separately.

With modern CPUs, the approach of passing function pointers at runtime might
actually turn out to be more efficient. Less code means smaller working set,
which means fewer cache misses and a single cache miss all the way to main
memory can easily cost more than hundred pointer dereferences.

Not only a class can be developed to be tweakeable. Methods could be also.
How many times have you develop a method that is just only one line
different from the one just below? How many times have you, for reusability,
have created a method that uses local variables or parameters just to change
its internal behavior?

Yes, yes, a method call, a IF, etc, have no cost for your mega CPU, but it
is not the same if you have millions of 'free' IF per second shared between
your program, your SO, your libraries... When you use a method call to a
library (from SO or not) could be thousands of unnecessary calls and lines
of code working below.

You might want to have a look at the D language. It has 'mixins', which are
even stronger than C++'s templates. Their arguments are inlined by the
compiler making them basically syntax-tree-level macros (I would prefer if
they were hygienic, i.e. if variables inside the inlined code were resolved
from the context that code was defined and not where it is being inlined, but
anyway).

However I think Jürg does not want to have extensible syntax in vala.

And: Less classes, less methods, a good GUI  = faster learning curve and
faster development.

Well, you have to be careful to keep simple things simple though. The
difference between having to write one and three statements to use something
can easily be a difference between one and ten minutes or more!

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]