I love this forum

Programming, for all ages and all languages.
dude101
Member
Member
Posts: 56
Joined: Thu Apr 09, 2009 10:26 pm

I love this forum

Post 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.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: I love this forum

Post 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..
dude101
Member
Member
Posts: 56
Joined: Thu Apr 09, 2009 10:26 pm

Re: I love this forum

Post 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 :-)
dude101
Member
Member
Posts: 56
Joined: Thu Apr 09, 2009 10:26 pm

Re: I love this forum

Post by dude101 »

I quickly browsed through your AlloyOS code. You seem like a smart guy. I wish there were more programmers like you.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: I love this forum

Post 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++.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: I love this forum

Post 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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: I love this forum

Post 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
dude101
Member
Member
Posts: 56
Joined: Thu Apr 09, 2009 10:26 pm

Re: I love this forum

Post 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.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: I love this forum

Post 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.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: I love this forum

Post 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.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: I love this forum

Post 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..
User avatar
steveklabnik
Member
Member
Posts: 72
Joined: Wed Jan 28, 2009 4:30 pm

Re: I love this forum

Post 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.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: I love this forum

Post 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.
User avatar
steveklabnik
Member
Member
Posts: 72
Joined: Wed Jan 28, 2009 4:30 pm

Re: I love this forum

Post 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.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: I love this forum

Post 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.
Last edited by NickJohnson on Sun May 17, 2009 8:16 pm, edited 1 time in total.
Post Reply