a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment by caelum19
caelum19  ·  3315 days ago  ·  link  ·    ·  parent  ·  post: Pubski: November 18, 2015

What language are you coding the game in?

I discovered Kotlin today and I'm in love.





user-inactivated  ·  3314 days ago  ·  link  ·  

Javascript, with a pinch of jQuery for DOM control (even though I barely need it so far). It's meant to be web-based and quite simple. I'd like to touch CoffeeScript sometime in the future, but I'm very used to the vanilla JS.

Not sure if I'm going to touch other languages in the foreseeable future for the same reason. Do you have any experience with switching between programming languages (from the one you know to the one you don't)?

caelum19  ·  3314 days ago  ·  link  ·  

Nice. I've never used CoffeeScript but I hear it's good.

    Do you have any experience with switching between programming languages (from the one you know to the one you don't)?

That's how I learn :D

I started out with JS, I barely knew it properly, then I did a free C course and I loved it, I manically constructed a 3000+ line text explorer using a giant IF tree and hundreds of variables. Then I found a tutorial for making 2D graphics in Java, again, I had no idea what I was doing but I kept modifying it until I did. I did hardly any Java tutorials actually,

I just searched "whatever was wrong" + java + stackoverflow, which I would recommend because it's a lot of fun but also recommend you still look through more official documentation so you learn the terminology.

Kotlin can work alongside Java(Not in the same file, but Kotlin files can interact with Java classes and vica versa), so switching current projects from Java is easy(IntelliJ IDEA 15 also provides a "convert Java to Kotlin" function.

Apparently it can also compile to Javascript, I'm not sure how that works but next time I do Javascript I will try Kotlin instead because the only good IDE for JavaScript I know is PhpStorm, and it's not free. What text editor/IDE do you use?

user-inactivated  ·  3314 days ago  ·  link  ·  

That's quite a programming journey you've had. Let me ask you a few questions, if you don't mind.

If I were to build a small app - something like "act as a clock and tell me when an hour since I've launched the app has passed" - would it be quicker for me to do it in C or in Java?

What are C and Java generally used for? Is there anything one's better for than the other? Keep in mind: I have no experience in either, or in programming apps for a PC.

    What text editor/IDE do you use?

Brackets, and loving it. What amazes me is that Brackets itself is written with JS while acting as a Win application - the only thing giving it away was error logs: something in there implied of its nature pretty clearly to me. It allows for good project management - both inside the project and between several of them - which is good for me since I can easily look up previous projects I did and copy/learn from how I solved the problem encountered previously. Instant testing - "live preview", they call it - is what I enjoy very well: it allows for instant checking and correcting whatever error I may have made or changing the style that didn't work out so well. Good stuff, and I'm enjoying it. Can't see a reason to switch off to anything else.

caelum19  ·  3312 days ago  ·  link  ·  

Assuming I understand what you mean, here's how you'd do it in C:

    #include <windows.h>

    #include <stdio.h>

    int main() {

        printf( "starting to sleep...\n" );

    Sleep( 3000 ); // sleep three seconds

    printf( "sleep ended\n" );

    }

And this is how you would do it in Java

    package ...

    public class SleepExample{

      public static void main(String[] args){

    System.out.println("Starting to sleep");

    try{

    Thread.sleep(1000); // Sleep 3 seconds

    }catch(InterruptedException e){

    e.printStackTrace();

    }

    System.out.println("Sleep ended");

    }

As you can see, Java's is bigger, but I've made a shitty gifv to demonstrate that it's not really a problem when you're using an IDE like IntelliJ IDEA http://i.imgur.com/XUPWXeb.gifv

Edit: The program actually sleeps 1 second because I'm an idiot

Another thing to note is

    #include <windows.h>
in the C version, this code would only work on Windows(Someone correct me if I'm wrong) and you'd need different implementations for different operating systems, optimized for different CPUs...

If you want to make an alarm that's actually useful, with a GUI etc. Java is defintely the way to go out of the two languages, there's no argument. C is pretty old, it's very fast and very low-level, which will mean you will need to reinvent the wheel pretty often, but also you're not limited(Very rarely a concern, but you will know when it will be). C is better for a few very specific tasks, but that's about it.

However, the answer to that question when it isn't limited to just Java and C will depend on who you ask. Personally, I'm conflicted on Java or C# (Leaning slightly toward Java because the JVM is full of potential and mono is pretty slow)

Brackets sounds cool. It's always good to look out for better things though, I was happy using Eclipse and so regret being lazy and not checking out IntelliJ IDEA sooner. Plus, if you're looking for a job, it's good to at least know the basics of an IDE you're likely to use if you get hired.

briandmyers  ·  3312 days ago  ·  link  ·  

Replace "windows.h" with "stdlib.h", and replace "Sleep" with "delay", and it'll run almost anywhere.

user-inactivated  ·  3310 days ago  ·  link  ·  

Thanks for the lesson! What do you think about C vs. Java, then?