• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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!

Kura

twitter.com/puccarts
10,994
Posts
19
Years
I don't know ANY programming.. though I am thinking of eventually trying to pick up some python as it would be helpful for me eventually with 3D software that I work with. I've never done any before so I don't know how hard it would be.. but I want to give it a shot sometime, anyways :3
 

Brizz

TM87
55
Posts
11
Years
I'm taking an intro to programming course this semester and we're working with C++. Computers aren't really my thing but it was recommended by my counselor that I take this course.

I'm not 100% on some of the stuff that we're learning but I've definitely got some kind of idea as to what I'm doing.

The labs/projects that we're doing are pretty time consuming (at least for me) and take me a solid 4-5 hours of frustration. On the bright side I've done all of my labs and projects almost 100% correct so all of that hard work pays off.
 

twocows

The not-so-black cat of ill omen
4,307
Posts
15
Years
I'm taking an intro to programming course this semester and we're working with C++.
GET OUT WHILE YOU STILL CAN

No, but seriously, any intro to programming course that's taught in C++ is a bad intro to programming course. You've got a few decent options for teaching programming to beginners and that is not one of them. C#, Python, Java, or maybe even C are acceptable choices. Scheme is also a solid choice. C++ is not a beginner's language. Heck, it's not an expert's language, either.

Again, I'll point any newcomers to programming toward one of the best books available: http://mitpress.mit.edu/sicp/full-text/book/book.html
 
58
Posts
13
Years
  • Seen Jan 3, 2015
I know C/C++ from my high school days then took introductory and advanced courses in college. I know a bit of Java, Python, Pascal, and -- call me obsolete -- Fortran. I started with BASIC like most programmers and found it relatively easy and limited, but it wasn't until my last year of high school that I learned about C. I tried learning alone but I wasn't as productive as when I entered college. I also learned a bit of Assembly through C++.
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
Scheme is also a solid choice.

My ears perked upon the mention of Scheme. That and Clojure are awesome in all of their Lispy awesome... I never knew you knew a LISP language..! And if you haven't seen it yet, this may interest you twocows: http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/

I gave it a try recently, and while it is kind of annoying that it requires Leiningen for Clojure, I thought the thing was pretty cool. I have not tried its Python mode yet because I don't know Python.


GET OUT WHILE YOU STILL CAN

No, but seriously, any intro to programming course that's taught in C++ is a bad intro to programming course. You've got a few decent options for teaching programming to beginners and that is not one of them. C#, Python, Java, or maybe even C are acceptable choices.

I would argue against this actually. While C++ has some oddities, it will be able to teach people about pointers as well as a more object-oriented approach than most languages that utilize memory in the same way as it. I agree that C is probably a better language to start out with, but C++ isn't that bad a language to start out with. It is also a very important language, so knowing it is definitely an asset, especially if you start writing larger programs. (It becomes easier to manage than C.)
 

twocows

The not-so-black cat of ill omen
4,307
Posts
15
Years
My ears perked upon the mention of Scheme. That and Clojure are awesome in all of their Lispy awesome... I never knew you knew a LISP language..! And if you haven't seen it yet, this may interest you twocows: http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/

I gave it a try recently, and while it is kind of annoying that it requires Leiningen for Clojure, I thought the thing was pretty cool. I have not tried its Python mode yet because I don't know Python.
Looks neat, I'll look into it.


I would argue against this actually. While C++ has some oddities, it will be able to teach people about pointers as well as a more object-oriented approach than most languages that utilize memory in the same way as it. I agree that C is probably a better language to start out with, but C++ isn't that bad a language to start out with. It is also a very important language, so knowing it is definitely an asset, especially if you start writing larger programs. (It becomes easier to manage than C.)
The worst problem with saying you know C++ is that you might someday be expected to write C++ code, and I could think of no worse fate.

No, but seriously, I just think pretty much anything's a better option. Pointers are often tough for beginners, but I think as long as you make it clear what's going on in memory while you're teaching and make sure they're aware of the concept, students won't have too many problems once they encounter them in a language that has them.
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
The worst problem with saying you know C++ is that you might someday be expected to write C++ code, and I could think of no worse fate.

No, but seriously, I just think pretty much anything's a better option. Pointers are often tough for beginners, but I think as long as you make it clear what's going on in memory while you're teaching and make sure they're aware of the concept, students won't have too many problems once they encounter them in a language that has them.

I may regret asking this, but why do you hate C++ so much anyway? I'm curious.

I see a lower level language that has a psuedo object-oriented paradigm, meaning it's easier to organize code in larger projects. I see improved APIs over C for things like String handling, and I see a language that you can write C code in and have it work if you rather.

It has quite a few more capabilities than C.

Granted, I personally rather C myself... But this is because it is a really small language and I can get my code to compile everywhere. I never really thought of C++ as an inferior language to it, much less as the monstrosity your posts make it out to be...

So, mind filling me in here?
 

Satoshi Ookami

Memento Mori
14,254
Posts
15
Years
Because I'm studiying IT it's pretty obvious I'm coding like crazy =D
I can code in C, C++, Java, a bit of Delphi, Javascript, HTML, CSS and especially C#.
By far, my favorite is C#, the other programming (no markup) languages were just needed to advance and I don't like them...
C# has always been my favorite =)
 

twocows

The not-so-black cat of ill omen
4,307
Posts
15
Years
I may regret asking this, but why do you hate C++ so much anyway? I'm curious.

I see a lower level language that has a psuedo object-oriented paradigm, meaning it's easier to organize code in larger projects. I see improved APIs over C for things like String handling, and I see a language that you can write C code in and have it work if you rather.

It has quite a few more capabilities than C.

Granted, I personally rather C myself... But this is because it is a really small language and I can get my code to compile everywhere. I never really thought of C++ as an inferior language to it, much less as the monstrosity your posts make it out to be...

So, mind filling me in here?
I get this question sometimes, and I always direct the people who ask it here. I could write an explanation myself, but there's nothing I could say that Yossi Kreinin hasn't said in more detail.

One of my biggest personal pet peeves is this. Operator overloading is far too easy to abuse and the benefits are negligible. That's not to downplay any of the other major problems with C++, but this one takes the cake for me.

Operator overloading's one of those things that sounds useful but really isn't. There are a lot of these type of things in C++ because it's a poorly thought out language. I can almost picture how C++ was made: Bjarne makes a public query "what's missing in C?" He gets about a billion responses. However, instead of filtering out the garbage and taking into careful consideration what C desperately needs and what's just nonsense that doesn't need to be there, he implements all ten thousand feature requests without looking at them twice. I'm sure it didn't quite happen that way, but that's kind of how it seems to me. There's too much garbage in C++; yes C lacked some very important functionality, but C++ is not the correct solution to that problem.

There are very few useful improvements in C++ over C, though unfortunately the ones that are there are pretty major. However, a good portion of those improvements are provided in glib, which I use most of the time if I'm doing C programming. I'm also looking into GObject at the moment, which seems useful.
 
Last edited:

Satoshi Ookami

Memento Mori
14,254
Posts
15
Years
Ever since learning C#, I've stuck with it because I can actually understand what I'm looking at. I started with VB.NET, but since learning C# and how flexible it is, I began to see how much VB.NET sucked in comparison to C#.
Visual Basic is one of the languages I'm interested to learn...
Of course, the first one on the list is F# :D
If I don't learn F#, I won't feel complete as programmer .D
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
Cool... Visual Basic is fantastic for hammering out really fast graphical programs... And Intellisense can really help you out with it's completions since the language is really simple.

One of my biggest personal pet peeves is this. Operator overloading is far too easy to abuse and the benefits are negligible. That's not to downplay any of the other major problems with C++, but this one takes the cake for me.

Operator overloading's one of those things that sounds useful but really isn't

The thing about that style of operator overloading is that C++ isn't the only language that has it, it's in other C-like languages as well. Java has "string" + "string" concatenation overloading for example, and the other overloads I saw mentioned are in C to begin with. (Like var++, or *pointer)

DISCLAIMER: The following is merely my opinion... One we obviously don't share.

The way I see it, provided you have good type handling or management, you can use overloaded operators in ways that are quite understandable and not horrible. It's all in how you present your code. For example, I can write C code that is non-obvious in it's operator usage too, consider the following:
Code:
int i = 10;
while(i --> 0) // While i goes to zero
  printf("%d\n", i);

Know why this works? (Try to figure it out before clicking the spoiler.)
Spoiler:

Another example:
Code:
result = value**count;
That is multiplying "value" to the value that a pointer called "count" is pointing to. And not dereferencing a pointer to a pointer. Sure you probably knew that, but it is more readable to do the following:
Code:
result = value * *count;

The same applies for overloaded operators. For example, in JavaScript, if you saw the following code:
Code:
string = "That " + name + " person is a cool guy";
You could very easily determine that that was string concatenation in the same way where if you saw this:
Code:
total = numGuests + numStaff;
You could reasonably assume that it is arithmetic.

Anything can be horrible if used horribly, but if you use the features you have available to your advantage, you can write good code in mostly anything with structure. You just need to write your code in a way that is intuitive.

In the end, the things that are horrible to you end up coming down to your own preferences. I can respect that though.
 
Last edited:

twocows

The not-so-black cat of ill omen
4,307
Posts
15
Years
Cool... Visual Basic is fantastic for hammering out really fast graphical programs... And Intellisense can really help you out with it's completions since the language is really simple.



The thing about that style of operator overloading is that C++ isn't the only language that has it, it's in other C-like languages as well. Java has "string" + "string" concatenation overloading for example, and the other overloads I saw mentioned are in C to begin with. (Like var++, or *pointer)

DISCLAIMER: The following is merely my opinion... One we obviously don't share.

The way I see it, provided you have good type handling or management, you can use overloaded operators in ways that are quite understandable and not horrible. It's all in how you present your code. For example, I can write C code that is non-obvious in it's operator usage too, consider the following:
Code:
int i = 10;
while(i --> 0) // While i goes to zero
  printf("%d\n", i);
Know why this works? (Try to figure it out before clicking the spoiler.)
Spoiler:

Another example:
Code:
result = value**count;
That is multiplying "value" to the value that a pointer called "count" is pointing to. And not dereferencing a pointer to a pointer. Sure you probably knew that, but it is more readable to do the following:
Code:
result = value * *count;
The same applies for overloaded operators. For example, in JavaScript, if you saw the following code:
Code:
string = "That " + name + " person is a cool guy";
You could very easily determine that that was string concatenation in the same way where if you saw this:
Code:
total = numGuests + numStaff;
You could reasonably assume that it is arithmetic.

Anything can be horrible if used horribly, but if you use the features you have available to your advantage, you can write good code in mostly anything with structure. You just need to write your code in a way that is intuitive.

In the end, the things that are horrible to you end up coming down to your own preferences. I can respect that though.
Your examples seem more like misleading spacing than anything. The problem I have with operator overloading is that it introduces ambiguity with regards to a given operator. You have to look at the context to figure out what it does, and that's just stupid. What an operator does should be self-evident; it should mean the same thing in every context. Overloading string concatenation is fine I guess because it doesn't do this; you're still essentially "adding" two things, even if internally it's completely different. But a lot of times this isn't what happens; operators are overloaded to mean all sorts of stuff that isn't even remotely related. This is horrible. And letting the programmer do it at his leisure is even worse; at least in C you can guarantee that * is going to mean one of three things and not fifteen other things that the programmer might have defined somewhere.

Speaking of *, C is not immune from this criticism; I already hate that * is overloaded to mean three different things in C by default. * means "multiplication" in almost every mathematical or programming language in some context, so that's fine. However, it's also taken to mean "dereference" in another context. I don't like that; there should be a symbol for dereferencing unique from one already widely used. It's confusing. However, that's not even the worst part. The absolute worst part is that it's overloaded again to mean "reference (noun)." This is completely ridiculous. If you're going to overload an operator to mean "the following thing is a reference," DON'T MAKE IT THE OPPOSITE OF WHAT IT MEANS IN ANOTHER CONTEXT! Overload & if you're going to do that! & already means "reference (verb)," at least stay consistent! This is probably why so many newcomers to C are confused by pointers (it's certainly why I was thinking back): the syntax is utterly absurd. The worst part is, if operator overloading didn't exist, this problem wouldn't exist at all. You could identify at a glance what the purpose of an operator is.

For instance, let's assign a unique operator to each of those operations.
In ALL contexts:
* means multiplication
& means reference (verb)
# means dereference (verb)
@ means reference (noun)

Wow! That was so hard! These are all symbols already conveniently available and, based on a quick glance at this page, unused. Let's take a look at some arbitrary C code and see how this changes things.

Code:
int main()
{
    int a = 5;
    int b = 6;
    int c = a * b;
    int @cr;
    cr = &c;
    a = #cr;
}
That might seem kind of weird at first because you're used to different uses, but look at it closer. Everything makes sense at a glance; you don't have to look at what's surrounding the operator to figure out what it means. This makes code so much more readable. It's impossible to get confused by this unless you just don't understand the underlying concepts.

Again, though, I'm... all right with operator overloading when it's intuitive. If you wanted to change @ to an overloaded version of &, that's fine with me, since it's intuitive; & means "address" in my head, whether it's "address of" or "this is an address." Past that, though, it just gets messy. And it certainly shouldn't be in the hands of the programmer; it should be defined at the language level and not be changeable.
 
Last edited:

Satoshi Ookami

Memento Mori
14,254
Posts
15
Years
The thing about that style of operator overloading is that C++ isn't the only language that has it, it's in other C-like languages as well. Java has "string" + "string" concatenation overloading for example, and the other overloads I saw mentioned are in C to begin with. (Like var++, or *pointer)
Uh... don't make me remember overloading operators... that was probably the biggest crap C++ had :D
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
Your examples seem more like misleading spacing than anything. The problem I have with operator overloading is that it introduces ambiguity with regards to a given operator. You have to look at the context to figure out what it does, and that's just stupid. What an operator does should be self-evident; it should mean the same thing in every context. Overloading string concatenation is fine I guess because it doesn't do this; you're still essentially "adding" two things, even if internally it's completely different. But a lot of times this isn't what happens; operators are overloaded to mean all sorts of stuff that isn't even remotely related. This is horrible. And letting the programmer do it at his leisure is even worse; at least in C you can guarantee that * is going to mean one of three things and not fifteen other things that the programmer might have defined somewhere.

Misleading spacing was indeed part of it. My point was that you can write code in obvious, and non-obvious ways. The same is true for code that utilizes overloaded operators.

Your code should be consistent and readable. Establish a way you use overloaded operators so that you don't really need context when looking at a given function; Make things obvious.

I won't quote your entire post, but you described your thoughts quite well and had some good points (Even if you were a bit condescending.). While I still don't share your opinion, I understand it better... So have a like.
 
Last edited:

twocows

The not-so-black cat of ill omen
4,307
Posts
15
Years
Misleading spacing was indeed part of it. My point was that you can write code in obvious, and non-obvious ways. The same is true for code that utilizes overloaded operators.

Your code should be consistent and readable. Establish a way you use overloaded operators so that you don't really need context when looking at a given function; Make things obvious.

I won't quote your entire post, but you described your thoughts quite well and had some good points (Even if you were a bit condescending.). While I still don't share your opinion, I understand it better... So have a like.
I was frustrated at C and C++, not you. I can see how you might have misinterpreted.

Again, though, my biggest problem with operator overloading is that they can be easily abused by newcomers without realizing it, and abused in such a way that makes it really, really hard for people who have to maintain the code later. This is a problem that only exists if you let the programmer do it. It's a lot nicer in C, where the only operator overloading occurs in the specification; the programmer can't do it. Having poorly thought-out stuff at the language level is a problem, but it's nowhere near as big of a problem as letting tens of thousands of bad programmers go nuts with a dangerous feature. At least once you're experienced with C, you'll know what's what; with C++, every new source file is potentially a new list of operators you need to memorize.

And again, yes it's possible to use it in an acceptable way. The problem isn't that there is a right and wrong way to use the feature, the problem is that abusing it causes far more problems than abusing other typical language features. For instance, take #define macros. Yes, these can be abused and in a very ugly way, but at least the relationship is still 1-to-1; you can guarantee that unhelpfulmacroname is going to expand to the same thing every time. With operator overloading, that's not the case; you can come across an operator and, unless you've memorized the author's arbitrary list of "things I overloaded," have no idea if it's going to mean this, that, or some other thing.

Basically, the biggest problem with operator overloading is that it makes a language context-sensitive. This is usually bad. Unless there's some compelling reason why it shouldn't be, everything within a language should be understandable without examining the context. And opening it up for the programmer to do that means that not only is the language context-sensitive, but each individual source file might have its own unique context-sensitive stuff, which is just outright horrifying.
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
Aye. No worries.

Also, I suppose that is where we differ. As an abstractions guy who likes the functional paradigm, I like context-sensitive code. While I'll admit it can be terrifying in the hands of an inexperienced programmer, if you utilize it well, you can make some stupid-powerful abstractions.

For example, I implemented an entire AJAX REST API using a single larger context-sensitive function, and a bunch of smaller functions calling it in various ways in JavaScript. I just committed it into a Github repo so you can see what I am talking about. (Hopefully this code wont give you an aneurysm, since it is by no stretch of the imagination in your style.)

(This abstraction is incomplete currently, and yes I am using jQuery as a crutch currently.)
This is the large dynamic function...

This is where all of the public smaller functions are...

Every one of those functions can be called with a callback function to call with data after the function is complete, they all provide the correct type of requests to add, edit, remove, update, and view things from the database. (With some further abstraction to combine functions to just store JavaScript objects in general if you are unsure of its status.) You can set a number of flags that modify how the function works by passing different data types, including how the function responds. You can do everything from:

Code:
users.store({"name":"Archenoth"}, function(data){
  alert(data);
});
...to add a user and echo out what it looks like in the database to:
Code:
users.store({"name":"Archenoth"}, 1);
...to update the user with the first ID with an awesome name to:
Code:
users.store(user)
...to add the user if it doesn't already exist but to update it if it does.

It all depends how you call it and that's not even scratching the surface of what it can do.

As you can see, you can squeeze out a lot of functionality by overloading things and by making context-sensitive code. The fact that I don't have to write a lot of code to get crazy amounts of functionality is something that I love.

The fact that I write like this makes me not care much about overloaded operators in languages, because I deal with similar risks all the time.

The thing about Python is that it is a very solid language. (From what I understand anyway, please correct me if I'm wrong.) There is usually one right way to do things, which makes the code into something that is relatively easy to read regardless of the author. Then there are languages like Perl (Yes, the code above is JavaScript, but it is written with Perl-like argument parsing for the request function.) that utilize the whole TIMTOWTDI ideology, which means I have the ability to make some really cool things, but also really really horrible code if I misuse it.
 
Last edited:

Serene Grace

Pokémon Trainer
3,428
Posts
14
Years
The first full programming language I've learnt is C# and I was wondering where to go from here. I'm interested in learning an unmanaged language such as C++ or C but I've not decided which one to opt for so if any of you have any preferences, please let me know (and also specific reasons as to why you prefer one over the other).

Also, I'm very interested in learning either Python or Java - but not at the same time. Which one do you guys think is more fun, or at least more relevant to the current programming ideal-isms (I couldn't think of a suitable way to phrase this - basically I was trying to say which is more "current")? So that I can learn that one first.
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
I'd say go C first... The things you pick up when learning C can be translated to C++ relatively easily. Also C is a really small language. It will make you work with pointers, with memory allocation, and quite a few low-level functions. It is also really portable if you avoid using system calls.

As for between Java and Python...

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

I recommend Java because Java is a lot more popular, and a lot more ubiquitous... (Your C# knowledge would come in handy when learning it too.) It has a lot more real-world usage currently (I mean job-wise.) so knowing it would be an asset if you were to become a professional developer. But you could choose Python too if you want, but I can't really speak for Python since I don't know it.
 

twocows

The not-so-black cat of ill omen
4,307
Posts
15
Years
Aye. No worries.

Also, I suppose that is where we differ. As an abstractions guy who likes the functional paradigm, I like context-sensitive code. While I'll admit it can be terrifying in the hands of an inexperienced programmer, if you utilize it well, you can make some stupid-powerful abstractions.

For example, I implemented an entire AJAX REST API using a single larger context-sensitive function, and a bunch of smaller functions calling it in various ways in JavaScript. I just committed it into a Github repo so you can see what I am talking about. (Hopefully this code wont give you an aneurysm, since it is by no stretch of the imagination in your style.)

(This abstraction is incomplete currently, and yes I am using jQuery as a crutch currently.)
This is the large dynamic function...

This is where all of the public smaller functions are...

Every one of those functions can be called with a callback function to call with data after the function is complete, they all provide the correct type of requests to add, edit, remove, update, and view things from the database. (With some further abstraction to combine functions to just store JavaScript objects in general if you are unsure of its status.) You can set a number of flags that modify how the function works by passing different data types, including how the function responds. You can do everything from:

Code:
users.store({"name":"Archenoth"}, function(data){
  alert(data);
});
...to add a user and echo out what it looks like in the database to:
Code:
users.store({"name":"Archenoth"}, 1);
...to update the user with the first ID with an awesome name to:
Code:
users.store(user)
...to add the user if it doesn't already exist but to update it if it does.

It all depends how you call it and that's not even scratching the surface of what it can do.

As you can see, you can squeeze out a lot of functionality by overloading things and by making context-sensitive code. The fact that I don't have to write a lot of code to get crazy amounts of functionality is something that I love.

The fact that I write like this makes me not care much about overloaded operators in languages, because I deal with similar risks all the time.

The thing about Python is that it is a very solid language. (From what I understand anyway, please correct me if I'm wrong.) There is usually one right way to do things, which makes the code into something that is relatively easy to read regardless of the author. Then there are languages like Perl (Yes, the code above is JavaScript, but it is written with Perl-like argument parsing for the request function.) that utilize the whole TIMTOWTDI ideology, which means I have the ability to make some really cool things, but also really really horrible code if I misuse it.
As long as your code's maintainable. If I have to go through a bunch of hoops to understand what you're doing, that's not good.

I'd say go C first... The things you pick up when learning C can be translated to C++ relatively easily. Also C is a really small language. It will make you work with pointers, with memory allocation, and quite a few low-level functions. It is also really portable if you avoid using system calls.

As for between Java and Python...

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

I recommend Java because Java is a lot more popular, and a lot more ubiquitous... (Your C# knowledge would come in handy when learning it too.) It has a lot more real-world usage currently (I mean job-wise.) so knowing it would be an asset if you were to become a professional developer. But you could choose Python too if you want, but I can't really speak for Python since I don't know it.
Java's a dying language. Python's more popular now. The only real remaining uses for Java are Android and companies already stuck with Java.
 

Archenoth

The arch foe
467
Posts
12
Years
  • Seen Nov 6, 2020
As long as your code's maintainable. If I have to go through a bunch of hoops to understand what you're doing, that's not good.
That's the idea. Reasonably easy to read, and bugs will only show up in obvious places. :)

Java's a dying language. Python's more popular now. The only real remaining uses for Java are Android and companies already stuck with Java.

You saw the link in my post, right? It's still the most popular language it seems according to it.
 
Back
Top