• 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

injurai

Banned
So I'm going through The Unix Programming Environment and there seems to be enough differences in the modern Linux Kernel and shells in general that I'm wondering if there are modern books of a similar caliber?

It seems really amazing, especially with the detail of history and design choices that were made for Linux. But it still seems dated enough that it can be misleading for today.
 

iapetus

Scary Euro Man
Based on your job search, and as others have noted: if employment is your goal, then C#/.NET is probably the way to go.

Most people assume that the best way to go is where most jobs are. The best way to go is where the ratio of candidates to jobs is best; if there's only one role available for a Brainfuck developer, and you're the only Brainfuck developer out there, you're in a better position than one of hundreds of thousands of Java developers going for thousands of Java roles...
 

Jokab

Member
Most people assume that the best way to go is where most jobs are. The best way to go is where the ratio of candidates to jobs is best; if there's only one role available for a Brainfuck developer, and you're the only Brainfuck developer out there, you're in a better position than one of hundreds of thousands of Java developers going for thousands of Java roles...

So you're saying I should learn COBOL?
 

vladimirdlc

Neo Member
Isn't that due largely to the .NET Framework handling most garbage collection? The only memory management that needs to be done is for files, windows, database connections, etc.

Indeed, unless you need to handle every bit of memory, and you consider you can do it better manually, the best option is to use a language with automatic garbage collection.
Let the machine do the dirty job,and concentrate on more practical code.
 

BreakyBoy

o_O @_@ O_o
Most people assume that the best way to go is where most jobs are. The best way to go is where the ratio of candidates to jobs is best; if there's only one role available for a Brainfuck developer, and you're the only Brainfuck developer out there, you're in a better position than one of hundreds of thousands of Java developers going for thousands of Java roles...

This is an excellent point. Being a pro in a niche is often far more lucrative.

That being said, only being good at a niche sometimes means finding a job is difficult, particularly if you're not willing to relocate to where the small number of jobs might crop up.

Best advice is probably the most common one. Learn as much you can, particularly the fundamentals that can apply across environments/languages. Don't ever stop, because it probably won't ever end.
 

Skinpop

Member
anyone has experience writing a (simple) raytracer? Can't seem to get my shadows right.

nvm, solved it. don't even know how which is frustrating. I just rewrote the function like 5 times.
 
What's the context? Are you referring to stuff like unsolved problems in computer science? If so, then you would be wanting to look into things like the P = NP problem.

Here's a list:

http://en.wikipedia.org/wiki/List_of_unsolved_problems_in_computer_science

Well its a project about making a simple payroll system using C++. The question prior is something about how to make a search program (search engine building block), it might be referring to mysteries about that but i have no idea the answer to that question either. Will take a look at that list thanks.
 

maeh2k

Member
CUDA or OpenCL, which should I learn?

Doesn't matter much. They are very similar. With OpenCL you get the benefit of having an open standard that's supported on all kinds of hardware. With CUDA you get a somewhat more advanced framework that limits you to one company. But seeing how similar the two are, porting from one to the other is no big deal.
In the end you don't just learn an API, but you learn how exactly the GPUs are set up and how to program for that. That's independent of the API.

If you have an NVIDIA GPU and don't care about running your stuff on AMD and CPUs, CUDA might be a bit nicer to work with.

(disclaimer: did a project porting from CUDA to OpenCL to analyze the performance on CPUs a couple of years ago, but haven't kept up with the newer versions of either)
 

Water

Member
CUDA or OpenCL, which should I learn?

I'd go CUDA first due to this course if nothing else. Another reason is CUDA tools are generally recognized to be higher quality, lower friction, which speeds up learning. That's to be expected from a single-vendor technology vs a committee-designed technology that has to be able to run on everything from GPUs to pocket calculators.

I would, however, also sign up to wait for the next session of this course that starts with CUDA but will also cover OpenCL and others.

(I haven't worked with these technologies, but when I find the time I'm doing what I just suggested.)
 

oxrock

Gravity is a myth, the Earth SUCKS!
OK, this post may seem stupid but I honestly have no idea why this is happening. I'm using python as always and I'm doing a simple variable declaration.

X = (246/100) * 88.333333

my calculator tells me that equals 217.29999918, however my program is steadfast in telling me that it's 176.666666

Obviously I could just plug in the answer and be done with it however the X variable will be dynamic and 88.333333 will be a different dynamic variable so I need the program to actually compute proper results.

Any thoughts/comments appreciated.

Edit: Well I of course figured it out within 5 seconds of hitting submit. I changed (246/100) to (246/100.0) and now it magically works. Python needs a float in the equation to give answers with decimals. I'll leave this up so you can all point and laugh :p
 

Tamanon

Banned
OK, this post may seem stupid but I honestly have no idea why this is happening. I'm using python as always and I'm doing a simple variable declaration.

X = (246/100) * 88.333333

my calculator tells me that equals 217.29999918, however my program is steadfast in telling me that it's 176.666666

Obviously I could just plug in the answer and be done with it however the X variable will be dynamic and 88.333333 will be a different dynamic variable so I need the program to actually compute proper results.

Any thoughts/comments appreciated.

Gotta make it (246.0/100).

With no decimals, Python assumes an integer only and rounds it to 2 instead of 2.46.
 

oxrock

Gravity is a myth, the Earth SUCKS!
Gotta make it (246.0/100).

With no decimals, Python assumes an integer only and rounds it to 2 instead of 2.46.

Try this

X = float(246/100) * float(88.333333)

Either of those would of worked fine and I appreciate the speedy responses. It's funny how the silliest thing can set you back sometimes. I spent a long while trying to figure out just what exactly was going on here and of course 5 seconds after posting I have a eureka moment and smack myself for missing something so simple.

May as well update since I bothered everyone. The player health bar in my game is now properly working with this silly task out of the way and now I get to continue working on sound effects, good times :)
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Edit: Well I of course figured it out within 5 seconds of hitting submit. I changed (246/100) to (246/100.0) and now it magically works. Python needs a float in the equation to give answers with decimals. I'll leave this up so you can all point and laugh :p

I don't think this is exclusive to Python, but just a fact of dealing with division inside computers.
 

hateradio

The Most Dangerous Yes Man
Try this

float(246/100)
That would just output 2.0.

Code:
>>> float(256 / 100)
2.0

# You just need one of the numbers to be a float.

>>> 256 / float(100)
2.56

I don't think this is exclusive to Python, but just a fact of dealing with division inside computers.
It's definitely not exclusive to Python. Integer division results in an integer, so the language is doing what it's supposed to.

When you cast or use one of the numbers as a float (or some other decimal) then it will promote the other number to the same type.
 

0xCA2

Member
Doing a web development project that is due today at 11PM and just came across a bug that indents text automatically at certain zooms. It only happens in Chrome and it seems to be happening no matter what font I use (though some fonts at least work at 100%). I have no idea why this is happening and I cannot seem to find anything online about it.

Is this what being a web developer is like?

Fake Edit: I don't know why, but changing the font-family of the parent div to Verdana and then setting the font-family of the child div for the text to Arial worked.
 

Massa

Member
Is this what being a web developer is like?

Yep.

css-is-awesome-20090407-142244.jpg
 

upandaway

Member
So seems like I'll start studying for CS this year, getting a bit scared because of both the job market stories (although I'm in a country where it's not that bad at all) and the drop outs stories but I don't really have any other direction. For what it's worth I read books and wrote stuff for a couple years now, and it's super fun, but I don't know how much that has in common with a degree (probably not much).

I went to a gathering there the other day and the instructors flat out told me they don't recommend to work during semesters because I'll need all the time I could get. But... I do have to work, so I'm not sure how to think about that.

Anyone have any advice or anecdotes or something?
 
So seems like I'll start studying for CS this year, getting a bit scared because of both the job market stories (although I'm in a country where it's not that bad at all) and the drop outs stories but I don't really have any other direction. For what it's worth I read books and wrote stuff for a couple years now, and it's super fun, but I don't know how much that has in common with a degree (probably not much).

I went to a gathering there the other day and the instructors flat out told me they don't recommend to work during semesters because I'll need all the time I could get. But... I do have to work, so I'm not sure how to think about that.

Anyone have any advice or anecdotes or something?

How much you'll be able to work is really up to your aptitude for the course material and how much you load yourself down with. Personally, I worked a minimum of 30 hours per week through college, but I also took several 12 hour semesters (not sure how it equates to your country or school, but at my university, the common per-semester course load was 15 hours, but 12 hours was still considered full time, and incidentally so was the 30 hours per week I was working) and then supplemented that with summer school for non-core classes. In fact, summer school is a great way to reduce your load by spreading it out over the entire year.
 

upandaway

Member
How much you'll be able to work is really up to your aptitude for the course material and how much you load yourself down with. Personally, I worked a minimum of 30 hours per week through college, but I also took several 12 hour semesters (not sure how it equates to your country or school, but at my university, the common per-semester course load was 15 hours, but 12 hours was still considered full time, and incidentally so was the 30 hours per week I was working) and then supplemented that with summer school for non-core classes. In fact, summer school is a great way to reduce your load by spreading it out over the entire year.
They did say something about summer courses but also noted that it was canceled this year, so yeah. From what I gathered the degree is split pretty evenly at 20~25 weekly hours (and also in terms of difficulty/intensity) over 3 years. I already have enough money for the tuition itself, so I don't need too much, though...
 

0xCA2

Member
Hey guys, would anyone like to critique my website ? Note, this is a project for a beginner's class, so I am already pretty much assured an A, but my I just want to know if there are some small things I can do between now and when it's due today to make it better.

As part of a peer review (phase 2 of the project) I was told that it looked bland, and I kind of know it does, but I don't know what to do to spruce it up. I was also told that I should have more questions on the FAQ page, but else should be there. Anyone have any suggestions?

Notes:
- Pages were generated using a Java program that uses an XML file that contains all of the info for the episodes
- Information about the episodes were obtained using PHP scripts to go through other websites (spent way too much time on this)
- Stupidly started the project assuming that I could use PHP and MySQL
- Could not feasibly obtain the episode descriptions using a program, so I think I might just add them by hand

EDIT: gah right of the bat, that server isn't can't sensitive so none of the episode links work. I'll fix this.
Edit: It works now.
 

Jokab

Member
One thing you need to work on is the fonts, they're pretty ugly as is. Most sites these days use sans-serif fonts, look into those.
 

r1chard

Member
Well I of course figured it out within 5 seconds of hitting submit. I changed (246/100) to (246/100.0) and now it magically works. Python needs a float in the equation to give answers with decimals. I'll leave this up so you can all point and laugh :p
No pointing and/or laughing here. This behavior is so surprising to beginners that Python 3 changed the behavior and added a truncating integer division operator to retain the old behavior:

Code:
>>> 276 / 100
2.76
>>> 276 // 100
2

You can get this behavior in Python 2 (2.6+ IIRC) by having "from __future__ import division" at the top of your code.
 

0xCA2

Member
Okay, so I've tried incorporate many of your ideas. I used Sans Serif fonts, fixed the links, changed the link colors on the FAQ and about pages, etc.

Keep in mind, the graders are only testing this in chrome, so that's all I considered. Here it is.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
No pointing and/or laughing here. This behavior is so surprising to beginners that Python 3 changed the behavior and added a truncating integer division operator to retain the old behavior:

Code:
>>> 276 / 100
2.76
>>> 276 // 100
2

You can get this behavior in Python 2 (2.6+ IIRC) by having "from __future__ import division" at the top of your code.

Wouldn't that just make your code more confusing for people reading it since it's going against the norm for languages?

I would think it'd be better to simply cast it to a float or do the division with a float whenever you needed it.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Hey guys, can you help me with translating something from Javascript to C#? I used the Javascript one in Unity, because I couldnt get it to work in C#, but now I noticed I need to have it in C# after all to access the script from another c# script:

Javascript:
Code:
#pragma strict
    import SpriteTile;
     
    private var speed = 3.0;
    private var pos : Vector3;
    private var tr : Transform;
     
    function Start() {
    pos = transform.position;
    tr = transform;
    }
     
    function Update() 
    {
	    var colliderUp = Tile.GetCollider (transform.position + Vector3(0,0.64,0));
	    var colliderRight = Tile.GetCollider (transform.position + Vector3(0.64,0,0));
	    var colliderDown = Tile.GetCollider (transform.position + Vector3(0,-0.64,0));
	    var colliderLeft = Tile.GetCollider (transform.position + Vector3(-0.64,0,0));
	    
	    if (Input.GetKeyDown(KeyCode.D) && tr.position == pos && colliderRight==false) 
	    {
	    Right();
	    }
	    else if (Input.GetKeyDown(KeyCode.A) && tr.position == pos && colliderLeft==false)
	    {
	    Left();
	    }
	    else if (Input.GetKeyDown(KeyCode.W) && tr.position == pos && colliderUp==false)
	    {
	    Up();
	    }
	    else if (Input.GetKeyDown(KeyCode.S) && tr.position == pos && colliderDown==false)
	    {
	    Down();
	    }
	     
	    transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * speed);
    }

C#
Code:
using UnityEngine;
using System.Collections;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using SpriteTile;

public class PlayerControls : MonoBehaviour {
	
	
	int speed = 3;
	public Vector3 pos = new Vector3();
	public Transform tr = new Transform();
	
	// Use this for initialization
	void Start () 
	{
		pos = transform.position;
		tr = transform.;
	}
	
	// Update is called once per frame
	void Update () 
	{
		Collider colliderUp = Tile.GetCollider (transform.position + Vector3(0,0.64,0));
		Collider colliderRight = Tile.GetCollider (transform.position + Vector3(0.64,0,0));
		Collider colliderDown = Tile.GetCollider (transform.position + Vector3(0,-0.64,0));
		Collider colliderLeft = Tile.GetCollider (transform.position + Vector3(-0.64,0,0));
		
		if (Input.GetKeyDown(KeyCode.D) && tr.position == pos && colliderRight==false) 
		{
			Right();
		}
		else if (Input.GetKeyDown(KeyCode.A) && tr.position == pos && colliderLeft==false)
		{
			Left();
		}
		else if (Input.GetKeyDown(KeyCode.W) && tr.position == pos && colliderUp==false)
		{
			Up();
		}
		else if (Input.GetKeyDown(KeyCode.S) && tr.position == pos && colliderDown==false)
		{
			Down();
		}
		
		transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * speed);
	}

The error I am currently getting from Unity is:
Code:
UnityEngine.Transform.Transform()' is inaccessible due to its protection level

Sorry to bother you guys, but I tried looking up that transform thing for quite a while now on the internet and still couldnt find the proper solution.
 

tokkun

Member
No pointing and/or laughing here. This behavior is so surprising to beginners that Python 3 changed the behavior and added a truncating integer division operator to retain the old behavior:

Code:
>>> 276 / 100
2.76
>>> 276 // 100
2

You can get this behavior in Python 2 (2.6+ IIRC) by having "from __future__ import division" at the top of your code.

It is crazy that Python is willing to just change the behavior of a basic operator when it is an interpreted language.
 
The error I am currently getting from Unity is:
Code:
UnityEngine.Transform.Transform()' is inaccessible due to its protection level

Sorry to bother you guys, but I tried looking up that transform thing for quite a while now on the internet and still couldnt find the proper solution.

I haven't used Unity, but it looks like it's telling you that the constructor on Transform is inaccessible, but it also looks like you don't need it, as you're overwriting those member fields later in your program with another instance. At the top of your class, just get rid of the instantiation of those fields.

Code:
public Vector3 pos;
public Transform tr;

Of course, double check that this is correct, given your program. I don't know, for example, where you get the variable "transform" that you're using inside Start() and Update(), but I assume it's a field of your base class or something.

It is crazy that Python is willing to just change the behavior of a basic operator when it is an interpreted language.

Yeah, that's pretty messed up.
 
It is crazy that Python is willing to just change the behavior of a basic operator when it is an interpreted language.
.

I like to give C++ and Java grief for being so pedantic about backwards compatibility, but it's an indictment of a language when programming for it is like trying to hit a moving target.

Like sticking a giant "don't code anything production-worthy" sign on your language.
 

Chris R

Member
Hey guys, can you help me with translating something from Javascript to C#? I used the Javascript one in Unity, because I couldnt get it to work in C#, but now I noticed I need to have it in C# after all to access the script from another c# script:


Sorry to bother you guys, but I tried looking up that transform thing for quite a while now on the internet and still couldnt find the proper solution.

Could the line

Code:
tr = transform.;

be the issue? Does it even let you compile that? Also, is the speed looks different between the two. No idea if that would screw things up though.
 

r1chard

Member
I like to give C++ and Java grief for being so pedantic about backwards compatibility, but it's an indictment of a language when programming for it is like trying to hit a moving target.

Like sticking a giant "don't code anything production-worthy" sign on your language.
That's a mischaracterisation of Python and the 2->3 transition. Python 2 still exists, and will be supported (by the core devs) until some ridiculous date like 2025 IIRC. Python 3 adoption is healthy with plenty of codebases running on both 2 and 3 (thanks to things like the __future__ imports).

The few changes that happened in Python 3 *are* incompatible, yes, but I think the language is much better-off for it.

I say this as someone who's been coding production-worthy Python in a variety of industries (not just web) for the last 14 years.
 

Water

Member
Wouldn't that just make your code more confusing for people reading it since it's going against the norm for languages?

I would think it'd be better to simply cast it to a float or do the division with a float whenever you needed it.

It's a design mistake in "languages". Division and integer division are fundamentally different operations, and using the same syntax for both is asking for trouble. Far too easy to do an accidental integer division when division was intended. Another reason integer division should not use "/" is that it breaks expectations based on mathematical notation for no reason.

Not all languages make that mistake. Javascript, Haskell, Lisps do not.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
I haven't used Unity, but it looks like it's telling you that the constructor on Transform is inaccessible, but it also looks like you don't need it, as you're overwriting those member fields later in your program with another instance. At the top of your class, just get rid of the instantiation of those fields.

Could the line

Code:
tr = transform.;

be the issue? Does it even let you compile that? Also, is the speed looks different between the two. No idea if that would screw things up though.

Thanks guys, your suggestions got me in the right direction. I didnt notice that Javascript doesnt need to declare vectors before using them, so I forgot to change that in the C# code.
 
It's a design mistake in "languages". Division and integer division are fundamentally different operations, and using the same syntax for both is asking for trouble. Far too easy to do an accidental integer division when division was intended. Another reason integer division should not use "/" is that it breaks expectations based on mathematical notation for no reason.

Not all languages make that mistake. Javascript, Haskell, Lisps do not.

Erm. Whether it breaks expectation depends on what your goal is. 9 / 6 can be seen 1 with a remainder of 3 or 1 and a half.
If you want to know how many complete groups can be formed, you care about only the never 1. For recipes and things of that nature, you want 1.5 of whatever your unit of measure is.
 

V_Arnold

Member
Folks, do you use any software that is a planner for programs?
I mean.... I can manually sketch everything on paper, but I find that wasteful, and sadly, I have come to type faster than I am writing manually :(

I do not like word programs, too hard to easily connect boxes and make random lists that fit well on a small space, and using xls-like calc documents do not cut it either... with all the automatic conversions going on.

Is there a programmer design tool like that?
 
Folks, do you use any software that is a planner for programs?
I mean.... I can manually sketch everything on paper, but I find that wasteful, and sadly, I have come to type faster than I am writing manually :(

I do not like word programs, too hard to easily connect boxes and make random lists that fit well on a small space, and using xls-like calc documents do not cut it either... with all the automatic conversions going on.

Is there a programmer design tool like that?

Hmm, sounds like you maybe want to use UML diagrams?
 

CrankyJay

Banned
Folks, do you use any software that is a planner for programs?
I mean.... I can manually sketch everything on paper, but I find that wasteful, and sadly, I have come to type faster than I am writing manually :(

I do not like word programs, too hard to easily connect boxes and make random lists that fit well on a small space, and using xls-like calc documents do not cut it either... with all the automatic conversions going on.

Is there a programmer design tool like that?

Visual Studio has a cool UML designer that will lay out your classes and member variables in the background as you map things out. It's really wicked, but apparently it's only available in like the highest paid tier their is.
 
Top Bottom