Scriptable text editor with Ruby?

Dolazy wrote:

I’m thinking of writing a platform independent text
editor myself that uses the ruby language for executing scripts. The
host application would be written in C++ (+Qt) and it would somehow be
able to interact with ruby.

Why start from scratch? Take over an existing, defunct open source
project:

http://aeditor.rubyforge.org/

Suraj K. wrote:

Dolazy wrote:

I’m thinking of writing a platform independent text
editor myself that uses the ruby language for executing scripts. The
host application would be written in C++ (+Qt) and it would somehow be
able to interact with ruby.

Why start from scratch? Take over an existing, defunct open source
project:

http://aeditor.rubyforge.org/

+1

Simon?

T.

Simon S. wrote:

I don’t know what exactly your goal is for this editor,
but if you want it to be great then take a look at
what other great editors is doing.

IMO TextMate is the best editor I have ever tried,
and was the reason I abandoned my own editor
project: http://aeditor.rubyforge.org/

Well TextMate has two important drawbacks: it’s Mac only and it’s not
free. I’ll give the evaluation version a try on my Mac at work to see
if I it can inspire me (hopefully not discourage me if it’s too
good!)…

btw: Know your enemy (maybe I should this one day)
The Art of War - Wikipedia

Hah, thanks :wink:

Simon S. wrote:

have you considered writing the entire editor in ruby and
then use ruby qt… so you don’t use any c++?

Ruby is good at string manipulation, so its possible
to do the entire syntax coloring in ruby. I think
this task is pretty big in c++.

:slight_smile: Syntax coloring could be implemented as a ruby plugin.
And all these advanced concepts I will try to delegate to libraries as
much as I can.

Thanks for your suggestions Edward, Vince (+others).

However, running a complete text editor application as a ruby script;
wouldn’t that be slow?

The idea of having a C++ skeleton application with lot’s of ruby
plugins seems more appealing to me. It would be faster and still
strongly customizable. However, if you think differently then please
share your insights on this…

On 1/5/07, Trans [email protected] wrote:

http://aeditor.rubyforge.org/

+1

Simon?

I will grant admin if anyone feels like continuing aeditor.
Actually I did the same yesterday with http://ros.rubyforge.org/
after talk in the ros forum.

The reason I stopped working on these things was that
I got a job that took up all my available time.
Only profesional work, no focus on the social side.
So I quit that job and started my own company,
hoping to do it better. I have plenty of time now,
but its allocated for the company beast.

If someone payed food/rent then I would have
been happy working entirely on ruby projects.

The person(s) that has interest in the aeditor project,
is free to do whatever she likes. Change website,
license, code. Write a entirely new aeditor. Add code,
licenses, websites, etc. I don’t mind as long as its
for a good purpose.

I still think an application written entirely in ruby would be slow.
Eclipse is slower than Visual Studio, Azureus is slower than
µTorrent… Higher level languages are slower, even if they use optimal
data structures. I know that this doesn’t have to be this way
theoretically, and that higher-level languages allow more compiler
optimization and all. But still you see that programs written in C/C++
are almost always faster than those written in Java, or other
high-level languages (esp ruby!).

I’m in favor of higher level languages, but wanting to make my
application customizable using external scripts does not mean my
language is too low-level. It just means that I want to make my program
programmable.

Dolazy wrote:

However, running a complete text editor application as a ruby script;
wouldn’t that be slow?

The idea of having a C++ skeleton application with lot’s of ruby
plugins seems more appealing to me. It would be faster

You cannot assume that things will be faster just because you use a
low-level language. If this were true, then all 3D games would be
written in straight machine code… forget about assembler!

Efficiency comes primarily from good choice of data structures and
algorithms which are best suited to tackle the problem at hand. Whether
or not the programming language being used is “close to the metal” is,
at best, of secondary importance.

and still strongly customizable.

Good, it seems you are implicitly seeking a higher level language so
that you can better manage complexity. (Google “No Silver Bullet” for
details.)

Yeah, you could be right…

I didn’t want to go off-topic, but I couldn’t resist writing my
previous post. I hope I didn’t open pandora’s box now.

Francis

I don’t know much about Eclipse and VS so I won’t comment on those;
however, uT and Azureus aren’t both trying to be lightweight so, IMO, it
is unfair to compare them like that.

Also, I think you have to remember that you are coding a text editor.
On any modern computer it honestly won’t matter what language you do it
in.

dan

I have taken a look at embedding and Swig.

Hmm… I’m very unsure about them.

Swig seems to assume that you want to take away the main() method and
treat the C++ code as a shared library. It’s not really the same as
interprocess communication.

The embedding solution also provides one way interaction. The C++
program calls ruby, but not the other way around. There might be ways
around this, using callbacks or so. I’d like to learn more…

I suspect that IPC using XmlRpc is the most powerful solution (and easy
to implement).

I am eager to learn your (anyone’s) insights.

Dolazy wrote:

Swig seems to assume that you want to take away the main() method and
treat the C++ code as a shared library. It’s not really the same as
interprocess communication.

The embedding solution also provides one way interaction. The C++
program calls ruby, but not the other way around. There might be ways
around this, using callbacks or so. I’d like to learn more…

I suspect that IPC using XmlRpc is the most powerful solution (and easy
to implement).

There is an easier way than having ruby in a separate process and having
to do IPC via RPC. Simply run ruby within a pthread and give it a SWIG
interface to your C++ app.

== Option1

If you cannot allow the Ruby thread to asynchronously use your C++ app,
then you can set up a mutual exclusion scheme where either (1) the C++
app or (2) the Ruby thread is active at a time. You would then have to
provide a way to transfer/relay control between them.

In fact, this is how my Ruby-VPI project works. It embeds a Ruby
interpreter into a C program that runs within a Verilog.

http://ruby-vpi.rubyforge.org

== Option2

If that’s not the kind of interaction you want, then see:

ruby embedded into c++

Java is attractive for several reasons. A powerful gui, speed is very
good, and there’s JRuby… But I want to explore new territory. That’s
why I want to choose Qt, because it’s something new for me. Also
because I am a C++ developer I want to improve my cv a bit :wink:

Francis

On 1/3/07, Dolazy [email protected] wrote:

As you probably already told by numerous people, Vim does that already.

Emacs is supposed to have something like that as well, but it hardly
works.

Whereas I managed to get Vim’s Ruby support running out of the box on
several flavours of Linux and even freaking Windows…! Respect.

-Alder

When embedding, you can add an extention that implements a ruby API to
your editor and thus the communication will be both ways.

Dolazy schrieb:

Java is attractive for several reasons. A powerful gui, speed is very
good, and there’s JRuby… But I want to explore new territory. That’s
why I want to choose Qt, because it’s something new for me. Also
because I am a C++ developer I want to improve my cv a bit :wink:

Francis

Be sure to look at http://software.jessies.org/Evergreen/ for some
insipiration. (Also remember, Java isn’t evil anymore now!)

Paulus

That’s attractive of course. I will check out this editor thoroughly
and let you know something.

  • Gregory B., 01/03/2007 06:17 PM:

but vi must run everywhere (According to POSIX). :slight_smile:

line-mode ex is scriptable. The TUI that can be started using
‘:visual’ (hence its commonly known name ‘vi’) isn’t. ex’s ancestor
ed is scriptable as well. I sometimes use the latter for shell script
controlled in-place editing of files to avoid unnecessary security
issues resulting from the creation and deletion of temporary files
(that is one of the largest source of harmful security holes known to
authors of shell scripts). It is a pity that many people only know
sed (wich is nothing but a stripped-down version of ed only being
capable to handle streams) because they are doomed to introduce such
problems.

Jupp

Qt provides lots of functionality for free that you had to implement in
your editor. I think I will continue on my own path.