This is the beta version of TWHL and is not currently active. Please go to twhl.info if you are looking for resources or information.

Journal #8693

Posted 1 year ago2016-04-17 07:53:38 UTC
I'm started coding Terraia. I think that's better. Because Terraria's codding looks like easier than Half-Life's. I looked some tutorials for modding Terraria and it looks interesting. This is the better way to learn codding right? :)

9 Comments

Commented 1 year ago2016-04-17 09:54:31 UTC Comment #66376
The reason of why you think Terraria modding is easier than Half-Life is because Terraria uses the C# language with the XNA Framework (close to Minecraft with Java and LWJGL). C# and Java are "high level" programming languages and C/C++ (Half-Life) are "low level" programming languages meaning that C#/Java does most of the "dirty work" for you.

I did a quick search on Terrria modding, are you using tConfig or tAPI ?
Commented 1 year ago2016-04-17 10:34:28 UTC Comment #66373
I'd consider C++ to be a fairly high level language too. The main difference between C++ and C# is memory allocation, and that's not important for HL modding since the engine handles it for the most part.

Sure, there's some additional stuff you need to know about pointers and macros and so on, but for the most part it's just differences in syntax. There's not really a lot of "dirty work" that C# does for you that C++ doesn't. You still write code and it runs. The C# code is just usually easier to read and debug.
Commented 1 year ago2016-04-17 13:44:30 UTC Comment #66375
While 20 years ago most of the people would agree with you Penguinboy, in today's programming languages landscape that's just not the case.
Consider the imperative, object-oriented languages. In my opinion, the ability to inherit abstract classes without the hassle of pointers and most importantly, not thinking about garbage collection at all, makes a HUGE difference and puts C++ where it is: close-to-the-metal.

Here's an example to illustrate the difference between Java and C++ when it comes to inheritance and polymorphism:

Java:

The interface(abstract class equivalent in Java):

public interface IntelligentBeing{

void doSomeShit(int nrTasks); this would be a virtual function in C++
}

The class:

public class Person implements Actions{
String name;

public Person(String cName){
this.name = cName;
}

public void doSomeShit(int nrTasks){

for(int i=0; i<nrTasks; i++){
System.out.println("I will not procrastinate!);

}
}
public void sayMyName(){
System.out.println("My name is: "+this.name);
}

}

Consider all the boilerplate main class written. Then you'd have something like:

IntelligentBeing striker = new Person("Striker"); //oh, very subtle!
striker.doSomeShit(100);

So what we see here is that we can create an abstract class that is inherited by another class, but in a special way: an abstract class dictates how the derived class should work. It's sort of like a contract. With this comes a beauty in some Java editors which are context-aware(although I'm pretty sure IntelliSense in Visual Studio is capable of the same thing): while creating a new IntelligentBeing object, code-completion can list what new type of object you can create that respects that contract. Wonderful and to the point!

Now let's see how that is done in C++.
The abstract class:

class IntelligentBeing{

virtual void doSomeShit(int nrTasks) = 0; this is actually called a pure virtual method because it forces the derived class to implement it
}

The class:

class Person: public IntelligentBeing{

private:
String name;

public:
void doSomeShit(int nrTasks){
for(int=0; i<nrTasks; i++){
std::cout<<"I will not procrastinate!"<<endl;
}
}

void sayMyName(){
std::cout<<"My name is: "<<this.name<<endl;
}

Person(cName){
this.name = cName; //haven't used C++ in a while, don't remember if the equal operator is overloaded for string copying or not
}
}

Consider all the boilerplate main function written. Then you'd have something like:

IntelligentBeing *striker = new Person("Striker");
striker->doSomeShit(100);

--
--

C++ is much more flexible in the inheritance model, but it does so at the expense of becoming confusing. For example, it allows multiple inheritance. In Java you can only inherit from one class, but you can implement multiple interfaces(contracts).
And then when it comes to actually instantiating and using the objects.
In c++ you have to use the arrow operator to access methods of pointer object, and the dot operator for a normal object. In Java you only need the point operator.

Example:

IntellgentBeing *genericBeing;
Person penguinboy("Penguinboy");
Person kamyon95("Kamyon95"):

genericBeing = &penguinboy;
genericBeing->sayMyName();
genericBeing = &kamyon95;
genericBeing->sayMyName();

In Java you just use the equal operator without the reference operator(&), and to good ol' point operator for accessing methods. Figuring out when you have to use the arrow operator or when to use the reference ones or pointers can become confusing in big projects. Yeah, maybe not if you're having some experience. But still, it's a burden.

Sure, in Java after a while you might even forget how this actually works in the backstage, but is this important or the fact that you're building software?
Please notice that this was not a biased argument: C++ has its specific purposes, and I surely still like C++ as it was my first language I learned( although never made anything major in it other than a simple OpenCV application). When you know that performance matters for every processed bit, then go for bare-metal programming. You're making a huge trade in the detriment of time though.

So the point is that in 2016 I think people who say C++ is a high-level programming language learn from old books. One might introduce a new term for languages like C++: "mid-level". Of course, that is just my opinion.
But if you call C++ high-level, what can you say about Python, Javascript, Matlab? They're certainly not human language :)).
Commented 1 year ago2016-04-17 14:47:35 UTC Comment #66377
Thanks for that little programming lesson Striker ^^
Commented 1 year ago2016-04-17 22:05:03 UTC Comment #66374
I don't disagree with what you're saying Striker, but you're arguing "modern" rather than "high-level". Java and C# are much easier to read and write than C++, but C++ is almost fully capable of everything C# can do in terms of control flow. The biggest difference is memory management, as you mentioned. Your code examples are just changes in syntax, which you would expect between any two languages.

Remember that C++ is still being updated. Things like closures, lambdas, foreach loops, and type inference were added in C++11. It's hard to argue that any language with such things isn't high level.

I fully agree that C++ syntax can be very obscure and downright arcane at times, but that doesn't mean it's not high-level. It's just harder to read. You can consider C# and Java to be on a slightly higher level because you get garbage collection, reflection and other dynamic programming capabilities.
Commented 1 year ago2016-04-19 11:40:22 UTC Comment #66379
Long time no see guys :)

I'm using tAPI for now but i have an error with version compatibility. Maybe i will use tConfig. And i didn't know level diffirence between C++ and C#. Looks like C# easier than C++, is that so hard? I mean i'm a begineer and wich program should i learn first?
Commented 1 year ago2016-04-19 11:46:22 UTC Comment #66380
OMG there's so much to learn something.
I found this site: http://rbwhitaker.wikidot.com/xna-tutorials
Tells how to use C# and XNA something and it's ENGLISH (a little hard for me)
I'm gonna take a look at this site. Should be useful.

I looked for tConfig but it works with 1.1x versions.
tAPI is for 1.2x versions but don't work with 1.3x versions.
Well i'm go with 1.2.4.1 then.
Commented 1 year ago2016-04-19 18:09:33 UTC Comment #66378
Start with C# because if you start with C++, you will run away from programming due to pointers, memory allocations... ^^
Commented 1 year ago2016-04-19 20:20:54 UTC Comment #66381
Oh. Thanks Shepard62700FR!

You must log in to post a comment. You can login or register a new account.