Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 281 282 [283] 284 285 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 902661 times)

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4230 on: March 18, 2013, 12:07:50 am »

Well... It does, actually. C99 introduced the stdbool.h header, which defines bool, true, and false.

They are not keywords, they are implemented as macros (Source here uses #define). So true and false remain C++ keywords.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4231 on: March 18, 2013, 01:02:54 am »

Well... It does, actually. C99 introduced the stdbool.h header, which defines bool, true, and false.

They are not keywords, they are implemented as macros (Source here uses #define). So true and false remain C++ keywords.

I never said they were keywords. They are indeed macros, but they can still be used for basically identical purposes as their C++ keyword counterparts.

RedKing

  • Bay Watcher
  • hoo hoo motherfucker
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4232 on: March 19, 2013, 02:48:59 pm »

Simple question (and not trying to start a flamewar or anything, I swear):

For a technical but non-progamming guy, can somebody explain to me why Java is *so* freakin' slow in most cases?? I'm not talking about downloading the JAR file, I'm talking about once all the resources have been downloaded, just getting the app to launch, and moving about within the app.
Logged

Remember, knowledge is power. The power to make other people feel stupid.
Quote from: Neil DeGrasse Tyson
Science is like an inoculation against charlatans who would have you believe whatever it is they tell you.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4233 on: March 19, 2013, 02:51:06 pm »

Well, since it's Java, that depends on a LOT of things. You're always running an emulator, essentially, with Java, rather than running the code directly, so there are quite a few choke points you might run up aginst...
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4234 on: March 19, 2013, 03:09:35 pm »

Simple question (and not trying to start a flamewar or anything, I swear):

For a technical but non-progamming guy, can somebody explain to me why Java is *so* freakin' slow in most cases?? I'm not talking about downloading the JAR file, I'm talking about once all the resources have been downloaded, just getting the app to launch, and moving about within the app.

Java is one of the fastest modern languages after c++. There are 4 things that make it feel "slow".

1: it takes time to load the JVM before any of your code ever gets to run.

2: it takes time to load the ridiculously bloated multi functional libraries common in java development.

3: for applications that make extensive of xml configuration, the process of marshalling and unmarshalling xml in a standards compliant manner is not a simple and quick task.

4: there is a small delay as bytecode is compiled to your local machine code on application startup.

Well, since it's Java, that depends on a LOT of things. You're always running an emulator, essentially, with Java, rather than running the code directly, so there are quite a few choke points you might run up aginst...

Java has not run in an emulator since 1.2 or so.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Twiggie

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4235 on: March 19, 2013, 03:49:10 pm »

yay, someone else who doesnt bash java! i was going to comment that the emulator thing was bogus, but i wasnt really sure
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4236 on: March 19, 2013, 09:44:45 pm »

Blarg. You know what I hate about custom collections in java? the fact that you actually have to implement 3 or 6 classes to actually fully flesh out the features if you have special logic in your add and remove methods.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4237 on: March 19, 2013, 09:49:36 pm »

Okay, I've been banging my head against this for the past day and my teacher was absolutely zero help. How would you print something like this in C?
Code: [Select]
5@@@@
@5@@@
@@5@@
@@@5@
@@@@5
where 5 is the user-entered number for the width and length of the block? I'm not asking for the exact code or whatever, but I've got an if-else statement inside of a for loop inside of another for loop, and things just won't print out correctly.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Twiggie

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4238 on: March 19, 2013, 09:51:44 pm »

that structure seems correct, you probably want to compare the iteration variables for equality in the if condition.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4239 on: March 19, 2013, 10:05:01 pm »

Yeah, turns out that was the problem. I managed to get it working two minutes after I posted my question :P
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4240 on: March 19, 2013, 10:13:59 pm »

Blarg. You know what I hate about custom collections in java? the fact that you actually have to implement 3 or 6 classes to actually fully flesh out the features if you have special logic in your add and remove methods.

It sounds like you are implementing a collection class from scratch (I am assuming that by implementing 3 or 6 classes you mean interfaces).

Cant you just inherit from one collection class (eg LinkedList) and override the add and remove methods?

Okay, I've been banging my head against this for the past day and my teacher was absolutely zero help. How would you print something like this in C?
Code: [Select]
5@@@@
@5@@@
@@5@@
@@@5@
@@@@5
where 5 is the user-entered number for the width and length of the block? I'm not asking for the exact code or whatever, but I've got an if-else statement inside of a for loop inside of another for loop, and things just won't print out correctly.

You have the right idea. Here is my (untested) solution:
Code: (rough C) [Select]
int input = get_input()
for (int y = 0; y < input; y++){
  for (int x = 0; x < input; x++){
    if (x == y){
      printf("%i", input);
    else {
      printf("@");
    }
  }
  printf("\n");
}

EDIT: Nevermind.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4241 on: March 19, 2013, 11:04:12 pm »

Blarg. You know what I hate about custom collections in java? the fact that you actually have to implement 3 or 6 classes to actually fully flesh out the features if you have special logic in your add and remove methods.

It sounds like you are implementing a collection class from scratch (I am assuming that by implementing 3 or 6 classes you mean interfaces).

Cant you just inherit from one collection class (eg LinkedList) and override the add and remove methods?

No I mean classes.

If the collection you implement does not inherit from one of the preexisting collection types, but rather implements the interface, you have to create new classes for the objects returned by certain functions.

For a list you must implement at least the list itself, a ListIterator and a SubList. The iterator can reuse the listLiterator.
For a map you must also implement  KeySet, EntrySet and Values collection, and possibly the iterators and SubLists of those collections.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4242 on: March 20, 2013, 12:07:04 am »

Oh I see now. The extra overhead would be a pain but at least your code would be easy to reuse.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4243 on: March 20, 2013, 12:22:11 am »

Oh I see now. The extra overhead would be a pain but at least your code would be easy to reuse.

Yes, it is very useful when you are creating a custom collection that you want to be able to optimize at runtime for the efficiency of the task you are performing. You would not want to be stuck using an class that extends LinkedList when you need random read for a specific task and you wouldn't want to be stuck with an array list if another task involved a lot of random inserts and deletes that require shifting a lot of elements. This way you can have a custom collection that uses the collection optimal to whatever your current task is without having multiple different types of collections.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4244 on: March 20, 2013, 12:42:42 am »

Quote
error C2065: 'check' : undeclared identifier
NO IT IS NOT! I DECLARED IT JUST FIVE LINES UP!

I've got a little more than an hour to get this thing done, but every time I think the code is right I get stupid errors. All I want to do is print a pattern, but I can't do that if freaking VS won't stop giving my bullshit.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread
Pages: 1 ... 281 282 [283] 284 285 ... 796