• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Programming!

1,235
Posts
10
Years
    • Seen Jun 17, 2017
    Programming languages are just that - languages. What seems illegible to someone would be perfectly understandable to another person.

    For example, take the following simple C++ piece:
    Spoiler:
    This is a simple command-line program that asks the user to input a fruit, and if their answer is either apple, orange, pear, grape or mango, the program will say such. If it is not any of those, the program will say "Unknown.".

    While this might be simple, it could be difficult to make sense of for someone who does not know anything about programming, or even someone who does but does not understand this particular language (C++).

    And that's one of the things I love about programming - what seemed like jibberish before all of a sudden makes sense when you learn it. And you can do so much.

    ---------

    Anyway, what do you think of programming? Are you a programmer? What do you like about the language(s) you know? What do you not like?

    And why does C++ not have switch statements for strings? I'm forced to use if-else chains to compare strings, unless I don't know the solution (I might not - I still only know the basics, haha).
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    That's great! I always find it awesome when experimentation with modification works.

    I'm not too experienced with C++ yet, but I want to learn more. So far I can competently use variables, functions, header files, strings (mostly), and cin/cout.

    C++ is based around "object-oriented programming", which is probably the next thing I need to get a grasp on. I don't fully understand classes properly yet.
     
    26
    Posts
    14
    Years
  • Programming is just an arrangement of logic in algorithms, so a competent programmer/computer scientist should be able to decipher code in most programming languages, especially since so many of them use C-based syntax (sounds odd, but there are computer scientists that don't program, instead focusing purely on solving programming related problems like p = np).

    Generally in OOP, classes are like blueprints. You create Objects from classes. So a class 'Car', had the basic code that pertains to cars, with attributes left up the Object, so you could create a variable that points to an instance of Car, named 'Junker', which might have a color of 'grey' and a gas supply of '10'.

    ---

    The reason why C++ doesn't support Switch Statements for strings due to two connected reasons:
    1.) C/C++ doesn't have Strings as a type. A string is just an array of characters in C/C++.
    1a.) Strings are not part of C/C++. Strings are include in the C++ standard library (the std namespace that you imported).
    2.) Code for Switch Statements is generated by the compiler, and because of reason 1, the compiler doesn't know how to check that two strings are equal.
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    Generally in OOP, classes are like blueprints. You create Objects from classes. So a class 'Car', had the basic code that pertains to cars, with attributes left up the Object, so you could create a variable that points to an instance of Car, named 'Junker', which might have a color of 'grey' and a gas supply of '10'.
    Thank you, that's helpful to me in understanding it. I've only read a bit about them so far, but that perspective sort of answers a few things I didn't get.
    The reason why C++ doesn't support Switch Statements for strings due to two connected reasons:
    1.) C/C++ doesn't have Strings as a type. A string is just an array of characters in C/C++.
    1a.) Strings are not part of C/C++. Strings are include in the C++ standard library (the std namespace that you imported).
    2.) Code for Switch Statements is generated by the compiler, and because of reason 1, the compiler doesn't know how to check that two strings are equal.
    Thank you again. Does it mean you generally have to use if-else chains to compare strings?
     
    27,749
    Posts
    14
    Years
  • I only know how to code stuff in PHP, but even that's very rusty for me at the moment. I would love to code in other languages, but I don't have the patience to self-teach myself at the moment :P

    I will say though that I am a computer programming student for the time being, so I'll start classes on those soon enough once these pre-reqs are wiped out.
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    Thought I'd add onto this, but since you're working with objects, you can always make a string class and/or extend it to work with a switch statement.
    That's quite right - I will use this if I get the chance.

    I've done more reading on classes and structs now, and I've got a much clearer understanding of what they are. The first time I read about them I didn't fully get it, but now I've gone back and read more context it makes sense. Just like objects IRL have different properties, that's what classes are - they are objects, and they can have booleans, values, and strings as part of them. It seems like the existence of OOP is very useful, and I now get that.

    I'm still a C++ nub though, haha

    I only know how to code stuff in PHP, but even that's very rusty for me at the moment. I would love to code in other languages, but I don't have the patience to self-teach myself at the moment :P

    I will say though that I am a computer programming student for the time being, so I'll start classes on those soon enough once these pre-reqs are wiped out.
    Sounds like a good plan! Best of luck to you!
     

    Urugamosu

    Happy, and Searching.
    588
    Posts
    15
    Years
  • I've taken up programming as a "hobby" of some sorts this year. I've so far gotten the hang of CSS, HTML, and Python. I'm planning to move onto java and C++ at some point. The fact that you can create basically anything by running code make me so happy. But with that C++ piece up there, I seem to understand it even though I don't get the language used. Funny right?
     
    23,331
    Posts
    11
    Years
    • She/Her, It/Its
    • Seen today
    While I do like programming, one of my main problems I always run into is finding a problem that I actually want to solve programmatically. I normally use Python for little programs although C# and Java are an option for me as well. At some point I even attempted to do something with Haskell, but Functional Programming is a whole different league to play in.

    Maybe sometime later I'll go back to it, though.
     

    Crunch Punch

    fire > ice
    1,374
    Posts
    11
    Years
  • I've applied to do computer science in university next year, so I should probably get some experience under my belt before that happens :d

    I know a tiny bit of Java but that's about it.
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    I've taken up programming as a "hobby" of some sorts this year. I've so far gotten the hang of CSS, HTML, and Python. I'm planning to move onto java and C++ at some point. The fact that you can create basically anything by running code make me so happy. But with that C++ piece up there, I seem to understand it even though I don't get the language used. Funny right?
    I agree, that's what I really enjoy about it too.

    And yeah, the piece is fairly simple, and C syntax usually isn't too hard to read. But to someone who doesn't understand anything about programming, or with a more complicated example, it might not make as much sense to read. But like Cocoa said, it's an arrangement of logic algorithms, so in the end it's just knowing what the keywords mean.

    While I do like programming, one of my main problems I always run into is finding a problem that I actually want to solve programmatically. I normally use Python for little programs although C# and Java are an option for me as well. At some point I even attempted to do something with Haskell, but Functional Programming is a whole different league to play in.

    Maybe sometime later I'll go back to it, though.
    I don't know what to program either, and I'd like to because it helps a lot to learn how to do things with the language when you can have a goal for a program, and have to use what you know (and find out what you don't) to achieve it.
     

    Leviathan

    [span="font-family:ubuntu; color: whitesmoke; padd
    1,103
    Posts
    10
    Years
  • Wait until you get onto making GUIs. Then the fun with forms begins. Although I'm still partial to looking at command line programs. </3 OO programming is handy to do, once you've grasped how to use it. Then, once you learn to implement inheritance in a class hierarchy, you'll be able to cut down on a fair bit of code, passing variables between classes.

    Programming is fun but I hate when it comes to compiling your thing, and the compiler then complains about an error, and in the IDE I use it's usually never on the line specified. Link errors are almost always my problem, but trying to find that one line in a program that consists of several hundred lines scattered across several header files and source files is a pain.

    Tried a few programming languages, but I like C# the most. C++ is useful, yes, but rather meticulous to me. In your case, I'd recommend you'd get yourself a C++ book. There's plenty to be found freely available online with a bit of googling. I even found a .pdf of one the books I paid €60 for, which the publishers themselves had released for free. ugh! How annoying is that?!
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    Wait until you get onto making GUIs. Then the fun with forms begins. Although I'm still partial to looking at command line programs. </3 OO programming is handy to do, once you've grasped how to use it. Then, once you learn to implement inheritance in a class hierarchy, you'll be able to cut down on a fair bit of code, passing variables between classes.

    Programming is fun but I hate when it comes to compiling your thing, and the compiler then complains about an error, and in the IDE I use it's usually never on the line specified. Link errors are almost always my problem, but trying to find that one line in a program that consists of several hundred lines scattered across several header files and source files is a pain.

    Tried a few programming languages, but I like C# the most. C++ is useful, yes, but rather meticulous to me. In your case, I'd recommend you'd get yourself a C++ book. There's plenty to be found freely available online with a bit of googling. I even found a .pdf of one the books I paid €60 for, which the publishers themselves had released for free. ugh! How annoying is that?!
    I tried creating a new Win GUI project just to see the base code behind it...immediately ran away because I had no idea what it was and it looked nothing like command line code. I will get up to GUIs, but I need to do the basics first, haha.

    Speaking of classes, what is the point of privacy options for class members? I can't really understand why you want to deny outside access to them. If you don't want something outside of the class to change them, simply don't code them to change it.

    At least it's usually pretty easy to track down what the compiler's talking about. But in hundreds of lines of code, with multiple vague errors...that's the not-so-fun part...

    Thanks for the suggestion! Any extra knowledge helps, so I'll do that. And yeah, that sucks ;)
    I'm actually proud of myself that I understood that code. <3

    I'm a computer science student, currently studying C++ and moving on to Java this June. I love making codes, even by brute force. It oddly helps me improve, haha. Programming is fun. ^^ Codechef, however, is not fun. I can't understand a single problem and that saddens me so.
    Do you know any Java yet? Is it similar to C++?

    Also I just had a look at Codechef. I haven't really had any programming problems that I need help with yet, so I've never asked anything on a site before...but I'll probably need to in the future... ^^
     
    2,709
    Posts
    18
    Years
    • Seen Feb 16, 2020
    Speaking of classes, what is the point of privacy options for class members? I can't really understand why you want to deny outside access to them. If you don't want something outside of the class to change them, simply don't code them to change it.

    This is an important part of programming once you start making things like frameworks and code for other people to use. :)

    With some programming languages, you can't write a class member and also make it read-only. Therefore, you typically make the member private (so that other people can't directly access it and change it), and instead make a public function within the class that returns that value, but doesn't allow people to change it (since it accepts no parameters).

    Imagine I have a Player class, and it has a Position member, which lets me know the Player's x- and y-coordinates. I don't want people outside my code to change the position, though; only read it.

    The example above isn't the best, but I think it gets the point across. Plus, there's a more general concern of wanting to hide individual variables of your program from other people – the more you hide, the simpler your code becomes from an outside perspective, and it also vastly reduces the likelihood of other people doing things you don't want with your objects and messing things up in the big picture ("hmm... I wonder what this variable does if I change it...").

    This is generally referred to as "Information hiding" within the topic of Encapsulation.
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    In Visual Studio, making a Winforms (GUI) project is absurdly simple. You just drag on your controls, set their properties, then just use the form's code to manipulate and do whatever with your controls. You don't have a massive list of properties you need to manually code out - VS does that all for you.
    I'm not actually using Visual Studio - any version will get halway through install and then give an error (without a code, IIRC). The machine I code on isn't the best, it's got several problems (including software ones).

    I use Code::Blocks. It works fine for me. I don't know if C::B has such a feature, all I remember seeing when I made then new project was the code for it, and it wasn't anything I could understand at the time (I probably still don't, I haven't learned GUIs as I said). I could compile and run it, but I didn't understand any of the code.

    I've read about encapsulation and getters and setters. I'm sure I'll use it more once I've got experience with using classes properly in general - but I really want to actually have a goal program to make. I can't put knowledge to use if I don't have anything to make with it, haha.
     

    twocows

    The not-so-black cat of ill omen
    4,307
    Posts
    15
    Years
  • I like the idea of D more than I like the idea of C++, but C++ usage is way more widespread.

    Rust also seems pretty neat. When I do work, I tend to use C but I'm thinking of learning Rust and using that instead.
     
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    I like the idea of D more than I like the idea of C++, but C++ usage is way more widespread.

    Rust also seems pretty neat. When I do work, I tend to use C but I'm thinking of learning Rust and using that instead.
    How different are D and C(++)? And I just looked up Rust, but I can't think of anything to say about it, haha.
    Sooo, who codes in Fortran? ¬_¬

    *hears crickets*
    I also just looked up Fortran. Same as above, haha.


    But anyway I want to do more programming but I've got no idea what to make. It's such a difficult thing to get past ~_~
     
    26
    Posts
    14
    Years
  • I only know how to code stuff in PHP, but even that's very rusty for me at the moment. I would love to code in other languages, but I don't have the patience to self-teach myself at the moment :P

    I will say though that I am a computer programming student for the time being, so I'll start classes on those soon enough once these pre-reqs are wiped out.

    I highly recommend Codeacademy in this instance. I've played with it myself, and while what they teach is fairly basic, it can contribute to building a fairly decent foundation. They have tracks in Ruby, Ruby on Rails, Python, PHP, as well as JavaScript and JQuery.

    @Greenflame: Rust is a really nice language, and is one that you might want to look into, along with Go/Golang, if you expect to be doing a lot of systems programming. If you're looking to make user side programs, you're far better off learning a .NET language like C# (especially considering that .NET Core is now open source and fairly crossplatform-ish, with other components of the new .NET coming along in the future). You also have Xamarin, which will let you use C# to build mobile apps for Android and iOS.

    A good thing to try out when you're learning a new language or trialing a new language is to write a small utility app, like a To-do List. Another thing that you can do is write a Markdown Compiler/Parser, especially since Markdown is a pretty messy spec at times, and you're probably going to be using a lot of features from the language and its standard library (if it has one) for it.

    @Tsutarja: My Computer Organization (Digital Logic Circuits, MIPS Assembly) professor codes in Fortran, although that's going to be a little more common if you work for NASA or the US Military.

    Java is definitely like C, although it abstracts you further from the computer, so it's a lot easier to use. There are also more protections against screwing up, so there are things here and there that would be possible in C/C++, but not in Java (or any other higher level language). If you're having trouble figuring out how to do something in C/C++, try coding in Java, Ruby, JavaScript, or some other C-based language at a higher level. Remember: It's always better to solve problems at the highest level possible. That's why we code in Java, C++, or any scripting language, instead of writing Assembler code or generate our algorithms on logic circuits.|

    EDIT: If you're looking for friendly coding practice in Java or Python, give CodingBat a visit.
     
    Last edited:
    1,235
    Posts
    10
    Years
    • Seen Jun 17, 2017
    @Greenflame: Rust is a really nice language, and is one that you might want to look into, along with Go/Golang, if you expect to be doing a lot of systems programming. If you're looking to make user side programs, you're far better off learning a .NET language like C# (especially considering that .NET Core is now open source and fairly crossplatform-ish, with other components of the new .NET coming along in the future). You also have Xamarin, which will let you use C# to build mobile apps for Android and iOS.

    A good thing to try out when you're learning a new language or trialing a new language is to write a small utility app, like a To-do List. Another thing that you can do is write a Markdown Compiler/Parser, especially since Markdown is a pretty messy spec at times, and you're probably going to be using a lot of features from the language and its standard library (if it has one) for it.
    I might look into Rust, it depends on how well I can learn other languages (C++/C#) first :).

    I looked at C#, and since it's so very similar to C++, the general syntax is familiar to me. You can code for iOS/Android with C#? That's definitely a good reason for me to try it out. I'll get an IDE for it today and give it a shot :).


    And by the way, does your username have anything to do with the language of the same name?
     
    27,749
    Posts
    14
    Years
  • So is there anybody here who goes to college for programming? What languages does your institution teach/not teach? Just curious.
     
    Back
    Top