• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

usea

Member
its parsing a calendar, so... empty string probably.


hmmm i feel like i tried catching before, but eclipse wasn't havin' it. so fickle. will try again.
Java has checked exceptions, which means that when you're writing a method, any other method you call can throw an exception. You must either catch that exception in your method, or declare that your method can throw that exception. It sounded like you're saying you can't add the exception declaration, so your only other option is to catch it.
 
Java has checked exceptions, which means that when you're writing a method, any other method you call can throw an exception. You must either catch that exception in your method, or declare that your method can throw that exception. It sounded like you're saying you can't add the exception declaration, so your only other option is to catch it.

yeah should be that.

shit my job is stressing me out. Graduated college with a computational media which is pretty much cs with a more design/media track... but my job is embedded java stuff and i need to learn about optimization and memory management and all that jazz lol.
 

usea

Member
yeah should be that.

shit my job is stressing me out. Graduated college with a computational media which is pretty much cs with a more design/media track... but my job is embedded java stuff and i need to learn about optimization and memory management and all that jazz lol.
I graduated almost 3 years ago now. Even though I already knew the basics about programming before I started college, I feel like I learned a ton in school. I was one of the top people who graduated my year, having won a regional programming competition and some other awards.

I'm pretty sure I learned at least as much during my first year on the job than I did while in school. And I've learned more since then than I had learned in that first year.

I feel like nobody should get down on themselves for not knowing something. That's pretty much the default state everybody is in at all times.
 

Bilix

Member
Hey guys, thought this might be the best place for me to ask for some advice.

I got my B.S. in Computer Science in January and have been looking for a job ever since with not much luck. Meanwhile, I have a part time job where I do some light I.T. stuff, but really no programming involved. I'm looking for advice as to where to put my efforts in. My classes mainly taught Java, and I've done some work in C, Assembly, and some Android Development. I'm currently trying to stay active by learning JavaScript and web development in general, as well as working on a simple android app. Is there anything in particular I should be focusing on or ways to stay in practice so I don't forget everything? There's an almost limitless list of things to do/learn, but I want to be on the right path if there's any such thing as a wrong path.
 

oxrock

Gravity is a myth, the Earth SUCKS!
Hey guys, so I'm in an intro to CS class (learning Java) and I was wondering if anyone could help me with a basic idea of how to set this up. I'm supposed to make a TicTacToe game with either a human and a computer player or two human players. The humans I can just assume that they aren't idiots and won't try to choose the same spot but I'm not sure how to get the computer to recognize an open spot. Spots are chosen using coordinates (ABC for the X-axis and 123 for the Y-axis).

I'm guessing I just need a recursive method that checks for spots the player has filled and then fills out different ones? Any ideas how to do that? The basic assignment just requires me to make a computer that fills spots at random, I can get extra credit if I create an "AI" that is unbeatable, but I think I'll just settle for the basic one for now.

Sorry this is so ridiculously basic. I'm just starting out :p
if you're creating a list of already filled spots for the AI to use, you may as well just apply it to the player as well.
I'm not java savy at all but if java doens't recognize empty strings you could always just use a placeholder string to represent the empty string. something along the lines: If grid[1] = 'placeholder': good_moves.append(grid[1])

That's about how you'd write it in python anyway, haha.
 
Java has checked exceptions, which means that when you're writing a method, any other method you call can throw an exception. You must either catch that exception in your method, or declare that your method can throw that exception. It sounded like you're saying you can't add the exception declaration, so your only other option is to catch it.

ahhh was because i did something like

public static String method () throws ParseException

{
..

try{
}
catch (parseexception e)

}
}

god damnit.
 
Hey guys, thought this might be the best place for me to ask for some advice.

I got my B.S. in Computer Science in January and have been looking for a job ever since with not much luck. Meanwhile, I have a part time job where I do some light I.T. stuff, but really no programming involved. I'm looking for advice as to where to put my efforts in. My classes mainly taught Java, and I've done some work in C, Assembly, and some Android Development. I'm currently trying to stay active by learning JavaScript and web development in general, as well as working on a simple android app. Is there anything in particular I should be focusing on or ways to stay in practice so I don't forget everything? There's an almost limitless list of things to do/learn, but I want to be on the right path if there's any such thing as a wrong path.

Where are you looking?

Either way keep working on side projects so you can point to those things in an interview if you need/want to. Do the kind of things that would interest you.
 

Bilix

Member
Where are you looking?

Either way keep working on side projects so you can point to those things in an interview if you need/want to. Do the kind of things that would interest you.

Indeed mostly. I can find plenty of entry level stuff there, but I never hear back from any of them. Maybe most jobs don't want to deal with long distance applicant at that level, or everything is super-competitive now and most people have more experience than I do.

I'll keep doing what I'm doing I suppose.
 

Water

Member
Hey guys, thought this might be the best place for me to ask for some advice.

I got my B.S. in Computer Science in January and have been looking for a job ever since with not much luck. Meanwhile, I have a part time job where I do some light I.T. stuff, but really no programming involved. I'm looking for advice as to where to put my efforts in. My classes mainly taught Java, and I've done some work in C, Assembly, and some Android Development. I'm currently trying to stay active by learning JavaScript and web development in general, as well as working on a simple android app. Is there anything in particular I should be focusing on or ways to stay in practice so I don't forget everything? There's an almost limitless list of things to do/learn, but I want to be on the right path if there's any such thing as a wrong path.
I suspect your potential employers will mainly be concerned with one thing: do you only have theoretical knowledge, or do you get things done?

Finishing a mobile app - no matter how small, as long as it works and does something fun or useful - and releasing it in Play for the world to see would be a great demonstration that you can actually wrap something up. Doing something visible and interesting with web stuff would also be good. I recommend concentrating, though. You know enough languages and environments. Getting really good at something will make you more attractive than familiarity with a ton of different things.
 
Sigh... I.m struggling to keep up in my programming class. I really want to understand this stuff =(

My instructor introduced:

Methods with the out Keyword
Named Optional Parameters
Using Combo Box Control
Enumerations
Using Windows Timer
The List Box Control

Can anyone recommend a good C# book to help supplement my learning?
 

Water

Member
Sigh... I.m struggling to keep up in my programming class. I really want to understand this stuff =(

My instructor introduced:

Methods with the out Keyword
Named Optional Parameters
Using Combo Box Control
Enumerations
Using Windows Timer
The List Box Control

Can anyone recommend a good C# book to help supplement my learning?
I'd be glad to hear about good C# books too. I've tried and failed to find any. I'm interested both in books aimed at total beginners, written from the introductory programming perspective, and well-written, tight "insight" books analogous to what Meyers, Sutter, Alexandrescu and others have written on C++.

The "Controls" are Windows Presentation Foundation UI stuff, not exactly core language - it's not likely they would be covered in a beginner book.
 

oxrock

Gravity is a myth, the Earth SUCKS!
I for one am on the lookout for online c# courses. Something similar to udacity's cs 101 with python would be perfect. It really helps to learn a concept and then have it reinforced by being tested on it by writing code, at least for me. I'm also very much a visual learner so just reading about something isn't ideal for me.
 

Bboy AJ

My dog was murdered by a 3.5mm audio port and I will not rest until the standard is dead
I'm taking a Python course on Coursera. Well, it uses Python to introduce programming. Anyway, I built my first Celsius to Fahrenheit converter. I can't believe something so simple was so satisfying to figure out. Really enjoyable. Maybe because it's a nice change of pace from my normal work. I know you guys are pros but this noob is having a good time.
 

Chris R

Member
So I'm known to over complicate things, but does anyone know of a simpler way to set this up?

http://jsfiddle.net/cx4mZ/

Basically the items from the FIRST select element determine which elements appear in the SECOND select element.

This isn't a full on example, just the basic outline to see if I'm going about this in a totally incorrect manner. The full version would of course maintain selections as various items are added or subtracted as well as other things.
 
Does anyone know how to subtract individual ranges in a cell from one another and output them in VBA? Like subtract all the cells in h3:k12 from cells in h22:k31? I can figure out how to subtract range totals but not those individual cells as a check for data consistency.
 

upandaway

Member
Opinions on Swing vs JavaFX?
My knowledge is really limited, but it seems that JavaFX will be the focus in the future in Java. I also wrote a couple small stuff in both and JavaFX was a lot faster/easier to write and the code was a lot cleaner, using the GUI editor. Lists and spreadsheets are still a bit rough last time I checked, but they're improving it.

The only reason I can think of to use Swing is if you want to support macs that only have Java 6, or I heard that Swing has a lot more 3rd party tools and libraries. I'm clueless about that though.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
So today I registered for classes at my new university. I'll be transferring next month to start the summer semester.

My new university uses C++ instead of Java, so will you guys recommend a book I can read to get up to speed on C++ before I start my programming classes here. (Programming class will start in July)

I already have the object oriented experience from Java, so ideally it wouldn't be an absolute beginners book

Thanks!
 

Onemic

Member
So today I registered for classes at my new university. I'll be transferring next month to start the summer semester.

My new university uses C++ instead of Java, so will you guys recommend a book I can read to get up to speed on C++ before I start my programming classes here. (Programming class will start in July)

I already have the object oriented experience from Java, so ideally it wouldn't be an absolute beginners book

Thanks!

C++ primer
 

hateradio

The Most Dangerous Yes Man
Opinions on Swing vs JavaFX?
What do you plan to do?

If it's a (fairly) simple GUI you can use Swing. I haven't used JavaFX myself.

So I'm known to over complicate things, but does anyone know of a simpler way to set this up?

http://jsfiddle.net/cx4mZ/
You can use objects, to better organize your types. Though you may want to keep using numeric keys, I used text (apple, orange, etc).

Code:
var food = {
	apple: {
		1: 'fuji',
		2: 'gala',
		3: 'red delicious'
	},
	orange: {
		6: 'navel',
		7: 'valencia',
		8: 'blood'
	}
};

var selectedFruits = $('#fruit :selected'); // code to get selected items

selectedFruits.each(function (index, optionEl) {
	var name = $(optionEl).text().trim().toLowerCase();

	if (name === 'All Fruit') {
		// code to attach all fruit
		$.each(food, function (fruit, list) {
			$.each(list, function (key, value) {
				$('<option>').val(key).text(value).appendTo('#types');
			});
		});
	} else {
		// this would now be something like food['apple']
		// so the list inside apple
		$.each(food[name], function (key, value) {
			$('<option>').val(key).text(value).appendTo('#types');
		});
	}
});
 

Timedog

good credit (by proxy)
Making a linked list and ran into an issue. I'll provide a very simplied version of what I'm doing that I *think* will still have enough info to solve my basic issue.

In each node of the LL, there is an object:

Code:
struct Node
{
	Node(const Factory& h);		
	Factory data;					
										
	Node * nextNode
};

the constructor for Factory objects looks like this (and it's the only constructor I'm able to use, I cannot create another constructor):

Code:
Factory::Factory(const char * const name, const int size)
{
        //code for copying arguments into Factory's data members
}

Here's the constructor for Node:

Code:
LinkedList::Node::Node(const Factory& h) : nextNode(NULL)  
{
     // ???
}

I want to initialize data by copying the data member values from h, but I'm not sure how to do this. In that first bit of code data does not have an argument list that corresponds with the constructor.

Basically, if line 4 in the top snippet was in the format "Factory data( argument1, argument2)" I'd know what to do. But with no argument list it seems like it needs to call the default constructor, where no default constructor exists. Hope that makes sense
 

Atruvius

Member
I downloaded Visual Studio 2013 a week ago and I'm having one problem, I can't type ending bracket "}". I don't remember having that problem in VS2010. What's the deal here, is it a feature?
 

maeh2k

Member
Not really a programming question, but I have to choose a new laptop for software development. So I thought this might be a good place to get some opinions.

It's supposed to be a pretty high-end device with 16GB of RAM (so most of the Ultrabook-type notebooks are out). Currently I'm considering the Dell Precision M3800 and the Thinkpad T440p, but I'm open to other suggestions.

With the Dell I'm not so sure about the glossy high-dpi display. Working on a glossy display isn't ideal. And I'm not sure how problematic the high-dpi display is. What if I want to install Linux next to Windows? Can IDEs like Eclipse deal with the resolution?

On the Thinkpad I don't like how the 9 cell battery protrudes from the case and with 4-4.5h the 6 cell battery seems a bit small. And the device seems a bit bulkier overall.

I probably won't have the chance to compare the keyboards and trackpads, since I'll have to order soon and I don't think there's a store nearby that has both on display.
Leaning towards the Thinkpad, but a 3800x1880 touch display is quite tempting...
 

Slo

Member
Hi guys, novice question about NoSQL databases like MongoDB. Specifically I would like to understand they claim that they scale horizontally much better than traditional databases. Increasing capacity by adding more servers implies that the data isn't replicated across all servers, otherwise why would adding more servers increase capacity right? So my question is if all servers in the db don't contain the same data, how do you ensure that you'l get consistent results when querying the db? If 1 out of 5 servers goes down are we just missing 1/5 of our result set when we run a query?

Is this a philosophical difference between relational and non-relational databases? I.E. when querying a non-relational database are we content with saying "get me whatever data is available at the moment?"
 

tokkun

Member
Not really a programming question, but I have to choose a new laptop for software development. So I thought this might be a good place to get some opinions.

It's supposed to be a pretty high-end device with 16GB of RAM (so most of the Ultrabook-type notebooks are out). Currently I'm considering the Dell Precision M3800 and the Thinkpad T440p, but I'm open to other suggestions.

With the Dell I'm not so sure about the glossy high-dpi display. Working on a glossy display isn't ideal. And I'm not sure how problematic the high-dpi display is. What if I want to install Linux next to Windows? Can IDEs like Eclipse deal with the resolution?

On the Thinkpad I don't like how the 9 cell battery protrudes from the case and with 4-4.5h the 6 cell battery seems a bit small. And the device seems a bit bulkier overall.

I probably won't have the chance to compare the keyboards and trackpads, since I'll have to order soon and I don't think there's a store nearby that has both on display.
Leaning towards the Thinkpad, but a 3800x1880 touch display is quite tempting...

I bought a Thinkpad T440s for this purpose, however it maxes out at 12GB of RAM, so if 16GB is a hard requirement for you, I guess it's not an option. For me, the additional portability was more important.
 
Hi guys, novice question about NoSQL databases like MongoDB. Specifically I would like to understand they claim that they scale horizontally much better than traditional databases. Increasing capacity by adding more servers implies that the data isn't replicated across all servers, otherwise why would adding more servers increase capacity right? So my question is if all servers in the db don't contain the same data, how do you ensure that you'l get consistent results when querying the db? If 1 out of 5 servers goes down are we just missing 1/5 of our result set when we run a query?

Is this a philosophical difference between relational and non-relational databases? I.E. when querying a non-relational database are we content with saying "get me whatever data is available at the moment?"

Most NoSQL databases are not ACID compliant if that's what you want to know. Some are eventually consistent, and there is FoundationDB which takes a different approach to it's scaling which allows ACID transactions.
 

Water

Member
Not really a programming question, but I have to choose a new laptop for software development. So I thought this might be a good place to get some opinions.

It's supposed to be a pretty high-end device with 16GB of RAM (so most of the Ultrabook-type notebooks are out). Currently I'm considering the Dell Precision M3800 and the Thinkpad T440p, but I'm open to other suggestions.
What kind of development do you do exactly?

In addition to Thinkpads, you could consider if Retina Macbook Pro fits. The low end 15" is pretty decent compromise between size/performance/quality/price.

I'm in an unfortunate spot with hardware and OSs myself. I'd really like to stick to OS X for everything else, but I have occasional need to do coding in Windows (sometimes low level graphics, so virtual machine doesn't do it), and it would be increasingly useful for me to be able to do it on the go. Windows runs just fine on Macs, but dual booting is a pain. And Apple's laptop hardware very specifically sucks for graphics coding. The high-end 15" is larger and more expensive than I want; every other Apple laptop has Intel integrated GPUs with garbage OpenGL support. Maybe I should bite the bullet, get a good Windows laptop, and figure out how to run Linux in a virtual machine to have adequate terminal tools.
 

Husker86

Member
I have a question about Unity and building for different operating systems.

So I released my first Unity game for Android and am now in the process of porting it to Kindle (basically just have to change from Google Play Games to GameCircle) and iOS (few more UI changes probably, and of course GameCenter).

So, between Android and iOS, my script changes should actually be easier because I can use their Platform Dependent Compilation that let you partition scripts; basically:

#if UNITY_IPHONE
--do iPhone stuff
#endif

#if UNITY_ANDROID
--do Android stuff
#endif

Now, when going to Kindle it's a bit different since it's still Android. I have been just separating the Android/Kindle code into blocks that I can comment and uncomment as needed when switching.

My question
Is it bad/stupid/ to put the respective Android and Kindle blocks of code in an if-statement, and set booleans for the platform? So, if I needed to switch I just need to change that one boolean in onStart(). So it would look like this

Code:
bool android = true;
#if UNITY_ANDROID
if (android){
   Google Play Games Stuff
} else {
   Kindle GameCircle Stuff
}
#endif

So if I needed to switch between Android and Kindle, I'd only need to change the boolean before deploying and not have to uncomment everything.

Does anyone see something wrong with this?

I'm taking a Python course on Coursera. Well, it uses Python to introduce programming. Anyway, I built my first Celsius to Fahrenheit converter. I can't believe something so simple was so satisfying to figure out. Really enjoyable. Maybe because it's a nice change of pace from my normal work. I know you guys are pros but this noob is having a good time.

It only gets better! I started programming from basically no experience at all in March 2013. I'm still very much a beginner, but I've made a couple of mobile games and apps. It just feels great using software that you created, no matter how simple.
 

Roflobear

Member
This might be a dumb Java question, but is there any benefit to using && or || over & or | in boolean statements? If my understanding is right, && and || evaluate both sides of the operator whereas & and | just evaluate the first side first, and then the second only if necessary. If that's the case, why not just use the single operators all the time instead of the double operators?
 
This might be a dumb Java question, but is there any benefit to using && or || over & or | in boolean statements? If my understanding is right, && and || evaluate both sides of the operator whereas & and | just evaluate the first side first, and then the second only if necessary. If that's the case, why not just use the single operators all the time instead of the double operators?

You have that reversed. && and || will only test the second part if they do not evaluate to false and true respectively. & and | test both sides of the operation as they are binary arithmetic operators.
 

Slavik81

Member
This might be a dumb Java question, but is there any benefit to using && or || over & or | in boolean statements? If my understanding is right, && and || evaluate both sides of the operator whereas & and | just evaluate the first side first, and then the second only if necessary. If that's the case, why not just use the single operators all the time instead of the double operators?
I think you got it backwards. The doubled symbols mean logical AND/OR, while the single symbols mean binary AND/OR.

When doing a logical operation, you can often know the result before the end. For example, False AND anything else is False, so if your first argument evaluates to False, nothing else is required.

When doing a binary operation, the result is not True or False, but a value. 0x66 OR 0xF2 is 0xF6. Because 0x00 is False and any non-zero value is True, the logical result of the binary OR matches that of the logical OR, but the binary value of the result could not have been known without evaluating it to the end.

The language could have been designed to short-circuit binary operations for ANDs containing 0x00 and ORs containing a value with all bits as 1, but I would guess that's not done as the requirements on the OR are weirder, and you'd also be left without any easy way to avoid short-circuiting for the purpose of ensuring that calculations with side-effects are run.
 

Roflobear

Member
When doing a binary operation, the result is not True or False, but a value. 0x66 OR 0xF2 is 0xF6. Because 0x00 is False and any non-zero value is True, the logical result of the binary OR matches that of the logical OR, but the binary value of the result could not have been known without evaluating it to the end.

That makes a lot of sense. I guess for the purposes of simple if or while statements, it's best to stick with the double operators then. Not sure I completely understood the last sentence of your post lol but I get the difference between binary and logical operations now
 

Slavik81

Member
That makes a lot of sense. I guess for the purposes of simple if or while statements, it's best to stick with the double operators then. Not sure I completely understood the last sentence of your post lol but I get the difference between binary and logical operations now

Good. That's the important part.

I explained the last section poorly, so don't worry too much about not understanding it.
 

Onemic

Member
Making a linked list and ran into an issue. I'll provide a very simplied version of what I'm doing that I *think* will still have enough info to solve my basic issue.

In each node of the LL, there is an object:

Code:
struct Node
{
	Node(const Factory& h);		
	Factory data;					
										
	Node * nextNode
};

the constructor for Factory objects looks like this (and it's the only constructor I'm able to use, I cannot create another constructor):

Code:
Factory::Factory(const char * const name, const int size)
{
        //code for copying arguments into Factory's data members
}

Here's the constructor for Node:

Code:
LinkedList::Node::Node(const Factory& h) : nextNode(NULL)  
{
     // ???
}

I want to initialize data by copying the data member values from h, but I'm not sure how to do this. In that first bit of code data does not have an argument list that corresponds with the constructor.

Basically, if line 4 in the top snippet was in the format "Factory data( argument1, argument2)" I'd know what to do. But with no argument list it seems like it needs to call the default constructor, where no default constructor exists. Hope that makes sense

Did you make the Factory constructor yourself or is that what you were given?
 

maeh2k

Member
I bought a Thinkpad T440s for this purpose, however it maxes out at 12GB of RAM, so if 16GB is a hard requirement for you, I guess it's not an option. For me, the additional portability was more important.

I'd like the 440s, but I'm supposed to get one with 16GB, so I'd have to get the 440p.

What kind of development do you do exactly?

No idea; haven't started the job yet. I suppose it'll be mostly standard Java stuff. At this point I really don't know what I could possibly need 16GB of RAM for.
Then again, having a quad-core CPU rather than one of the ULV ones surely can't hurt.

At this point I'm really over Macs, even though I know they have pretty great hardware. I want a repairable machine where I can e.g. easily change the battery should the need arise. And I want a Windows machine (maybe install Linux on the side).
 

Timedog

good credit (by proxy)
Did you make the Factory constructor yourself or is that what you were given?

What I was given, if I made that myself and it didn't work I'd just make different constructor and or change my code around. Figured it out though, used an initialization list. Which is something I've never really done, but I guess I understand now why they could potentially be useful now.
 
No idea; haven't started the job yet. I suppose it'll be mostly standard Java stuff. At this point I really don't know what I could possibly need 16GB of RAM for.
Then again, having a quad-core CPU rather than one of the ULV ones surely can't hurt.

At this point I'm really over Macs, even though I know they have pretty great hardware. I want a repairable machine where I can e.g. easily change the battery should the need arise. And I want a Windows machine (maybe install Linux on the side).

16 GB of ram would be useful for having both a application server and one or more databases runniGBP on your machine. That's about the only reason I could see for having that much ram on a work comp.
 
Hmm... the inability to seamlessly cast a C++ std::function or lambda expression into a C-style function pointer is legitimately problematic. Really limits the ability to abstract away callbacks, since the only way to do the cast effectively is to abuse static variables.

Oh well. Maybe in C++2x.
mBEbGgn.png


/blog
 

Atruvius

Member
I downloaded Visual Studio 2013 a week ago and I'm having one problem, I can't type ending bracket "}". I don't remember having that problem in VS2010. What's the deal here, is it a feature?

I solved what was wrong and in case someone will have the same problem in the future here's what fixed it:

Go to Tools->Options->Environment->Keyboard change "Apply the following additional keyboard mapping scheme" to (Default). And now you should be able to type all brackets correctly.
 

maeh2k

Member
Maybe I should bite the bullet, get a good Windows laptop, and figure out how to run Linux in a virtual machine to have adequate terminal tools.

How do you feel about Windows/Linux dual booting vs Windows + Linux VM?

So far I've never really had to use Linux much. Mostly used Windows and OS X. But from what I've heard most people at the company I'll join shortly use Linux, so I might try to expand my horizons some more. My current machines weren't really powerful enough to run VMs well.
 

tokkun

Member
How do you feel about Windows/Linux dual booting vs Windows + Linux VM?

So far I've never really had to use Linux much. Mostly used Windows and OS X. But from what I've heard most people at the company I'll join shortly use Linux, so I might try to expand my horizons some more. My current machines weren't really powerful enough to run VMs well.

I used to dual boot, now I use VMs. If you have the RAM and you don't need low-level hardware access on both OSs, I think it's the way to go. You save time not having to reboot to switch OS, you can multitask across OSs, and if you are using Windows as the host OS you can rely on its superior driver support.

It's especially convenient with laptops; hibernate is much easier to get working properly on Windows than it is on Linux. Used to be that every time I upgraded software packages in Linux I would have to fix a bunch of power management stuff on my laptop. With the VM, that's no longer a concern.
 
Top Bottom