:: [DNG] Readable code; making code mo…
Kezdőlap
Delete this message
Reply to this message
Szerző: Apollia
Dátum:  
Címzett: dng
Új témák: [DNG] Non-popularity of Lisp
Tárgy: [DNG] Readable code; making code more easily writable; Emacs, multifiles-apmod; VUE; Code Bubbles; Lisp; Inform 7; HyperCard and HyperTalk - was Re: "Common knowledge?"-question
On Fri, Jan 22, 2016 at 4:34 PM, Rainer Weikusat <
rainerweikusat@???> wrote:

> Can the effect of the following C function
>
> static void print_start(char const *name, char const *what)
> {
>     char *buf, *p;
>     unsigned name_len, what_len, total;

>
>     name_len = strlen(name);
>     what_len = strlen(what);
>     total = name_len + what_len + 3;

>
>     p = buf = alloca(total);
>     memcpy(p, name, name_len);
>     p += name_len;
>     *p++ = ' ';
>     memcpy(p, what, what_len);
>     p += what_len;
>     *p++ = ':';
>     *p = ' ';

>
>     *buf &= ~0x20;

>
>     Write(2, buf, total);
> }

>
> be considered obvious or should it rather get an explanation?
>
> An ASCII lowercase letter can be turned into the corresponding uppercase
> letter by clearing the sixth bit.
>


I'm quite inexperienced with C, so I don't understand that function at all,
despite having some experience with PHP, Perl, JavaScript, SQL, Bash, Emacs
Lisp, Python, and various other things.

I find it so mind-boggling I can't make any very specific suggestions for
how to make it more understandable.

But, I definitely agree with adding explanations, and others' suggestions
also sound good to me (though I'm probably not really qualified to judge).


Anyway, the rest of my message is going to consist of hopefully
interesting/useful tangents related to the topics of making code more
readable, and more easily writable.


I think if I ever did code much in C, my code would end up looking very
unusual and unconventional to many people, because I often like to use
long, descriptive names for functions and variables, no matter what
language I'm using, even Bash.

Ideally I'd like to make my scripts as readable/understandable as plain
English. (Not that I constantly strive for that - it's often too much
work.)


Here's one recent example of my perhaps rather strange coding style - an
Emacs add-on I modified a lot. (Actually, maybe a better example would be
the even more recent shell scripts I've been working on for my Puppy Linux
Setup Kit, but those aren't done yet.)

https://github.com/Apollia/multifiles-apmod.el/blob/master/multifiles-apmod.el

https://github.com/Apollia/multifiles-apmod.el

And here's the original add-on's source code (not by me):

https://github.com/magnars/multifiles.el/blob/master/multifiles.el

(If anyone has any comments, criticism, tips, etc., on multifiles-apmod or
any other topics, I'd be interested to read them, even via private email if
they're too off-topic for the mailing list.)


Actually, I think at the moment, multifiles-apmod is probably the best
already-useable thing I worked on that I can contribute to Devuan. (At
least until I finish some of my other projects...)

multifiles-apmod, Emacs (which I finally started seriously using almost 3
months ago), and the many other great Emacs add-ons I've installed, have
all made my programming hobby tremendously easier and more enjoyable.

Even my former favorite text editors (Notepad++ and Geany) were slowing me
down and getting in my way, because I had so many separate files in
different tabs to work on that it was becoming quite a nuisance having to
click tabs all the time, and struggle to remember what files I put things
in, or do searches.

And bookmarks in Notepad++ and Geany (as far as I know) don't let you jump
to locations in different files - only the current file you're working on.

But now, with multifiles-apmod, I can work on numerous separate files all
in a single large buffer. I can quickly and easily get an overview of my
entire projects just by scrolling around, and I can jump from file to file
by pressing Ctrl-Page Up or Ctrl-Page Down.

And I found 3 different bookmark add-ons for Emacs that I like. :-)


multifiles-apmod definitely has some problems (as you can read in the
readme, or the giant comments section at the top of the source code), and
I'm still very inexperienced with Emacs and Emacs Lisp - but, nonetheless,
multfiles-apmod has still been very useful to me, and has already saved me
a lot of time and frustration.

So, since multifiles-apmod, Emacs, etc. have done me so much good, I just
thought I'd mention them, in case they might help anyone here too.

https://github.com/Apollia/multifiles-apmod.el


Another thing that helps me code is the VUE concept mapping software:
http://vue.tufts.edu/

I use it for making notes, flow charts, documentation, etc.

I sometimes wish I could use VUE as a GUI for editing my actual code. But,
that's not possible (yet?).

The only thing I've heard of so far which can do something like that is a
Java program called Code Bubbles - which I haven't tried yet, since it
might only be for editing Java code, and I mostly haven't done much of
anything with Java code yet.

http://cs.brown.edu/~spr/codebubbles/


Emacs recently reawakened my curiosity about Lisp, which was originally
piqued years ago by Paul Graham's articles on Lisp:

http://www.paulgraham.com/lisp.html

I never got far with Lisp all those years ago. But, recently, I found
working with Emacs Lisp a lot more enjoyable and productive than I thought
I might, and in some ways Emacs Lisp is actually more comfortable to use
and easier for me to understand than Perl and Bash.

And I've encountered so much high praise of Lisp that I'm now extremely
curious to know if it really is as superior to other programming languages
as it's reputed to be. And if it is, why isn't Lisp more popular?

I'm greatly looking forward to finally reading Paul Graham's "On Lisp"
book, legally available for download (gratis) from his website:

http://www.paulgraham.com/onlisptext.html


And, some less practical but hopefully still interesting and
thought-provoking things:

Two other programming languages I'm quite intrigued by (even though I
haven't done much with them) are Inform 7 and HyperTalk, because they look
so much like plain English.

http://inform7.com/
https://en.wikipedia.org/wiki/HyperTalk


A pity Inform 7 is (unless I'm mistaken) closed source (despite being
available gratis), and primarily intended for writing text adventure games.

I probably would've experimented a lot more with Inform 7 by now if I could
more easily use it for something more practical.

How bizarre and thrilling it would be to be able to write (for example)
shell scripts in something like Inform 7 instead of Bash. :-)


And, a pity that HyperTalk is (I assume) owned by Apple. Actually, I can't
really comment much on HyperTalk or HyperCard, since the last time I even
used those was when I was around 8 years old. :-) But I really liked
those, and I've never found anything else quite like them.

And I think it's great that HyperCard/HyperTalk made it so easy even for
average not-so-technical people to write their own software. A darned
shame they're closed source and proprietary.

Someone's interesting blog post on HyperCard:

http://www.loper-os.org/?p=568


Well, this turned out to be a quite long message. :-) I hope it was
interesting and helpful.

I look forward to trying Devuan (or a Devuan-based Puppy Linux) sometime
after I finish renovating my Puppy Linux Setup Kit.

Best wishes,
Apollia