i've had experience programming with C (for a month) before using C++ for half a year. what I really do primarily is Javascript and HTML dev, so... I'm fairly entrenched in one kind of world. I have a bunch of newb questions I've always wondered about though. I understand a primary-use case of C++. for example, application development... a compiled language. having a TON of standard libraries to draw upon out there. its distinction and merits when starting a new project are pretty clear to me.
but let's say you're starting a brand new project. i want to just ramble off a few kinds.
1. let's say you want to "model" some physics, or something. anything a scientist would want to do. I know historically Fortran was used for this. but is that MERELY because of its syntax? its simply EASIER for a relative "non-programmer" scientist to get something up and running in it -- right? meaning, technically, you COULD choose to do it all in a language like C++ and have it RUN just as fast+effeciently, but the process of getting it up and running is probably more time-consuming for someone who isn't a seasoned programmer?
2. ADA confuses me. having read up on it, i know it's used extensively in avionics, military things, etc. and it seems like it's because it's super safe with the runtime checking? meaning you cant make mistakes in it or you get called out on it, there's really no potential for unexpected crashes once your project is live. am i right? But if that's the case... couldn't you just make a C++ compiler that is SUPER STRICT? It sounds like Ada's strengths only appear when you're COMPILING something. Couldn't ANY programming language just be run through a super tight-ass compiler that yells at you for every little fault? As a language itself I'd love to know what else it does BETTER than any other language.
3. could you use ADA for say, a commercial game? if so.. how would that work? would you need to write entire frameworks to support OpenGL and all of that, or do those exist for people to leverage?
4. what about say, Lua? all i hear is that Lua is used for 'scripting in games'. well, what really does that mean? let's take a SUPER hypothetical question. could you thereotically code a site like Facebook entirely on one language like Lua? is the language even capable of interfacing with web servers, etc?
5. for all of these languages like Lua, LISP, or even COBOL... .do they have native libraries that allow you to build GUI applications? like I understand Win32 through C++ to a degree through importing libraries, etc. is there a 1:1 equivalent for these languages like COBOL? are they all built in a way where you can easily just start connecting functions to GUI buttons, etc...
some Newb questions regarding Ada, Lua, LISP, etc...
Fortran's dominance in scientific computing was largely the result of two factors: 1) Inertia. It was used largely because thats the language everything was already written in. All the scientific computing libraries were already in Fortran, the code your prof gave you was in Fortran, etc. 2) Fortran compilers tended to produce faster code than comparable compilers for other languages. This was a combination of the fact that a lot of code was written in Fortran, so a lot of money got spent on improving Fortran compilers and the fact that Fortran had slightly different semantics than other languages which allowed for simplifying assumptions that could be made by the compiler. That advantage has largely disappeared as languages and compilers have evolved.
Fortran's dominance in scientific computing was largely the result of two factors: 1) Inertia. It was used largely because thats the language everything was already written in. All the scientific computing libraries were already in Fortran, the code your prof gave you was in Fortran, etc. 2) Fortran compilers tended to produce faster code than comparable compilers for other languages. This was a combination of the fact that a lot of code was written in Fortran, so a lot of money got spent on improving Fortran compilers and the fact that Fortran had slightly different semantics than other languages which allowed for simplifying assumptions that could be made by the compiler. That advantage has largely disappeared as languages and compilers have evolved.
Wow, replace "Fortran" with "C++" and the quote still holds!
Back on topic: having some experience with Ada, I wouldn't use it for game programming. On the positive side, it has access to OpenGL (look for AdaOpenGL). On the negative side, it is not *that* big an improvement over C++ and it really isn't popular enough to get timely help if you encounter an issue.
C++ is indeed a pain to setup and use. This topic has been discussed to death so I'm not going to expand here, but suffice to say that its design is seriously outdated. It's a 1989 language that failed to evolve in any meaningful way.
Lua is a scripting language in the sense that it's generally meant to be hosted inside a larger application (typically written in a different language). It can be used to write applications from the ground up, but that's not what it was designed for.
My 2cc: go for C# or Python. They are popular languages with great documentation, libraries and IDE support. They are well-designed and make good code simple and bad code obvious. More importantly, they are actually fun to use and get out of your way so you can focus on your game rather than fighting with technicalities. You really can't go wrong with either.
[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]
thanks. I'm not particularly looking to use them, but I'm reaaaally curious about this stuff, since I'm so green to it all. and I only continually bring up C++ because it's easy to draw a comparison to that, as I understand its history, its usage, its legacy, etc...
As mentioned earlier, Fortran enjoys wide popularity in the academic and simulation communities largely due to historical inertia. Fortran is still (sort of) easier to make fast than C++ because of the simplifications the languages makes in certain areas. However, this comes at substantial costs in terms of the ease of building certain types of abstractions; as simulation complexities continue to increase, it is less and less relevant. Moreover, advances in compiler technology and hardware have all but obviated the need for a truly "fast" core language; so Fortran will continue to ebb just as assembly language programming does in the games field.
C++ is harder to do "right" than Fortran, but then again, C++ is harder to do right than virtually every other language out there, so take that for what you will. Fortran is mostly a legacy from when Fortran was the only substantial game in town.
Ada is a beautiful language, albeit on the strict and harsh end of the spectrum. Its strength comes from a combination of both static and dynamic safety checks. On the static side, its type system is fairly strict, versus C++ which has a weak and relatively permissive type system. It's possible to do things like distinguish between "int which means a distance" and "int which means a monetary value" in Ada, which has no parallel in C++. This is incredibly useful when engineering robust systems because you can enforce the impossibility of mixing up data types which share data representations at the hardware level. C++, by contrast, will happily let you assign a Nuclear Warhead where you expect a Puppy provided that the bits look the same in the hardware. (You can also convince it to do this anyways via things like reinterpret_cast, which is evil but thoroughly permissible in the language.)
The dynamic checks also make it very difficult to cause data corruption and other classes of nasty bugs via things like trampling memory. Because Ada does not have pointers, you can't just stomp on random bytes with no discipline, which is frighteningly easy to do in C++. While it is not true that Ada is totally crash-proof, it is highly reliable in the face of failures; a problem will likely simply terminate the program (or even generate a handleable exception) rather than risk data corruption or other nastiness as is common in C++.
What makes Ada so great for robust systems is the semantics of the language. You simply can't do things that are unsafe in many cases; this is totally different from writing an anal-retentive C++ compiler.
Consider: it is not possible, even in theory, to prove that an arbitrary program in C++ will not trample arbitrary memory, because of the presence of pointers. Ada, without any pointer-type facility, eliminates this issue entirely. It is not necessary to prove that an arbitrary Ada program will not access random, uninitialized, or otherwise corrupt memory, because the semantics of the language prohibit it.
On the flip side, consider the use of RAII in C++ over traditional C-style resource management. With RAII, the semantics of the language allow you to completely avoid an entire class of bugs; C lacks the notion of deterministic object destruction, and is fundamentally incapable of implementing anything like RAII without essentially reimplementing the bulk of the C++ object system in an ad hoc and poorly defined way. (Yes, you technically could accomplish something vaguely similar, c.f. Turing Completeness and the fact that C++ was originally compiled to C, but you'd hardly be coding in C anymore.) Thinking about this should reveal that the strengths of Ada (and other restrictive languages) are impossible to attain in C++ without essentially reinventing the language from scratch.
There's no reason why it would be impossible to build a game in Ada, although it's far from practical, largely due to a lack of library and tool support. The language itself is perfectly capable of implementing something like a game; why not, if it can control stock markets and missiles?
Lua is a different beast. As noted above, it is generally designed to be embedded within another, larger system, typically one built around C or C++. There exist rich bindings between C++ and Lua, for instance, which let you share objects transparently between the languages, and so on; this is what makes it so appealing for scripting usage. You can build the stuff that needs to be fast and solid in low-level tools like C++, then take advantage of the higher-level language constructs and semantics of Lua to make your job a lot easier for the bulk of the game logic.
There's no reason you can't write a web application in Lua, although it would probably require some contortions. You could technically write a web server in Brainfuck if you had the patience; again, c.f. Turing Completeness and fundamental language equivalence. However, this is somewhat akin to using a Volkswagen to sail around the world. Thoroughly possible, but would require prohibitive amounts of modification and unpleasantry to make it practical.
Not all languages have native GUI bindings, no. Most in fact do not; it is more common to write bindings to C or C++ and allow the language to utilize existing libraries targeting those languages. Not all languages are designed to solve the same problems, so of course it doesn't make sense for them all to look alike in terms of what they can do out of the box. By analogy: not all vehicles are designed for heavy towing. Your motorcycle does not come equipped with a winch for good reasons. You could technically attach a winch to a motorcycle and use it for limited purposes, but really you should just buy a truck ;-)
C++ is harder to do "right" than Fortran, but then again, C++ is harder to do right than virtually every other language out there, so take that for what you will. Fortran is mostly a legacy from when Fortran was the only substantial game in town.
Ada is a beautiful language, albeit on the strict and harsh end of the spectrum. Its strength comes from a combination of both static and dynamic safety checks. On the static side, its type system is fairly strict, versus C++ which has a weak and relatively permissive type system. It's possible to do things like distinguish between "int which means a distance" and "int which means a monetary value" in Ada, which has no parallel in C++. This is incredibly useful when engineering robust systems because you can enforce the impossibility of mixing up data types which share data representations at the hardware level. C++, by contrast, will happily let you assign a Nuclear Warhead where you expect a Puppy provided that the bits look the same in the hardware. (You can also convince it to do this anyways via things like reinterpret_cast, which is evil but thoroughly permissible in the language.)
The dynamic checks also make it very difficult to cause data corruption and other classes of nasty bugs via things like trampling memory. Because Ada does not have pointers, you can't just stomp on random bytes with no discipline, which is frighteningly easy to do in C++. While it is not true that Ada is totally crash-proof, it is highly reliable in the face of failures; a problem will likely simply terminate the program (or even generate a handleable exception) rather than risk data corruption or other nastiness as is common in C++.
What makes Ada so great for robust systems is the semantics of the language. You simply can't do things that are unsafe in many cases; this is totally different from writing an anal-retentive C++ compiler.
Consider: it is not possible, even in theory, to prove that an arbitrary program in C++ will not trample arbitrary memory, because of the presence of pointers. Ada, without any pointer-type facility, eliminates this issue entirely. It is not necessary to prove that an arbitrary Ada program will not access random, uninitialized, or otherwise corrupt memory, because the semantics of the language prohibit it.
On the flip side, consider the use of RAII in C++ over traditional C-style resource management. With RAII, the semantics of the language allow you to completely avoid an entire class of bugs; C lacks the notion of deterministic object destruction, and is fundamentally incapable of implementing anything like RAII without essentially reimplementing the bulk of the C++ object system in an ad hoc and poorly defined way. (Yes, you technically could accomplish something vaguely similar, c.f. Turing Completeness and the fact that C++ was originally compiled to C, but you'd hardly be coding in C anymore.) Thinking about this should reveal that the strengths of Ada (and other restrictive languages) are impossible to attain in C++ without essentially reinventing the language from scratch.
There's no reason why it would be impossible to build a game in Ada, although it's far from practical, largely due to a lack of library and tool support. The language itself is perfectly capable of implementing something like a game; why not, if it can control stock markets and missiles?
Lua is a different beast. As noted above, it is generally designed to be embedded within another, larger system, typically one built around C or C++. There exist rich bindings between C++ and Lua, for instance, which let you share objects transparently between the languages, and so on; this is what makes it so appealing for scripting usage. You can build the stuff that needs to be fast and solid in low-level tools like C++, then take advantage of the higher-level language constructs and semantics of Lua to make your job a lot easier for the bulk of the game logic.
There's no reason you can't write a web application in Lua, although it would probably require some contortions. You could technically write a web server in Brainfuck if you had the patience; again, c.f. Turing Completeness and fundamental language equivalence. However, this is somewhat akin to using a Volkswagen to sail around the world. Thoroughly possible, but would require prohibitive amounts of modification and unpleasantry to make it practical.
Not all languages have native GUI bindings, no. Most in fact do not; it is more common to write bindings to C or C++ and allow the language to utilize existing libraries targeting those languages. Not all languages are designed to solve the same problems, so of course it doesn't make sense for them all to look alike in terms of what they can do out of the box. By analogy: not all vehicles are designed for heavy towing. Your motorcycle does not come equipped with a winch for good reasons. You could technically attach a winch to a motorcycle and use it for limited purposes, but really you should just buy a truck ;-)
Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement