[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

for your languages

io_x

5/28/2011 7:09:00 AM

are you sure your langages are better than some type of macro-assembly?


145 Answers

cr88192

5/28/2011 9:48:00 AM

0

On 5/28/2011 12:08 AM, io_x wrote:
> are you sure your langages are better than some type of macro-assembly?
>

apologies in advance for taking what seems to be troll bait...

but, anyways...
the main advantages of C and C++ over macro-assembly is that these
languages are far more readily portable (between OS's and CPU
architectures), whereas most macro-assemblers are still often very
specific to a particular OS and/or architecture, and, most often, to a
specific macro-assembler.

so, in this sense, they are "better"...

now, as for C vs C++, or something being "universally better", I don't
personally believe any such "universal betterness" exists.

ASM has its uses, and C also has its own uses. neither is ideal for what
the other is strong at.


much like, the strength of C++ is that it has lots of features...
and the strength of C is that it does not have these features...

to clarify:

C++ has lots of features which make programming in C++ arguably somewhat
nicer than programming in C.

but, most of these same features being absent from C, give it a much
simpler syntax, meaning it is much easier to use tools with it (either
having tools which automatically generate special-purpose code, or which
effectively parse the source code to mine information for use for other
purposes, such as gluing against custom HLL's, implementing reflection
mechanisms, ...).

another area is that C generally has a more standardized ABI than C++,
meaning that mixing code from different compilers is a little less
liable to blow up in ones' face.


but, for example, one can do things like Class/Instance OO or generic
containers or similar in C++, and not have it look so much like an
awkward and nasty mess. whereas in C, it is more common to use raw
structs and function pointers to do OO style tasks, and typically any
"container" style tasks have the logic written clean for the specific
type of object being contained (typically there is no real clear
separation between the "container" and "the thing being contained").

that, or one resorts to using dynamic-type checking for implementing
their containers (this is its own matter, along with using a garbage
collector, ...).

so, where a C++ programmer may think "std::sort", a C programmer may
resort to memorizing the quicksort algorithm and typing it out
on-demand, or a C++ user using "std::hash_map" vs a C programmer
proceeding to write out the logic for hashing and fetching values, ...


but, what is "best" is rarely as clear-cut as people make it out to be.


much like many people think Java is one of the best languages around,
and some of us can't bring ourselves to try to choke it down... it has
some merits (fairly clean language design, and many interesting
VM-related capabilities) and some drawbacks (such as being awkward to
use and often needing far more code to accomplish the same task, as well
as being rather awkward to use in mixed-language projects with C and
C++...).

and, meanwhile, I have my own scripting HLL (BGBScript), which sort of
resembles a mix of JavaScript, ActionScript, Java and a few other
languages (some other influences have included Scheme, Self, and
Erlang), and tries to offer a fairly transparent FFI (its main feature
at present is that it is smart enough to largely interface directly with
C-based APIs with little or no special treatment).

my "general" goal has then been an FFI no more particularly difficult to
use than C++'s 'extern "C"' mechanism (take, for contrast, the piles of
nasty cruft needed to make things like JNI work).

a standing goal though is to get around to making it more symmetric, so
that the FFI transparently goes both ways (transparent C->BS calls, in
addition to transparent BS->C calls...).

yes... it also generally (mostly) works on raw pointers and C structs
and similar as well.



but, its drawbacks are that the implementation is notably far from being
"mature" (just how often do I have to debug things?...). and, as well, I
am probably the *only* person who uses it, so it doesn't have the same
sort of status or popularity as say, Java or Lua or Python or ...
(Python being IMO one of the few languages which would make me much
rather use Java instead...).

but, in this case, what is "best" likely depends more on personal
preferences and what one is doing with it, than any sort of empirical
measure.


or such...

Rui Maciel

5/28/2011 10:07:00 AM

0

io_x wrote:

> are you sure your langages are better than some type of macro-assembly?

I would say that all high level programming languages are macro-assembly
languages of sorts, varying in their level of abstraction and how their
macros are implemented and handled.


Rui Maciel

Kleuskes & Moos

5/28/2011 10:34:00 AM

0

On May 28, 9:08 am, "io_x" <a...@b.c.invalid> wrote:
> are you sure your langages are better than some type of macro-assembly?

They're certainly more convenient in many circumstances.

cr88192

5/28/2011 10:38:00 AM

0

On 5/28/2011 3:06 AM, Rui Maciel wrote:
> io_x wrote:
>
>> are you sure your langages are better than some type of macro-assembly?
>
> I would say that all high level programming languages are macro-assembly
> languages of sorts, varying in their level of abstraction and how their
> macros are implemented and handled.
>

well, except that traditional macro-assemblers (say, MASM or TASM) are
more like "ASM with features", whereas HLLs generally work in terms of
some basic abstract computational model, with little/no direct
visibility into what is going on in the machine-level ISA.

for example, C represents a different conceptual model than does, for
example, an x86 assembler...


granted, yes, compilers do sort of resemble macro-transforms, except
that compilers usually use ASTs and free-form transformations (and often
various optimizations, ...), whereas traditional macro-expanders are
typically far more limited, usually only performing simple expansion and
substitution tasks.

also, most macro-expanders I have seen are single-stage (single pass or
multiple pass, and assembly is usually single-stage, although AFAICT
many assemblers use multiple passes for sake of compacting jumps and
similar), whereas typically compilers will use a chained set of
transformation stages, for example:
preprocessor;
parser (source -> AST);
front-end compiler (AST -> high-level IR);
middle-end compiler (high-level -> low-level IR);
back-end compiler (low-level IR -> ASM);
assembler;
....

or such...

Bartc

5/28/2011 3:02:00 PM

0



"Rui Maciel" <rui.maciel@gmail.com> wrote in message
news:4de0c923$0$16160$a729d347@news.telepac.pt...
> io_x wrote:
>
>> are you sure your langages are better than some type of macro-assembly?
>
> I would say that all high level programming languages are macro-assembly
> languages of sorts, varying in their level of abstraction and how their
> macros are implemented and handled.

Not really. How would you implement this as a macro:

a=b;

And which of the hundreds of possible machine language sequences would it
end up as?

--
bartc

Uncle Steve

5/28/2011 3:15:00 PM

0

On Sat, May 28, 2011 at 11:06:30AM +0100, Rui Maciel wrote:
> io_x wrote:
>
> > are you sure your langages are better than some type of macro-assembly?
>
> I would say that all high level programming languages are macro-assembly
> languages of sorts, varying in their level of abstraction and how their
> macros are implemented and handled.

OO representations are a lot of work in C, but the language isn't
designed to make OO tasks convenient by way of some abbreviated
syntax. ASM is even worse. I enjoy using C for several reasons, not
the least of which is its near-asm performance with optimizing
compilers. The simple abstract numerical model of arithmetic in C
makes 99% of mathematical expressions simple to write, e.g.: a = b +
sqrt(c) -- no messy syntax. Input and output file operations are
convenient enough to use for scripting purposes, and in general the
C-library has everything you might need for 99% of the software you
might have to write.

ASM is non-portable by definition, so regardless of the size of your
macro-library, it's usefulness is tied to the life of the platform.
There must be tons of good code and algorithms lost forever because
they were written for a specific platform that was succeeded by
something with a different instruction set. C gets you just far
enough away from the hardware to make portability feasible, reducing
all that otherwise wasted effort.

Genetic programming or artificial intelligence research might not be
very nice to do in C, but for those problems we have OO languages, and
you really don't want macro assembler for that.



Regards,

Uncle Steve

--
Should a professional politician be charged with molestation if he
kisses babies while attending political rallies?

Lorenzo Villari

5/28/2011 6:05:00 PM

0

On Sat, 28 May 2011 11:15:18 -0400
Uncle Steve <stevet810@gmail.com> wrote:

>
> Genetic programming or artificial intelligence research might not be
> very nice to do in C,
>

Why?

Uncle Steve

5/28/2011 6:16:00 PM

0

On Sat, May 28, 2011 at 08:05:20PM +0200, Lorenzo Villari wrote:
> On Sat, 28 May 2011 11:15:18 -0400
> Uncle Steve <stevet810@gmail.com> wrote:
>
> >
> > Genetic programming or artificial intelligence research might not be
> > very nice to do in C,
>
> Why?

I haven't tried to, if that's what you're asking. I can just
sort-of envision what it is that AI programmers do from the little
literature I've skimmed, and I can't imagine doing that stuff in C.

I think you'd have to be a robot to do it successfully.



Regards,

Uncle Steve

--
Should a professional politician be charged with molestation if he
kisses babies while attending political rallies?

Rui Maciel

5/28/2011 6:37:00 PM

0

BartC wrote:

> Not really. How would you implement this as a macro:
>
> a=b;

What do you mean by a=b ?


Rui Maciel

Keith Thompson

5/28/2011 7:07:00 PM

0

Rui Maciel <rui.maciel@gmail.com> writes:
> io_x wrote:
>> are you sure your langages are better than some type of macro-assembly?
>
> I would say that all high level programming languages are macro-assembly
> languages of sorts, varying in their level of abstraction and how their
> macros are implemented and handled.

I would say that you're ignoring the meaning of "macro-assembly".

A program in a macro-assembly language specifies (perhaps indirectly in
some cases) the CPU instructions to be generated. A program in a high
level language, including C, specifies behavior.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"