Author Topic: Language advice for project  (Read 1424 times)

0 Members and 1 Guest are viewing this topic.

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Language advice for project
« on: July 18, 2014, 09:27:40 pm »
Sup everyone. I've read a good way of getting good at coding is coming up with some project and coding it. So here's the thing, I thought of a program that will make my job easier and save me some serious time. I'm guessing it's somewhat simple, so here's what I need it to do:

Given a folder full of unsorted pictures, I'd need it to show them one at a time and take a simple 2 digit input from the user (first digit is a 1 or a 0 for a true or false condition, the other one is 1 to 9 for lets say quality), till they are all gone through.
Finally it would have to sort the whole bunch (maybe by renaming them numbers from 1 to n) based on the number they got from the user (something fixed, like 19 09 19 18 06or16 07or17 11 01 13..)

So here's the real question: I started comp science school recently, and first year is mostly about maths and boolean logic, but I know I'll have to get the hang on C for the rest of it. Is C ok to do this? I need the program more than I need the C skills right now, so if it is no task for a C noob then I can take a different language and start with C later.

Any input is really appreciated, it's also my first non-introductive post, and I'm not sure if this is the right section, I'll be glad to move it if it isn't. thanks =)
« Last Edit: July 18, 2014, 09:28:31 pm by wofyendor »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Language advice for project
« Reply #1 on: July 18, 2014, 09:51:50 pm »
How about Java and Swing? or Python and Qt? or Python and Tkinter? or Delphi and Embarcadero RAD Studio? or simply PHP?

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Re: Language advice for project
« Reply #2 on: July 18, 2014, 10:07:36 pm »
How about Java and Swing? or Python and Qt? or Python and Tkinter? or Delphi and Embarcadero RAD Studio? or simply PHP?
Being at start point of all of them (i've completed a few python web tutorials, but they're so basic I don't know if they count), the only thing I want is to do this in the language that is going to be most useful to me in the future, so I take care of my program and practice my coding in a language I will likely use in the future, all at the same time.
 That being said, you've given me a lot to research on, I'll go do some googling and maybe come back later. Thanks a lot!
« Last Edit: July 18, 2014, 10:08:08 pm by wofyendor »

Offline Schalla

  • VIP
  • Peasant
  • *
  • Posts: 81
  • Cookies: 29
    • View Profile
Re: Language advice for project
« Reply #3 on: July 18, 2014, 10:39:28 pm »
I vote to go for Qt or Python, C GUI is a bit overkill to start with.

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Re: Language advice for project
« Reply #4 on: July 18, 2014, 10:44:53 pm »
I will say one thing; the fact that you want to code a C program with a GUI for this as basically your first project is a little crazy as GUI programming can be intimidating even utilizing frameworks like wxWidget. I think something a bit more simple may lead to a higher chance of success for you in your programming endeavors.
I vote to go for Qt or Python, C GUI is a bit overkill to start with.

thanks guys, i hadn't thought of that.But is a GUI strictly needed here ? couldn't I make the program open the photos with whatever image viewer there is in the os, and then close them and open the next one when input is entered?

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Re: Language advice for project
« Reply #5 on: July 18, 2014, 11:01:41 pm »
While you could do that, if that was really your intention then you really don't need to code it in anything outside of either the native command-line scripting langauge (BASH, batch, powershell, VBScript, etc) or for a more cross platform solution a scripting language like perl, python, on my personal favorite, ruby.

Wow, i had no idea simple command line languages could do this kind of stuff, I'll look into it for sure, thank you.
However, since i already have to learn C for next semester, i was just asking if it would complicate things too much to write it in that language, so I practice at the same time. In fact, would you consider it that unwise to do so? I think what I mean is: Is it worth the time ? Thanks, you're being really patient on this.
« Last Edit: July 18, 2014, 11:02:19 pm by wofyendor »

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Re: Language advice for project
« Reply #6 on: July 18, 2014, 11:29:37 pm »
I think writing it in C would be fun for you just because you have to learn it but understand that relying on things like system() is a good way to introduce vulnerabilities into your code

I love how I posted an issue that I thought could be answered by strict yes / nos / xyz languages, and all of a sudden I have a ton of interesting homework and research to do. Thanks guys, I think I get what you're telling me now. Gonna get my ass reading now.

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Re: Language advice for project
« Reply #7 on: July 19, 2014, 12:35:43 am »
Gave you a cookie because you seem to have a good head on your dong and actually take constructive criticism without freaking out. Remember this day as I was the first person to ever give you a cookie.
woah thanks! will do!
how come some of you have negative cookies ? also, is asking off topic questions on your own thread still against the rules? lol, thanks again, i'll be back when I have some actual code to show ya!

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Language advice for project
« Reply #8 on: July 19, 2014, 09:29:21 am »
idk about others but I for one have negative cookies because I asked the admins to give me a large amount of negative cookies in an attempt to cause an integer overflow and end up with a huge amount of positive cookies. Now I have a large amount of negative cookies that can't be stolen from, only added to lol
You will never stop explaining that^ to people.
@OP, don't know about others  but GO programming language is something to looks into. Never mind, just go with whatever you decided, i will feed the GO gospel to someone else.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline wofyendor

  • Serf
  • *
  • Posts: 21
  • Cookies: 9
    • View Profile
Re: Language advice for project
« Reply #9 on: July 19, 2014, 11:51:56 am »
You will never stop explaining that^ to people.
@OP, don't know about others  but GO programming language is something to looks into. Never mind, just go with whatever you decided, i will feed the GO gospel to someone else.

Hey! Thanks for the suggestion, I'll check it out, seems really cool.
I've actually started this today and I must say it's been quite more difficult than I thought (a big leap from my calculator, at least). C wasn't the friendliest choice indeed (please don't go I told u so on me =P), but thankfully there are plenty of resources out there so I managed to make some progress. I think I'll post the code I have so far, so if I'm screwing up I can realize I am, and maybe give someone a good laugh.
Which brigns a question, can I post the code here ? or should I make a thread in C/C++ section? I've done my cookie research, and it seems a reliable way to lose one is by posting in the wrong section, so, better careful than cookieless.

EDIT: Nvm, I've checked the other posts, and apparently it's ok to post some code here.
So here it is so far, I'm pretty sure there are some headers there that aren't used at all, product of trial and error,  I'll have to go over them again to find out which ones =P.  Also I think it looks quite messy, don't know how to improve that though.. Right now, what it does is:
-asks for amount of pictures in folder
-opens pictures one at a time
-asks for number and stores it
-then displays the filenames with corresponding numbers on screen (just to make sure everything is still there)

Code: [Select]
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
     DIR *mydir = opendir("/home/martha/Pictures/test");
     int filetotal;
        printf("input total amount of files:");
        scanf("%d",&filetotal);
     char filepath[100];
     typedef struct {
        char *name;
        int score;
     } packet;
     packet img;
     packet table[300];
     struct dirent *entry = NULL;
     int i;
    for(i=0;i<=(filetotal+1);i=i+1){
        entry = readdir(mydir);
            if(entry->d_name[0] != '.'){
            img.name = entry->d_name;
            strcpy(filepath,"eog /home/martha/Pictures/test/");
            strcat(filepath,img.name);
            printf("%s\n",filepath);
            system(filepath);
            printf("enter 0 to 19 score\n");
            scanf("%d",&img.score);
            printf("%d assigned\n",img.score);
            table[i]=img;
        }
    }
    for (i=0;i<=filetotal+1;i=i+1){
        printf("%s %5d\n",table[i].name,table[i].score);
    }
    return 0;
}

Current issues are
-Pictures still have to be manually closed, as program doesn't continue running until they are. (still haven't found a way of solving this)
-Can't get rid of "." and ".." output in the table, although it doesn't really matter, since I'm gonna discard 0s anyway.

So, what do you think? It looks clumsy, doesn't it? I'm kinda proud of it anyway, cause it was sort of challenging, and it's way better than nothing =).

EDIT 2: I  find that system() line terrifying after reading nonce's advice.
« Last Edit: July 19, 2014, 12:36:10 pm by wofyendor »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Language advice for project
« Reply #10 on: July 19, 2014, 05:43:36 pm »
Could use better variable name conventions and that for loop looks really messy, try with spaces :/
As far as the language with benefits go, I strongly advice on giving Python a go - you will never regret it and it's one language you want to have in your arsenal.

The project itself doesn't seem very hard, all could be done in Qt.

Offline Phenom

  • Peasant
  • *
  • Posts: 51
  • Cookies: -29
  • Dreamer by Day , Hacker by Night
    • View Profile
    • The Nexus Web
Re: Language advice for project
« Reply #11 on: July 19, 2014, 10:00:42 pm »
Python, C or PhP
Cookies are cookies, cookies dissapear, they come , they give and they take.
Honour cookies, respect cookies.
Dont complain about cookies, cookies dont like that, cookies will punish you.
Cookies are life , Cookies are love, Cookies define the very fiber of space.
Roses are red, violets are blue welcome to evilzone , may the cookies be with you

News Website made by me :
<a style="color:red" href="http://www.thenexusweb.com">The Nexus Web</a>

Offline Schalla

  • VIP
  • Peasant
  • *
  • Posts: 81
  • Cookies: 29
    • View Profile
Re: Language advice for project
« Reply #12 on: July 20, 2014, 12:16:56 am »
Phenom, could you stop post hunting? You just listed 3 languages without comparing them in any way or giving arguments why exactly these 3.


You just hunt posts, nothing else.

Offline Phenom

  • Peasant
  • *
  • Posts: 51
  • Cookies: -29
  • Dreamer by Day , Hacker by Night
    • View Profile
    • The Nexus Web
Re: Language advice for project
« Reply #13 on: July 20, 2014, 08:15:03 pm »
Python - Easy to learn
PhP - Web dev. , fits with HTML
C - Hard GUI but very powerful (I use Code::Blocks or TurboC)

Sorry for post-hunting -1 (to myself) , will improve
« Last Edit: July 20, 2014, 08:15:35 pm by Phenom »
Cookies are cookies, cookies dissapear, they come , they give and they take.
Honour cookies, respect cookies.
Dont complain about cookies, cookies dont like that, cookies will punish you.
Cookies are life , Cookies are love, Cookies define the very fiber of space.
Roses are red, violets are blue welcome to evilzone , may the cookies be with you

News Website made by me :
<a style="color:red" href="http://www.thenexusweb.com">The Nexus Web</a>

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Language advice for project
« Reply #14 on: July 20, 2014, 09:32:07 pm »
First, Easy to learn is not an argument, not a valid one anyway.
Second, people writing PhP makes Factionwars cry.
Third, C has no GUI, it has GUI FRAMEWORKS, so hardness to learn one solely depends on the framework you choose to use (and your brain capacity). Code::Blocks as well as TurboC are IDE's.

Just sayin'...
« Last Edit: July 20, 2014, 09:32:47 pm by Kulverstukas »