• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 00:44
CET 06:44
KST 14:44
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
Which season is the best in ASL? [ASL20] Ask the mapmakers — Drop your questions BW General Discussion FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread The Perfect Game Path of Exile Nintendo Switch Thread Should offensive tower rushing be viable in RTS games?
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1325 users

The Big Programming Thread - Page 399

Forum Index > General Forum
Post a Reply
Prev 1 397 398 399 400 401 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-11-24 13:48:02
November 24 2013 13:44 GMT
#7961
On November 23 2013 21:12 Manit0u wrote:
Show nested quote +
On November 22 2013 10:47 sluggaslamoo wrote:
On November 22 2013 08:39 3FFA wrote:
On November 22 2013 08:21 sluggaslamoo wrote:
On November 21 2013 08:09 3FFA wrote:
(I just started learning about them so I feel like playing with it and making a small text adventure game, the array is an array of the rooms)

As I said here, this is for a set of 20 rooms to be navigated in. It gets really complicated to navigate more than one or two players/creatures through a ton of numbers that are listed but don't really make much sense. The reason I have 3 columns is because there are 3 routes to other rooms for each room on the map.

I'll make sure I take 21 out of a loop and make it have its own separate assignment statement, thank you for pointing that out.


From a design standpoint a 3D array is not really the right way to go about it. It would be better to have a single array of rooms, and each room has 4 variables, north/south/east/west which link to other rooms. ("3 routes to other rooms" suggest that there are 4 rooms connected for each room, including the one you came from)

Also look at your program in terms of roles and responsibilities and the kind of components you want in your program, don't think about the implementation first.

For example.
- It has a number of rooms = This tells me that a 1D Array of rooms is sufficient
- A room can connect to multiple rooms = Each room either needs an array of more rooms or N/S/E/W, in your case 4, NSEW should be sufficient and less complicated.
- Each room contains XYZ = A room needs to be a data-structure

Depends what you are trying to do though, if you are trying to learn multi-dimensional arrays there's much better problem domains in which multidimensional arrays are useful for. Such as a 2D array for a graphical tile-game, or matrix manipulation for 3D programming.

There's really no point in learning strange ways of implementing things because you're not really learning how to program. You learn to program by learning how to solve real problems in the best way possible. If you wanna learn how to use certain features of programming, you are better off finding a problem domain where the method you are using is appropriate, that way when you visit the same problem, you know exactly the best way of doing it.

I'm using a 2D Array, not a 3D Array. o.O

And I'm sorry, I meant that each room has 3 routes to rooms other than the current room. So NEW or SEW for each room. The way I'm doing the 2D Array is that the 1st column is E 2nd column is W and 3rd column is N or S depending on the room the player is in. Then the player inputs whether he wants to go N/S E or W...


Man I nearly finished writing my reply and then my computer crashed T_T, time to write it all again.

Anyway I looked at your original post again and I think I get it now. There is an initial array of 21 rooms, and each element has another array of 3 elements, which contain the index of the rooms in the original array.

Anyway I've found that telling people that their method is wrong never gets us anywhere so lets do it your way, then we'll design the program in a way that gives it enough flexibility that you can change it later if you want to.

Because you are using C, we'll use a mixture of object pool and factory patterns which makes life easier when using C. Also just because we are using C doesn't mean we can't take anything from OOP.

So initially we will need a Room Manager which is responsible for managing all your rooms and handling room instantiation. Your Room Manager will need
- object pool [base array]
- number_of_rooms [variable]
- initialize_rooms
- clean_up function [for use at the end of the program]
- create_room [factory function]
- has_room_available [true/false]
- retrieve_room

So first of all create those functions with no implementation, and your base array.

We don't need to use ADTs (classes for C), this can just be a separate file, or hell just separate it with comment lines for now.


####### Room Manager ######
function XYZ ()
etc etc
###########################


In your mind its important that you see these functions as belonging to a separate entity even if in reality they are global and don't belong to anything, it will make life easier in the long run.

Create your base array (object pool) globally (yes global variables are poisonous in a vacuum but lets not go down that path for now). Its not a real object pool (it contains arrays not objects) but we can treat it like one because it can be later.

In your initialize_rooms function this will create the pool. It should take a number_of_rooms argument which determines the size of the pool (base_array). Implement this first and test that it works (on its own), once it works move on.

In your clean_up function create an implementation that deallocates the array. This will eventually go at the end of your program.

In your has_room_available function, it will tell you if there are any empty rooms left in the pool. Basically you need to check if number_of_rooms doesn't exceed the number of rooms in the array, returning true or false. Test to make sure this works (on its own), then move on.

In your create_room function, it will take room1_number, room2_number, room3_number. Use your has_room_available() function to determine if you can create more rooms, if not, throw an error. It will then create an array in the next element in pool with 3 elements (using the arguments provided) using the number_of_rooms variable. When the array is created, the function returns the index of the room in the pool that was just created. Test to make sure this works (on its own), then move on.

In your retrieve_room function, you will just take a room_number argument. This will return the array from the pool, given the appropriate room index. This will also allow you to use a 1 based instead of 0 based numbering system, if you wanted to. Test to make sure this works, then move on.

Ok if you have unit tested your Room Manager (even just manually using traces), then you should be able to put the pieces the puzzle together without much problem knowing that each function on its own won't be causing errors allowing you to home in on any bugs much faster.

*************** Rooms done!

Now for the Player. We do the same thing, without using datastructures we create some variables for the player. Create another "component" for the Player like we did with the Room Manager.

Player
- player_position variable = Room number he is in
- move_to(room_number) = self explanatory
- current_room() = actually retrieves the room he is in using the retrieve_room function

See if you can implement those, remember to test each function separately. This is also where you can output your text adventure logging. "You enter room XYZ which room do you want to go now?"

************** Player done!

The last component for our minimum viable product will be the controller. Much like a gamepad, the controller is the interface responsible for handling all the input.

wait_for_input() will pause the terminal to wait for input using your terminal read function and return the appropriate data for which other components will use.

*************

The last bit comes with actually implementing the program. These components should be able to give you the tools to easily create a working program and in a very clean manner too.

The program should look something like

initialize_rooms(21)
starting_room = create_room(1,2,3)
create_room(starting_room,3,4)
move_to(starting_room)

while running
wait_for_input()

clean_up()


*************

Now you may ask why you can't just throw everything in the main function and try and get it to work? Doing it this way gives you direction and prevents you from getting lost, even if you are writing more code, what takes time is not writing the code, its understanding the implementation.

If you can write 75 words per minute, chances are the time spent figuring out what to do is going to be the biggest bottleneck in your program implementation time. So next time instead of rushing into the implementation take a step back and have a think about what are the tools you need to make it work.

At first it will take a long time to do it this way, but eventually in the long run it will be much more efficient, I didn't stop to think one time during this whole post, I just wrote everything off the top of my head. There could be stuff missing, but it should be enough for you to fill in the gaps.

Because this implementation is flexible, if you ever decide to, you can have your Room Manager return data structures instead of arrays if you ever want a more complex program, without much effort.


Why are you trying to re-invent the wheel? Get yourself some MUDlib and driver (they're usually free) and you can create entire worlds. Each room there is a separate object (class) and you have all the basic handling and interaction built-in.

http://en.wikipedia.org/wiki/Mudlib

Even if you don't make it this way, you can at least take a look at the code involved there and get some good ideas on how to handle such things. It's way easier than using some huge arrays since each room is a separate class you can easily add, remove and move stuff around.

Some tutorials:
http://discworld.starturtle.net/lpc/creating/lpc_basic/contents.html
http://discworld.starturtle.net/external/lpc_for_dummies/index.shtml

Example of a room done in LPC:



/*
This is a basic room!
Written by Drakkos.
29/09/2000
*/

inherit "/std/room";

void setup() {
set_short("blobby lair");
set_long("This is where the grey blob lives. All around lie "
"frogs, and wombles, and strange oozy things. It's a "
"very nice lair, as lairs go.\n");
add_property("determinate", "a ");
set_light(50);
add_item("frog", "The frogs are very nice. Very froggy.");
add_item("womble", "It's Uncle Bulgaria!");
add_item("strange oozy things", "Ewww!");

add_exit("east", "/w/your_name/workroom", "road");
}

void reset() {
call_out ("after_reset", 3);
}

void after_reset() {

object ob = find_object("/w/your_name/simple_npc");

// if (!ob) will return true if ob is 0... in other words, it
// didn't find an object with find_object().

if (!ob) {
// There's no object with that filename loaded, so we load it
// and then move it into this_object()... which in the case of
// this example, is the room we just coded.

ob = load_object("/w/your_name/simple_npc");

// For information on how the move() function works, you
// can check out 'help move'. But briefly, the first argument
// is where the object is to be moved to... the second is the
// message that objects in the destination get when the object
// enters. $N will be replaced with the short of the object.
// 'appear$s' is a pluralisation code... it will change to
// 'appear' when more than one object enters at the same time,
// and 'appears' when only one enters.

ob->move(this_object(), "$N appear$s with a wet squelch.");

}

// if (!environment(ob)) will return true if ob returns 0 for
// environment... in other words, it's loaded, but located in
// null-space.

else if (!environment(ob)) {
ob->move (this_object(), "$N appear$s with a wet squelch.");
}

}


As a bonus you also get the entire network code and can set it up in 2 minutes time for multiplayer online play.


There are heaps of easier ways to do it, I already explained one such solution, he could even just write the whole thing in Ruby and just install a bunch of gems, that would be easier than using MUDlib.

The whole point was to answer 3FFA on how HE wanted to do it. Not to mention the learning to program part.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
3FFA
Profile Blog Joined February 2010
United States3931 Posts
November 24 2013 14:31 GMT
#7962
Hehe thanks again slug.

Yeah I'm probably not going to be learning MUDlib. Never even heard of it until Manit0u's post.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
November 24 2013 15:38 GMT
#7963
On November 24 2013 09:21 Kambing wrote:
Show nested quote +
On November 24 2013 09:13 Arnstein wrote:
Cygwin has bugged out, so I downloaded gVim Easy to use that instead. But it starts in insert mode, and esc doesn't make you go into command mode. How do I get to command mode?


AFAIK gvim easy comes from the standard windows gvim distribution which includes a raw gvim shortcut. Just use that instead or install the standard gvim distribution from vim.org if that isn't the case.

Alternatively, it seems like ctrl-L is the short to go into command mode: http://superuser.com/questions/353776/executing-commands-in-gvim-easy


thanks!
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
November 24 2013 17:04 GMT
#7964
Today I found some code with a void (*callback) function. What's that? How do they work? I can't seem to find anything relevant by googling!
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
misirlou
Profile Joined June 2010
Portugal3241 Posts
November 24 2013 17:51 GMT
#7965
On November 25 2013 02:04 Arnstein wrote:
Today I found some code with a void (*callback) function. What's that? How do they work? I can't seem to find anything relevant by googling!


you mean a line void (*callback)(); ? it means callback is a pointer to a function that takes no arguments and returns void.
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
November 24 2013 17:53 GMT
#7966
Hmm, can I get a little better explanation at how that works? I don't quite understand.
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
misirlou
Profile Joined June 2010
Portugal3241 Posts
Last Edited: 2013-11-24 18:09:52
November 24 2013 18:04 GMT
#7967
On November 25 2013 02:53 Arnstein wrote:
Hmm, can I get a little better explanation at how that works? I don't quite understand.


hm bout 2 years since i last coded in c, but basically you declare a variable to use as a function. You then assign a function to this pointer and you can use that pointer as a function instead of the original function. This is a bit like polymorphism but in original C. Imagine you are coding a simple calculator, all operations take 2 float arguments and return float. So you can make the functions like float sum(float x,float y) and float sub(float x,float y).
Now imagine your CLI input is like
>10.0
>+
>11.0

You can store the operation in a int status and then do the correct operation after the second number, or you can read the operation and then assign it to the pointer, when the user enters the second number, you simply call the pointer. This is a very limited use of it but it's simple enough to understand I believe. Function pointers are a way of doing something close to OOP in C

edit: this answer as the same code basically http://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work
ExChill
Profile Joined September 2011
Germany179 Posts
November 24 2013 18:13 GMT
#7968
On November 24 2013 05:29 Morfildur wrote:
Show nested quote +
On November 24 2013 05:18 ExChill wrote:
I'm not sure if this is the right thread for my question, sorry if I'm wrong here.
While learning HTML, PHP, CSS, etc. is it better to use something like XAMPP (local server), or is it better to rent a "real" server, which is hosted somewhere else?


It depends. A XAMPP Server is really enough for learning. If you want to learn all the surrounding stuff, e.g. having remote git repositories that you share with others, administrating apache through ssh and installing different websites, managing a live & dev environment simultaneously, etc., then a cheap vserver with root access can be nice to have. There are lots of vhost providers that offer servers for less than 10 bucks a month and which are easily enough for those needs, though if you don't care about that stuff, it's perfectly fine to do everything locally.

Personally, i like having a real server since i can use it for whatever i like and could install vservers to simulate software that is distributed across servers, e.g. with seperate database servers and such, which i don't actually do, so it's really just expensive overkill that i, and definitely also you, don't actually need.


Thank you I decided to try out a free hoster and rent webspace later.
https://twitter.com/ExChill_
Manit0u
Profile Blog Joined August 2004
Poland17490 Posts
November 24 2013 18:57 GMT
#7969
On November 24 2013 23:31 3FFA wrote:
Hehe thanks again slug.

Yeah I'm probably not going to be learning MUDlib. Never even heard of it until Manit0u's post.


I only suggested checking it out to see how it's being done there since it's way more efficient way of doing what you want to do than using arrays. Slug's Ruby suggestion is basically the same concept, I used MUDlib as an example since it's an environment specifically designed to do what you want to do (text-based RPG, RogueLike etc.) that's been developed for over 25 years. It's also great if you want to just learn general object programming (and LPC is an awesome language and Pike that derived from it is likewise amazing).
Time is precious. Waste it wisely.
3FFA
Profile Blog Joined February 2010
United States3931 Posts
November 24 2013 20:14 GMT
#7970
On November 25 2013 03:57 Manit0u wrote:
Show nested quote +
On November 24 2013 23:31 3FFA wrote:
Hehe thanks again slug.

Yeah I'm probably not going to be learning MUDlib. Never even heard of it until Manit0u's post.


I only suggested checking it out to see how it's being done there since it's way more efficient way of doing what you want to do than using arrays. Slug's Ruby suggestion is basically the same concept, I used MUDlib as an example since it's an environment specifically designed to do what you want to do (text-based RPG, RogueLike etc.) that's been developed for over 25 years. It's also great if you want to just learn general object programming (and LPC is an awesome language and Pike that derived from it is likewise amazing).

Could you please stop? I understand that you love that language but I would rather prepare myself for taking a CS degree in college than learning about a language that I actually have 0 idea as to its worth except for the fact that I've never actually heard of it before.

I will note that I am planning to learn at least the basics of a few languages in the near future although it will probably take 3 or so years to learn as much as I want about these various languages while also doing my school work. Languages I am curious about learning in the near future(Not right now, probably in the Summer when I have less on my plate) are:
C++
C#
Perl
Python
Ruby/Ruby-on-Rails

One thing I would like feedback on is what order do you think I should learn the above? I've learned basics of C, Objective C, and (bare basics so far, taking another class next year to get more advanced) Java.

Another thing I would like to know is what exactly are the differences between the various C's? Is there specific purposes/situations each is better for?
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
bangsholt
Profile Joined June 2011
Denmark138 Posts
November 24 2013 20:55 GMT
#7971
Decide on a project to do. Then decide on a language. Then DO IT.

Project list -> http://www.dreamincode.net/forums/topic/78802-martyr2s-mega-project-ideas-list/

Now get going
Manit0u
Profile Blog Joined August 2004
Poland17490 Posts
Last Edited: 2013-11-24 21:19:58
November 24 2013 21:17 GMT
#7972
On November 25 2013 05:14 3FFA wrote:
Show nested quote +
On November 25 2013 03:57 Manit0u wrote:
On November 24 2013 23:31 3FFA wrote:
Hehe thanks again slug.

Yeah I'm probably not going to be learning MUDlib. Never even heard of it until Manit0u's post.


I only suggested checking it out to see how it's being done there since it's way more efficient way of doing what you want to do than using arrays. Slug's Ruby suggestion is basically the same concept, I used MUDlib as an example since it's an environment specifically designed to do what you want to do (text-based RPG, RogueLike etc.) that's been developed for over 25 years. It's also great if you want to just learn general object programming (and LPC is an awesome language and Pike that derived from it is likewise amazing).

Could you please stop? I understand that you love that language but I would rather prepare myself for taking a CS degree in college than learning about a language that I actually have 0 idea as to its worth except for the fact that I've never actually heard of it before.

I will note that I am planning to learn at least the basics of a few languages in the near future although it will probably take 3 or so years to learn as much as I want about these various languages while also doing my school work. Languages I am curious about learning in the near future(Not right now, probably in the Summer when I have less on my plate) are:
C++
C#
Perl
Python
Ruby/Ruby-on-Rails

One thing I would like feedback on is what order do you think I should learn the above? I've learned basics of C, Objective C, and (bare basics so far, taking another class next year to get more advanced) Java.

Another thing I would like to know is what exactly are the differences between the various C's? Is there specific purposes/situations each is better for?


I do love the language even though I don't do anything in it any more (just from time to time). LPC is basically C++ but everything there is an object rather than a class.

What you want to start with doesn't matter that much. I've seen people start with C++ then go to Java then C# and then to something else entirely (switch job -> switch language). When you get the basic programming concepts down it doesn't really matter that much what language you learn (what matters is if it's oop, structural etc.) because if you learn one you can learn another in a matter of a couple of weeks (as you do exactly the same thing but with a different syntax). <-- this is very simplified answer though.

Personally I'd pick C++/C# first since it's easy to transition from them to many others. Python will teach you some consistency, code formatting and overall good practices (except braces, braces are important ). Just pick one, learn it until you're good in it and it'll be a simple matter to transition to other languages if you need to.

Differences between C-language family:
Time is precious. Waste it wisely.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
November 24 2013 22:44 GMT
#7973
On November 25 2013 05:14 3FFA wrote:
Show nested quote +
On November 25 2013 03:57 Manit0u wrote:
On November 24 2013 23:31 3FFA wrote:
Hehe thanks again slug.

Yeah I'm probably not going to be learning MUDlib. Never even heard of it until Manit0u's post.


I only suggested checking it out to see how it's being done there since it's way more efficient way of doing what you want to do than using arrays. Slug's Ruby suggestion is basically the same concept, I used MUDlib as an example since it's an environment specifically designed to do what you want to do (text-based RPG, RogueLike etc.) that's been developed for over 25 years. It's also great if you want to just learn general object programming (and LPC is an awesome language and Pike that derived from it is likewise amazing).

Could you please stop? I understand that you love that language but I would rather prepare myself for taking a CS degree in college than learning about a language that I actually have 0 idea as to its worth except for the fact that I've never actually heard of it before.

I will note that I am planning to learn at least the basics of a few languages in the near future although it will probably take 3 or so years to learn as much as I want about these various languages while also doing my school work. Languages I am curious about learning in the near future(Not right now, probably in the Summer when I have less on my plate) are:
C++
C#
Perl
Python
Ruby/Ruby-on-Rails

One thing I would like feedback on is what order do you think I should learn the above? I've learned basics of C, Objective C, and (bare basics so far, taking another class next year to get more advanced) Java.

Another thing I would like to know is what exactly are the differences between the various C's? Is there specific purposes/situations each is better for?


The different Cs are basically completely different and only related in name and some syntax elements, not in the actual use.

C is the oldest of the bunch and a purely procedural language. It has no objects, very bare-bones memory management but a huge amount of libraries to use. It's a very rough language to work in since it doesn't have any of the built-in magic that modern languages have, so you usually need to write a lot more code to do the same task but you gain more control about it, which is why some people advocate towards learning it first. I'm of a different opinion, but it's still a valid point of view.

C++ is the object oriented enhancement of C. It's built on top of C, so most C code compiles fine in a C++ compiler, though there are some differences, e.g. NULL pointers and the like that can lead to unexpected behavior. It has slightly more advanced memory management with new/delete, it can use C libraries natively and is basically the ideological foundation for all modern object oriented languages. I haven't used the C++11 standard yet, which added a ton of modern features like lambda functions or convenience elements like initializer lists. C++ is often criticized for the choice of allowing multiple inheritance, meaning one class can inherit from multiple other classes instead of just the one that java and other modern OO languages allow, which can sometimes lead to very messy code and architecture. It's language design also allows for object templates, which are very similar to generics in C#/Java but a lot more powerful, leading to template metaprogramming which is useful at times but can lead to even messier code and should generally avoided unless it's really, really neccessary. However, while both those language elements, i.e. multiple inheritance and template metaprogramming, can lead to poor code and program architecture, they are also powerful tools if used correctly. However, a last problem with C++ is the problematic portability. Microsoft had enhanced the language with their own features, which lead to some syntactical differences between ISO C++ and Visual C++, making them essentially incompatible dialects of the same language. However, C++ is a mix between the control (and as such also performance) of C and the more rapid development on modern languages and as such definitely is of use.

C# has nothing to do with either of those languages, meaning it's code is completely incompatible. It's Microsofts vision of modern language and personally it's the one thing Microsoft did that made me forgive them for Windows 95, ME and Vista - i'm still on the fence about Windows 8. It abandoned all procedural parts of the C language and is a fully object oriented language similar to Java, which might be it's closest rival and if you come from a Java background, learning C# will be a relatively easy transition. Together with the extensive .NET framework, it's very fast and easy to develop applications in it, though at the cost of all the fine control you had in C and C++. It also doesn't compile down to machine code but instead - like Java - to intermediate code that then gets interpreted at execution time, which adds binary portability but costs some performance. Personally it's my by far favorite language, probably the best thing Microsoft ever created. I don't have to care about the behind the scenes stuff, it just works and everytime i have a problem, there is a library in the .NET framework that solves it. If you want to port programs over to linux, the mono project does such a great job that for deploying my last project, which was a multithreaded game server with a built-in webserver (which .NET provides), was as simple as copying over the .exe and running "mono Server.exe". However, as i said, you lose control over the finer parts of your program and performance wise it feels faster than Java but still slower than C++ or C. I still would recommend learning it first if you want to do application and not web development. Stay away from ASP.NET, it sucks. Visual Studio Express C# is also a nice IDE, far superior to Eclipse, which makes learning it really easy.

Perl was 15 years ago as advanced as PHP is slowly becoming now. It was the language i started my professional career with and it's still close to my heart. However, it has a very complex syntax which, when not properly used, can lead to very hard to read code, which is the source for the "Perl is a write-only language" joke. It's possible to write clear code in Perl, it's just harder than in PHP or even Python. Perls CPAN archive is like Microsofts .NET, for every problem there is a library in it. However, Perl is basically only used by administrators these days, in almost all other languages it has been replaced by PHP or Java/C#. I would not recommend learning it, eventhough i still think it's one of the best languages available. It's lack of use basically means there is no incentive to actually use it after learning it.

I can't say much about Python and Ruby since i haven't gotten around to learning them yet.

So in summary, my personal recommendation would be:
1. C# since it makes learning fast and fun instead of bothering you with details.
2. Java since that is where the job market is. I don't like Java but a lot of companies do, so you should still learn it.
3. PHP since that is also where the job market is. Most of the web development is done in PHP and most of the programming these days moves towards the web instead of applications, so it's good to know it.
4. Javascript since that is the standard of scripting languages, not just for browsers. It integrates with other languages and allows you to provide moddable frameworks more easily.
5. Python/Ruby since, well, might as well learn them then.
6. C++ since you learn how all those things you learned about actually work behind the scenes.
7. C since you learn how all those things you learned about actually work even further behind the scenes.
Cyx.
Profile Joined November 2010
Canada806 Posts
November 24 2013 22:56 GMT
#7974
On November 25 2013 07:44 Morfildur wrote:

I can't say much about Python and Ruby since i haven't gotten around to learning them yet.

So in summary, my personal recommendation would be:
1. C# since it makes learning fast and fun instead of bothering you with details.
2. Java since that is where the job market is. I don't like Java but a lot of companies do, so you should still learn it.
3. PHP since that is also where the job market is. Most of the web development is done in PHP and most of the programming these days moves towards the web instead of applications, so it's good to know it.
4. Javascript since that is the standard of scripting languages, not just for browsers. It integrates with other languages and allows you to provide moddable frameworks more easily.
5. Python/Ruby since, well, might as well learn them then.
6. C++ since you learn how all those things you learned about actually work behind the scenes.
7. C since you learn how all those things you learned about actually work even further behind the scenes.


Pretty solid post overall, just wanted to add - I really like the order of this post but I might start with Python instead ^^ you said you hadn't used Python at all so I figured someone should probably say something about it.

As far as learning goes, Python is awesome for all the same reasons as C#, except that it doesn't FORCE you to start learning about classes IMMEDIATELY. You can still write classes in Python (and probably should if you're writing something big!) but as far as learning goes, I've always felt like starting with Java or C# or one of those languages that really makes you write OOP is a little counterintuitive.

I'm teaching my girlfriend how to program in Python right now, and she's spent a solid couple months playing around with things without ever even knowing what a class is - and that's totally fine for learning, and I even think it lets her focus on the more important things, like 'how do I write a loop' or 'how do I define a function' without worrying about how it fits into proper OOP design.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 25 2013 01:50 GMT
#7975
On November 25 2013 02:04 Arnstein wrote:
Today I found some code with a void (*callback) function. What's that? How do they work? I can't seem to find anything relevant by googling!


Google "C++ callbacks"! :D
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 25 2013 02:03 GMT
#7976
On November 25 2013 05:14 3FFA wrote:
Show nested quote +
On November 25 2013 03:57 Manit0u wrote:
On November 24 2013 23:31 3FFA wrote:
Hehe thanks again slug.

Yeah I'm probably not going to be learning MUDlib. Never even heard of it until Manit0u's post.


I only suggested checking it out to see how it's being done there since it's way more efficient way of doing what you want to do than using arrays. Slug's Ruby suggestion is basically the same concept, I used MUDlib as an example since it's an environment specifically designed to do what you want to do (text-based RPG, RogueLike etc.) that's been developed for over 25 years. It's also great if you want to just learn general object programming (and LPC is an awesome language and Pike that derived from it is likewise amazing).

Could you please stop? I understand that you love that language but I would rather prepare myself for taking a CS degree in college than learning about a language that I actually have 0 idea as to its worth except for the fact that I've never actually heard of it before.

I will note that I am planning to learn at least the basics of a few languages in the near future although it will probably take 3 or so years to learn as much as I want about these various languages while also doing my school work. Languages I am curious about learning in the near future(Not right now, probably in the Summer when I have less on my plate) are:
C++
C#
Perl
Python
Ruby/Ruby-on-Rails

One thing I would like feedback on is what order do you think I should learn the above? I've learned basics of C, Objective C, and (bare basics so far, taking another class next year to get more advanced) Java.

Another thing I would like to know is what exactly are the differences between the various C's? Is there specific purposes/situations each is better for?


Haha ouch :<

The most important thing is to learn the paradigms not the language. This is because you can know all the syntax in the world, but if you don't have the right mindset you will struggle very hard to wrap your head around how to actually code non-trivial things.

C++ = Structured programming paradigm, Object Oriented paradigm
C# = Fully OO
Perl = Functional programming
Python = Functional
Ruby = OO and functional

I'm saying this from experience, I spent a good year on Java writing terrible code but knowing how to do weird crap, and then I read 10+ books on OO in 6 months and suddenly I knew how to code 10x better and faster even though I didn't learn anything more about Java.

I would also recommend fully grasping the structured programming paradigm before moving to OO. This is because you still need to understand the processes of abstraction and functional decomposition doing OO.

You can spend a whole year going through the great tome on Java and still know next to nothing bar weird Java idioms, or you can read books on responsibility driven design and object oriented programming and actually learn how to write good Java code.

I mean its probably best to do both, but if I had to choose one or the other, or prioritise one or the other, it would be read books on the paradigm itself.

To answer your question though it really doesn't matter which one you learn as long as you understand how to program to-the-metal somewhat, so IMO its always best to start in C or Pascal.

There's nothing more embarrassing than seeing a Java programmer not understand how to manage memory "because he doesn't have to", only to see his program's memory leak more than Edward Snowden.

That's pretty much the minimal I'd say, understand pointers, references and dynamic memory allocation and after that I don't really care what anyone does.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 25 2013 03:15 GMT
#7977
Hello Teamliquid. I'd like help with part of an app I'm working on in Eclipse's ADT in Java. I've searched a lot online and spent a lot of time on this, so any help is awfully appreciated.

The goal is to implement basic file I/O with a text file in order to use it for a login system. The idea is to have a file for each user containing their personal info, which is titled Username+".txt" and have a "Usernames.txt" file that can be quickly searched to determine if a user account exists(so if not then I can reject them and tell them that no account exists, and if it does I can tell them whether they have the right password or not). However, I am partly confused by the method Android does file storage in, and partly by the actual implementation of the file storage.

The questions I have are these:

when I store data on the android phone for the first time, where does this data get stored? I've some file explorers on my phone, but when I search for the file name I can't find anything, so I don't really know where this is.

when I am writing data where should I be placing it? Is the default location okay?

Can it be I stayed away too long? Did you miss these rhymes while I was gone?
3FFA
Profile Blog Joined February 2010
United States3931 Posts
Last Edited: 2013-11-25 03:26:42
November 25 2013 03:24 GMT
#7978
Ok that's great guys! Any books you would recommend Slug? With Christmas coming up…

Thanks Cyx and Morfildir. Very informative and interesting to read. I'll probably take Perl off my to-do list then.

Another question- how different is it to program for web than for applications(like javascript vs java)?
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 25 2013 04:21 GMT
#7979
On November 25 2013 12:24 3FFA wrote:
Ok that's great guys! Any books you would recommend Slug? With Christmas coming up…

Thanks Cyx and Morfildir. Very informative and interesting to read. I'll probably take Perl off my to-do list then.

Another question- how different is it to program for web than for applications(like javascript vs java)?


Very different, the web programming world is much further developed and you will have an easier time developing web-apps than desktop apps especially on the UI side. Its gotten to the point where people have transferred a lot of webapp technology over to desktop/mobile, such as using HTML/CSS/Javascript for desktop apps. A good example is Appcelerator Titanium http://www.appcelerator.com/

As for your daily readings on OO, these are ones I would personally recommend. I have by no means read every single book on programming so I'm sure other people would have different recommendations, but I have read a lot!

In order of usefulness

Wirfs-Brock, R., & McKean, A. (2003). Object Design. Boston: Addison-Wesley. (This one is my favourite, its small, concise and very well written)

Entsminger, G. (1991). The Tao of Objects. Redwood City: M&T Publishing.

Josuttis, N. M. (2003). Object-Oriented Programming in C++. Chichester: John Wiley & Sons, Ltd.

Jacobson, I., Griss, M., & Jonsson, P. (1997). Software Reuse. New York: ACM Press.

Khoshafian, S., & Abnous, R. (1995). Object Orientation Second Edition. New York: Katherine
Schowalter.

For general structured programming I would recommend

http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882

This is also a journal that I wrote for one of my subjects, you might find it useful. This is mainly Java oriented, there are mistakes in some of the sample code that people have pointed out (It was kind of rushed as I had only a few weeks to write it ), I never got around to fixing it Its about 5 years old and I would change a lot but should serve as a decent [free] primer.

http://www.netgore.com/sites/default/files/ObjectOrientedProgramming.pdf
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
November 25 2013 06:15 GMT
#7980
On November 24 2013 09:21 Kambing wrote:
Show nested quote +
On November 24 2013 09:13 Arnstein wrote:
Cygwin has bugged out, so I downloaded gVim Easy to use that instead. But it starts in insert mode, and esc doesn't make you go into command mode. How do I get to command mode?


AFAIK gvim easy comes from the standard windows gvim distribution which includes a raw gvim shortcut. Just use that instead or install the standard gvim distribution from vim.org if that isn't the case.

Alternatively, it seems like ctrl-L is the short to go into command mode: http://superuser.com/questions/353776/executing-commands-in-gvim-easy


I started gVim, and got reminded of why I wanted to use Easy instead: I can't fucking backspace in the normal gVim on Windows! Is this a normal problem? Sometimes it works 2-3 times, but normally I just get that annoying Windows "you-can't-do-this"-sound.
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Prev 1 397 398 399 400 401 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 6h 17m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 215
RuFF_SC2 198
SortOf 77
trigger 2
StarCraft: Brood War
actioN 374
PianO 123
Noble 45
Icarus 9
NotJumperer 8
Dota 2
monkeys_forever560
XaKoH 229
League of Legends
JimRising 724
Counter-Strike
Coldzera 1537
Other Games
summit1g14383
WinterStarcraft534
C9.Mang0344
Organizations
Other Games
gamesdonequick980
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Hupsaiya 98
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Diggity6
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1140
• Stunt451
Upcoming Events
Wardi Open
6h 17m
StarCraft2.fi
11h 17m
Replay Cast
18h 17m
The PondCast
1d 4h
OSC
1d 10h
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 18h
Korean StarCraft League
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ]
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
OSC
4 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
5 days
StarCraft2.fi
6 days
PiGosaur Monday
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.