Page 2 of 4
Re: Why do people say C is better than Assembly?
Posted: Thu Jan 12, 2017 4:02 pm
by dozniak
bzt wrote:@dozniak: what I meant constant folding and constant propagation and liveness analysis never will be as good as algorithmic optimalization.
Contradiction: they ARE algorithmic optimisations. Ergo they are AS GOOD AS.
Re: Why do people say C is better than Assembly?
Posted: Thu Jan 12, 2017 4:03 pm
by dozniak
bzt wrote:@Octocontrabass: could be! According to the wiki, DEC have used MIPS. I really don't remember, I can only recall my "wtf is happening here?!?" moment
https://en.wikipedia.org/wiki/Delay_slot
MIPS and SPARC are probably the most prominent users of these.
Re: Why do people say C is better than Assembly?
Posted: Thu Jan 12, 2017 5:05 pm
by gerryg400
bzt wrote:I agree on all what you said, except this one. A human is always smarter than any compiler, .....
This is either wrong or irrelevant depending on how you define 'smarter'.
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 2:44 am
by DixiumOS
Another way to say that C is good is that in Assembly you can't use numbers as large as... 1.7x10^308.
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 2:57 am
by dchapiesky
Schol-R-LEA wrote:
Well, that's the thing, you really can't - I mean, you can learn to read it to some degree, just from the similarities it has to other procedural languages if nothing else, but without practice at writing C code, you'll never really get a feel for the language. So in that sense, yes, you would need to write a significant amount of C code before you could read it well.
To expand upon this statement I think the reason we have so many different languages is the that we have so many different problem contexts.... a simple example being:
1) geometry
2) topography
3) algebra
4) calculus
each involves math but each has a different nomenclature for describing problems within their respective contexts.
So if your problem context is controlling hardware in a very specific fashion - perhaps a programmer would feel more comfortable thinking about solving the problem in assembler.
If a programmer were not versed in assembler - they might still have a chance to solve the problem using C and absolute address pointers and in() and out()....
Yet said programmer could not attempt to solve the problem using a language such as PHP as it is directed at a completely different problem context - building web pages programmatically.
I have found that thinking about a problem and its solutions via different languages enlightening if only to find - hey you can't actually do that in C++ but you can in C because of less type checking... etc..
cheers
Techel
Posted: Fri Jan 13, 2017 2:59 am
by Techel
DixiumOS wrote:Another way to say that C is good is that in Assembly you can't use numbers as large as... 1.7x10^308.
What does make you think this?
Re: Techel
Posted: Fri Jan 13, 2017 3:09 am
by DixiumOS
Techel wrote:DixiumOS wrote:Another way to say that C is good is that in Assembly you can't use numbers as large as... 1.7x10^308.
What does make you think this?
floats, doubles...
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 3:15 am
by Octocontrabass
DixiumOS wrote:floats, doubles...
Have you checked any
assembler documentation for those, or are you just guessing?
Re: Techel
Posted: Fri Jan 13, 2017 3:16 am
by iansjack
DixiumOS wrote:Another way to say that C is good is that in Assembly you can't use numbers as large as... 1.7x10^308.
And yet C translates into assembler. There's a paradox there somewhere.
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 3:18 am
by BrightLight
DixiumOS wrote:floats, doubles...
This clearly says you don't know how C works. Did you know that part of compiling your C file is converting it to assembly language and then assembling it? Literally, yes literally,
anything that can be done in C can be done in assembly language, because assembly is just the mnemonic representation of the CPU's bytecode.
Please, don't argue about topics you know nothing about. In a few years from now, you'll realize you've been humiliating yourself since you signed up for this forum.
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 3:19 am
by DixiumOS
I meant that almost no one knows how to do floating point in Assembly.
Hint:
Code: Select all
fld num1 ; load num1 and push it onto the fpu stack
fld num2 ; load num2 and push it onto the fpu stack
faddp ; pop two numbers, add them, push sum on the stack
fstp res ; pop sum from the stack and store it in res
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 3:33 am
by BrightLight
DixiumOS wrote:I meant that almost no one knows how to do floating point in Assembly.
Hint:
Code: Select all
fld num1 ; load num1 and push it onto the fpu stack
fld num2 ; load num2 and push it onto the fpu stack
faddp ; pop two numbers, add them, push sum on the stack
fstp res ; pop sum from the stack and store it in res
Just because you don't know doesn't mean no one knows. BTW, using the FPU is deprecated and, by default, 64-bit applications utilize SSE.
Code: Select all
; double precision (this is "double" type in C)
movapd xmm1, [num1]
movapd xmm2, [num2]
addpd xmm1, xmm2
; XMM1 contains result
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 5:32 am
by iansjack
DixiumOS wrote:I meant that almost no one knows how to do floating point in Assembly.
Hint:
Code: Select all
fld num1 ; load num1 and push it onto the fpu stack
fld num2 ; load num2 and push it onto the fpu stack
faddp ; pop two numbers, add them, push sum on the stack
fstp res ; pop sum from the stack and store it in res
Well, anyone who can cut and paste from stackoverflow "knows" how to do that. Whether they understand it or not is another matter.
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 6:10 am
by bauen1
Re: Why do people say C is better than Assembly?
Posted: Fri Jan 13, 2017 6:44 am
by TheDev100
Assembly is much better than C.
so many people think C is fast these days... Assembly is like a few bytes. Imagine a boot sector in C. It would reach 1KB instead of 512 bytes.