Slightly OT : New Language
Slightly OT : New Language
Why do we assume that anything like C hsa to be a high level language. Surely you could design a new C compiler with more in built functions such as loadgdt (replacing the assembly lgdt) and allow the compiler to skip the assembling step and convert it straight to an object file or flat binary. Why hasn't this been done as it incorperates the speed and low level functions of assembly with the easier programming of C. Have I missed something? Does anyone know how this would be done? Any other comments? If there are no problems would anybody else be interested in the project?
Therx
Therx
Re:Slightly OT : New Language
Why not just create an inline function called GDT with the asm code for GDT inside it?
What you are suggesting would also reduce the portability of the language and tie a particular subset to a specific platform.
Peter
What you are suggesting would also reduce the portability of the language and tie a particular subset to a specific platform.
Peter
Re:Slightly OT : New Language
Right, this can all be achieved by writing some inline assembly-language functions and linking to flat binary. Granted, it's not Standard C (there's that word again! ) but it does already exist.
Re:Slightly OT : New Language
But it would still increase speed as it would turn C from being a language to an assembler
Re:Slightly OT : New Language
Not necessarily. Some C code is faster than some assembler code, and some assembler code is faster than some C code. It's all machine code in the end.
Maybe you're thinking of a language where each source line translates directly to one instruction; something like HLA.
Maybe you're thinking of a language where each source line translates directly to one instruction; something like HLA.
Re:Slightly OT : New Language
I hate to pick up on tecnicalitys. But C can only be AS fast as asm, not faster. Because the code produced by the compiler can be copied in asm.
Re:Slightly OT : New Language
There is slow assembly and fast assembly. For example, a quicksort routine written in C will out-perform a heapsort algorithm written in assembly. Assembly vs. C is only one small factor in overall speed; rewriting a bad routine in assembly won't make it any better.
Re:Slightly OT : New Language
I know that, all I was saying was you can wright assembly code that is just as fast as C's output. But you can NOT make code in C that is faster than asm.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Slightly OT : New Language
i have to disagree with this. The compiler can make use of complex optimization rules (for a better use of the pipelines) than a human being will miss ... Some new optimization technique can be learned by disassembling compiler-generated code, but in most of the case a human just do what it guess being the fastest (provided that he want to do the best optimization when the code is written - which is not the case in 80%), while a compiler can try out several options, quantify them (in terms of bytes consumed or cycles consumed) to produce the best code for the target platform ...jamescox3k wrote: I know that, all I was saying was you can wright assembly code that is just as fast as C's output. But you can NOT make code in C that is faster than asm.
Re:Slightly OT : New Language
..
Last edited by Perica on Sun Dec 03, 2006 9:07 pm, edited 1 time in total.
Re:Slightly OT : New Language
Yeah, but let's face it, human beings can cheat by looking at the output from a compiler and improving on it. So a skilled human can always (Unless it's a very simple program) beat the compiler simply by taking the compiler's output and adding some of the seriously complicated optimisations that can't be done in a generic fashion by the compiler.
Of course there's a very good reason why we use compilers more than assembly language now. There's also a very good reason why there aren't that many gifted assembly language programmers left. Pity.
Of course there's a very good reason why we use compilers more than assembly language now. There's also a very good reason why there aren't that many gifted assembly language programmers left. Pity.
Re:Slightly OT : New Language
..
Last edited by Perica on Sun Dec 03, 2006 9:07 pm, edited 1 time in total.
Re:Slightly OT : New Language
The answer to the second question intuitively lies in the obvious answer to the first question.
All in all though, I just see a lack of truly gifted programmers (regardless of language) in the market all together. It is pretty easy to fake your way though programming - and many people do never really understanding what they are doing. But more important, is why. A common question I ask in interviews for C++ canadat is why would you NOT declare a destructor virtual. You should see some of the answers I get - even from people with CS degrees and 5+ years C++ experience. And ask a person to write you some code in an interview sometime, and God forbit you ask them to do it on a white board.
It is funny to see how many people get offended that I might test their "said" skill set.
_mark()
All in all though, I just see a lack of truly gifted programmers (regardless of language) in the market all together. It is pretty easy to fake your way though programming - and many people do never really understanding what they are doing. But more important, is why. A common question I ask in interviews for C++ canadat is why would you NOT declare a destructor virtual. You should see some of the answers I get - even from people with CS degrees and 5+ years C++ experience. And ask a person to write you some code in an interview sometime, and God forbit you ask them to do it on a white board.
It is funny to see how many people get offended that I might test their "said" skill set.
_mark()
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Slightly OT : New Language
Of what use would be such a language ? i mean, consider how often you use low-level functions like "lgdt" or "lsl" in a kernel ... you only have a couple of call to them ... if not a single oneTherx wrote: Why do we assume that anything like C hsa to be a high level language. Surely you could design a new C compiler with more in built functions such as loadgdt
And i'm not even talking about the use of such features in a system program like a file server or a device driver nor about their use in a common user program ...
where do the speed of asm come from ? isn't it just a myth .... i mean, in 80486 times, it was much faster to unroll your loops and use registers ... Now with the multi-level caches of the Pentium processor, it has roughly the same cost to access a register-held variable or a L1-cached memory location (and most of the stack content for your local frame *will* be cached ... so is there really a measurable advantage of using very low-level code ?Why hasn't this been done as it incorperates the speed and low level functions of assembly with the easier programming of C. Have
even replacing stack by register in calling conventions don't really speed up the code nowadays ...
and virtually nothing prevents you to write your C code so that you explicitly reuse the result of intermediate computation.
If you doubt the compiler will optimize
Code: Select all
x*y + (z*x*y)/2
Code: Select all
{int xy = x*y; xy+(z*xy)>>1;}
Re:Slightly OT : New Language
This is the point i've been trying to get at. You can craete code in asm that is faster than C. But you can never code any thing in C that couldn't be done in asm at the same speed. Simply becuase C compiles to machine code and asm is just a slight layer above machine code.Yeah, but let's face it, human beings can cheat by looking at the output from a compiler and improving on it. So a skilled human can always (Unless it's a very simple program) beat the compiler simply by taking the compiler's output and adding some of the seriously complicated optimisations that can't be done in a generic fashion by the compiler.
Of course there's a very good reason why we use compilers more than assembly language now. There's also a very good reason why there aren't that many gifted assembly language programmers left. Pity.