Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it,
follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given
their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!
The beginner programming thread
Posts
I know it's free. But see, here's the thing, I just don't like how C++ 2005 Express operates, while 2003 doesn't piss me off near as bad. C# 2005 is fine. Also, my version of 2003 is the standard edition, which means I get cool things with it like the GUI designer, which is pretty handy when dealing with Win32.
VC++.net 2005 express comes with a GUI designer as far as I know. All the other expresses do, so it seems logical.
What do you mean by "GUI designer?" Express Edition has basically the same visual form designer that other editions have.
I use Visual Studios 2003 Enterprise Developer at work and the various Express Editions at home. There aren't many times that I run into things that I need that are missing. Add-ons and conditional break points would be nice. The express editions don't have as many project types, but usually that just means you have to go into options and change a setting or write a line or two of code to get the same effect. It is worth it to get generics and anonymous delegates and LINQ and whatever that feature is called where you create a static method that takes an instance of some type and some other arguments, and then allows you to call it as if it were an instance method of that type that you passed in.
[edit]
Crap, you are talking about C++ and I am talking about C#. C++ is the only Express Edition I haven't installed. Several of the CS courses I took used C++, but damn I wouldn't want to use it day to day. If you know what you are doing in C# you can usually get >90% of the performance for a fraction of the effort. I say usually because a C# program could never get anywhere near 90% of the performance of FFTW, but that is what P/Invoke is for. Here is a good example.
They come with a designer for Windows Forms, but not Win32, and I'm pretty sure C++ comes with neither. Even if it did have Forms, if I were using Forms, I'd be in C# anyway.
Added: I should note that it's actually not mostly a matter of features. Fact is, I rarely use Win32 anyway. There's just something in the feel of it that annoys me, and is only present in VC++.net 2005. VC#.net 2005 doesn't suffer from this oddly enough.
Added again: just tried the 2008 beta, as it occured to me that I hadn't messed with it yet. Same problems, though I appreciate them loading it up with Win32 stuff on install, rather than having to install other stuff as well as modifying the template files to get first class support going. Still no designer though.
jackal: Ah, yeah, easy mistake to make. I actually really like the C# express edition, I think it works really well. What I hate the most about the C++ version is the build output window. It doesn't make it easy to find errors in that mass of output at all. I don't understand why they did it like they did- the C# version is great, and is identical to the 2003 editor. It confuses me greatly.
Also, I usually code in C#, but often times C++ is needed when working with some specific API that doesn't have .Net bindings. I work in C# when I can, but C++ will always always get the job done.
Lists are cool and all, but not when I just need a mass of data of a fixed size that has to be accessed very quickly and is also mutable (unlike a tuple).
Specifically, my roguelike calls for a ton of 2D arrays. I have a 2D array of tiles in the current map. My display class needs an array of tile-to-screen mappings to avoid doing lots of repeated multiplication to place tiles on the right pixels (actually I suppose that wouldn't be much faster, if at all, but I thought of this idea and dammit it seems like a good one). I need to iterate through these with "for" loops. If Python has an equivalent way of implementing this kind of thing that's not horribly inefficient, I haven't found it.
Also, I've looked at Numeric some, and I don't need arrays of numbers - I need arrays of objects.
T-shirts | Last.fm | Flickr | dA
As far as I know, it's because C++ isn't actually supported out of the box, and relies on a plugin that's not actually done yet.
However, whenever someone breaths Java, Eclipse is always shouted pretty loudly.
The same reason people don't seem to like Blender or The GIMP. They're excellent programs with many strengths, but there is a minor learning curve on the interface.
I didn't like Eclipse's interface, but that was a first impression, and I haven't had any incentive to try it since Code::Blocks works for me.
You could try using list comprehensions, I've found those to be faster than for loops in general. However, to get near-C performance in Python you'll want to take a look at a library like Pyrex.
However, the speed benefit of moving to compiled modules in C is likely to be much less than what you could gain by simply using a more efficient algorithm.
Interesting. Code::Blocks handles Java or does Eclipse handle C/C++? Either way, color me surprised, because I thought the former was mostly for C/C++ and the latter was Java. I'm a NetBeans guy, myself.
Wow, that last sentence makes me sound like a fairy.
Eclipse has support for C/C++ through CDT. I learned how to program in Eclipse, but was never very fond of it. I stopped using it when it began to take longer to start up than to compile my applications.
Eclipse supports a surprising amount. I haven't used it much, but it seems a real demonstration of the power of extensibility. Nothing like Emacs (a text editor that can do email?), but still impressive.
And compiling compilers really sucks – as a notice to any Haskell users reading this for whatever reason, GHC 6.8.1 is now available. Of course, I couldn't get at a binary version, so I had a five-hour compilation on my hands. Which was truly wonderful.
In what context would I use list comprehensions though? My problem is not with generating or altering lists, it's with accessing them quickly. For example, my "MapView" class first decides which ranges of tiles in the array of map data will be visible, and then iterates through all the visible tiles, blitting their sprites to locations specified in a screen mapping array. At the moment, the speed of this is perfectly acceptable on my MacBook Pro, so I'm calling it good for now, but I'm concerned that it may be an issue.
1. Make something that works.
2. Make it work fast.
Do number 1 throughout the whole project first. Worry about the other stuff later; that's why we use abstraction in object-orientated programming; you get to screw to your heart's content later on, and not break stuff (as long as you pay attention to the API).
So I'm messing around with PHP and SQL/MySQL, and well... there's something bugging me. Do you *really* put the username/password to the SQL database in every PHP file that wants to access it? Doesn't that seem... just a little insecure to anyone else?
I mean, if there's ever an apache glitch, and a user gets the raw PHP file... all your data is compromised. No?
I'M A TWITTER SHITTER
As a dynamic language, ways to increase performance in Python might not be obvious. I wouldn't worry about it at all until it starts affecting your framerate.
Put connection details in an external configuration file, then create a PHP function to load + parse the file, and return a database connection based on the data contained. If you put the configuration file outside the webroot, a proper webserver won't display it.
Ewww.. really? Is that what "everyone else" does, too?
I'M A TWITTER SHITTER
That way, rather than having to load and parse the text file, you just include the PHP file:
http://www.php.net/manual/en/function.mysql-connect.php#73983
I'M A TWITTER SHITTER
Damn this OOD&P class and its horrible teacher.
I'm not familiar with PHP specifically, but for ASP .NET you almost always store your connection strings in a Web.Config file, similar to what Janin is talking about. Although in ASP, the Web.Config consists of key/value pairs in a very fast hashtable, so it's extremely easy to read from.
Something similar to what you're doing would be fine. The main idea behind removing all magic numbers and using constants instead is that your code is basically documenting itself.
scale * 6.37894 doesn't make much sense compared to scale * SCALE_FACTOR_SIX.
You need to give your constants names that express the meaning of them and not the value. I hope I can explain this:
In this case it mostly depends on how the value is chosen. If, say, these values can be chosen by the user (in a combo box or something), I would probably name them something like SCALE_LEVEL_1, SCALE_LEVEL_2 and so on (or better yet, create a lookup array). Like this, if the options for the user change you can just change the value of a certain SCALE_LEVEL.
If the used value depends on a different thing you need to give it a different name. Perhaps it depends on current connection speed to a server, then you should name them something like SCALE_LEVEL_FAST_CONN, SCALE_LEVEL_SLOW_CONN and so on.
If you do it like this, and somebody decides that for super fast connections you don't have to scale anything at all, you just need to change the value of SCALE_LEVEL_SUPER_FAST_CON to "1". If you would have called it SCALE_DOWN_BY_TWO, then for clarity's sake you would also have to change the name to DONT_SCALE (or something) and all of its occurences in the code. And this is exactly what you are trying to avoid when using constants.
Simple rule: If you need to change the name of your constant whenever its value changes than the name is bad or you just don't need a constant at all.
Did this help?
EDIT: When can the Java compiler tell what the exact method that will be called before a program executes? W/regards to polymorphism. I'm trying to find it in this chapter of my textbook, but I cannot.
It can't. When you call a virtual method it's decided at runtime which implementation is executed. The compiler just doesn't know. It only stores somethig like "Call method xyz on the object at this place.", and when the program executes, different methods get executed depending on the type of "the object at this place".
The compiler can probably determine that someMethod of type MyType will be called and optimize the dispatching away. But from a programming perspective this doesn't matter at all.
I don't even put it outside the the webroot (because my hosting company won't allow it). I actually have it set variables. The variables will never display unless I actually tell them to display.
This is actually pretty damned secure because even if somebody knows where your config file is the web server will never serve that up as text that they can read. The only way they'd be able to read your database username and password would be if they had file access to your server ... and then you'd have bigger problems to worry about.
The bigger danger is from SQL injection, but as long as you realize that you can take steps to prevent it.
He was specifically asking how to avoid compromising his password if his server was misconfigured to send PHP scipts as plain text, which your solution does not address. Get a better hosting provider.
There's a language modeled after Ruby called Groovy. It's pretty cool because it has a very Ruby-like syntax (most of Ruby's core language features like dynamic typing, closures, etc...), but it runs on Java's JVM. It can also be compiled to Java .class files and then imported in any Java class (and vice versa). This allows a lot of quick prototyping opportunities where you can create an implementation of some component in Groovy and replace it later with a Java implementation if you need to.
There's a "Static Languages" section, but I'd rather not put too much of that stuff in the OP. I'm sure everybody in the thread would be happy to help with Java questions, but if somebody stumbles in wanting to learn the basics I'd rather they learn with an easy language.
Hmmm
Exact question being this:
In Java, a method call on an object such as x.f() is resolved when the program executes, not when it is compiled, in order to support polymorphism. Name two situations where the Java compiler can determine the exact method to be called before the program executes.
Even if the one I mentioned is one of those... I can't think of the other..?
Is it possible in Java to have non-virtual methods?
I need to find and define different "super" patterns, just looking up the definitions on the web, and I could find most on wikipedia or other sites, but I'm not sure how to define Fundamental patterns... the other ones are pretty simple, like a Creational pattern is obviously one that deals with the instantiation process.
Hm. Design... what madness. Important I guess though.
That's a good point. If a method is declared final, then no child class can override it, so if you had something like this:
public class ParentClass{ public final void someMethod(){ //do something} }Then you will get a compiler error if you try to do something like this:public class ChildClass extends ParentClass{ public void someMethod(){//compiler error} }Another case where the compiler would know the exact class that a method is invoked for would be for static methods.
Ewww, patterns. Wiki has pages on Fundamental and Creational desgin patterns. If your library has the Gang of Four book, that would be a good reference.