Queste sono le FAQ del newsgroup italiano dedicato a C++.Mi sono reso conto che in effetti non è facilissimo trovarle,ache se contengono molte informazioni che risparmierebberodomande banali sul newsgroup.
Per cui, nel caso, le linko.Link.
Queste sono le FAQ del newsgroup italiano dedicato a C++.Mi sono reso conto che in effetti non è facilissimo trovarle,ache se contengono molte informazioni che risparmierebberodomande banali sul newsgroup.
Per cui, nel caso, le linko.Link.
An image is worth a thousand words.
It was a matter of mod-probing i2c-dev.
It is a custom Linux 2.6.20 Kernel on Debian Unstable. Cool!
#!/usr/bin/env ruby
args = $*
if args.size == 0
puts "You should provide a file to process"
exit 0
end
dict = Hash.new
File.open(args[0]) do |f|
f.each_line do |line|
key, action = *line.split
dict[key] = action
end
end
# sudo apt-get #{v} #{k}
dict.each do |k, v|
exec("sudo apt-get -y #{v} #{k}") if fork.nil?
Process.wait
end
What is a scripting language?
From Wikipedia we read that:
Scripting languages (commonly called scripting programming languages or script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard. Thus, scripts are often distinguished from programs, because programs are converted permanently into binary executable files (i.e., zeros and ones) before they are run. Scripts remain in their original form and are interpreted command-by-command each time they are run. Scripts were created to shorten the traditional edit-compile-link-run process.
Of course any self respecting computer scientist knows that definition is meaningless, because a language is a mathematical constructand is not tied to its implementation. You can write a C interpreter, for example (and there are some). You can also write a compiler for any 'interpreted language' (of course the term 'interpreted language is also meaningless). And there are theoretical constructs (Futamura projections) that given any interpreter are able to build a compiler from it (you could implement them even in practice, though it would be terribly inefficient).
However, any other definition would be misleading as well: if you define a scripting language as a language you can use to "script" (as in "bash script"), then you've got definition that's even more stupid. bash is a scripting language, and so it is Python. However, if someone writes an application that is scripted in C, C becomes a 'scripting language').
Both definitions have an additional problem: scripting languages are considered somewhat inferior to 'non-scripting languages'. Some even use the term 'true programming languages' (and this 'true programming languages' are usually considered to be C and C++, for example).
Lisp, Haskell, OCaml, Prolog
In this dissertation on 'scripting languages', Lisp is quite emblematic. Lisp can be compiled (there are some Lisp compilers around). But Lisp can also be interpreted. This is one of the most widespread Lisp environments (and it is an interpreter). Moreover, in Emacs you can just run some Lisp snippets. And Emacs itself is scripted in Lisp (thus Lisp would be a scripting language according to the second definition). However, no one can assert that it is not a 'true' programming language. Emacs itself is a beautiful (and complex) piece of software, and a lot of 'real' (and extremely difficult) stuff in the AI field has been written in Lisp.
Haskell can be another example. Hugs is an interpreter, ghc is both an interpreter and a compiler. And Haskell is even statically typed (so you see, being dynamic is not necessary ). The very same applies for OCaml or Prolog. And all thislanguages have been used by the most theory-oriented computer scientist toimplement real programs.
I suppose nobody would say that Lisp or Haskell are 'scripting languages' (even if according to the definitions they are -- Haskell is used in many configuration tools by Linspire programmers).
Bash, Perl, Python, Ruby.
All this languages have been labeled as 'scripting languages'. And in fact according to definitions, they are. However, they are very different languages.
Bash is a very simple language designed to do simple things. Unix system administrators used it intensively (along with awk and sed and other utilities) to automate many repetitive tasks. Although this is surely 'programming', in some sense it's different from programming an application from scratch. Some even consider it a 'lower level' kind of programming (and surely we must recognize that skills involved in writing a boot script are different from skills used to write a compiler)
Perl was born in this environment: its goal was textual manipulations and interactions between processes in a system. It is a nicer alternative to bash + awk in many situations. Later it has been added a fully fledged object model, but in the while it has been used to write very complex applications that go outside the 'lower level programming domain' that is usually associated with 'scripting'. Even though I don't like Perl anymore, it is a general purpose language, with the same dignity of C or C++.
The 'scripting language' monicker is not fitting anymore. And it is even less fitting for Python. Python has been an object oriented programming language from the beginning. Good software engineering practices have always been employed. However, many consider it just another scripting language. And of course Python makes a great scripting language.
The domains in which Python excels are the same in which Java is used, for example. However, Python can be used for scripting, too. That is to say... some (and I'd be tempted to say 'most' ) 'scripting languages' can be used both as general purpose languages and automation/scripting.
The reason why they can be used for automation/scripting and that they are easier to use and we can write programs faster. The development cycle is faster, too. And to me, they all seem good properties.
I think that the very same features that make Python (or Ruby) great for scripting, make it even greater for general purpose programming. That is to say we should consider a 'scripting language' not a poorer language, but a better one (yeah, of course this is exaggerated, since there are languages suited for scripting that are not suited for general purpose programming -- AppleScript and bash, for example).
#!/usr/bin/env ruby
fork do
exec('emacsclient', '-n', *$*)
end
Process.wait
if $?.exitstatus != 0
fork do
Process.setsid
Signal.trap('HUP', 'SIG_IGN')
exec('emacs', *$*) if fork.nil?
exit!(0)
end
Process.wait
end
Ubuntu discontinued?
Recently there are rumors that Ubuntu PPC will be discontinued.
In fact there is an IRC log about it:
Something asked a few times: Will PPC support be discontinued soon?
We will make a final decision on PPC for Feisty by the end of next week
if there is sufficient community contribution on this, then the community port can be just as good as a Canonical-supported one
we would keep the builds in place, but not block the release if things failed to build
so if people step up to unblock issues when they occur, then PPC would be on the same footing as it currently is
sabdfl, will "but ps3 is ppc" be a valid argument? (asked a few times as well)
the extra architecture costs us a lot in terms of testing bandwidth at release time, and figuring out issues like how to deal with the live CD are compicated
if SONY fund Ubuntu-on-PS3 then I guarantee it will happen :-)
I have to say I've not been pleased about it. Of course Canonical should make its own interests: that is to say, if they feel that supporting PPC is not worth it, they are doing the right thing. However, it's quite sad: there are a loto of perfectly functioning G3, G4 and G5 machines out there. Dropping support like this, seems to be the way commercial companies act.
The point is that we must realize that Canonical is a commercial company. You just can't do anything about it and accept it.
Since at the moment I run Linux mostly on a PPC machine (my notebook), PPC support becomes a key factor in chosing the right distribution. My choice was obvious: I had been using Debian for ages before Ubuntu, why not going back to Debian? Welcome home, Debian!
Debian PPC
I downloaded the DVD iso for testing. Since I'm running on PPC, the new graphical installer is still experimental. Moreover, I quite feel at home with good old Debian textual installer.
Installation was really smooth. Debian recognised all my hardware with no need for manual intervention. Of course the airport card did not work without bcm43xx-fwcutter. Unfortunately enough, I left my working ethernet cable at the university, in the office I share with some fellow students. This was just a small delay.
Quite interesting Debian recognised my display better than Ubuntu (I still don't know why, but I had to set the resolution manually or Ubuntu would not start X11). However, Debian did not preload pbbuttons (that are used for the notebook multimedia keys, volume, lcd backlight, etc).
In fact I think a noob prefers to find a system with no multimedia buttons and working graphics than vice-versa. It seems that the guys at Debian did a pretty good work. Nonetheless, I'm quite sad for the exclusion of pbbuttons: I did chose a macro-package (when installing) called 'laptop' or something like that. I think that pbbuttons should be included in the first DVD. In fact most PPC machine out there should be laptops (well, maybe not 'most', but surely a great number).
Everything else worked smoothly. I recompiled the kernel (I would like to have that backlit keyboard working, it should work even with the 2.6.18 default kernel, but maybe something useful was not compiled into it). The backlit keyboard still does not work, which is a pity, but is something I can live without. Beryl does not work too (but it didn't work with Ubuntu, either). And it should work. But that is another thing I can happily live without.
I recently bought the Ruby Cookbook. I bought the italian version (whose title is 'Ruby Cookbook con elementi di Rails' which roughly translates to 'Ruby Cookbook with elements of Rails'). However, the book itself is not different.
Although I prefer to read technical books in English, I often buy books in Italian in order to show the publisher interest on that particular technology. In fact, in a country where most people avoid buying book in English because they feel they are 'too' difficult (like in Italy), good technologies do not spread if there are no good books in the local language.
The first impression with the book has been terribly negative. Actually if instead of buying the book online, I found it in a shop and leafed through it, I suppose I would have put it down.
Strings in Ruby are much like strings in other dynamic languages like Perl, Python
and PHP. They’re not too much different from strings in Java and C. Ruby strings are dynamic, mutable, and flexible.
In this paragraph you learn that "Ruby strings are dynamic, mutable, and flexible." And that is true. However, you get another impression: the authors do not know what they are talking about.
They say that Ruby strings are 'much like' the strings in Perl. This is almost true (well, Perl unicode support is much better than Ruby, and Perl deals natively with unicode strings. However, saying that Ruby strings are like Python strings is plainly wrong: Python strings are immutable and are somewhat more akin to Ruby symbols (in fact if you call intern on a Python string you get something semantically very similar to a Ruby symbol). Moreover, Python deals with unicode natively.
Again, the comparison with Java strings is plainly wrong: in Java strings are immutable. The comparison with C is terrible: in C, strings are not even a primitive data type.
As I said before, at this point I was tempted to put the book on a shelf and never open it again. Luckily enough I went on and soon enough I found out I bought one of the best books on Ruby available.
The impression that the authors are not competent (or at least they speak of something they do not know) is plainly wrong. A few chapters later, there are some chapters that quite accurately confront Ruby pragmatic with Python one. They are poignant and precise: definitely the authors know both languages quite well. I suppose the 'bad' paragraph at the beginning was a tentative to be didactical.
The book in fact is quite didactical. You can read it with almost no previous knowledge of Ruby. The reader is guided through Ruby syntactical conventions (for example when dealing with strings, you learn that parentheses are optional, which is known to everybody who coded a bit in Ruby).
In the later chapters (most notably the ones on modules and objects), the reader learns the nature of Ruby power, and how to reason and develop in order to unleash that power. This book is a cookbook, but every single receipt does more than teaching a way to achieve its goal: it teaches something about the way Ruby programmers should think and code *in general*. In fact you can consider this cookbook a 'beginner' book that teaches by examples (and that is a very effective way in a language such as Ruby). Of course, there is also plenty of intermediate and advanced stuff, or subjects not covered elsewhere (for example the ones about image manipulation).
This is a precious book and the ideal companion for everyone who's seriously motivated in learning Ruby. But it is also a book that a Ruby programmer may want to keep on her desk to find out how to do things without reinventing the wheel.
>> class A(object): pass >> a = A() >> a.foo() Traceback (most recent call last) ... <type 'exceptions.AttributeError'>: 'A' object has no attribute 'foo' >> def ext_foo(self): print 'foo' >> A.foo = ext_foo >> a.foo() foo
targets = {
'SEARCH': 'search', 'INFO': 'info', 'VARIANTS': 'variants',
'DEPS': 'deps', 'DEPENDENTS': 'dependents',
'INSTALL': 'install','UNINSTALL': 'uninstall',
'ACTIVATE': 'activate', 'DEACTIVATE': 'deactivate',
'INSTALLED':'installed', 'LOCATION': 'location',
'CONTENTS':'contents', 'PROVIDES': 'provides',
'SYNC': 'sync', 'OUTDATED': 'outdated',
'UPGRADE': 'upgrade', 'CLEAN':'clean', 'ECHO': 'echo',
'LIST': 'list', 'VERSION': 'version',
'SELFUPDATE': 'selfupdate', 'HELP': 'help'
}
locals().update(targets)
for k in PackageKey:
# do something
if key in PackageKey:
returnself.foo(key)
class_ConstantNamespace(type):
def__iter__(cls):
for v incls.keys:
yield v
class PackageKey(object):
__metaclass__= _ConstantNamespace
NAME ='name'
VERSION ='version'
REVISION ='revision'
DIRECTORY ='directory'
VARIANTS ='variants'
HOMEPAGE ='homepage'
DESCRIPTION ='description'
BUILD_DEPENDENCIES ='build_dependencies'
LIBRARY_DEPENDENCIES ='library_dependencies'
RUNTIME_DEPENDENCIES ='runtime_dependencies'
PLATFORMS ='platforms'
MAINTAINERS ='maintainers'
keys = [locals()[key]
for key inlocals().keys() if (key.upper()== key and
(key.isalpha()orkey.endswith('_DEPENDENCIES'))]