Why do people say C is better than Assembly?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Why do people say C is better than Assembly?

Post 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.
Learn to read.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Why do people say C is better than Assembly?

Post 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.
Learn to read.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Why do people say C is better than Assembly?

Post 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'.
If a trainstation is where trains stop, what is a workstation ?
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Why do people say C is better than Assembly?

Post 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.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
dchapiesky
Member
Member
Posts: 204
Joined: Sun Dec 25, 2016 1:54 am
Libera.chat IRC: dchapiesky

Re: Why do people say C is better than Assembly?

Post 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
Plagiarize. Plagiarize. Let not one line escape thine eyes...
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Techel

Post 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?
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Techel

Post 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...
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Why do people say C is better than Assembly?

Post by Octocontrabass »

DixiumOS wrote:floats, doubles...
Have you checked any assembler documentation for those, or are you just guessing?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Techel

Post 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.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Why do people say C is better than Assembly?

Post 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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Why do people say C is better than Assembly?

Post 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
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Why do people say C is better than Assembly?

Post 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
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why do people say C is better than Assembly?

Post 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.
User avatar
bauen1
Member
Member
Posts: 29
Joined: Sun Dec 11, 2016 3:31 am
Libera.chat IRC: bauen1
Location: In your computer
Contact:

Re: Why do people say C is better than Assembly?

Post by bauen1 »

Dixium 2 google searches later:
You got it from here:
http://stackoverflow.com/questions/1185 ... n-assembly
and this one even says its wrong:
http://stackoverflow.com/questions/3371 ... y/33716807

=D> =D> =D>
myunix (version 3) (name suggestions are welcome!)
GPG Key fingerprint: 5ED6 D826 ACD4 3F8E D9D4 FBB2 FF0A AF5E 0812 BA9C
TheDev100
Member
Member
Posts: 27
Joined: Wed Jan 11, 2017 3:29 pm

Re: Why do people say C is better than Assembly?

Post by TheDev100 »

Assembly is much better than C. 8) 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.
Post Reply