Page 1 of 2

[Solved] programming languages

Posted: Sat Apr 24, 2010 7:11 am
by cndr
I'm thinking about learning a second language right now I only know c++, and would like to know which language compliments it, I've heard that python, and lua are good to use, but what about xml? I don't know much about any of those languages, so I'm not really sure what is right for me, any ideas?

Re: programming languages

Posted: Sat Apr 24, 2010 8:01 am
by thejahooli
It depends on what you want to use it for. Lua can be used as an embedded scripting language in C++ to run external scripts in your program. XML isn't really a programming language, it's just a way of displaying data in a file which you read into your program to use.

Re: programming languages

Posted: Sat Apr 24, 2010 8:43 am
by ajtgarber
As thejahooli said, it depends on what your using it for. You could learn C# and XNA to make games for the Xbox, Objective-C for Iphone development, Java for... just an all around language, or even Assembly if your brave enough.

Re: programming languages

Posted: Sat Apr 24, 2010 9:51 am
by avansc
C compliments C++ pretty well.

Re: programming languages

Posted: Sat Apr 24, 2010 9:58 am
by dandymcgee
avansc wrote:C compliments C++ pretty well.
You sure do love C don't you? :) I wholeheartedly agree, learning C would be a great investment of your time.

Re: programming languages

Posted: Sat Apr 24, 2010 11:01 am
by Ginto8
dandymcgee wrote:
avansc wrote:C compliments C++ pretty well.
You sure do love C don't you? :) I wholeheartedly agree, learning C would be a great investment of your time.
Most certainly. I started as a C++ programmer who foolishly abused and overused OOP. I started using C, and then D (don't try it, it's still a LONG way from being complete - it doesn't even have all the features it says it has! :( ), and I learned a lot of the pros (and cons) of OOP, and (for the most part) why abused OOP can murder code. I think you should try out C definitely, and then a more OOP language, maybe Java, so you learn why C++ is a very good language that successfully combines procedural and OOP, without forcing complete use of one or the other :) . You'll also learn how you can resist the urge to abuse either :mrgreen: .

Re: programming languages

Posted: Sat Apr 24, 2010 11:33 am
by thejahooli
I agree with learning C. It teaches you not to abuse some features of C++, such as using STL strings when a C-style string could be a better choice.

Re: programming languages

Posted: Sat Apr 24, 2010 11:35 am
by GroundUpEngine
avansc wrote:C compliments C++ pretty well.
Agreed 100%

Re: programming languages

Posted: Sat Apr 24, 2010 12:06 pm
by MrDeathNote
Ginto8 wrote:
dandymcgee wrote:
avansc wrote:C compliments C++ pretty well.
You sure do love C don't you? :) I wholeheartedly agree, learning C would be a great investment of your time.
Most certainly. I started as a C++ programmer who foolishly abused and overused OOP. I started using C, and then D (don't try it, it's still a LONG way from being complete - it doesn't even have all the features it says it has! :( ), and I learned a lot of the pros (and cons) of OOP, and (for the most part) why abused OOP can murder code. I think you should try out C definitely, and then a more OOP language, maybe Java, so you learn why C++ is a very good language that successfully combines procedural and OOP, without forcing complete use of one or the other :) . You'll also learn how you can resist the urge to abuse either :mrgreen: .
Agreed, C is great, but there are other great languages out there c# is really useful and is very widely used. I learned C and then C++, if you are a competent C++ programmer you should be able to pick up C quickly as you should be familiar with a lot of the functions since C++ includes C as a subset. You've probably used quite a few C functions and don't even know it.

Re: programming languages

Posted: Sat Apr 24, 2010 9:03 pm
by jacob.krustchinsky
Might I be the one to recommend a more OO language such as Java or C#. Learning either of those languages will give you a far better understanding of OOP, which you can apply in C++

Re: programming languages

Posted: Sat Apr 24, 2010 10:09 pm
by cndr
Thanks for the help everyone, I think I'm going to learn c, and do some lua on the side.

Re: programming languages

Posted: Sat Apr 24, 2010 10:17 pm
by dandymcgee
jacob.krustchinsky wrote:Might I be the one to recommend a more OO language such as Java or C#. Learning either of those languages will give you a far better understanding of OOP, which you can apply in C++
Just out of curiosity have you ever used C#? I've been using it for my CS project since September, and although it's highly OO I disagree that it helps to teach you OOP concepts any better than C++. Many of the other students in my class have no idea why a function called "Write()" pops up when they type "Console." in visual studio, but rather just take for granted that it does.

Obviously everyone is learns differently, but I've found C++ to be a far better tool than C# for learning what OO means and how it works.

Keep in mind I'm arguing that C# isn't better than C++ at teaching OOP, not that it isn't a good learning resource. C# is a great language, is widely used, and has many useful applications.

Re: programming languages

Posted: Sat Apr 24, 2010 10:48 pm
by MadPumpkin
For scripting? Python, LUA, JavaScript are all my favorites. But as an all around language I'd say C, Java, C++ and since you know the later, I'd say one of the first two would be great.

Re: programming languages

Posted: Sun Apr 25, 2010 1:56 am
by EccentricDuck
Anyone with an opinion on Lisp? I've heard people go "oh, it's outdated, no one uses it, etc etc." and a select few say things like "it's made me a far better programmer" or "it's the reason I can rapidly create effective tools and software while others take several times as long with XX language". I've never really seen a good description of WHY either of those parties have those opinions though; but I would like to know since the latter group certainly have appealing positions.

Re: programming languages

Posted: Sun Apr 25, 2010 10:01 am
by wtetzner
EccentricDuck wrote:Anyone with an opinion on Lisp? I've heard people go "oh, it's outdated, no one uses it, etc etc." and a select few say things like "it's made me a far better programmer" or "it's the reason I can rapidly create effective tools and software while others take several times as long with XX language". I've never really seen a good description of WHY either of those parties have those opinions though; but I would like to know since the latter group certainly have appealing positions.
Yes, I actually use Lisp at work every day. Well, I actually use Clojure, which is a Lisp dialect that runs on the JVM.
The reason people say it's made them a better programmer is that Lisp has abstractions that other languages don't, so you learn to think differently when solving programming problems.
I think the reason people say Lisp is the reason they can create software faster than in other languages is also that the abstractions are good.

The main abstraction mechanism Lisp has that other languages don't have is macros, which let's you create new language constructs by hooking into the compiler, and having your code run at compile time. See, the reason for all of the parentheses in Lisp is that Lisp code is defined in terms of Lisp lists. A List with a symbol and three number in Lisp looks like (+ 1 2 3). When this is read by the reader, it gets turned into a list data structure in memory, and is then passed to the compiler. So the compiler compiles data structures, not text. And not just any data structures, but the core Lisp data structures. In most Lisps this is just lists, but Clojure also has literal vectors and hash maps.

So...what was I getting at? Oh right, macros. Macros are called at compile time, and the arguments to a macro are passed in as code (in the form of data structures). The macro then returns data structures, which represent code, and the compiler compiles the returned code.

Here's an example. The built-in way to create a function in Clojure is

Code: Select all

(fn [x] (* 2 x))
This function takes one argument, and returns the input times two. But notice this function doesn't have a name. So to give it a name, you would do

Code: Select all

(def times-two (fn [x] (* 2 x)))
But this is kind of annoying. Wouldn't it be nice if there was a cleaner way to define a named function? Well, why not write one?

Code: Select all

(defmacro defn
  [name args & body]
  `(def name (fn args ~@body)))
I know you don't know exactly what's happening in the above code, but the point is that now we can use the macro 'defn':

Code: Select all

(defn times-two [x] (* 2 x))
In this example, I used a pattern syntax in the macro definition, but it could have been written like this too:

Code: Select all

(defmacro times-two
  [name args & body]
  (cons 'def (cons name (concat ['fn args] body))))
Anyway, the point is that you can return any code from a macro, which can be manipulated/generated by the full Lisp language.

Lisp also has other powerful abstractions, like closures, but other languages have closures as well.

I don't know if you wanted that much of an explanation of Lisp macros :), and I probably did a bad job explaining them anyway.
If you want a better explanation, I would recommend this: http://www.defmacro.org/ramblings/lisp.html

Anyway, the point is that I think it's worth learning Lisp. People tend to complain about all the parens, but I like the syntax. I like it because it's simple and consistent.
Also, there really aren't many more parens in Lisp than in other languages, it's just that Lisp doesn't have any of the other syntax in it.

Code: Select all

C++ function call:
someFunc(foo, bar, baz);

Lisp function call:
(some-func foo bar baz)

C++ if:
if(someFunc(foo, bar, baz))
{
  return otherFunc(foo);
}
else
{
  return anotherFunc(bar);
}

Lisp if:
(if (some-func foo bar baz)
  (other-func foo)
  (another-func bar)))
Same number of parens. :)