Search found 197 matches

by fazzone
Fri Oct 09, 2009 10:13 am UTC
Forum: Coding
Topic: Scheme Makes Me Not Want to Code Ever Again
Replies: 64
Views: 6955

Re: Scheme Makes Me Not Want to Code Ever Again

Philwelch wrote:Being able to write an interpreter for a language is definitely sufficient to learn the language. Arguably, it's even necessary. But C++ seems like a lot of trouble to parse even for a compilers class.

That's how I learned Lisp.
by fazzone
Tue Oct 06, 2009 2:00 am UTC
Forum: Coding
Topic: Macros hate me :(
Replies: 27
Views: 2734

Re: Macros hate me :(

As did I.
by fazzone
Mon Oct 05, 2009 8:11 pm UTC
Forum: Coding
Topic: Scheme Makes Me Not Want to Code Ever Again
Replies: 64
Views: 6955

Re: Scheme Makes Me Not Want to Code Ever Again

Computer Science is very very different from anything you have done in Python. To make an analogy, being a good programmer is like being a very technically skilled musician, while being a computer scientist is like being a great composer. While technically true, your analogy gives me a strong desir...
by fazzone
Sun Oct 04, 2009 9:02 pm UTC
Forum: Coding
Topic: First "actual" java program, and it's... strange.
Replies: 17
Views: 1756

Re: First "actual" java program, and it's... strange.

Weird...I just did that test and it didn't exit. I always thought it did. Well, I guess I'm just an idiot today.
by fazzone
Sun Oct 04, 2009 2:15 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2003168

Re: Coding: Fleeting Thoughts

Or do something like:

Code: Select all

public class someClass {
   private static InputStream foo=null;
   public someClass() {
      if (foo==null) foo=System.in;
                ...
   }
}
by fazzone
Sun Oct 04, 2009 2:07 pm UTC
Forum: Coding
Topic: First "actual" java program, and it's... strange.
Replies: 17
Views: 1756

Re: First "actual" java program, and it's... strange.

No, this what you do: catch (WhateverException e) { throw new Error(e); } Swallowing exceptions is a really, really bad idea, and should only be done when you've written code to recover from the exception. I agree. Calling e.printStackTrace(); prints the exception's stack trace to stderr, and then ...
by fazzone
Sun Oct 04, 2009 3:06 am UTC
Forum: Coding
Topic: First "actual" java program, and it's... strange.
Replies: 17
Views: 1756

Re: First "actual" java program, and it's... strange.

Never catch an exception unless you can recover from it and let the program continue normally afterwards. That's the idea, but with certain constructs in Java (like doing file I/O) the compiler won't let you ignore certain types of exceptions, so you have to just write exception handlers that look ...
by fazzone
Sun Oct 04, 2009 1:19 am UTC
Forum: Coding
Topic: First "actual" java program, and it's... strange.
Replies: 17
Views: 1756

Re: First "actual" java program, and it's... strange.

...catch (Exception ex) { System.out.println("Exception! " + ex); return null; } Never, ever do this. I know you said you're new, so I'm not saying you're dumb, but this pretty much defeats the entire purpose of exception handling. Also: Unless you plan to dust off and carry on the progra...
by fazzone
Sat Oct 03, 2009 1:05 pm UTC
Forum: Coding
Topic: First "actual" java program, and it's... strange.
Replies: 17
Views: 1756

Re: First "actual" java program, and it's... strange.

This would be easier if you posted the actual error messages you get. If you didn't catch the exception, it should automatically print its stack trace, and tell you which lines caused the problem.
by fazzone
Thu Oct 01, 2009 10:31 am UTC
Forum: Coding
Topic: Vague and newbish question about C versus java
Replies: 11
Views: 1329

Re: Vague and newbish question about C versus java

In general I've found (anecdotally) that in terms of code optimisation, ICC > MSVC > GCC. This is for C++, though, I don't know about C. It's interesting to see some hard numbers to back this up. I've found this too, but I'm not sure how accurate my results may be, because I only use MSVC on Window...
by fazzone
Mon Sep 28, 2009 11:58 pm UTC
Forum: Coding
Topic: Teach a C noob segfaults
Replies: 39
Views: 5234

Re: Teach a C noob segfaults

Forgetting the '&' in scanf statements is an extremely common stupid error.
Unparallelogram wrote:The -Wall flag is very much your friend.
This.
by fazzone
Mon Sep 28, 2009 8:21 pm UTC
Forum: Coding
Topic: Teach a C noob segfaults
Replies: 39
Views: 5234

Re: Teach a C noob segfaults

Yup. Because scanf changes it's second argument, it needs to be a pointer. scanf("%d"", &someInt); is what you need. Without the & addressof operator, scanf interprets the variable as a pointer, and tries to write to that location in memory, which you don't own, so you get a s...
by fazzone
Mon Sep 28, 2009 6:06 pm UTC
Forum: Coding
Topic: Retrieving a color-code depending on value of string?
Replies: 4
Views: 565

Re: Retrieving a color-code depending on value of string?

If you're using Java, you could just do

Code: Select all

Color c=new Color(someString.hashCode);

In other languages, the idea would be basically the same I guess, make some sort of a hashing function that outputs an integer which can then specify a color.
by fazzone
Sun Sep 27, 2009 11:26 pm UTC
Forum: Coding
Topic: Int to char in C?
Replies: 5
Views: 961

Re: Int to char in C?

you need a new variable. The quickest solution would probably be something like: char buf[2]; buf[1]='\0'; /*...*/ buf[0]=m /* now buf has a null terminated string containing the single character stored in m */ On second thought, you could just keep an integer index to output, and in the else just d...
by fazzone
Thu Sep 24, 2009 10:25 am UTC
Forum: Coding
Topic: Scheme Makes Me Not Want to Code Ever Again
Replies: 64
Views: 6955

Re: Scheme Makes Me Not Want to Code Ever Again

So I have done some programming in Python on my own but nothing particularly serious, but it seems like a really nice language. It "clicks" for me and I've really enjoyed simple scripting in it. Now I'm taking my school's intro to CS course ... and I ended up with Scheme. I'm ten days int...
by fazzone
Sat Sep 19, 2009 4:22 pm UTC
Forum: Coding
Topic: Good programming music
Replies: 93
Views: 15688

Re: Good programming music

Arancaytar wrote:Thanks! I have an awesome addition to my ~/bin/ now. Who needs pesky memory-hogging GUI music libraries?

The cool thing about that command is that you can press Ctrl-C to go to the next track if you have it open in an xterm or something. And you can exit by pressing Ctrl-C twice really fast.
by fazzone
Fri Sep 18, 2009 8:39 pm UTC
Forum: Coding
Topic: Good programming music
Replies: 93
Views: 15688

Re: Good programming music

For simple stuff I just put my music player on shuffle, which mainly consists of OSI, Muse, Metallica, Porcupine Tree, and a little Megadeth. Sometimes I just put Pandora on too. But for really tricky or fun bits I am obliged to wheel out the trance (Tunnel Trance Force ftw!) Edit: the day I realize...
by fazzone
Thu Sep 17, 2009 10:49 pm UTC
Forum: Coding
Topic: Radix sort C/C++ help
Replies: 8
Views: 4510

Re: Radix sort C/C++ help

C provides no standard facility to access individual digits in a number. You could use an epic hack and just use itoa(number, buffer, 10)[whatever]. Or you could use modulus. (my suggestion: use modulus). If you don't know how to do the modulus thingy to get the digits, search "itoa implementat...
by fazzone
Wed Sep 16, 2009 10:54 pm UTC
Forum: Coding
Topic: Programming Science Projects
Replies: 9
Views: 1225

Re: Programming Science Projects

I guess I was more talking about the broader category of "Computer Software" or something. Strictly speaking, Computer Science isn't "science" ... (By "science" I mean high-school/layman science.) This seems to be exactly their problem. It's not a big deal, I have a few...
by fazzone
Wed Sep 16, 2009 2:36 am UTC
Forum: Coding
Topic: Programming Science Projects
Replies: 9
Views: 1225

Programming Science Projects

So for a thing at my (high) school I have to do a independent project, culminating in a poster to show in a few months' time. I'd really like to do something programming/computer-science related, but they want your project to have a hypothesis-trials-data format; and I can't think of any good progra...
by fazzone
Sat Sep 12, 2009 12:45 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2003168

Re: Coding: Fleeting Thoughts

I think I'm going to go with the horribly ugly solution, actually. Multiply all the floats by a constant k . Then make a new container. For every object in previous container, add (int)(prob* k ) to the new container, then pick a random object out of the new container. It's abhorrent but it's easier...
by fazzone
Sat Sep 12, 2009 12:27 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2003168

Re: Coding: Fleeting Thoughts

Question: I have an array of objects, and a parallel array of floats containing a probability for each object (0-1). I want to pick a random object taking the probabilities into account, but I haven't found a nice way to do it (that works). I'm sure it's obvious, any ideas?
by fazzone
Tue Sep 08, 2009 10:26 am UTC
Forum: Coding
Topic: C and C++ compiler for windows
Replies: 15
Views: 1605

Re: C and C++ compiler for windows

I use Dev-C++ whenever I do coding on windows, because (even though it's old) I prefer it to Visual Studio. It comes with a simple but good IDE, and the MinGW toolset, so if you add C:\Dev-cpp to your $PATH, you can invoke gcc from a regular command prompt.
by fazzone
Sun Sep 06, 2009 3:44 pm UTC
Forum: Coding
Topic: Writing an Open Source Operating System
Replies: 27
Views: 3741

Re: Writing an Open Source Operating System

Well, even if it doesn't turn out to be as fast as Linux or other kernels, it does sound like an interesting project. I've never done any OS development before, but it is definitely something I'd like to learn about, and I consider myself pretty good if not great at C and ASM, so I'd like to help if...
by fazzone
Sat Sep 05, 2009 8:30 pm UTC
Forum: Coding
Topic: Language anthropomorphisms
Replies: 36
Views: 3153

Re: Language anthropomorphisms

Java is like a really strict high school English teacher who wishes he could still use the paddle to etch the principles of object oriented design into his students' heads.
by fazzone
Fri Aug 28, 2009 10:26 pm UTC
Forum: Coding
Topic: Emulating templates in C
Replies: 4
Views: 4398

Re: Emulating templates in C

No. Don't do this. Unless you happen to be programming for an embedded system that has no C++ compiler, never do this. C++ templates are much neater, much more elegant, much less work, and much safer.

(Nice avatar, btw (Sanitarium ftw))
by fazzone
Thu Aug 27, 2009 1:03 pm UTC
Forum: Coding
Topic: Fake Programming Language
Replies: 210
Views: 31282

Re: Fake Programming Language

So... int main(int argc, const char* argv[]) { int N=3, i; void (^p)(NSString *) = ^ (NSString *str) { if ([str length] > 0) { for (i=0; i<N; i++) NSLog(@"Hello %@!", str); } else { for (i=0; i<N; i++) NSLog(@"Hello World!"); } }; p(@"Steve"); // prints "Hello Stev...
by fazzone
Thu Aug 27, 2009 2:37 am UTC
Forum: Coding
Topic: Fake Programming Language
Replies: 210
Views: 31282

Re: Fake Programming Language

That actually sounds pretty sweet...

For me, a perfect language would be about an even mixture of Java and C++ (that compiles to native code), with a little functionality so that literal blocks of code can be used as function parameters and stored in variables and so on.
by fazzone
Mon Aug 24, 2009 8:02 am UTC
Forum: Coding
Topic: BioTech mutating particles C++ help/idea
Replies: 20
Views: 2368

Re: BioTech mutating particles C++ help/idea

Yes; it looks like you will need arrays. An array basically says to the compiler: I want to store this many of this type of object. In C++, the syntax to declare an array is: SomeClass arrayName[arraySize]; That creates an array of arraySize SomeClass objects. Then, to refer to each individual objec...
by fazzone
Sat Aug 15, 2009 4:14 pm UTC
Forum: Coding
Topic: Safety
Replies: 15
Views: 1458

Re: Safety

I don't think it can be turing complete with only non-conditional looping. Not sure at all, I've just never seen a turing-complete language without conditional loops (jumps). Still, cool nonetheless. Edit: I think that since your problem was that not all random strings are legal in brainfuck, you've...
by fazzone
Mon Aug 10, 2009 2:05 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2003168

Re: Coding: Fleeting Thoughts

How I do Java animation:
Make a class (AnimatedPanel or whatever) that extends JPanel and implements Runnable, and use a Vector or ArrayList of images, a counter, and a

Code: Select all

while (...) {
...
Thread,sleep(60/fps);
}
loop
by fazzone
Wed Aug 05, 2009 11:19 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2003168

Re: Coding: Fleeting Thoughts

Yeah, but this is the 1024th reply.
by fazzone
Thu Jul 30, 2009 2:41 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2003168

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:...

What does the factorial function look like? Or factoring an integer or something like that. Can you do any of the Euler problems in it yet?
by fazzone
Sun Jul 26, 2009 4:14 pm UTC
Forum: Coding
Topic: C - pass by value vs. pass by pointer
Replies: 9
Views: 3032

Re: C - pass by value vs. pass by pointer

In C++ I make sure to pass by reference-to-const for type T such that sizeof(T) > sizeof(void *). Usually in C I just pass structs by value unless they're more than 5 integers big or I really care about speed.
by fazzone
Fri Jul 24, 2009 12:36 am UTC
Forum: Coding
Topic: About C++/C and Java
Replies: 28
Views: 2304

Re: About C++/C and Java

To make a tool analogy, Java is safety scissors and C++ is a chainsaw. Yeah, C++ is more efficient, but if you mess up in C++, you cut your whole leg off.
by fazzone
Wed Jul 22, 2009 7:37 pm UTC
Forum: Coding
Topic: Bouncing a ball off a line
Replies: 8
Views: 957

Re: Bouncing a ball off a line

quintopia wrote:there are a very small set of slopes which the laser can have

I want to have the laser able to go in whatever direction, and have parabolic reflectors and stuff, instead of a kind of grid-based game where the laser can only go up down left or right, if that's what you're talking about.
by fazzone
Wed Jul 22, 2009 11:21 am UTC
Forum: Coding
Topic: About C++/C and Java
Replies: 28
Views: 2304

Re: About C++/C and Java

Sorry to not give you a real answer, but it all depends what industry you're talking about. Today, C and C++ dominate game programming, and Java is used a lot for enterprise applications and general tools. C and C++ also are used very heavily in OS development As for my preference for C or C++, that...
by fazzone
Wed Jul 22, 2009 11:15 am UTC
Forum: Coding
Topic: Bouncing a ball off a line
Replies: 8
Views: 957

Re: Bouncing a ball off a line

I'll have to try theses later, I haven't had time yet, but it's not actually a ball, it's a laser reflecting off a mirror (which should behave the same way, right?) It's for a game I'm working on where you have some mirrors and have to bounce a laser off them and around other stuff to get to a goal.
by fazzone
Sun Jul 19, 2009 7:40 pm UTC
Forum: Coding
Topic: Bouncing a ball off a line
Replies: 8
Views: 957

Bouncing a ball off a line

So for a project I'm working on, I need to be able to bounce a ball properly off of a wall. I know how to do it for vertical and horizontal walls, but I haven't been able to do it for a wall defined by any linear function, I tried reflecting the vector of the ball's speed over the normal to the func...
by fazzone
Fri Jul 10, 2009 8:08 pm UTC
Forum: Coding
Topic: How should undo/redo be implemented?
Replies: 9
Views: 1189

Re: How should undo/redo be implemented?

Just implement a Command class that can do and undo itself, and in the main program store a bunch of them in a linked list or an array or something, and store the index of the current one.

Go to advanced search