• 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

What would ProgrammingGAF consider the difference between a beginner and intermediate programmer?

I consider myself a beginner but I don't know if Im selling myself short. I haven't done any complex algorithms or written games, but I've done a lot of scripting around APIs and understand the basics of OOP.
 

Fishlake

Member
I consider myself an intermediate programmer and I'm about to graduate with a bachelors degree. The more I learn to program the more I learn how little I know.
 
What would ProgrammingGAF consider the difference between a beginner and intermediate programmer?

I consider myself a beginner but I don't know if Im selling myself short. I haven't done any complex algorithms or written games, but I've done a lot of scripting around APIs and understand the basics of OOP.

A beginning programmer is someone who does not have at least 3 years experience working on a real, large-scale project. An intermediate programmer is someone who has.


Note that I didn't require the project be an actual job. I've known good programmers who were still in college, because they worked heavily on open source while they were still in high school / college.
 
I was asking because it was on a job application form for a qa/support role. I don't do programming non-stop, but I feel like I know a bit more than beginner. I opted to go for intermediate, explain myself in my cover letter and throw some links to github projects. I'll let them suss it out from here.
 
I was asking because it was on a job application form for a qa/support role. I don't do programming non-stop, but I feel like I know a bit more than beginner. I opted to go for intermediate, explain myself in my cover letter and throw some links to github projects. I'll let them suss it out from here.

Part of the trick in figuring out how to answer that question is figuring out what scale the person reading your answer is using. And usually it means "where do you rank compared to other people likely to apply for this same job"
 
That's a good piece of advice. I kind of approached it from the context of what the role was and what it was looking for. I would assume in this case beginner is just basic print, if, for, while kind of stuff. So that's why I just went for intermediate. We'll see.
 

Somnid

Member
I'd say:

A beginner can take a task, virtually any task, and write code that will produce the correct result in a tech-stack they are familiar with.

An intermediate programmer is someone who can not only do that, but architect it in a way that is optimized, flexible, modular and readable with great understanding of design patterns and programming philosophies.

An expert can do that on various stacks and will also also have a strong understanding of the tools around the code, building, testing, deploying, and project management for multiple devs. They will know strengths and weaknesses of multiple stacks and use the one most suited for the job, rather than the one they favor.
 
Curious about your definition of large-scale...

I'll give you the definition I would use if we could limit the world to open source projects. Some of these will still apply to closed source projects, but the list would need to change for closed source, and I haven't thought too much about it. It's tricky to define.

* has at least 10 active developers
* supports multiple platforms (osx, linux, windows)
* has an active developer mailing list (20+ posts / month with regular patches)
* has a decent sized test suite
* has at least 20,000 active users

Random examples include:

* Linux
* Chrome
* Firefox
* Any open source programming language / compiler (GHC, GCC, Clang, Python, Java, etc)
ffmpeg
* OpenSSL
* Blender
* SWIG
* Zero MQ
* OpenVPN
* OpenGL

I don't know, there's probably hundreds more. The point is that to me, in order to progress from beginner to intermediate, being more comfortable in your programming language(s) of choice is necessary but not sufficient. You need to have experience with project dynamics, testing, and impact.

I mean with such a coarse granularity of only having presumably 4 levels (novice, beginner, intermediate, advanced), the bar for moving up one level has to be higher.
 

Koren

Member
I'll give you the definition I would use if we could limit the world to open source projects. Some of these will still apply to closed source projects, but the list would need to change for closed source, and I haven't thought too much about it. It's tricky to define.

* has at least 10 active developers
* supports multiple platforms (osx, linux, windows)
* has an active developer mailing list (20+ posts / month with regular patches)
* has a decent sized test suite
* has at least 20,000 active users
Thanks...

I can't say i really agree that it's required to be an intermediate programmer, but I'm not sure we can settle on a definition, anyway.

With this kind of definition, most of historic programmers are beginners...
 

X05

Upside, inside out he's livin la vida loca, He'll push and pull you down, livin la vida loca
Eclipse was what I was told to use for Mac in my first programming class and I never really looked for alternatives. :p I'll look into XCode.
Do it, I'm not particularly fond of XCode but Eclipse sucks.
 
Not sure Dijkstra would fit your criteria, for example.

I'm not sure I would consider him a good programmer. I mean, he was a theoretical computer scientist. And a great one at that, but I don't think the skills required to be a good software engineer and the skills required to design algorithms and prove mathematical properties of computer science problems necessarily always align well with each other.

I'm not saying he's a beginner at what he does, I'm saying that what he does is not software engineering.

That begs the question or whether "software engineer" and "programmer" should be synonymous, but the person who asked the question was asking in the context of answering a question on a job application, so I think equating with "software engineer" in this context is appropriate.
 

Koren

Member
I'm not saying he's a beginner at what he does, I'm saying that what he does is not software engineering.

That begs the question or whether "software engineer" and "programmer" should be synonymous, but the person who asked the question was asking in the context of answering a question on a job application, so I think equating with "software engineer" in this context is appropriate.
Fair enough, I can agree with this. If you talk about software engineers, it makes more sense.

Although I'm not sure companies are only looking for software engineers. Sometimes you need more insight, creativity, brute force optimization capabilities at the cost of a lack of some experience in project management (i don't say software engineers lack creativity, it's just that it's difficult to put numbers on everything).

you can always recognize you've worked on lesser known projects or in smaller teams without presenting yourself as a beginner.

Besides, if you've worked on military or company internal software, you'll miss the 20000 rule, and possibly the team size rule while any minor contributor of a gimp routine will qualify...


Photographs have books, web developpers portfolios, architects already built buildings... I think you're best defined by what you've done anyway, or what you can achieve in a given situation.
 

Koren

Member
Didn't mean to start a massive debate, was just curious. Sorry folks.
No need to be sorry, that's actually an interesting question... One that made me think a lot in the past years, too.

I think the best strategy is still to be honest on your strong and weak points, instead of trying to devise a measurement of "skill" as a whole.

Pretty sure that most company wanting to hire people will conduct some kind of test, anyway.
 

Zeus7

Member
I have a question regarding RSA Encryption: For my studies I have to write about the algorithm and whether or not it is secure. What is a feasible way to test it? I am pretty stumped at this part as I know it is practically unbreakable but I need to show some practical work. I thought about running an algorithm for a day or two and seen how many numbers it got through, and then comparing this to how long it would take to factor a 1024/2048-bit integer. Any ideas would be appreciated :)
 

kswiston

Member
I am taking an introduction to C course, and have a question.

I am writing a practice program that grades student quizzes. The user enters student answers to the quiz and checks them against an answer key. I have my program working, but I was wondering if there is a cleaner way to have the user input the student answers.

The test answers for each student is an array of 20 single digit integers. The user must be able to enter all 20 integer answers at the same time and on the same input line.

eg.

Type in the answers:
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0

The following code works:

Code:
	for(r=0; r<4; r++)
	{
		printf("Type student name and hit enter \n");
		scanf("%s", student[r]);
		printf("Type in %s's answers in order (leave a space between answers) \n", student[r]);
		scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &answers[r][0], &answers[r][1], &answers[r][2], 
			&answers[r][3], &answers[r][4], &answers[r][5], &answers[r][6], &answers[r][7], &answers[r][8], &answers[r][9], 
			&answers[r][10], &answers[r][11], &answers[r][12], &answers[r][13], &answers[r][14], &answers[r][15], &answers[r][16], 
			&answers[r][17], &answers[r][18], &answers[r][19]);
	}

but as you can see, the second scanf statement is sort of long (and in practice it would be a pain in the ass to reformat for a test that had a different number of questions).

Is there a better way of writing the second scanf statement that gives me the same desired result (given the criteria above)?
 
You said C, so I'm assuing you can't use C++.

One thing you could do is keep two pointers. Make a loop that checks the value of the first pointer, if it's not a space increment it, if it is a space replace it with the number 0. The call atoi() on the second pointer, store the result in the array, increment the first pointer, set the second pointer equal to the first pointer, and repeat.

This method gets rid of the scanf entirely, and also allows you to support a non constant number of grades.
 

hateradio

The Most Dangerous Yes Man
If you want a quick and dirty way to run Linux on your non-Linux box you can try Virtualbox:

https://www.virtualbox.org/

It's free and will let you emulate a Linux box which you can put Ubuntu or whatever on.


On windows, the tool linuxlive usb creator create bootable linux usb sticks easily in minutes, that also have "in a window" virtualization capability.

Really handy if you don't want to configure virtualbox and install Linux manually.
Also . . .

With Vagrant you can just download a "box" and configure it quick-ish with the stuff that you need it to have.

Then there's also docker if you just want light Linux VMs. But that's probably more than required, probably.
 
Anyone here work with Python and/or Flask? Trying to work with web forms and passing data between routes WITHOUT using a database. I think using Sessions would be the right way but not sure. For now I'm just trying to see if I can pass form_data into the route /results. I know I can use sqlite, but none of this data is going to be preserved.

Code:
from flask import Flask, request, render_template, redirect, url_for
from wtforms import Form, TextField, BooleanField, validators
app = Flask(__name__)

class SpotifyForm(Form):
    artist_name = TextField('Artist:')
    album_name = TextField('Album:')
    track_name = TextField('Track:')
    results_type = TextField('Type:')
    explicit = BooleanField('I do not want explicit tracks')

@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def spotify_form():
    form_data = []
    form = SpotifyForm(request.form)
    if request.method == 'POST' and form.validate():
        form_data.append({'artist': form.artist_name.data, 'album': form.album_name.data, 'track': form.track_name.data, 'type': form.track_name.data, 'explicit': form.explicit.data})
        return redirect(url_for('results'))
    return render_template('index.html', form=form)

@app.route('/results', methods=['GET', 'POST'])
def results():
    return render_template('results.html')

if __name__ == '__main__':
    app.run(debug=True)
 

kswiston

Member
You said C, so I'm assuing you can't use C++.

One thing you could do is keep two pointers. Make a loop that checks the value of the first pointer, if it's not a space increment it, if it is a space replace it with the number 0. The call atoi() on the second pointer, store the result in the array, increment the first pointer, set the second pointer equal to the first pointer, and repeat.

This method gets rid of the scanf entirely, and also allows you to support a non constant number of grades.

Thanks for the help!
 

Ambitious

Member
For some reason, Eclipse's built-in color settings seem to partially overwrite my theme's colors. I'm using the Eclipse Color Themes plugin with the Obsidian theme. The background color of selected text is supposed to be dark red, but everytime I launch Eclipse, it's dark blue instead. When I simply re-apply Obsidian in the theme list, the selection color is changed to red just as it should be. But when I start Eclipse the next theme, it's back to blue again.

The same happens with the line highlight color. It's rather annoying.

edit: This only happens when I use Eclipse's Dark Theme.

edit 2: I found a bug report related to this, but it's not quite the same. I can't reproduce it. After some experimentation, it seems the only colors which are overwritten for me are the ones from the ECT plugin (Settings: General -> Appearance -> Color Theme). Any changes I make in Appearance -> Colors and Fonts, Editors -> Text Editors and Java -> Editor -> Syntax Coloring are preserved. Weird.

I guess I have no choice but to use the standard, light theme instead.
 

taybul

Member
Anyone here work with Python and/or Flask? Trying to work with web forms and passing data between routes WITHOUT using a database. I think using Sessions would be the right way but not sure. For now I'm just trying to see if I can pass form_data into the route /results. I know I can use sqlite, but none of this data is going to be preserved.

Code:
from flask import Flask, request, render_template, redirect, url_for
from wtforms import Form, TextField, BooleanField, validators
app = Flask(__name__)

class SpotifyForm(Form):
    artist_name = TextField('Artist:')
    album_name = TextField('Album:')
    track_name = TextField('Track:')
    results_type = TextField('Type:')
    explicit = BooleanField('I do not want explicit tracks')

@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def spotify_form():
    form_data = []
    form = SpotifyForm(request.form)
    if request.method == 'POST' and form.validate():
        form_data.append({'artist': form.artist_name.data, 'album': form.album_name.data, 'track': form.track_name.data, 'type': form.track_name.data, 'explicit': form.explicit.data})
        return redirect(url_for('results'))
    return render_template('index.html', form=form)

@app.route('/results', methods=['GET', 'POST'])
def results():
    return render_template('results.html')

if __name__ == '__main__':
    app.run(debug=True)
Instead of redirecting why not just process form_data right there and return what you'd otherwise be doing in the results route?

You could also treat your server as a REST service and do all your rendering client-side.
 
very new user btw
I'm using eclipse for my Java class right now and for every chapter I'm given a folder of java files to run as examples for the chapter. Is there any way to create multiple projects at once for all the different java files or do I have to continue manually creating a separate project for each file?
 

upandaway

Member
very new user btw
I'm using eclipse for my Java class right now and for every chapter I'm given a folder of java files to run as examples for the chapter. Is there any way to create multiple projects at once for all the different java files or do I have to continue manually creating a separate project for each file?
A project can have multiple Run configurations. Say you have two different classes, both have different main() functions which run two entirely different programs using different files, right click on one of them and click Run->As Java Application, and both files can be in the same project
 
A project can have multiple Run configurations. Say you have two different classes, both have different main() functions which run two entirely different programs using different files, right click on one of them and click Run->As Java Application, and both files can be in the same project

-_- fuck. been creating a new project with the same name as file and creating a new class for each project just copy and pasting the file into the new class.

And thank you. don't know why I never thought of this. it just makes sense.
 
I'm not sure I would consider him a good programmer. I mean, he was a theoretical computer scientist. And a great one at that, but I don't think the skills required to be a good software engineer and the skills required to design algorithms and prove mathematical properties of computer science problems necessarily always align well with each other.

I'm not saying he's a beginner at what he does, I'm saying that what he does is not software engineering.

That begs the question or whether "software engineer" and "programmer" should be synonymous, but the person who asked the question was asking in the context of answering a question on a job application, so I think equating with "software engineer" in this context is appropriate.

They are not and should not be, but are used interchangeably. But that's a whole holy war of nonsense that isn't worth getting into.
 
Anyone here work with Python and/or Flask? Trying to work with web forms and passing data between routes WITHOUT using a database. I think using Sessions would be the right way but not sure. For now I'm just trying to see if I can pass form_data into the route /results. I know I can use sqlite, but none of this data is going to be preserved.

Code:
from flask import Flask, request, render_template, redirect, url_for
from wtforms import Form, TextField, BooleanField, validators
app = Flask(__name__)

class SpotifyForm(Form):
    artist_name = TextField('Artist:')
    album_name = TextField('Album:')
    track_name = TextField('Track:')
    results_type = TextField('Type:')
    explicit = BooleanField('I do not want explicit tracks')

@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def spotify_form():
    form_data = []
    form = SpotifyForm(request.form)
    if request.method == 'POST' and form.validate():
        form_data.append({'artist': form.artist_name.data, 'album': form.album_name.data, 'track': form.track_name.data, 'type': form.track_name.data, 'explicit': form.explicit.data})
        [B]return render_template('results.html', results=form_data)[/B]
    return render_template('index.html', form=form)

@app.route('/results', methods=['GET', 'POST'])
def results():
    return render_template('results.html')

if __name__ == '__main__':
    app.run(debug=True)
I'd try this, but I haven't actually tested it. You'd then have the variable "results" available in your results.html template. As already mentioned, a REST interface would also be a good fit here.
 

Moosichu

Member
weird2.png


I'm getting mystery shadows :( I thought it may be todo with colors overflowing as (at the moment) I am using an unsigned byte to represent each color channel. However, I did add code to check for that so that doesn't seem to be the issue. The only problem is that I really don't know what it could be.

Code:
 static uint8 addChannels(uint8 c1, uint8 c2) {
      if((c1 | c2) == 255) {
            c1 = 255;
        } else {
            uint8 newC = c1 + c2;
            if(newC < (c1 | c2)) {
                //Have overflow, max out color!
                c1 = 255;
            } else {
                c1 = newC;
            }
        }
        return c1;
    }

Here is all the code: https://github.com/Moosichu/RayTracer/blob/master/src/ray_tracer.cpp

Ignore the really bad project structure and bad code style. I am improving things bit by bit! I just want to sort all the bugs first :p.
 

vypek

Member
Recently started working with REST and SOAP services. Kinda interesting/fun but confusing for me at times. I think I'm getting a little better though.
 
I'd try this, but I haven't actually tested it. You'd then have the variable "results" available in your results.html template. As already mentioned, a REST interface would also be a good fit here.

Instead of redirecting why not just process form_data right there and return what you'd otherwise be doing in the results route?

You could also treat your server as a REST service and do all your rendering client-side.

Thanks.

I've never worked with a web framework and this is my first web application so a lot of this is new to me.
 

taybul

Member
Trying my hand at Android app programming for the first time. It's strangely similar to web development. I've done non-web UI development in the past and it's always felt like a pain but this seems pretty easy and straightforward. Just following the official tutorial for now but if anyone has some good resources it'd much appreciated!
 
Trying my hand at Android app programming for the first time. It's strangely similar to web development. I've done non-web UI development in the past and it's always felt like a pain but this seems pretty easy and straightforward. Just following the official tutorial for now but if anyone has some good resources it'd much appreciated!

I always recommend using the official materials and documentation since those are authored by the actual developers and people working closely with the developers so it'll tend to emphasize best practices. Third-party tutorials will often endorse subtly wrong or inefficient methods. It's the difference between w3schools and developer.mozilla.org.

Just to soapbox a little, I kind of cringe when I hear about programmers who Google their specific problems and copy-paste solutions all the time from places like Stack Overflow. I do the same thing but I'll never just take the solution that someone posted and apply it to my own code; I'll use it to guide me to the relevant section of the official documentation. You never know if some code you find on the internet is truly the best solution or doesn't have edge failure cases unless you completely understand how it works.
 
Just to soapbox a little, I kind of cringe when I hear about programmers who Google their specific problems and copy-paste solutions all the time from places like Stack Overflow. I do the same thing but I'll never just take the solution that someone posted and apply it to my own code; I'll use it to guide me to the relevant section of the official documentation. You never know if some code you find on the internet is truly the best solution or doesn't have edge failure cases unless you completely understand how it works.

I've done/do this, but I also try to make it a point to deconstruct it so I know what it's actually doing. Then for the future I'll know I have a reference point of where to go and look further if need be.
 
I'm a bit lost on this problem, in C++.

Lets say I have

int* GAF; So GAF is a pointer to an int.

now I make a dynamic array of 5 ints and have GAF point to it.

GAF = new int[5];

Lets say that this array has the values {1, 7, 5, 2, 3}

and the user wants to remove 7 from it. The end result I want is:

{1, 5, 2, 3}. Ok so this should be easy enough. I could just make a new array and copy the values (sans the one I want removed) over to it. Except, I'm not allowed to do that.

Instead I need to remove the 7 by shifting all the elements after 7 one space down.

Except how do I do that. I could loop through the array starting at GAF[1] and then have GAF[1] = GAF[2], etc... down through the loop. But that won't work for the final element.
 
Hey, Programming GAF. I am very much new to programming. As it turns out, I have a programming class requiring us learn C#. Do you guy know of any good tutorials or videos out there to supplement my learning? I'd really appreciate it!
 

Aureon

Please do not let me serve on a jury. I am actually a crazy person.
I'm a bit lost on this problem, in C++.

Lets say I have

int* GAF; So GAF is a pointer to an int.

now I make a dynamic array of 5 ints and have GAF point to it.

GAF = new int[5];

Lets say that this array has the values {1, 7, 5, 2, 3}

and the user wants to remove 7 from it. The end result I want is:

{1, 5, 2, 3}. Ok so this should be easy enough. I could just make a new array and copy the values (sans the one I want removed) over to it. Except, I'm not allowed to do that.

Instead I need to remove the 7 by shifting all the elements after 7 one space down.

Except how do I do that. I could loop through the array starting at GAF[1] and then have GAF[1] = GAF[2], etc... down through the loop. But that won't work for the final element.

do a for(int i=0;i<len-1;i++).
And "it's simple" if you're using lists, but raw arrays trade convenience of manipulation for performance.
 
I'm a bit lost on this problem, in C++.

Lets say I have

int* GAF; So GAF is a pointer to an int.

now I make a dynamic array of 5 ints and have GAF point to it.

GAF = new int[5];

Lets say that this array has the values {1, 7, 5, 2, 3}

and the user wants to remove 7 from it. The end result I want is:

{1, 5, 2, 3}. Ok so this should be easy enough. I could just make a new array and copy the values (sans the one I want removed) over to it. Except, I'm not allowed to do that.

Instead I need to remove the 7 by shifting all the elements after 7 one space down.

Except how do I do that. I could loop through the array starting at GAF[1] and then have GAF[1] = GAF[2], etc... down through the loop. But that won't work for the final element.

A raw C array has no size. It's size is whatever you know it to be. Whether you "know" correctly or not is a different story. If you have this:

int* GAF;

How many elements are in the array? Who knows! What about this:

int * GAF = new int[5];

How many elements are there now? Still don't know. We only know that there are at most 5. But there could be less than 5. It just all depends how you use it. That's why you don't write this:

Code:
for (int i=0; i < 5; ++i)
    printf("%d", GAF[i]);

Instead you write this:

Code:
for (int i=0; i < len; ++i)
    printf("%d", GAF[i]);

If len==4, you're saying that this array has 4 elements. If len==5, you're saying it has 5 elements. Back to your original example, if you want to remove one item. Do what you said. shift everything down, or use a for loop to copy the values. Then set len==4, and use that variable in any loops or anything that needs to know how many items are in the array.
 
A raw C array has no size. It's size is whatever you know it to be. Whether you "know" correctly or not is a different story.

I thought there was a way to identify the number of elements in a C array through the application of sizeof. It's one of the few instances where there's a difference when defining a a variable as an array type instead of as a pointer.

Something like

Code:
int a[5];
printf("a has %d elements\n", sizeof(a) / sizeof(a[0]));

Just an academic question. In practice you're usually either going to dynamically allocate arrays into a pointer variable or set the array size using a constant, which you can just reuse.
 
Top Bottom