First off, I didn't mean to - lol - offend anyone with my java rant. Note to self: Do NOT go in the dev section after, during, or before a loong (C/C++/ASM) coding session (erm - not at all?). After this message, I will NOT post anything java related in this thread - at all. I suggest everyone else does the same - but I won't stop you nor comment. Argh, how do I make this NOT sound like i'm trying to monopolise C/C++? Because that's just not it.
I said at the top of the post that some of the stuff in my post was not going to directly target points raised in this thread (yeah, bad sign
)
Klaue. I agree, I majorly derailed. And i'm still off the tracks
. If you'd like me to just obliterate all traces of Java-flaming, i'd be more than happy to. I really don't see why I feel the need to flame java, but it's always there. I guess I'm just jealous of those with the epic gaming rigs that can run x, and I can't, on my aging, yet still powerful, computer. I'm not being sarcastic here, i'm not trying to subtly add a point here. (If I had some DDR3 I'd probably not have any issues, one of the biggest things that makes C faster is that the RAM isn't getting raped as much).
I never assumed all java programmers were complete morons (I _knew_ it - just kidding
. Some of you are the smartest people I know). But I know that this has happened (again - by someone who is rather intelligent).
It's gonna be more than 1% for exotic platforms if you're doing anything other than games - there's so many microcontroller projects out there. The PC is no longer the only platform. Furthermore, (IIRC - and it might have changed)Apple's app store only allows programs written in Objective-C - so there's a platform with millions of users. So tell me now that java works everywhere useful(though it's rather hypocritical for me to mention this, I hate Apple, and especially their policies too). True, you can't port a C program to the iAnything either, without work - for one you gotta make it compile in an Objective-C compiler. Then you gotta not use any of your own, non-apple libraries, etc...
And knowing ASM is *very* helpful when optimising. Don't say optimisation is useless. It saves battery life, for one. And makes your music skip less(so does
renice for those having issues with that). It allows your program to *actually do stuff* in some cases. Just using CPU because you can is the worst thing a programmer can do(this is not the same as using CPU because using less requires a lot of extra programming). Plus, learning ASM first makes you appreciate C/C++. It won't make you think C/C++ is the hardest thing on the planet, because you'll know about ASM(I'm not making it out that it's the most impossible thing to work in, it's not really _that_ hard, but organisation is, arguably, a lot harder).
Learning ASM is good for improving security. While with things like mudflap and canary values, etc already set up for you, buffer overflows are pretty much not an issue (except on embedded systems, where protections are not an option due to the overhead), without ASM you wouldn't know how to fix this issue (besides the blatant ones). Or to exploit it, yes, ASM is good for breaking security too: www.smashthestack.org .
Also, knowing ASM allows you to, well, use it. You don't need to know how to cook to live, but it's good to be there, so when life gives you roadkill, you can make dinner (ew!). I have performance issues coding in C even, when writing a synth for the Arduino(speaking of roadkill). I had to tighten my code considerably, more needs to be done(yeah i'll admit my code sucks!), even, but I still would not achieve the performance I could with raw ASM. There are a lot of things I can see I could get around in ASM. Some of the changes I made to the C program I would not know without knowing (basic) AVR assembly. The interrupt has to complete in 32microseconds(31250KHz interrupt, 16Mhz CPU clock. I do 3 multiplications in the ISR (IIRC this is okay-ish since there's a two-cycle multiplication instruction, don't quote me on that. My result goes in a 16bit value though, which could make that instruction useless). One for each sound channel, as part of the volume control. This is a lot faster than alternatives (like modulo - hey does anyone know if that would actually work?I tried it first, and got noise so I just assumed I ran out of CPU time (like I predicted I would)) That doesn't give me a lot of instructions (well, it actually gives me plenty to do the work, it's all comparative).
Anyone who says you "Absolutely" don't need to learn ASM doesn't know asm. So, as if you were my friend, which is how I will treat you,
http://homepage.mac.com/randyhyde/webster.cs.ucr.edu/www.artofasm.com/DOS/fwd/fwd.html. A bit dated but still a good reference. The way I first learned any 'ASM' is in raw machine code (POKE'd in the opcodes) with a (real) C64 and a (real - btw - not being elitist with the mention of 'real') copy of The "Commodore 64 Programmer's Reference Guide", which can be found
Here. If you wanna try it, get a copy of VICE and poke in the program, starting at, idk, $C000 (hex C000, or dec 49152)
You need to convert the opcodes and addresses into decimal to POKE them. You'll need to split the addresses into two bytes (C64 is little-endian, which actually means the least significant goes first). For extra vintage flavor, no calculators
.
Then just SYS 49152.
Press keys and note the change of effect as the keyboard interrupt changes timing.
Yay - an ASM tutorial. Outdated, rather useless(tho it's a start for more useful projects - go out there and get an Arduino/AVR dev board (arduino is actually inconvenient for ASM - i've never done anything besides inlines, so I can't help)), but now they're not all C++
. (definately not trying to snipe the first poster - or anyone!).
There are reasons to not write your entire project, or any part thereof, in ASM - YES it is more difficult than a high level language. Ok, I was too extreme in my earlier post - you can gain from higher level languages, but spending a little more of your time can save a lot. Just like when a greenie asks you to walk to work instead of driving your V8 monster. I don't write whole projects in ASM(But when I finally get my parts i'll be running both my Z80 computer and DIY CPU with pure ASM - partly because the systems are too slow (can't get insane clock rates on protoboard. The sharp rises cause too much interference, using a slew limiter (RC lowpass filter) would just make stuff too complicated and unreliable (would need schmitt buffers) Also delay along the wires become a problem in a DIY cpu at high speeds.), and also because I can't be bothered to set up/write my own C compiler). I love ASM, as gfrancisdev said (not exactly), the simplicity is refreshing(I do believe he is my brother!). But I love C so much, I write in C - just like Java addicts are Java addicts, i'm a C addict. Like all addicts, I naturally recommend 'trying this shit' over anything else.
I never _meant_ C++ was 'new', but newer. People seem to always jump to the newest thing (like the people saying the Pandora is slow?).
"Hey I'm bored and I have nothing to do but hunt wild pointers. Let's make an out-of-place off-topic Java flame! Again!" - yep.
I left out an important statement: Use java if you will.
I'm not stopping anyone from either ignoring my post or using java. But i'm recommending (yeah, quite forcefully) against it. I'll post what I wanna post. It's possible to add me to an ignore list, I believe. Feel free, I really don't hold grudges. I'd never be able to contact you anyway, what's it matter?
The word 'java', in this context, is connected to a Non-Maskable Interrupt in my brain, which, unlike on x86(yeah, kinda contradictory, huh), cannot be masked. Idea: Make a huge "Don't use java, it's shit, and why" on another site, and link to it in my "ISR". I'm not hinting by this analogy, that people need to learn more about their hardware, you really don't need to understand this analogy to be a programmer.
Yes, yes, Java is just a language. But have you ever tried compiling (more than Hello World) Java code to an actual binary, and had it work properly? No, because see below. Have you tried the inverse, compiling C to bytecode? Yeah, the result is not exactly a rainbow either (Pawn, while it does everything that it aims to, sucks).
My biggest hatred is not that it's slow, but that it's proprietary (well, mostly. There's openjdk, but i've even heard veteran Java programmers complaining (I agree) about that - hey does Ubuntu still use openjdk by default? IIRC I had to enable the 'partners' repo to install sun java. Which a lot of users will not be doing).
Lerning ASM nowadays is about as useless as learning ancient greek. Sure, it's nice to know if you want to feel really elitist, but there's absolutely no need for it.
Yeah, because writing emulators is totally useless. Nobody would ever want to do that.
...
And Klaue: I for one did not learn ASM to feel elitist(I learnt it to get stuff done, because on the C64 I didn't have a C compiler). It's rather wrong for you to 'assume' that all ASM programmers are elitist, isn't it?
And not all C programmers are 'elitist' either. I don't consider myself a better programmer because I know, and use C. I didn't want to make it sound that way. We're not better 'people'. We're not more intelligent. I have a friend who uses 'Game Editor'(his games are awesome - yet slow and CPU consuming - that's what happens when you interpret C), and I hate it when he says i'm elite for making x with only C code. Game Editor is not recommended, but might be a good start to people who just wanna write a game, with minimal coding. I've done this(just remember, if you're gonna do C later, try to get GE out of your mind while C programming) No Pandora target though.
Anything can be done in ASM. Anything. ASM is executed by your processor (well, machine code is, so for example, NOP is, on x86, 0x90 in machine code). C++ is not, so your compiler just does what an ASM programmer does in ASM. Just looking at what the hell polymorhism actually is (yes, I really am NOT a C++ programmer. We don't use big words in C, cuz we're stupid n stuff
. I know what polymorphic code is, as in, code that modifies itself, and have written code that does this(6510 ASM). Doing that in C/C++/Java would be hard/possibly impossible(lol!))
http://en.wikipedia.org/wiki/Type_polymorphism, you don't really need it. The type of a variable would never change during runtime, and I fail to see where you'd use this? Possibly, like this, I encountered recently:
In my x86 OS (bad code(I admit it!), not ready for release, but I can give pics, or a disk image), I got video by using a QEMU specific hunk of code. It worked nice, I wrote some functions to draw, all was good, I made it draw icons/windows that could be added/removed freely. Then I wanted it to run on hardware, so I wrote some VGA stuff, to get a VGA mode. I wanted to make my previous functions work, so I could just set VGA and run my regular graphics stuff.
So I made a function pointer for each draw function, in the spec taking an unsigned long for color. The function pointer would point to the 32bpp drawing code by default. When entering VGA mode, i'd change these pointers to my vga functions, which take an unsigned char as a color argument (yeah I can see a problem with this, I need to go study the ASM output when I get the time - no, my code does not work
. I didn't quite expect it to. I can get around this with ease by using the unsigned long.), then call my graphics loop. it works, no faults are raised, but the screen fills with garbage (The colors would of course be wrong - but I think I might have actually just drawn beyond 320/240, screwing the array - for an OS I really should be paying for attention XD).
Yes. Yes you DO have to compile a java program each time you run it, while running it. That's no secret little thing that Java tries to hide.
Are you sure that that Minecraft server wasn't just dying because the server itself is a little dodgy?
Klaue, my kernel is as stable as Linux has ever been. My RAM is fine, too. I can run memtest all night without any errors. No other programs segfault. Are you on Linux x86_64? I'm using (X)ubuntu's packages, in the partner repo, iirc. For the record, I have used other Linuxes. If it weren't for my need of several things for
About straw man arguments, reread _your_ post, please.
I hope you weren't hinting that history -c makes you superior. I actually wouldn't do either, my .bash_history is symlinked to /dev/null.
urjaman: YAY - Craft ftw! I'm so jealous of Linus' l33t skillz. Demo awesomeness increases exponentially with limitedness of the hardware
, even while ignoring the fact that the hardware is limited.
And I agree, knowing ASM makes pointers much easier to understand. But I can't recommend learning ASM just to shake out not knowing pointers, unless it's your _only_ problem. ASM can be overwhelming- more so depending on your architecture - VAX? Ugh. Good thing nobody here is using a VAX (I hope)
.
I really do love these forums. They're entertaining. Really, flamewars sure beat what i'm supposed to be doing!
If anyone would like to make a rebuttal, or comment, PM me, since this IS getting out of control. Yeah, I should not have posted..
XxionxX: You should learn ASM, yes, but you should not necessarily use it as your primary language. My biased opinion is that you should use C, of course, and I can say there's definitely nothing wrong with it for game programming. But there's no harm done in using a C++ compiler to compile your games instead of C compiler. Way back when I first started with SDL, my program refused to compile with a C compiler, I was no doubt doing something stupid, but the compiler was saying there was issues in the library file (SDL/SDL.h), so being a noob, I said wtf, and used g++ where my C worked perfectly. Plus doing this would let you tell your boss that you're using C++, to please him, if you ever do programming for work. He often won't know any better. New/delete are actually very nice additions, but things like streams (that look like bitshifts, gets me every time) are not all that useful to a game programmer.
Jump in and try C. If you don't like it, try ASM, then you will(nah, ASM ftw) try alternatives until you find something that you like. I missed the ultimate goal - make an awesome game(but the biggest thing to remember is that your first game will no doubt be crap, it's normal. Nobody liked Super Hit-Enter-And-Get-an-Error-in-C64-Basic Brothers either(no, I didn't actually name it that). Don't try tetris first, I really don't get why people recommend it. Go for moving characters around with the keyboard. Then build up on that.)
I'm going to go on a looong C/C++/ASM coding session(see top)
*Add Reply* (Todo: regret - then, realise I don't regret anything)
EDIT: Wtf how did I miss Exophase's post? That makes my pro-asm arguments redundant(NO it wasn't otherwise). Also, hi Exophase!