Page 22 of 26

Posted: Mon 02 Nov 2009, 03:23
by rarsa
disciple wrote:And how much easier do you think it would be to learn vala than C?
C : Pretty easy to learn, and there are a lot of resources. The problem is that it is not easy to program well. It's very easy to write crappy code that's difficult to understand and maintain.

Vala : Although the language is simple, documentation is still lacking so you must resort to look at examples in other languages to understand how to do some things in Vala. It is easier to write maintainable programs. Vala is a more modern language which takes care of many of C pitfalls (e.g. memory management) but to use it properly you better have an Object Oriented background. (most of the examples I've seen are spaghetti code)

Posted: Mon 02 Nov 2009, 03:37
by rarsa
OK, I'm jumping into the Vala wagon.

I started today with Genie but found several little annoyances which, without proper documentation, gave me a headache.

So I moved to Vala and it just feels natural.

I wrote a little test application that uses Gtk, Glade, and SQLite. Creating multiple windows defined in separate classes and source files. Some of those things are not well documented but I drew from experiences from other languages.

I know I'm at the bottom of the learning curve but I hope to put my new learnings to a good use. (time permitting)

Posted: Mon 02 Nov 2009, 23:13
by BarryK
rarsa,
Great to "hear" from you again!

Ah yes, I always remember your statement that anything with the name "Basic" in it makes you break out in a rash! :)

Posted: Fri 06 Nov 2009, 00:14
by rarsa
BarryK wrote:Great to "hear" from you again!
Thanks!
BarryK wrote:Ah yes, I always remember your statement that anything with the name "Basic" in it makes you break out in a rash! :)
Oh, I wouldn't put Genie in the same leage as Basic.

I think it is a nice language which I will surely get into once I get my head around Vala which is better documented.

I am also a python guy so Genie seemed familiar just that I wasted time with some very basic things:

I mixed tabs and spaces and the interpreted got confused until I added the [indent..].

When setting an object method as the event handler I had to do

Code: Select all

button.clicked += def () myMethod()
But if it was a global method

Code: Select all

button.clicked += myMethod()
which wasn't documented anywhere. In Vala the def() is not required.

Most examples use global methods, not classes so it was quite an experience.

So this combined with the indent issue was quite confusing: The myMethod() looked indented as other class methods (4 spaces), but it really wasn't due to using tabs (1 tab) so it was interpreted as a global method outside the class but without visibility to the private members of the class.

:) enough rambling, I like both languages, I just decided to start with Vala to understand the programing model and then try Genie.

Posted: Fri 06 Nov 2009, 10:43
by BarryK
Oh, I didn't want to imply that Basic and Genie are in the same league. It is just that my memory was jogged, about the comment you made about "anything with Basic in the name" long ago -- or I think it was you, maybe my memory is faulty.

It is probably unwise to stir up that tabs versus spaces thing again. It is interesting that Jamie decided to use tabs as the default.

Personally, I like tab indents. Very easy to indent consistently, also easy when editing existing text. As long as nobody opens/edits my code in a text editor configured to convert tabs to spaces...

Posted: Fri 06 Nov 2009, 10:49
by BarryK
Double post

Posted: Fri 06 Nov 2009, 13:32
by rarsa
BarryK wrote:"anything with Basic in the name"
Yep, it was me. I'm scratching already. :D

And no, no intention to stir any debates :) . Once I understood the [indent=...] things were clear.

Its clearly a matter of preference.

Well, back to Vala/Genie

vala 0.7.8 pet??

Posted: Mon 16 Nov 2009, 12:53
by gyro
Hi,

Is there a .pet of vala 0.7.8 anywhere?
I wish to install it on pup-431.

There seems to be omissions in Xlib.vapi in vala 0.7.4.

gyro

Edit: It is x11.vapi not Xlib.vapi.

Re: vala 0.7.8 pet??

Posted: Mon 16 Nov 2009, 14:02
by ttuuxxx
gyro wrote:Hi,

Is there a .pet of vala 0.7.8 anywhere?
I wish to install it on pup-431.

There seems to be omissions in Xlib.vapi in vala 0.7.4.

gyro
here try this :)
ttuuxxx

Re: vala 0.7.8 pet - works

Posted: Tue 17 Nov 2009, 07:34
by gyro
ttuuxxx wrote:here try this :)
ttuuxxx
Thanks
The updated x11.vapi looks good
gyro

Edit: Works fine, thanks ttuuxxx

Posted: Tue 01 Dec 2009, 08:33
by tsura
disciple wrote:Hi guys, I haven't really looked at Vala yet, but I'm wondering - does anyone have any idea how hard it would be to convert a simple-ish gtk program from c to vala? And how much easier do you think it would be to learn vala than C? Is Vala:
0. No easier than C
1. A little easier than C
2. Quite a bit easier than C
3. A lot easier than C
4. So much easier than C that there's no comparison.

Any thoughts?
Hmm. It's a whole lot easier, but I wouldn't say there's no comparison. It has its similarities, but at least you don't have to deal with header files, having to put functions in certain places, funky less-readable syntax and all that other stuff. Plus you get some nice string functions, such as up(), down(), strip() and split() out of the box. Making a GUI in Vala is easy, too, and although there's not a whole lot of extensively commented-on documentation, you can always look at Gtk documentation for other languages and often figure out the Vala method with ease.

I highly recommend learning Vala. It's worth it, I'd say.

Here are some helpful links:
http://references.valadoc.org/
http://live.gnome.org/Vala
http://www.pygtk.org/docs/pygtk/
• etc.

Anyway, other, non-Vala sites on Gtk often give information that the Vala sites don't give, so that's why I list a few others. Even the C documentation on Gtk can be quite helpful, actually. Vala is one of the few languages that seems quite easy to use documentation from other languages with.

I like to ask questions on the programming forum at Ubuntuforums. People don't always answer, but they do often enough that it's worth it.

JWM shortcut manager

Posted: Mon 01 Feb 2010, 13:28
by ljfr
Hi,

Note:Some objects of the bellow examples are not freed correctly, some function to do that are missing in the current libxml bindings (reported to gnome bugzilla).

following Caleb72 example, I attached a jwm shortcut manager (similar to the one in jwmconfigmgr) in vala using libxml, using xpath to find desired nodes.

To compile and run it:

Code: Select all

valac -X -Os --pkg libxml-2.0 --pkg gtk+-2.0 jwmshortcut.vala
strip --strip-unneeded jwmshortcut
./jwmshortcut
As libxml provide an easy way to handle jwm configuration files, a full jwmconfigmgr in genie/vala might not be so big and ... improved.

Regarding compilation, is there a better way to decrease executable size?

regards,

Posted: Tue 02 Feb 2010, 04:16
by technosaurus
the compile scripts that were packaged with nicoedit first generate the "C" code and then compile it
if you add this after gcc
gcc -Os -fomit-framepointer -momit-leaf-frame-pointer -fmerge-all-constants -march=i486 -mtune=i686 ... rest of stuff

then better stripping
strip --strip-all --remove-section=.comment --remove-section=.note *

Posted: Tue 02 Feb 2010, 05:12
by Lobster
Hi rarsa :)

This is quite a technical question
- so make the answer fit for an idiot (me)

Is Vala more secure than C?
Or is it how the code is written?

As you know some languages such as javascript are very useful but insecure (so let's base the whole Cloud thing on them :oops: )

Is Vala pronounced valour
and suitable for the brave?

Posted: Wed 03 Feb 2010, 00:54
by DMcCunney
Lobster wrote: Is Vala more secure than C?
Or is it how the code is written?
It is always how the code is written.
As you know some languages such as javascript are very useful but insecure (so let's base the whole Cloud thing on them :oops: )
And your vast knowledge of how insecure JavaScript is comes from where, exactly?

See above about it always being how the code is written.

(And while you're at it, define just what you mean by "security".)
______
Dennis

Posted: Wed 03 Feb 2010, 03:29
by tsura
DMcCunney wrote:(And while you're at it, define just what you mean by "security".)
I think Lobster may have security issues with web-based client-side and server-side scripting mixed up with general programming security. That's only an issue for browser-oriented client-side scripting, really (I don't know of anything besides JavaScript that would have this issue).

The client can see the JavaScript code, since it's mostly a client-side thing. If that's what you're thinking, no you won't have that problem with Vala or C. In fact, you probably don't need to worry about it at all, unless you want people to type in a password for something (on the Internet) and you don't have access to the server. You could try using encryption keys in that case.

What do you need security for?

Posted: Wed 03 Feb 2010, 03:54
by DMcCunney
tsura wrote:
DMcCunney wrote:(And while you're at it, define just what you mean by "security".)
I think Lobster may have security issues with web-based client-side and server-side scripting mixed up with general programming security.
I do too, which is why I asked.
That's only an issue for browser-oriented client-side scripting, really (I don't know of anything besides JavaScript that would have this issue).
Microsoft Active-X controls, which are fortunately confined to Internet Explorer under Windows. (Microsoft was pushing VBSript as well back when, but it thankfully remained a client side product, and never gained traction as an alternative to JavaScript on web sites.
The client can see the JavaScript code, since it's mostly a client-side thing. If that's what you're thinking, no you won't have that problem with Vala or C. In fact, you probably don't need to worry about it at all, unless you want people to type in a password for something (on the Internet) and you don't have access to the server. You could try using encryption keys in that case.
The usual security problems with compiled languages exploit things like buffer overflow, and are more examples of "how the code is written".
______
Dennis

Posted: Thu 04 Feb 2010, 20:52
by technosaurus
Vala Releases

Vala 0.7.10
source tarball

released on February 4, 2010


Changes
Support coalescing operator ??.
Support to_string and bitwise complement with enums.
Return handler id when connecting signal handlers.
Support struct comparison.
Support constructor chaining in structs.
Enforce protected member restrictions.
Improve performance of flow analysis.
Support automatic line continuations in Genie.
Improvements to the .gir reader and writer.
Add --enable-mem-profiler commandline option.
Many bug fixes and binding updates.

Posted: Sat 06 Feb 2010, 13:37
by rarsa
Sorry for the late response, I've been quite busy at work.
Lobster wrote:Hi rarsa :) Is Vala more secure than C?
Or is it how the code is written?
Someone responded with "Define security". But based on your question it seems to me that you meant "Safety". Quite similar words, used as synonyms in regular English but in coding terms a bit different.

Security basically means: Who has access to what and when. That applies to users as much as the calls and objects passed around inside an application.

Some languages and runtime environments provide Security mechanisms such as code level signing. To the best of my knowledge, neither C or Vala provide that, so it depends on the program itself to determine security.

Safety in this context is the syntax or mechanisms that a language has to protect from having code vulnerabilities. So in a sense depends on the language ONLY if the programmer uses such syntax and mechanisms.

In this sense C is less safe "out of the box" but there are library frameworks that provide the extra safety such as protection against memory overflow.

Vala in a sense is safer C as it implements those safety mechanisms for the programer such as proper type checking.

I haven't used Vala long enough or in programs large enough to find out if it has safety mechanisms that would help prevent for example SQL injections other than using the same libraries as C.

So responding to the question: I think Vala is safer than C mainly because Vala does the work of writing safer C.

Example of Safety lapse
Example of security lapse

Posted: Sat 06 Feb 2010, 16:35
by Lobster
C mainly because Vala does the work of writing safer C.
That makes sense - being forced to write better code.
Many thanks :)