Page 1 of 2
I love this forum
Posted: Mon Apr 27, 2009 9:42 pm
by dude101
I was getting depressed browsing the net and reading so many comments everywhere saying that computers are fast now days so use an interpreted language because C is to hard blah blah.
I find it discusting that IC engineers have to do so much work to bring us modern awsome processors, and then lazy programmers just crap on their work by using interpreted scripts for things that really should be compiled.
Then I browse this forum and everyone is talking about C, assembly, registers, optimizations, etc...
Good stuff. Its nice to know there are still people on the internet that care about performance and actually understand how computers work.
Re: I love this forum
Posted: Mon Apr 27, 2009 9:50 pm
by earlz
yay! someone to join in the fight against garbage collection! lol
I have two sides to my world though.. the low-level side and the portable side... I contradict myself quite a bit in this kind of discussion..
Re: I love this forum
Posted: Mon Apr 27, 2009 9:57 pm
by dude101
Well C code can be pretty portable and C compiler exists for nearly ever processor out there.
Of course if your write portable code that means you cant do fun stuff like use intrinsics and inline assembly
Re: I love this forum
Posted: Mon Apr 27, 2009 10:00 pm
by dude101
I quickly browsed through your AlloyOS code. You seem like a smart guy. I wish there were more programmers like you.
Re: I love this forum
Posted: Tue Apr 28, 2009 8:24 am
by Creature
I agree; it actually is a comfort to see these forums will loads of C/C++/ASM/D programmers cause for some reason, these languages (and a few others) only give the feel of a real language. Java can theoretically be seen as just a platform (it runs on top of JRE, unless you use a seperate Java compiler). Visual Basic was simply 'abandoned' by Microsoft in favour of C# which I find pretty sad. Besides that, there are other BASIC languages that are better.
I would probably never be good as an interpreted language programmer, I'd be wondering too much about the possible (doesn't matter how small) performance increase I could have if I were to use C/C++.
Re: I love this forum
Posted: Tue Apr 28, 2009 12:20 pm
by earlz
Creature wrote:I agree; it actually is a comfort to see these forums will loads of C/C++/ASM/D programmers cause for some reason, these languages (and a few others) only give the feel of a real language. Java can theoretically be seen as just a platform (it runs on top of JRE, unless you use a seperate Java compiler). Visual Basic was simply 'abandoned' by Microsoft in favour of C# which I find pretty sad. Besides that, there are other BASIC languages that are better.
I would probably never be good as an interpreted language programmer, I'd be wondering too much about the possible (doesn't matter how small) performance increase I could have if I were to use C/C++.
Yea.. performance is what I worry about. Even with PHP code I find myself thinking "Well I could write a C executable and use exec instead of doing this complex computation in PHP" But my problem with most interpreted languages is there is no set variable size. Pointers can be any size, as can integers and even characters. And in quite a few such languages there isn't a "sizeof" and there is no easy and direct way to know the size of things such as stdint. so you end up either hoping that it'll convert to big numbers(which ruby does, so I kinda like it) when appropriate, or that my application isn't vulnerable to integer overflow.
Re: I love this forum
Posted: Tue Apr 28, 2009 4:38 pm
by pcmattman
dude101 wrote:Of course if your write portable code that means you cant do fun stuff like use intrinsics and inline assembly
That's what #ifdef is for
Code: Select all
#if defined(_GNUC) // Or whatever it is, can't remember off the top of my head
#if defined(X86)
asm volatile("x86 asm here");
#elif defined(ARM7)
asm volatile("ARM7 asm here");
#else
#error Unsupported target!
#endif
#elif defined(MSVC) // Again, you get the idea :)
// MSVC-specific inline ASM
#endif
Re: I love this forum
Posted: Tue Apr 28, 2009 8:19 pm
by dude101
pcmattman wrote:dude101 wrote:Of course if your write portable code that means you cant do fun stuff like use intrinsics and inline assembly
That's what #ifdef is for
Code: Select all
#if defined(_GNUC) // Or whatever it is, can't remember off the top of my head
#if defined(X86)
asm volatile("x86 asm here");
#elif defined(ARM7)
asm volatile("ARM7 asm here");
#else
#error Unsupported target!
#endif
#elif defined(MSVC) // Again, you get the idea :)
// MSVC-specific inline ASM
#endif
Lol, yea.
Re: I love this forum
Posted: Wed Apr 29, 2009 5:25 am
by Creature
It's neat that the compilers have inline assembly code and all, but I still resent the difference between the VC++ compiler and the GCC compiler. Even though I understand they want to use AT&T syntax (for some people, code in this syntax 'says more'), it's pretty annoying that GCC has AT&T syntax whilst Visual C++ has a (IMHO) much easier to use Intel syntax. Besides that, I think Visual C++ ASM is just much easier to use. It's like writing code for NASM in your C code and in the meantime you can simply use parameters and variables as operands, it's just so easy in comparison to GCC.
But then again, that's just my opinion.
Re: I love this forum
Posted: Wed Apr 29, 2009 6:08 am
by yemista
Well I love the low level programming, but after doing a bit of web programming, I can see why php has its place. The amount of work that goes into creating a basic web page run on a server is bad enough, so it is nice to be able to throw something together in php because your most dealing with text, so untyped variables prove to be very useful.
Re: I love this forum
Posted: Wed Apr 29, 2009 12:41 pm
by earlz
I think intel syntax is much better. It just seems better, and it follows the format of the official intel documents.
And for PHP it's true that's better for text processing.. I wish it had regex support more built in though.
But thinking "everything is a string in some form" is bad. My Java teacher taught us today how all files are strings, and to write integers you must first convert them to string. That annoyed the hell out of me. Text files are big strings(also, \n characters don't exist in files, Java just magically knows where to stop reading a "line") but data files are big numbers! grr ignorance..
Re: I love this forum
Posted: Thu May 14, 2009 12:58 pm
by steveklabnik
Often times higher level languages provide the ability to develop applications much more quickly, which easily outweigh the benefits of C.
Use the right tool for the job. If I'm using Ruby and you're using C, I'll smoke you when it comes to making websites, you'll smoke me when it comes to writing drivers.
Re: I love this forum
Posted: Thu May 14, 2009 2:55 pm
by NickJohnson
Well, that also depends on how good of a library you have at your disposal in either language. Even though C syntax is (arguably) not as "concise" as Ruby or Python, effectively all languages have the ability to be augmented with the right functions. Not only that, but if you made a library that could, say, emulate most of the useful functions of Python (lists, slices, GC), it would probably more than pay off for the weird syntax with the 20 to 500 fold increase in speed. You could even do dynamic typing by making all variables void pointers that point to a structure preceding a data type that identifies it, and only maybe double memory usage.
Re: I love this forum
Posted: Thu May 14, 2009 3:51 pm
by steveklabnik
nickbjohnson4224 wrote:Not only that, but if you made a library that could, say, emulate most of the useful functions of Python (lists, slices, GC),
Isn't this called a Python interpreter?
it would probably more than pay off for the weird syntax with the 20 to 500 fold increase in speed.
Speed in an absolute sense
does not matter. At all. I care much, much more about how fast I can make my program do what I want it to do. Optimization comes later.
I'm not the only one who thinks so.
Re: I love this forum
Posted: Sun May 17, 2009 7:55 pm
by NickJohnson
I'm not talking about making another Python interpreter, and I'm not talking about premature optimizations either. I mean you could actually have a C library with functions that allow you to make things work like Python in *native C code*. The syntax would be odd, but it is undoubtedly possible.
Here's an example of how I could implement slices in C. First off, you make a string structure with two elements. The first is an integer, and the other a pointer. The integer lists the length of the string (essentially making a Pascal-style string) and the pointer points to the string. If you want a slice, a function called slice() would pass back a string structure pointing to a section of the original, with a different length. You can then concatenate strings with a special version of strcat(). GC can be done with some special restrictions on pointers as well as threading. If C had a more flexible syntax, more like Lisp, you could make nearly anything work, and at a smaller speed price than a very high level language.
The whole optimization thing doesn't even really apply. If you match completely unoptimized C code to even horrendously optimized Python, also assuming the same algorithm, the C will always beat the Python. So if you could get C to look decent while doing high level stuff (which I'm not claiming is possible), why not use it?
The main reason why we aren't using C for more things is it's lack of really good, powerful libraries. There's nothing magic about very high level languages - everything is equally powerful (although C also has pointers, which are a big plus). It's just the syntactic sugar that sets things apart.
Edit:
What I really mean to say is that: A. it would be really cool to make C do much that Python can, and B. why waste so many clock cycles by restricting ourselves to languages that have such strict requirements if we can adapt something with more control? I don't mean to sound like a zealot: I just think it might be an interesting idea.