# Off-Topic Discussion > The Lounge > Tech Talk >  >  Where do I start? Learning computer language

## Abra

I know how to program graphing calculators. I'm pretty darn good at it, I guess. Not only can I make pretty cool triangle solvers and other equation junk, but I can make awesome animations and games using 'basic' style programming, as well. Whether it's a virtual fishtank, an RPG, a high-score arcade game, or a puzzle game, I can crank 'em out in good quality and fun.

But that's the extent of my programming knowledge. As my use of the calculator declines, and my use of computer increases, I want to switch my skills from calc to comp. But I've never taken any courses for computers. I know very little HTML(!). My goal is to learn how to make these simple games and tools on the computer (eventually evolving into cooler stuff). But I have no clue where to begin. What language should I start with? Java? Flash? Which would be easiest? Any good tutorials out there?

Discuss:
-Graphing calculators
-programming n00bs

----------


## Kushna Mufeed

Or...download a graphing calculator emulator!

----------


## ninja9578

C

If you're planning to go into that field then C is a must-know.  Almost all programming now-a-days is done in C++.  Since you've never had proper classes then I assume that you've never done OOP, which is difficult to teach yourself so C would be the best bet, since C++ is a derivation of C.  Java is also OOP, which would make it hard to learn and very few applications are written in it.

You mentioned games.  Almost all game engine are written in C, it's the fastest and in gaming speed is everything.  The ones that aren't OpenGL use C++, but it's a decreasing amount and will soon become the minority.

Since you're good a BASIC I might recommend an opensource project called FreeBasic.  It's a Windows/Linux upgrade to the old QBasic, but much more powerful, I use it from time to time and it's very easy to code it.  It's also a good gateway to C because it has a GNU back end and has syntax and commands very similar to C.

----------


## Ynot

Either C or C++

everything is based off of C or C++ to varying degrees
once you know these, anything else is a cinch to pick up

Initially, you may be happier with C
like Basic, it's a procedural language (executes top down, and includes functions and sub-routines)

C++ is an extension to C, and provides a strong object orientated approach as well as the procedural approach
OOP (object orientated programming) requires a different mind-set to work in.


*edit*
as for tutorials,

http://www.cprogramming.com/tutorial.html


*edit 2*
probably the most difficult concept to get to grips with (coming from Basic), is the separate header files
make sure you have a good understanding of why & how code is split into header and source files
and if in doubt, ask

----------


## M-Cat

Learn calculator assembly language. Or you can help me and Dan Cook, search up "Antidisassemblage" on ticalc.org.

----------


## ninja9578

> probably the most difficult concept to get to grips with (coming from Basic), is the separate header files
> make sure you have a good understanding of why & how code is split into header and source files
> and if in doubt, ask



Basic has separate header files.  It's not as imperative with C, I've done small projects (1000 LOC) all in one big files, but it's not good practice.  Learn how to do a top down design and modulate your program.  Headers are much more imperative in C++ than C, but it's good to have then for both.

----------


## Ynot

> Basic has separate header files.



oh, ok

well, sinclair basic didn't....

----------


## M-Cat

> oh, ok
> 
> well, sinclair basic didn't....



Neither does ti-basic, which is the language he's coming from. But headers are simple to understand and they're logical, I can't see how someone could have trouble with C just because of headers.

----------


## ninja9578

No, C headers are simple.  I think that Ynot was referring to C++ headers. They're a little bit different because there are a few kinds.  There are skeleton headers, abstract headers, interface headers, headers with inline methods.  Don't yell at me, I don't remember the exact terminology for each kind, but you know what I'm talking about.

----------


## Ynot

> Neither does ti-basic, which is the language he's coming from. But headers are simple to understand and they're logical, I can't see how someone could have trouble with C just because of headers.



just recounting my own troubles, really

I came from sinclair basic
one program = one source file

hitting C++ head on,
and wondering why one program had half a dozen files

It was my biggest hurdle with C++
I just did what other people did, with regards to splitting up the file
and for the longest time, not knowing why I did it or what it's purpose was

I'm hideously out of date with modern forms of Basic (save for the occasional dabble with Word Basic)
so I had no idea basic had adopted headers...

----------


## ninja9578

Yeah, there is a powerful semi OOP language called FreeBasic that can be modulated very well.  I've written some large programs with 50 individual files.  My favourite part about that is that compiling the main one automatically compiles all of them, no makefiles  :smiley: 

Oh, for Abra, read up on makefiles, unless you are using an IDE, those are pretty important.

----------


## Pyrofan1

avoid assembly unless you want to go into really hardcore hacking, device drivers, os creation or intense game engines. while assembly is easy to learn it takes a lot more code than any other language.
for example
this C code



```
aFunction((a*b/c),c*c);
```


would look like this in assembly



```
mul $c, $c
push $c
mul $a, $b
mov $a, %eax
idiv %eax, $c
push %eax
call aFunction
```

----------


## Needcatscan

I would suggest java.  It's widely used (not for gaming) and is basically an easier version of C and C++.  I don't think anyone really uses C anymore, C++ is the norm since it has OOP.

My bro and I made a Final Fantasy-esque game in Visual Basic 6.  We made 20 classes (as in mage, warrior, not as in OOP classes) instead of just a few.  It was a lot of fun.

----------


## Pyrofan1

> I would suggest java.  It's widely used (not for gaming) and is basically an easier version of C and C++



Java was invented long after C and i think after C++ too.  I don't get why programmers seem to have a fetish with OOP.

----------


## Ynot

> I don't think anyone really uses C anymore, C++ is the norm since it has OOP.



C is very widely used outside of the personal computer world

it's fast, and has a low memory footprint
and functionally, it sits very close to the hardware

in the world of 2gig ram PC's, different languages rise & fall depending on trends, software frameworks and time saving (but memory costly) features

outside of PC's....
embedded systems / portable devices / firmware
C is king, and will probably always be king

anything else will reduce performance, battery life and general usability






> I don't get why programmers seem to have a fetish with OOP.



Reusable code, mainly
while libraries can be created in any language paradigm, OOP has evolved from the ground up to compliment the design issues of "pluggable" libraries

----------


## Needcatscan

> C is very widely used outside of the personal computer world
> 
> it's fast, and has a low memory footprint
> and functionally, it sits very close to the hardware
> 
> in the world of 2gig ram PC's, different languages rise & fall depending on trends, software frameworks and time saving (but memory costly) features
> 
> outside of PC's....
> embedded systems / portable devices / firmware
> ...




Didn't know that.
My major (CS) hasn't focused very much on C, we only programmed in it for 2 weeks.  The rest has been c++ and java.

----------


## Ynot

it all comes down to a compromise between ease of development and run-time speed & efficiency

If you're programming a car's traction control system, then you know it will only be run on a single piece of hardware
it'll need to be as fast as possible
so you'll probably program the chip directly using machine code, or possibly the assembly language of the CPU

If you change chips later on, you'll have to rewrite the traction control system in the new chips native language

If you're writing a general purpose program to be used on a variety of hardware, but speed is all important (an operating system, for example)
you'll probably write in in C

If you're writing a word processor, you may choose C++, as it'll take less time to write

----------


## Abra

'Kay, so now I downloaded a compiler and am starting to dabble with very simple stuff. I'm working on If statements and variables. I'm slow, I know.  :tongue2:

----------


## Ynot

your first task is a "Hello World" program

have fun

----------


## Sornaensis

> C
> 
> If you're planning to go into that field then C is a must-know.  Almost all programming now-a-days is done in C++.  Since you've never had proper classes then I assume that you've never done OOP, which is difficult to teach yourself so C would be the best bet, since C++ is a derivation of C.  Java is also OOP, which would make it hard to learn and very few applications are written in it.
> 
> You mentioned games.  Almost all game engine are written in C, it's the fastest and in gaming speed is everything.  The ones that aren't OpenGL use C++, but it's a decreasing amount and will soon become the minority.
> 
> Since you're good a BASIC I might recommend an opensource project called FreeBasic.  It's a Windows/Linux upgrade to the old QBasic, but much more powerful, I use it from time to time and it's very easy to code it.  It's also a good gateway to C because it has a GNU back end and has syntax and commands very similar to C.



Sorry to burst your bubble, but C++ is becoming more PROMINENT. Not declining. C is a must-klnw, but C++ really is the standard.

----------


## Ynot

well,
what he said was correct (at least, it's also how I understand it)

he said "Almost all programming now-a-days is done in C++"

but, "Almost all game engine are written in C"

both of which are true

game engines, by their very nature, need to be as fast as possible - C is the best choice for them

----------


## Abra

Assuming I continue this C stuff, would it be pretty easy for me to learn C++?

----------


## Pyrofan1

yes

----------


## Ynot

C & C++ are 80&#37;, or so, the same

there's a few new things introduced in C++
and a few other things change slightly

The new things, are:
classes (for OOP)
templates (for generic programming)

Both of these give rise to the standard template library, which gives you generic containers and simplifies a lot of the dynamic allocation and pointer stuff

But the STL doesn't do everything
(far from it, in some cases)
so sooner or later you'll find yourself doing dynamic allocation and pointer work in C++ manually

If you come up though C, you will end up with an advanced knowledge of dynamic allocation and the use of pointers will be second nature, and you won't write leaky code
(well, only by accident, not though poor understanding)

there's a lot of C++ people who try to avoid pointers completely cause they're too reliant on the STL

----------


## ninja9578

> Sorry to burst your bubble, but C++ is becoming more PROMINENT. Not declining. C is a must-klnw, but C++ really is the standard.



You misread my quote.  I meant that the number of games using Direct3d is declining compared to OpenGL.  I wasn't comparing languages.  OpenGL is just better suited for C, DX is better for OOP.

----------


## Sornaensis

> You misread my quote.  I meant that the number of games using Direct3d is declining compared to OpenGL.  I wasn't comparing languages.  OpenGL is just better suited for C, DX is better for OOP.



Oic. I haven't used OGL w/ C before. I usually use C++ w/ AllegroGL and Classes.

----------


## dsr

Most performance-critical code is written in lower level languages like C or C++, but Abra's question was where she should start. I've said this before and I'll say it again: I highly recommend Python as a first language. Thanks to this excellent tutorial, you can learn the syntax in a day or two. Python is very easy to learn and use, and it produces much clearer, more consistent, more concise, and more bug-free code than any other language (with the possible exception of Haskell) that I have ever used. Python also has a larger application domain than almost any other language. While you could just use it as a replacement for shell scripts, you can also use Python for desktop applications, games, server-side scripting, and web development. The only real downside of Python is that performance sometimes suffers due to the lack of a real compiler, but there are many remedies. The fact that Python is interpreted directly from the source files also means that the development time is drastically shorter than that of a language like Java, C, or C++. Eric Raymond's "Why Python" shows that even expert programmers use the language.

----------


## Sornaensis

CLI == The **** to me.

C is a great place to start.

----------


## Pyrofan1

> he fact that Python is interpreted directly from the source files also means that the development time is drastically shorter



how does the fact that a language is interpreted make development time shorter?  if i remember right Brainfuck is interpreted, but that doesn't make it's dev time shorter.

----------


## arby

> it produces much clearer, more consistent, more concise, and more bug-free code than any other language (with the possible exception of Haskell)



Ah, Haskell. The language that the real psychopaths men use.

----------


## dsr

> how does the fact that a language is interpreted make development time shorter?  if i remember right Brainfuck is interpreted, but that doesn't make it's dev time shorter.



Python is interpreted directly from the source code, which means that there is no compile phase of the development cycle. With a language like Java, which requires compilation to bytecode before running with the Java interpreter, or a language like C++, which compiles directly to machine language, it can take minutes or hours (in the more extreme cases) to test any changes you make to the source code. It's a tradeoff between development time and execution time.

If memory serves, by the way, Brainfuck just maps to C code. It has nothing to do with interpreted scripting languages.

----------


## Sornaensis

::rolllaugh:: 

You are sadly misinformed.

Interpreted languages are known for their slowness. Just look at BASIC. Python is only different in that it can be used for large projects, but is still highly inferior to it's lower-level ancestors.

----------


## dsr

> You are sadly misinformed.
> 
> Interpreted languages are known for their slowness. Just look at BASIC. Python is only different in that it can be used for large projects, but is still highly inferior to it's lower-level ancestors.



In what way am I misinformed? I stated that software written in a higher level language is faster to develop while software written in a lower level language performs faster. And please don't say that language x is inferior to language y without establishing specific criteria. Python is obviously better than, say, C++ for certain tasks and worse for others.

----------


## Sornaensis

Actually, I find Python harder to develop with. There isn't just an IDE to write the code then compile it to whatever you need. 'Tis why I prefer C/C++/C--/C+=; Quicker.

----------


## Pyrofan1

> If memory serves, by the way, Brainfuck just maps to C code.



Nope, While brainfuck can be compiled (which can be said about every programming language) it is mostly an interpreted language.




> or a language like C++, which compiles directly to machine language, it can take minutes or hours (in the more extreme cases) to test any changes you make to the source code. It's a tradeoff between development time and execution time.



i've never heard anyone include compile time with dev time.

----------


## dsr

> Nope, While brainfuck can be compiled (which can be said about every programming language) it is mostly an interpreted language.



No, all eight characters have a one-to-one correspondence with specific C code (see here). Brainfuck "interpreters" exist, but those are just programs that convert brainfuck code into the equivalent C, which would then be passed through a C compiler to produce an executable binary.





> i've never heard anyone include compile time with dev time.



Then you've never had a conversation about compile time and development time.  ::D:  By development time, I mean the time it takes to development the software. In order to test code, it must be compiled, and that can be an inconvenience. Large software programs can take an hour or so to compile, and that's not so pleasant if you're just fixing a bunch of syntax errors. The whole point of an interpreted language like Python, Ruby, or Perl is to save the developer time at the expense of execution speed. For most tasks, speed of development is more important than speed of execution, but performance is critical for certain kinds of programs. Similar arguments can be made in debates about static vs. dynamic typing, by the way.

Let's try to get away from this rather pointless debate (there are always going to be pros and cons of compiled languages and pros and cons of interpreted languages). The point of my original post was that Python is an excellent first language (see that post), not that everyone should use it for everything (although I've read about some people who do...).

----------


## Pyrofan1

> No, all eight characters have a one-to-one correspondence with specific C code



that's like saying that because assembly and machine code have a one-to-one conversion they are the same.




> Brainfuck "interpreters" exist, but those are just programs that convert brainfuck code into the equivalent C, which would then be passed through a C compiler to produce an executable binary.



that would be called a compiler, not an interpreter.
if you want a brainfuck interpreter here's one



```
void parse_brainfuck(char *code)
{
    unsigned int ptr=0;
    unsigned char memory[1000];

    while(*code!=NULL)
    {
        switch(*code)
        {
            case '>':
            ptr++;
            code++;
            break;

            case '<':
            ptr--;
            code++;
            break;

            case '+':
            memory[ptr]++;
            code++;
            break;

            case '-':
            memory[ptr]--;
            code++;
            break;

            case '.':
            putchar(memory[ptr]);
            code++;
            break;

            case ',':
            memory[ptr]=getch();
            code++;
            break;

            case '[':
            if(memory[ptr]==0)
            {
                while(*code!=']') code++;
                code++;
                break;
            }
            else
            {
                code++;
            }
            break;

            case ']':
            if(memory[ptr]!=0)
            {
                while(*code!='[') code--;
                break;
            }
            else
            {
                code++;
            }
            break;

            default:
            break;
        }
    }
}
```


you can also do one in assembly (and pretty much every other language), but i don't feel like typing that much

----------


## dsr

> ```
> void parse_brainfuck(char *code)
> {
>     unsigned int ptr=0;
>     unsigned char memory[1000];
> 
>     while(*code!=NULL)
>     {
>         switch(*code)
> ...



I stand corrected.  ::lol::

----------


## Identity X

> Actually, I find Python harder to develop with. There isn't just an IDE to write the code then compile it to whatever you need. 'Tis why I prefer C/C++/C--/C+=; Quicker.



You obviously haven't done much searching for a decent Python IDE. Actually, as far as I'm aware even python-mode in your standard copy of XEmacs (and GNU Emacs too?) has that option. 

And besides, if you want a Python-like language that compiles to executable in one mouse press, download Boo and SharpDevelop.

Boo is the clearest and most sensible language I've come across, and compiles straight to CLI (and thus an exe file).

----------


## M-Cat

> avoid assembly unless you want to go into really hardcore hacking, device drivers, os creation or intense game engines. while assembly is easy to learn it takes a lot more code than any other language.
> for example
> this C code
> 
> 
> 
> ```
> aFunction((a*b/c),c*c);
> ```
> ...



Assembly is one of the best languages you can learn. Even if you dont program in it, you learn more from assembly than any other language.





> Interpreted languages are known for their slowness. Just look at BASIC. Python is only different in that it can be used for large projects, but is still highly inferior to it's lower-level ancestors.



Actually speed is rarely an issue today except in the most intensive programs. Most applications are a breeze for modern processors to run. That's why languages like Python, which are easy to use, are becoming more favourable.

----------


## Replicon

Haha I was about to mention brainfuck.





> Actually, I find Python harder to develop with. There isn't just an IDE to write the code then compile it to whatever you need. 'Tis why I prefer C/C++/C--/C+=; Quicker.



How does not having an IDE slow people down? I find IDE's slow me down. I'll take the command line over most IDE's any day. I can code faster with vim (if it's properly set up), and building is as simple as typing 'make' (assuming you have a good makefile hehe - I actually wrote a magic one that I never have to touch).

Not to sound like an evangelist, but Ruby (http://www.ruby-lang.org/en/) is really neat. There's a link on the site where you can go through an interactive tutorial without having to install anything.

If you go the C/C++ way (which is fine), check out http://cprogramming.com/ for good tutorials that take you through the basics. Good design skills and the likes will come from experience.

----------


## ninja9578

> Assembly is one of the best languages you can learn. Even if you dont program in it, you learn more from assembly than any other language.



Agreed.  It also helps with CG since [good] assembly is always the fastest, if you do really low level stuff then you will be using inline assembly.


You must be writing some huge programs if it takes hours to compiler.  I have all optimizations turned on and I've never had a program compile for more than a few minutes.  

Now I'm not writing full-size apps, but full-size apps are modulated and the modules can be compiled and tested individually, so most of the bugs are out of the system (especially something simple like syntax errors,) by the time that the modules are put together.





> How does not having an IDE slow people down?



XCode does syntax and semantic checking on the fly so if I miss a semicolon or parenthesis it automatically yells at me.  It also does debugging without writing tons of tests and can show me all of the variables when an error is encountered, which definitely speeds things up.  As far as I know Eclipse, .NET, and Bloodshed all do the same.  For apps with a GUI it also does drag and drop of buttons and such.


If you're planning to go to college for CS then you should learn what is taught there.  Most colleges teach C/C++/Java and sometimes VB.  If you're planning on concentrating in CG then C is what will probably be used.  Checking out the OpenGL Red Book might also be a nice idea, the format is the same in every language (for the most part.)

----------


## Identity X

> [good] assembly is always the fastest



Yes, and the best assembly is written by GCC et al.

I've done a course on compiler optimization and some of the techniques are astounding. Much of the code now generated by compilers is fantastic in its efficiency.

----------


## Pyrofan1

> Assembly is one of the best languages you can learn. Even if you dont program in it, you learn more from assembly than any other language.



i'm not bashing assembly, in fact it's my favorite language. i'm just saying it's not too useful today and if you want to get a programming job most companies won't ask you if you know assembly.

----------


## M-Cat

Well you shouldn't do something just so it looks good on your resume. Even if companies don't want it, hell, even if it's not useful at all, learning assembly will help you with in a lot of other aspects of computer science.

----------


## Abra

As a follow-up, I'm now taking a course in Java, and what I've learned in C is helping. I like this stuff. Anyone know where to get me started on making shweet pixel graphics? Once we get to loops and what I like to call "getkey," I want to make me a simple game of some sort.

----------


## Replicon

SDL is a pretty easy way to go: http://libsdl.org

Cross-platform, too!

----------


## ninja9578

I still recommend OpenGL, I know there is an API for Java.  Pixel graphics means that you are directly manipulating the buffer instead of using OpenGL's primitives.

Forget getkey, use a listener instead.  GLUT has a listener built in called GlutKeyFunc(void keys())

Again, OpenGL is best for C and other procedural oriented languages.  For OOP most would use Allegro or DirectX.  I've never used either, I've heard bad things about DirectX, but I've heard that Allegro was easy to use.

EDIT: Oh, SDL uses OpenGL  ::?:   I guess it's a library for buffer manipulation?

----------


## Ynot

SDL (Simple DirectMedia Layer) is an API container
Very similar to what DirectX is

DirectX is a container,
comprising Microsoft's Direct3D, DirectDraw, DirectInput, DirectSound, Etc. Etc.

SDL is the same, except you can switch & swap between different "inner API's"
A program using SDL will use Direct3D when run on Windows, and OpenGL when run of *nix, for example

Same program, same code
translating to different API calls depending on platform

----------


## ninja9578

I know what DirectX is.  Technically speaking OpenGL is a package too.  When most programmers say that their program uses OpenGL" they usually mean gl.h, glu.h and glut.h, usually OpenAL too.  It's not quite as modulated as DirectX, but still a nice package.  I wish we had something like DirectDraw  ::?: 

It uses DirectX on Windows?  That's strange considering that OpenGL has been (mostly) ported to Windows and completely if you use MESA. It looks like it only supports DirectX9 though.  Bad news since DirectX 10 has little to none backwards compatibility. 

Looks useful though, I might have to look at it closer once I get some free time.  I never found OpenGL all that difficult for most things, but things like buffer manipulation is a pain in the ass sometimes.  Hence the reason that I want a DirectDraw  :tongue2:

----------


## Ynot

> I know what DirectX is.



I know - it's more for other people reading this




> I wish we had something like DirectDraw



I always thought openGL did both 2D & 3D acceleration?
Does it not?

----------


## ninja9578

Nope, OpenGL is an _entirely_ 3D based library.  There is a 2DOrtho mode, but everything is still actually rendered and projected in 3D.  The only way to do true 2D is to directly manipulate the buffer.  They designed it that way so that everything was perfectly uniform, all OpenGL function use the same 4 coordinate system (x, y, z, w) for points and 4x4 matrices for manipulations.

For 2D I'm sure that DirectX can run circles around OpenGL (using built-in primitives of course.)  I'm sure with libraries like SDL the buffer manipulation runs as quickly as DirectDraw.

----------


## Ynot

Admittedly I don't have any real in-depth knowledge of CG graphics
but didn't OpenGL originally come from 2D
(CAD, medical imaging, ray tracing)
with the 3D parts coming later (3D modeling, virtual reality & 3D games)

??


*edit*
Lifted straight from the website




> OpenGL is the premier environment for developing portable, interactive 2D and 3D graphics applications. Since its introduction in 1992, OpenGL has become the industry's most widely used and supported 2D and 3D graphics application programming interface (API), bringing thousands of applications to a wide variety of computer platforms. OpenGL fosters innovation and speeds application development by incorporating a broad set of rendering, texture mapping, special effects, and other powerful visualization functions. Developers can leverage the power of OpenGL across all popular desktop and workstation platforms, ensuring wide application deployment.

----------


## ninja9578

It's _drawn_ in 2D.  In fact, every single primitive function in the standard pipeline is done in 2D (The projections are the first things that get done.)  But everything is still stored in 3D.  How it handles them in the pipeline is exactly the same, the only difference is that for the Ortho2D matrix, all of the z values zero out.

The Ortho2D mode probably also skips things in the pipeline that aren't needed in 2D, fog, shading...

I'm assuming that the 2D acceleration that they are talking about is things like antialiasing of lines, Phong interpolation, bit-line filling, and things like that.

And this wiki says that even in 1992, OpenGL was still 3D.

----------


## Replicon

In any case, if you're an absolute beginner, SDL is probably the easiest way to get started. I'm not sure how/whether it handles on Vista, however.

----------


## ninja9578

Googled it, looks like there are problems on Vista.  ::?: 

If you have a Vista machine then I would recommend dual booting Linux.  I think all computer scientists should at least have a little bit of knowledge of Linux.  I'm assuming that you are using Eclipse, which is cross platform.  SDL seems cross platform as well.  This way you can build the project in Linux and send it to your professor.

Your professor will more than likely be running XP or OSX.  A good cross platform program will compile and run perfectly on both.  I know OpenGL moves seamlessly between platforms.  If you build under Linux and your Prof tests it on a Mac then you're golden because it never has to touch DirectX.

----------

