Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ppmd code

15 views
Skip to first unread message

exama...@gmail.com

unread,
Aug 4, 2006, 11:23:12 AM8/4/06
to
wow, this code is awful, gotos all over the place, exotic indentation.
impossible to read. very well. and it's supposed to be c++ hahaha

cr88192

unread,
Aug 4, 2006, 9:30:11 PM8/4/06
to

<exama...@gmail.com> wrote in message
news:1154704992.7...@b28g2000cwb.googlegroups.com...

> wow, this code is awful, gotos all over the place, exotic indentation.
> impossible to read. very well. and it's supposed to be c++ hahaha
>

actually, wrt bizarre or irregular conventions, I see that far more often in
C++ code than I do in C code.

my suspition is that, anymore, people that use C have been using it for a
while, wheras many people starting out use C++ I guess because they hear
that it is 'better'.

as for ppmd, I don't know, I haven't looked at it personally.


in my case I use C, in part, because I started coding back in the 90's, when
C was apparently a little more popular than it is now...

or such...


Sachin Garg

unread,
Aug 6, 2006, 7:35:35 PM8/6/06
to
exama...@gmail.com wrote:
> wow, this code is awful, gotos all over the place, exotic indentation.
> impossible to read. very well. and it's supposed to be c++ hahaha

It is the fastest and most 'exotic' ppm implementation I have seen.
Some of those gotos and other hacks are probably the reason why it is
as good as it is.

But yes, this doesn't changes the fact that the code is hard to read,
and that there isn't much documentation to help either. You are
definitely not the only one having a hard time understanding it, code
readibility can ofcourse be improved.

You might find this old thread helpful in your adventure :-)

http://groups.google.com/group/comp.compression/browse_thread/thread/8ac90e59cd3b1eb1


Sachin Garg [India]
www.sachingarg.com | www.c10n.info

Pavel Vozenilek

unread,
Aug 7, 2006, 7:46:03 PM8/7/06
to
"exemachine" wrote:

> wow, this code is awful, gotos all over the place, exotic indentation.
> impossible to read. very well. and it's supposed to be c++ hahaha
>

The code is mostly C with few classes added.
It is very heavily optimized thus the gotos.
The "two columns" indentation is likely
to help to keep both pipelines of Pentium full.

Look at source code for LZO or other
compressors, they are complicated too.

/Pavel


Aslan

unread,
Aug 8, 2006, 4:01:02 AM8/8/06
to

"Pavel Vozenilek" <pavel_v...@yahoo.co.uk>, haber iletisinde şunları
yazdı:4jq1ltF...@individual.net...

> "exemachine" wrote:
>
> > wow, this code is awful, gotos all over the place, exotic indentation.
> > impossible to read. very well. and it's supposed to be c++ hahaha
> >
>
> The code is mostly C with few classes added.
> It is very heavily optimized thus the gotos.

> The "two columns" indentation is likely
> to help to keep both pipelines of Pentium full.

How come? You mean the C++ compiler will do it in a better way than what it
normally does, if it is written that way?
I thought it was for displaying it (or printing it out) in a very tight
space.

Ignorant

unread,
Aug 8, 2006, 10:15:54 AM8/8/06
to
Dears,
When reading programs or segments of prograsm without knwing the
algorithms
is like fat cat in a rat hole.
One cant hide one's intelligence quotient by commenting that the code
is unreadable
when you are searching for the algorithm from the code.
Mahesh Naik

Aslan wrote:
> "Pavel Vozenilek" <pavel_v...@yahoo.co.uk>, haber iletisinde þunlarý
> yazdý:4jq1ltF...@individual.net...

jacko

unread,
Aug 8, 2006, 10:55:37 AM8/8/06
to
hi

do you guys/gals ever write anything in forth or is the bloat of C++
more to your job requirement?

algorithm bloat is such a seriously underrated problem now that
objectionable oriented languages have become fad and one class handle
is wasted not getting to the practical need for four primary classes.

All this object abstract behiviour is overridden in the actual
subclasses, that to start with one class and fail to grasp the
everything will either be a process, a output, a input or a persistant
memory of something in the way computer programmers would use the
objects.

die object die!!

ada io channel 4 mux blend quad name sun.package.reflection .....

michael

unread,
Aug 9, 2006, 10:42:57 AM8/9/06
to
You're not serious, are you? If written correctly, C++ is extremely
streamlined.
You get inheritance, polymorphisms, templates etc. When they are all
used
effectively, you get code that is inherently more stable, more easily
expanded
and quite often far smaller code wise.

In general, if you understand the problem you are about to model using
the
language C++, from beginning to end, then you can lay out your classes
in
such a way as to make the problem far clearer to those who do not see
the
problem so clearly.

A good example of this is human language. If you grab a book written
in
English without knowing how to model what you are seeing, you won't be
able
to get any information out of the text. But, if you understand the
core of the
language (symbols) then you can build upon this atomic object and
create a
very robust language. So, in C++ you might start by creating a
'Symbol' class.
Then this symbol class might be expanded to include several descendants
such as 'Letter' and 'Digit' and 'Punctuation'. Then you can create a
second set of classes which are related that deal with vectors of these

Symbol descendants such as 'Word', 'Number' etc. and then finally,
these
are expanded upon in vectors of their own called 'Sentences',
'Paragraphs' etc.

Now you have a method with a few small classes which can be used to
begin to model
all of the syntax of the English language. This in turn allows you to
construct syntax
checking, context modeling etc. So from very little, you can begin to
model
something that is almost boundless using object oriented languages such
as C++.

I'm not knocking other languages, but you can not slight object
oriented approaches
in this regard, where they are so very strong.


To the OP, yes, the code is ugly (sorry Dmitry) but just spend a little
time normalizing
the spacing, indenting etc and start adding your own comments in as you
start to
understand some small localized areas of code. Before you know it, you
will start
to see it all more clearly. And there is some room for improvement,
speed wise,
above what he has achieved too. Also, I agree that it is not the text
book version of
fine C++. But then, the algorithm is great.

-Michael A Maniscalco

rug...@gmail.com

unread,
Aug 9, 2006, 12:36:09 PM8/9/06
to
Hey,

michael wrote:
> You're not serious, are you? If written correctly, C++ is extremely
> streamlined.
> You get inheritance, polymorphisms, templates etc. When they are all
> used
> effectively, you get code that is inherently more stable, more easily
> expanded
> and quite often far smaller code wise.

More stable than what? Java? ANSI C? Ada?

Smaller than what? In my limited experience (and dynamic linking
doesn't count!) C++ always seems to be bloated.

> In general, if you understand the problem you are about to model using
> the
> language C++, from beginning to end, then you can lay out your classes
> in
> such a way as to make the problem far clearer to those who do not see
> the
> problem so clearly.

Only if they understand C++. Even the best-written, cleanest, most
standard-compliant C++ code is gibberish to the uneducated. Not sure
C++ is what I'd call "clear".

> A good example of this is human language. If you grab a book written
> in
> English without knowing how to model what you are seeing, you won't be
> able
> to get any information out of the text. But, if you understand the
> core of the
> language (symbols) then you can build upon this atomic object and
> create a
> very robust language.

<snip>

> So from very little, you can begin to model
> something that is almost boundless using object oriented languages such
> as C++.
>
> I'm not knocking other languages, but you can not slight object
> oriented approaches
> in this regard, where they are so very strong.

If you can work with it, good. BTW, not implying that it's no good, BUT
... I wouldn't use it for exclusively, that's for sure.

> To the OP, yes, the code is ugly (sorry Dmitry) but just spend a little
> time normalizing
> the spacing, indenting etc and start adding your own comments in as you
> start to
> understand some small localized areas of code. Before you know it, you
> will start
> to see it all more clearly. And there is some room for improvement,
> speed wise,
> above what he has achieved too. Also, I agree that it is not the text
> book version of
> fine C++. But then, the algorithm is great.

If you don't like the code layout, use GNU indent on it.
http://www.gnu.org/software/indent/

As far as "goto" usage is concerned, I don't think that can constitute
"ugly" anymore: almost every C/C++ program seems to use it (Bzip2,
Zlib, GNU diff, GNU sed, GNU ed, NASM, OpenWatcom WASM, Descent, Duke
Nukem 3D, etc.).

P.S. jacko, lol: "die object die!!" :-)

michael

unread,
Aug 9, 2006, 1:06:13 PM8/9/06
to

rug...@gmail.com wrote:
> Hey,

<snip>

>
> More stable than what? Java? ANSI C? Ada?

I'm not talking specifically about the language, but more about the
concept of
object oriented design. Once you have your base classes and object
hierarchy
set up well and well tested, you can extend them quickly and clearly
with a
good chance of maintaining the original stability of the core classes.
The STL
is a good example. You don't rewrite a queue class or a stack class.
You simply
use them because they are fast, well written and very stable.

>
> Smaller than what? In my limited experience (and dynamic linking
> doesn't count!) C++ always seems to be bloated.

I'm talking code in the written sense. Not in the compiled sense. And
I have never
noticed C++ code being any more or less bloated than any other language
in this
regard either.

>
> > In general, if you understand the problem you are about to model using
> > the
> > language C++, from beginning to end, then you can lay out your classes
> > in
> > such a way as to make the problem far clearer to those who do not see
> > the
> > problem so clearly.
>
> Only if they understand C++. Even the best-written, cleanest, most
> standard-compliant C++ code is gibberish to the uneducated. Not sure
> C++ is what I'd call "clear".

Well, that probably goes without saying. But I'm assuming that anyone
who is
going to comment in such as way is familiar with the language before
making
such comments. Again, I'm addressing more OO than C++ but using C++ as
the example.

True. But I would do it by hand since it's only a few hundred lines
and
there are a lot of oddities in the code in this example. Plus you need
to go
through this code line by line anyhow to get a clear understanding of
what
Dmitry is doing.

>
> As far as "goto" usage is concerned, I don't think that can constitute
> "ugly" anymore: almost every C/C++ program seems to use it (Bzip2,
> Zlib, GNU diff, GNU sed, GNU ed, NASM, OpenWatcom WASM, Descent, Duke
> Nukem 3D, etc.).

Ehh. Goto is fine, I guess. I wouldn't ever use it but that's more
style than anything
else.

- Michael

Pavel Vozenilek

unread,
Aug 11, 2006, 5:25:39 PM8/11/06
to

"Aslan" wrote:

>> The "two columns" indentation is likely
>> to help to keep both pipelines of Pentium full.
>
> How come? You mean the C++ compiler will do it in a better way than what
> it
> normally does, if it is written that way?
> I thought it was for displaying it (or printing it out) in a very tight
> space.
>

Either this or to visually separate code
that goes into different pipelines.
Tools like VTune allow to find this information
and the formatting may represent it.

/Pavel


Matt Mahoney

unread,
Aug 12, 2006, 1:59:29 PM8/12/06
to

Maybe it is to save paper when printing the source code.

-- Matt Mahoney

0 new messages