Export thread

Which programming language to learn?

#1

David

David

I'm having an itch to attempt to learn a new programming language. So far my only experience has been as a hobbyist with ActionScript, some webdesign (HTML, CSS, PHP), and a C++ class at my college that I didn't do so well in.

I'm working as an artist with a group making an indy game and we're using Unity as our engine. Unity equally allows for JavaScript, C#, or Boo (a Python-based language, apparently) as it's scripting language. I figure this is a good chance for me to get familiar with one of these well enough to insert my own art into the levels.

I'm leaning towards JavaScript because it would have a use in helping me regain my footing in web design if I ever need/want to. I know C# can be useful, but I'm not feeling excited about it as I would if it were Java because I'd rather learn something that isn't windows-specific.

What are your guys' thoughts on what might be a more useful language to start learning in the long term?


#2

Bowielee

Bowielee

I'm familiar with C, C++ and Java, I don't have any experience with C#, but from what I understand, it's like the bastard child of java and C.

I'd recommend Java, personally. I found that much easier to program with than I'm finding C++. I think Java would probably translate more easily to learning other object based programming, such as iOS development and such.


#3

PatrThom

PatrThom

Are you interested in learning in order to practice programming technique? Some languages lend themselves to the process of learning more than others, so it's important to decide whether you are choosing a language to learn that language, or to learn programming.

--Patrick


#4

David

David

Right now I think I'd have to say to learn programming. It would be nice to choose one of the three with immediate beneficial use, but we do have a dedicated programmer on board who could probably breeze through things it would take me hours to figure out if I just let him take care of it. It may be better for our start-up in the long run if I get programming in general down first.


#5

strawman

strawman

For your specificuoses, I'd go for JavaScript. It's universal, relatively easy, very well documented, and it will be more useful for you down the road than C# or python, although those are both valuable in their own way.

I'd vote for C# second. The will always be a job for those programmers that know C#. Python jobs are a little harder to find.

I suspect that C# is going to be a little more powerful and speedy though, so if you are planning on making more than just a simple game, you might want to take a second look at using C# for it.

You really can't be the cross platform capability of JavaScript, though, especially given how good the current JavaScript engines are these days.


#6

Bowielee

Bowielee

I just finished up a C++ exam and boy, do I miss the object library of Java. Inheretence in Java is sooooo much easier.


#7

David

David

I talked to the project leader about my interest in it and he said C# would probably be the most beneficial for our purposes. I've gone ahead and started reading a tutorial book for it and will see how well I can start grasping it.


#8

Covar

Covar

If you're going to be working with Unity and don't want to get platform specific I'd recommend Python.

JavaScript is insanely flexible and powerful, but also soul crushingly difficult and strict (not a contradiction, the language allows for some interesting things, but that also means it's easy to break the parser if you're not careful). JavaScript is also an incredibly useful language to learn, good to learn if you've got tough skin.

Python is an awesome scripting language, easily does some things that are big PITA and time wasters in other languages. Its string manipulation is amazing, and you'll never have to type a curly brace.

C# is a good language. Comparable to Java, your big advantage here is Microsoft Visual Studio and .NET.

Java is another good language. Cross-platform (largely, there's edge cases, but you'd most likely never hit them) and a solid Object Oriented language makes Java ideal for learning. Most people will cite performance issues with java applications due to the cost of running on the JVM (Java Virtual Machine), but the truth is that it has become negligible for most applications over the years due to performance improvements to Java and the fact that computers have gotten exponentially faster since the mid-90s. Unless you're writing a AAA quality game you shouldn't care. Minecraft is written in Java. Many large-scale enterprise applications are also Java.

C is the low level language. Direct access to memory makes it powerful and efficient. If you need performance you want to write in C or for Object Oriented programming, it's younger brother C++. Things that are easy in nearly every other languages need to be implemented manually (or with helper libraries) in C/C++. A great language to know, not one I would recommend now if you're just starting out.


#9

Bowielee

Bowielee

I may start looking into learning C# on my own after I'm finished with my C++ class. I'll state for the record that I HATE, HATE, HATE C++.

I know it's good for me to know it for understanding exactly how memory is managed, but jesus christ is it a pain in the ass.

I'll probably be getting a C in that class (heh) when I got an A in my Java class.


#10

HowDroll

HowDroll

I vote Javascript to start, if for no other reason than it has a C-like syntax, which would make the jump to Java or C# that much easier.

Also, you can use http://www.codecademy.com/ to learn it, which is FREEEEEEE!


#11

David

David

JavaScript said:
But we use === (three equal signs) to check if one variable's value is "equal"
THREE EQUAL SIGNS!?



#12

Bowielee

Bowielee

int main(){
bool worth_it=true;
int fucks_given = 0;
if (! worth_it){fucks_given = 0;}
else{fucks_given++;}
}


#13

David

David

Is it weird that I'm having an absolute blast with the codecademy website? I wish could have found a tutorial site like this for ActionScript when I was trying to get into flash game programming.


#14

HowDroll

HowDroll

Is it weird that I'm having an absolute blast with the codecademy website? I wish could have found a tutorial site like this for ActionScript when I was trying to get into flash game programming.
Codeacademy rocks. Some of the lessons are better than others, but it's been my favorite way to learn a language so far.


#15

bhamv3

bhamv3

I still have nightmares of learning to code in C. All... those... pointers...

Now that I think about it, my university course throwing us right into the deep end by having us start with C might have contributed to me flunking out.

/personal responsibility sucks anyway


#16

PatrThom

PatrThom

Programming is fun.
Until you get stuck on a bug or hit a limit of your chosen language.
Then it can be frustrating.

--Patrick


#17

Bowielee

Bowielee

I actually had fun doing java programming, but C/C++ is kind of kicking my ass right now.

Doesn't help that my professor is straight out of Russia and doesn't come close understanding student questions enough to explain answers to them. I swear that dude THINKS in binary.

Great mathematician, but not so great teacher.


#18

David

David

I had a similar problem with my c++ professor. She was a lady from China, spoke English pretty decently, but was bad at it just enough that exchanging a conversation with her took some effort and rethinking how to explain a problem I was having. She seemed like someone who mastered the language in a classroom, but had only very recently started having practical experience with native speakers in it.


#19

Bowielee

Bowielee

Bless his heart, you can tell that he's trying his best to understand what you're asking and wants to help you, but he's just not very good at it.

Sometimes I just think I should have taken a nice, easy communications or literature minor, but those classes don't challenge me. I came back to college specifically to be challenged. Let's just put it this way. I've been on the deans list for the last 2 years even with a semester of Cs and Ds from back when I was young and stupid and left college the first time. I've gotten all of 2 Bs so far. With that in mind, I'll be getting my first C since returning to school in his class. I could possibly pull it up to a B if I ace the final, but yeah... shit be hard.


#20

David

David

How I feel every time I finish a new codecademy lesson set:


#21

Bowielee

Bowielee

Wish me luck, I have a programming competition this weekend and my prof is giving us extra credit for every java program we successfully get to compile and run. If I play my cards right, I could change that C into a B.


#22

David

David

Sweet. Good luck!


#23

Bowielee

Bowielee

It's in Java, so I think I may actually be able to get a few programs running.


#24

David

David

Code:
//Beginning Game Programming, 2nd Edition
//Chapter 2
//HelloWorld program
#include <windows.h>
 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nShowCmd)
{
    MessageBox(NULL, "Motoko Kusanagi has hacked your system!", "Public Security Section 9", MB_OK | MB_ICONEXCLAMATION);
}
Any ideas why this gives me a fail error when I try to compile with Visual Studio C++ express 2010, but Dev-C++ compiles and creates a windows pop-up for me just fine? VS gives me this output:
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
1>c:\users\david\documents\visual studio 2010\Projects\HelloWorld\Debug\HelloWorld.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


#25

Covar

Covar

You're missing the required libraries in your VC++ project. You can add them in the project settings or right clicking the references in the solution explorer.


#26

Bowielee

Bowielee

Grades are in, got a B in my C++ class!


#27

Gared

Gared

Congrats! That's much better than the D I got in my C class.


#28

Covar

Covar

Grades are in, got a B in my C++ class!
You mean you scored a C+=2; ? congrats.


#29

David

David

I've finished through most of the codecademy javascript course and for practice and am trying to write a script to make a text adventure game. Still mostly pseudo code so far.

Code:
items {
description: "string to use after examining item"
locationData: "String for room to use to describe item"
canTake: true/false //determines if player can pick up the item
}
 
locations {
description: "string to use when entering location"
items: [array of items inside of location]
exits: [array of directions that lead to new locations]
}
 
player {
inventory: [array of items in player's inventory]
equiped: [array of items the player is wearing]
}
 
 
//The player should be able to input [VERB] [OBJECT] syntax for commands.
 
var commandLine = ""; //the player's input
 
var commandVerb = ""; //the player's action
 
var commandObject = ""; //object the action is on
 
var parseCommandLine(commandLine){ //splits the player's command into a verb and object
    this.verbStop = commandLine.indexOf(" ");
    commandVerb = commandLine.subString(0, this.verbStop);
    commandObject = commandLine.substring(this.verbstop + 1, commandLine.length);
    performAction(commandVerb, commandObject);
 
    this.getItem = function(commandObject){  //moves item to player's inventory
        player.inventory.push(commandObject);
        for (var i = 0; i < locations.items.length; i++){
            if (locations.items[i] === commandObject){
                locations.items.splice(i, 1);
                break;
            }
        }
    }
       
}
 
//Takes an action and calls for the appropriate response from the targeted object
var performAction = function(commandVerb, commandObject){
    switch(commandVerb) {
   
    case "examine":
    console.log(commandObject.description);
    break;
   
    case "take":
    if(commandObject.cantake === true){
        getItem(commandObject);
    } else { console.log("You cannot take the " + commandObject); };
    break;
 
    case "inventory":
    for(var i = 0; i < player.inventory.length; i++){
        console.log(player.inventory[i]);
    };
 
    default:
    console.log("I don't understand what you're saying.");
   
    }
 
 
}


#30

Necronic

Necronic

This is an old thread, but I thought I would throw something out there. Learn SQL. It's ridiculously easy to learn and it's invaluable for working with databases (which most programs do at one point or another.) It's not a proper language, but it's something you should be able to execute from C# or Java or whatever.

Also screw Java . Sun was terrible about updating their libraries.


#31

Bowielee

Bowielee

Also, would it kill java to put a search function in their API database?


#32

Covar

Covar

Considering it's just a big javadoc dump, probably.


#33

Eriol

Eriol

C is the low level language. Direct access to memory makes it powerful and efficient. If you need performance you want to write in C or for Object Oriented programming, it's younger brother C++. Things that are easy in nearly every other languages need to be implemented manually (or with helper libraries) in C/C++. A great language to know, not one I would recommend now if you're just starting out.
I'm in way late here, but if you consider C++ to be "C with Classes" (I'll admit that was literally the early name for the language) you are doing a MASSIVE disservice to C++ as it is today. Templates alone offer a staggering amount of flexibility, though as with most things in C/C++, they give you enough rope to hang yourself with, and then some (and hang your friends, and your neighbors, and your city, and...). But I always feel like the language trusts YOU to be "not an idiot" rather than giving you the scissors that can't cut butter, which is how I feel in the "coffee" languages. (I saw the "coffee" term when talking about any language on a runtime, such as on the JVM or the CLI, and thought it was great)

I'd say that 90%+ of why people like Java and C# is because of their respective standard libraries. They have stuff to do everything in there, and it's all in one nice documentation spot. Great. But what if you want to do something else? You're pretty much screwed, or you have to link back down to a C/C++ library again. But people haven't LOOKED at the C++ standard library in a long (long) time typically. See here, as that's the modern standard. It does a LOT more than it used to, and is extremely usable for virtually all tasks. Don't see what you need there? Then try boost, which covers nearly everything else and is open source in a good way (use it with anything, non-bitchy license terms). I guess I just wouldn't be afraid of using "helper libraries" because if you're doing "serious" programming you're going to have to do it eventually in the other languages too, and it'll be 10x more painful. But for the hobbyist, you don't need to in C++ anymore either.

Are there a few areas that both Java and C# do better? Sure there are, and I would never begrudge people from learning or using those languages, but don't shy away from C++ just because you think it'll be "harder" there. It probably won't be, and you'll be able to do things that you just can't in those other languages, and the list of things you can't do in C++ that you can do in C# or Java is extremely small (no, you CAN do closures in C++ now. Lambdas that capture variables are in C++11). If you think I'm wrong about that last claim, I really want you to challenge me on that one: name things you can't do in C++ (language, not library, though low-hanging fruit there is OK) that you can in Java/C#. And if you try memory management, I'll pwn you. ;)


#34

Necronic

Necronic

name things you can't do in C++ (language, not library, though low-hanging fruit there is OK) that you can in Java/C#. And if you try memory management, I'll pwn you. ;)
The internet


#35

Eriol

Eriol

The internet runs on C/C++ on the low level (routers, etc, aren't running javascript), and for web applications: NaCl from google

That being said, as I mentioned, I'm not saying that there's no places for scripts and such, and they can be extremely useful (there's a reason I know and use Python too), but there's many things you can't do in those that you can't in C++. There's much you can not do without native (C/C++) glue code in those other languages.


#36

Necronic

Necronic

Except that they can't do it quickly or easily.

High level languages are amazing for their ability to produce code that is easy to read/write and is intrinsically secure (to a point), and to do so very very fast. They show a human/deployment-side efficiency.

Low level languages are amazing for their ability to get down into the guts of what's going on. They require a LOT of expertise to properly write and take a ton of time and effort to do so. They show a hardware/execution-side efficiency.

Saying that C/C++ can do everything a high level language is like saying that my Hinkel knives are superior to a chainsaw. Sure, the chainsaw would mangle a steak, and technically the Hinkel knife could cut down a tree. But is that mean that the Hinkel can do all the same stuff the Chainsaw can?


#37

Eriol

Eriol

Low level languages are amazing for their ability to get down into the guts of what's going on. They require a LOT of expertise to properly write and take a ton of time and effort to do so. They show a hardware/execution-side efficiency.
And that's the fallacy I run into a lot, even at work. There's an old saying that "An engineer can write FORTRAN in any programming language." And that's what C++ used to be capable of too, and that was best practices even. But it isn't anymore. There's very little intrinsically in the coffee languages that you can't write "like" in C++. Want easier memory management? Declare all your variables with "new" and store them in a shared_ptr<> for everything. Boom, you have "garbage collection" of a sort. You'll never need to call delete again. Care about array out-of-bounds? Use the "at" method of the standard containers so that you catch array-out-of-bounds at runtime (ref here). And that's 90% of the argument for the coffee languages shot to hell right there. Those are the two most common programming mistakes out there for amateurs that the coffee languages will catch at runtime (well, kinda catch, in that they still throw exceptions. You're still just as screwed if you're doing it wrong in either type of language) but C++ wouldn't by default. Now it does if you use it correctly.

What I'm saying is that most of the "justification" for those languages either come from memory management arguments, which disregard the ability to DO these things already, or from "look how rich our standard library is!", which is really just an argument to use the right libraries, and standardize better, but the libraries are there already in C++. It's possible, but I challenge you to find a library that only exists in C# or Java for a reasonably standard task that doesn't exist for C/C++. The C# and Java languages are no "easier to use" than C++, and they don't have many (if any) significant language features that make things easier than C++ either anymore (they used to). You can write well and horribly in all 3 of them. But C++ has advantages the others don't, and the advantages that used to be there for C# and Java are mostly gone now.

Dynamic languages? That's a whole other ball game, and I'd say that they have a bright future, but the coffee languages are rapidly getting edged out at BOTH sides of the equation. They're too rigid to fill the dynamic language role (specifically the not-needing-to-compile part), but not fast and specific enough to be the full-bore systems languages either. I'd say that the CLR and the JVM will survive, but under different languages as their flagships. So you'll be running F# and IronPython/Ruby/etc on the CLR/.NET, and Scala on the JVM, but not C# and Java respectively (at least not as much as today).


#38

Necronic

Necronic

Good read, would read again.

So can you do dynamic and/or jagged arrays easily in C/C++?


#39

Covar

Covar

Oh god yes. Power of the pointer makes Arrays far more powerful in C/C++ than other languages. Remember arrays are just pointers to blocks of memory, with some behavior to access them.

Code:
char* array = malloc(sizeof(char) * 256); // 256 item array of chars, a.k.a. a string
 
char* array2d[256]; // array of pointers, gives you an array of arrays
char** another_array2d; // pointer to pointers is another way of having 2d arrays
The direct access to memory pointers give you is a crazy powerful tool. It's more to worry about, but you get more flexibility. Like an automatic vs a manual transmission.


#40

Necronic

Necronic

Pointers have pretty much always made me feel stupid.


#41

Eriol

Eriol

The way I'd do a jagged array is a vector of vectors, to the N-th deep level of how big I wanted it to be. See below:

Code:
#include <vector>
using namespace std;  // so I don't need to put "std::" in front of everything.  NEVER use this in header files, but it's usually OK in .cpp files
 
int main(int argc, char** argv)
{
    vector<int> fibon = {0, 1, 1, 2, 3, 5, 8};  // check your compiler to make sure it supports this syntax.  Most do these days
    for(auto x: fibon) // need C++11 for this one  GCC 4.7 or VS11 beta
    {
        cout << x << ", ";
    }
    cout << "done!" << endl;
 
    // Jagged now
    vector<vector<int> > jagged2D;
    vector<int> tmp = {0, 1, 2, 3, 4};
    jagged2D.emplace_back(move(tmp)); // C++11 again, but you can just push_back() the other vector too.  I'm trying to be efficient here with std::move() and emplace_back()
 
    tmp.clear();
    for(int i = 0; i < 10; i++)
    {
        tmp.push_back(i);
    }
    jagged2D.emplace_back(move(tmp));
 
    // Now you have a 2D array with 5 elements in the first row, and 10 in the 2nd.
    cout << "jagged2D[0][4] is: " << jagged2D[0][4] << endl;
    cout << "jagged2D[1][8] is: " << jagged2D[1][8] << endl;
    //cout << "jagged2D[0][8] is: " << jagged2D[0][8] << endl; // Don't do!  No array index checking on the [] operator so undefined behavior.  You may be accessing anything at this point.
    cout << "jagged2D.at(0).at(8) is: " << jagged2D[0][8] << endl; // throws a std::out_of_range exception
 
    return 0;
}
So yes, jagged arrays are no problem in C++, even re-sizable at runtime. Non-jagged n-D arrays are also possible, but the syntax is "funky" but useful when you need screaming efficient access to a lot of elements.


#42

fade

fade

I am a big C++ proselytizer. I do find that when you mention that C++ is your favorite language, people tend to treat you like you just said Hitler was Jesus. Then they go off on some rehearsed list of things that are wrong with C++, and usually why Java is better. That very attitude is responsible for most of the complaints. C++ ain't Java. Sure, there is no garbage collection. Use the RAII paradigm, and you're golden 99% of the time. Scope isn't something that should only come up at debug time. It's a tool to be used like anything else in your toolbox. This is just an example of the kinds of complaints out there, that lead to stupidity like (most of) the C++ FQA.

I don't really have anything against Java, but you can keep your class proliferation. If you're inheriting the crap out of everything, then it's possible you need to redesign. Use templates and/or policies, for example. I certainly don't think of Stroustrup as holy, but he does have a great FAQ that does a a pretty good job of explaining how to think of C++ as C++. It's not Java, so not everything needs to be a class. I much prefer this over Java because you can restrict classes to things that should be instantiated that have some cohesive invariant that defines the class as what it is. You get structs to use as collection of POD, and namespaces to throw all of your mangled globals into. Also STL. People still use 15 year old invalid arguments against it, which is like arguing that you can't right click on a Mac.

Sorry for the rant. Too much time on stackoverflow lately looking at dumb answers.

---

To answer the OP though, I would suggest something that you could put to immediate use. As PatrThom pointed out, (for all that ranting) it doesn't matter what language you use. They all basically do the same thing in slightly different ways. Remember it's the slight differences that start holy wars. I would suggest staying away from things with wacky syntax like Haskell, though. Here's a breakdown of the languages I think you'd have the easiest time with AND that would translate well to general situations.

  • Matlab: If you have a copy, go for it. You can see immediate results, see the values of variables as the program runs, and with the click of a mouse, you can stop the program anywhere in the middle of its run. The syntax is easy, and it's very close to both C(++) and Fortran. You can be procedural or object oriented. This is my #1 pick for new languages IF you have something to practice on.
  • Javascript: You'll use it, and it's easy. On the other hand it doesn't really get you into thinking of a program as a whole.
  • Python: Free and useful. Good on the resume. Good tutorial on its home website. Poor man's matlab for the most part so the same arguments generally apply
  • C/C++: good next step up. My advice is to pick one at the beginning and stick with it. Don't try to learn both at the same time. If you want to learn both, I think it's easier to go from C to C++. Also best compiler out there is free.
  • Fortran: People love to rag on Fortran, but when it comes to scientific programming, Fortran is still one of the best. It is designed for science, unlike C, and it has a lot of builtin stuff to help you with scientific programming. If you learn it, best to stick to Fortran 90. A lot of tutorials on the web are for Fortran 77 (yes as in 1977), which is still the most widespread. But it's dated.
  • Ruby: Lifehacker has this one as its top pick, but I think the whole "everything is an object" idea might be confusing for newbies.
  • Java: Want a job? This is it. Probably one of the most popular languages right now. Similar to C++ in many ways (I know--I just said C++ isn't Java, but they are very similar in a lot of ways).
These are just my opinions of course.


#43

Eriol

Eriol

  • Matlab: If you have a copy, go for it. You can see immediate results, see the values of variables as the program runs, and with the click of a mouse, you can stop the program anywhere in the middle of its run. The syntax is easy, and it's very close to both C(++) and Fortran. You can be procedural or object oriented. This is my #1 pick for new languages IF you have something to practice on.
The biggest problem with learning that one IMO is that you may get into the wrong mindset with arrays. I remember that was my biggest problem with Matlab when I used it in school (Engineering) was that Matlab uses math-style vector/matrix indexes (starts at 1) and every other programming language anywhere uses zero-based indexes (starts at zero) and the number of times I screwed it up because I've been programming a long time was embarrassing. So anybody trying to learn on that language may get into habits there that will screw them over in a big way anywhere else. Given that one-off errors are some of the most common anyway (in any language), starting somebody off in a language that's different than all others seems inadvisable.


#44

fade

fade

Fortran uses 1 based arrays too. (Though you can start them at zero)


#45

Covar

Covar

Fortran uses 1 based arrays too. (Though you can start them at zero)


#46

strawman

strawman

That is my favorite xkcd strip.


Top