Vala and Genie programming

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#436 Post 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)
Last edited by rarsa on Mon 02 Nov 2009, 03:39, edited 1 time in total.
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#437 Post 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)
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#438 Post 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! :)
[url]https://bkhome.org/news/[/url]

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#439 Post 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.
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#440 Post 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...
[url]https://bkhome.org/news/[/url]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#441 Post by BarryK »

Double post
[url]https://bkhome.org/news/[/url]

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#442 Post 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
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

vala 0.7.8 pet??

#443 Post 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.
Last edited by gyro on Tue 17 Nov 2009, 07:36, edited 1 time in total.

User avatar
ttuuxxx
Posts: 11171
Joined: Sat 05 May 2007, 10:00
Location: Ontario Canada,Sydney Australia
Contact:

Re: vala 0.7.8 pet??

#444 Post 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
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games :)

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Re: vala 0.7.8 pet - works

#445 Post by gyro »

ttuuxxx wrote:here try this :)
ttuuxxx
Thanks
The updated x11.vapi looks good
gyro

Edit: Works fine, thanks ttuuxxx

tsura
Posts: 3
Joined: Tue 01 Dec 2009, 08:25

#446 Post 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.

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

JWM shortcut manager

#447 Post 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,
Attachments
jwmshortcut.tar.gz
(5.28 KiB) Downloaded 590 times
Last edited by ljfr on Mon 08 Mar 2010, 11:20, edited 1 time in total.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#448 Post 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 *
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#449 Post 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?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

DMcCunney
Posts: 889
Joined: Tue 03 Feb 2009, 00:45

#450 Post 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

tsura
Posts: 3
Joined: Tue 01 Dec 2009, 08:25

#451 Post 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?

DMcCunney
Posts: 889
Joined: Tue 03 Feb 2009, 00:45

#452 Post 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

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#453 Post 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.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#454 Post 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
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#455 Post by Lobster »

C mainly because Vala does the work of writing safer C.
That makes sense - being forced to write better code.
Many thanks :)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

Post Reply