Computer Science, programming languages discussion

For everything not related to either Rayman or Pirate-Community.

Moderator: English moderators

Forum rules
Please keep the forum rules and guidelines in mind when creating or replying to a topic.
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

My first thought was that C++ isn't a very good language to learn programming with (don't get me wrong, it's awesome, but I'd usually recommend a higher-level, strongly-typed, multi-paradigm, curly-bracket programming language to start with), but if you're looking to create GameBoy games then C and assembly might be of more (direct) interest to you.
Image
Master
Rayman 1
Posts: 50143
Joined: Sun Aug 21, 2011 10:14 am
Location: Somewhere specific, I'd assume.
Tings: 404084

Re: Computer Science, programming languages discussion

Post by Master »

Wow, this is old. I haven't touched Visual Basic in ages. I've been using C and C# for the most part in Uni, though not with the greatest depth, C is what we use for programming embedded ARM chips, while C# is what we use for basic desktop applications that interface with said chips. I'd like to expand on both in time, there's a lot yet for me to learn.

I've also used some basic Python just to interface with some graphing APIs is all. It does seem to be fairly popular with robotics, from what I've heard, which isn't necessarily the field I expect myself to end up in, but there's a potential overlap.
Image
Ambidextroid
Mini Jano
Posts: 12809
Joined: Tue Mar 19, 2013 1:04 am
Location: Jaffa Castle
Tings: 675

Re: Computer Science, programming languages discussion

Post by Ambidextroid »

Hunchman801 wrote:My first thought was that C++ isn't a very good language to learn programming with (don't get me wrong, it's awesome, but I'd usually recommend a higher-level, strongly-typed, multi-paradigm, curly-bracket programming language to start with), but if you're looking to create GameBoy games then C and assembly might be of more (direct) interest to you.
Well I did get to grips with Python and I've used a lot of basic before, so I'm somewhat confident that I understand the general logic and themes of coding. I'm planning to indeed learn assembly and eventually C (as I've heard it's the most popular/supported choice for Gameboy programming) but that's a little way down the line for me, I think C++ isn't a bad choice for the stage I'm at now.
Still, I'd like to know what languages you'd recommend that fit the criteria you mentioned!
Image
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

Ambidextroid wrote:Still, I'd like to know what languages you'd recommend that fit the criteria you mentioned!
For a beginner not looking to specialize anytime soon? C# or Java.
Image
Serza5
Mr Dark
Posts: 48329
Joined: Sat Jul 26, 2008 7:51 pm
Location: MOTHER FUCKING SCOTLAND OH YEAH BABY
Contact:
Tings: 486315

Re: Computer Science, programming languages discussion

Post by Serza5 »

Thinking about uni I think c++ was the language I learned first there granted it was an optional module, and I didn't have too much trouble learning the language given that true basic was my only other experience with coding before that.

Needless to say I don't think c++ is that bad to start off with. He'll I think I had more issue with c since I found the language to be frustrating with how little functions it has in comparison to c++.

C# (and Java?) are a lot more higher levelled than those sonic not sure if they'd be good for ambi to look into.
Image
Words of Wisdom :
Master wrote:< can't compete with Serz, her power level is too great.
Hoodcom wrote:^^^ does underestimate the power of the mighty Serza. You shall beheaded for your insult to the Queen of Scotland. :mefiant:
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

Serza5 wrote:C# (and Java?) are a lot more higher levelled than those sonic not sure if they'd be good for ambi to look into.
Well yeah, I said C and assembly would be a better choice.
Image
PluMGMK
Aline Louïa
Posts: 37009
Joined: Fri Jul 31, 2009 9:00 pm
Location: https://www.youtube.com/watch?v=cErgMJSgpv0
Contact:
Tings: 102740

Re: Computer Science, programming languages discussion

Post by PluMGMK »

While I dislike Python, my father hates Java. :P He's had bad experiences in the past with needing to install the entire JVM just to run a program or two. It's something that's probably got better down through the years, but the constant badgering about Java updates on Windows is still somewhat annoying. (Of course with Linux+IcedTea that's not a problem, but that's neither here nor there, ahem…)
I started programming in Visual Basic 6. Were it not for the nostalgia factor, I would probably dislike VBA even more than I do Python. The bloody thing doesn't even short-circuit the "And" and "Or" operators for crying out loud. :boon: That caused me to waste ages one day wondering why a macro I had written kept erroring… Oh yeah, and the debugging's terrible too!
Hmm, maybe some other time I'll be in the mood to talk about what I like. :fou:
LoveMetal
André
Posts: 14899
Joined: Fri Oct 09, 2009 6:11 pm
Tings: 217520

Re: Computer Science, programming languages discussion

Post by LoveMetal »

This whole discussion reminds me that I still have to code my posting bot for the upcoming Record Day. :mrgreen:
Hunchman801 wrote:
Serza5 wrote:C# (and Java?) are a lot more higher levelled than those sonic not sure if they'd be good for ambi to look into.
Well yeah, I said C and assembly would be a better choice.
I don't think I get the point to start off with assembly, assuming you want to learn programmation in a broad way. Of course if you want to have some fun with a 68k you found in your attic, that's another story.

Learning to code with a high level and not very rigorous language then switching to C might be a good decision. I started with a simplified version of BASIC for the kiddos, then I switched to C, and I learned a lot from that change. With BASIC I understood what programmation was about, and with very wordy language it wasn't a big issue, and then I forked other people's codes to understand all the things I could get from it. Finally, with C I learnt the low level part, and most of all the rigor every coder needs to have.

And regarding high level languages such as C#, the big advantage is that once you learnt one of them, and you are comfortable with, then you can use any of them without any trouble. I started learning Java with a book to develop Android apps, then when I switched to C# I only had to read some code snippets on MSDN and that was it.
Hunchman801 wrote:So, having found that .NET lacks native support for integer math
What do you call integer math?
Image
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

LoveMetal wrote:I don't think I get the point to start off with assembly, assuming you want to learn programmation in a broad way. Of course if you want to have some fun with a 68k you found in your attic, that's another story.
Ambi wants to program for the Game Boy, that's pretty much the same. :confus:
LoveMetal wrote:What do you call integer math?
Operations on integers, i.e. Math.Pow(int, int).
Image
LoveMetal
André
Posts: 14899
Joined: Fri Oct 09, 2009 6:11 pm
Tings: 217520

Re: Computer Science, programming languages discussion

Post by LoveMetal »

Hunchman801 wrote:Ambi wants to program for the Game Boy, that's pretty much the same. :confus:
Well then you are right, the Z80 being even less powerful than a 68k. :mrgreen:
Hunchman801 wrote:
LoveMetal wrote:What do you call integer math?
Operations on integers, i.e. Math.Pow(int, int).
The reason seems to be that an implementation of pow(double, double) is at least as efficient than pow(int, int), regardless of the values. It's because a^b = exp(b*ln(a)). And as you can imagine, exp and ln are not evaluated each time you call them, these functions are already pre calculated and tabulated in memory.

Then, the pow function can be computated very quickly (and it's probably why your attempts to create your own implementation are slower, even though you are using ints) :

Code: Select all

public static double Pow(double x, double y) {
    return Math.Exp(y * Math.Log(x)); // only a multiplication and 2 look ups on tables to do
}
If you still want to create your own pow(int, int) method, for instance if you don't want any floating point errors, and if you still want a quick computation, then you can consider the fact that a power of 2 can be computated with a bitwise shift. Because (b1b2 ... bn)binary = bn*20 + bn-1*21 + ... + b1*2n in decimal, then c = a2*n is equivalent to c = a << n, assuming n > 0.

Then, you can decompose xy in x2x2... x2 if y is even, and in x x2... x2 if y is odd, and repeat recursively.
Image
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

LoveMetal wrote:The reason seems to be that an implementation of pow(double, double) is at least as efficient than pow(int, int), regardless of the values. It's because a^b = exp(b*ln(a)). And as you can imagine, exp and ln are not evaluated each time you call them, these functions are already pre calculated and tabulated in memory.

Then, the pow function can be computated very quickly (and it's probably why your attempts to create your own implementation are slower, even though you are using ints) :

Code: Select all

public static double Pow(double x, double y) {
    return Math.Exp(y * Math.Log(x)); // only a multiplication and 2 look ups on tables to do
}
You misunderstood my message, it's the C++ bindings that are (slightly) slower than than using Math.Pow(double, double) and casting it to and int. My own C# implementation, using bit shits, is almost three times as fast.
LoveMetal wrote:If you still want to create your own pow(int, int) method, for instance if you don't want any floating point errors, and if you still want a quick computation, then you can consider the fact that a power of 2 can be computated with a bitwise shift. Because (b1b2 ... bn)binary = bn*20 + bn-1*21 + ... + b1*2n in decimal, then c = a2*n is equivalent to c = a << n, assuming n > 0.

Then, you can decompose xy in x2x2... x2 is y is even, and in x x2... x2 if y is odd, and repeat recursively.
Well no, c = a << n = a * 2n, not a2n (let aside overflows). As for the recursive algorithm you mentioned, it's just exponentiation by squaring and as far as I know it doesn't require bit shifts.
Image
LoveMetal
André
Posts: 14899
Joined: Fri Oct 09, 2009 6:11 pm
Tings: 217520

Re: Computer Science, programming languages discussion

Post by LoveMetal »

Hunchman801 wrote:You misunderstood my message, it's the C++ bindings that are (slightly) slower than than using Math.Pow(double, double) and casting it to and int. My own C# implementation, using bit shits, is almost three times as fast.
I was just trying to explain is why Math.Pow has been implemented natively as (double, double) and not (int, int).
LoveMetal wrote:Well no, c = a << n = a * 2n, not a2n (let aside overflows). As for the recursive algorithm you mentioned, it's just exponentiation by squaring and as far as I know it doesn't require bit shifts.
Sorry for the mistake you are obviously right, and yes that algorithm can't use bit shifts, since I had mistaken x2n with x*2n. Else it could and should have. :mrgreen:
Image
Matyuv
Gangsta Globox
Posts: 21363
Joined: Thu Apr 29, 2004 10:22 am
Tings: 54431

Re: Computer Science, programming languages discussion

Post by Matyuv »

Hunchman801 wrote:using bit shits
:mrgreen:
MandM81 wrote:YYYYYYYRRRHLHLPYYYYYYPDPPPYYYYYYYYYYYYRRRRRR
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

LoveMetal wrote:I was just trying to explain is why Math.Pow has been implemented natively as (double, double) and not (int, int).
I know, and that's why I showed you that you were wrong, since my integer implementation is much faster than .NET's double implementation. :mrgreen:
Matyuv wrote:
Hunchman801 wrote:using bit shits
:mrgreen:
This one's too good to be corrected. :lol:
Image
LoveMetal
André
Posts: 14899
Joined: Fri Oct 09, 2009 6:11 pm
Tings: 217520

Re: Computer Science, programming languages discussion

Post by LoveMetal »

Well, that's unfortunate, I remember reading that a while ago on stackoverflow. :mrgreen:

Edit: Found a thread about this method, this guy is not using look up tables but some fancy approximations for exp and log.
Image
Hunchman801
Bad Rayman
Posts: 83840
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 609979

Re: Computer Science, programming languages discussion

Post by Hunchman801 »

LoveMetal wrote:Found a thread about this method, this guy is not using look up tables but some fancy approximations for exp and log.
Interesting! But for now I'll stick to integer calculations, there's enough algorithms like this already. :lol:
Image
Ambidextroid
Mini Jano
Posts: 12809
Joined: Tue Mar 19, 2013 1:04 am
Location: Jaffa Castle
Tings: 675

Re: Computer Science, programming languages discussion

Post by Ambidextroid »

Does anyone here have experience in 3D rendering? I'm trying to get my head around how texture depth calculation works but there don't seem to be any good explanations online other than long equations you can plug into your program...
Image
LoveMetal
André
Posts: 14899
Joined: Fri Oct 09, 2009 6:11 pm
Tings: 217520

Re: Computer Science, programming languages discussion

Post by LoveMetal »

By texture depth calculation, do you mean shadow mapping or something else?
Image
Ambidextroid
Mini Jano
Posts: 12809
Joined: Tue Mar 19, 2013 1:04 am
Location: Jaffa Castle
Tings: 675

Re: Computer Science, programming languages discussion

Post by Ambidextroid »

I'm talking about how to avoid affine texture mapping, like you'd see on a PS1, and actually apply textures to polygons with depth so that the texture is more compressed the more distant the polygon's face is. Not that I'm really likely to use the information, I've just always been interested in graphics rendering
Image
The Jonster
Joe
Posts: 34040
Joined: Sat Mar 24, 2018 6:15 am
Location: The realm of Mario Karting
Tings: 78140

Re: Computer Science, programming languages discussion

Post by The Jonster »

Bump. I wonder if I can use this topic to ask questions if I ever have any programming errors I'd like to ask about? Hmm..

Well currently, after finishing my web developer class, I've come to add HTML, CSS, Javascript, Jquery, and other web developer languages to my repertoire of languages that I do know which involve Java and C (which I'm both pretty ok with, C more than Java). What I hated more than anything when I was learning programming in Uni was that in my first class we learned Java, then in the next few classes we were learning in mostly C and then in the last few classes we switched back to Java. As a result my knowledge is spotty in some areas in both languages. I also remember some things about Python and SQL but not enough in the former to be able to code accurately as of yet. I'd love to list all the langauges here that I can program/have knowledge in but I'm not sure what all of them are since there are some that I've probably forgotten in time.
Always be true to yourself.
Image
Sigs by Steo and R4Y_ANC3L
Post Reply