• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 02:58
CET 08:58
KST 16:58
  • 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
ByuL: The Forgotten Master of ZvT28Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Team Liquid Map Contest - Preparation Notice0Weekly Cups (Feb 23-Mar 1): herO doubles, 2v2 bonanza1Weekly Cups (Feb 16-22): MaxPax doubles0Weekly Cups (Feb 9-15): herO doubles up2ACS replaced by "ASL Season Open" - Starts 21/0258
StarCraft 2
General
Nexon's StarCraft game could be FPS, led by UMS maker How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Team Liquid Map Contest - Preparation Notice Weekly Cups (Feb 23-Mar 1): herO doubles, 2v2 bonanza Terran AddOns placement
Tourneys
https://www.facebook.com/Nail.Refresh.Official/ RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) Sparkling Tuna Cup - Weekly Open Tournament SEL Doubles (SC Evo Bimonthly)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 515 Together Forever Mutation # 514 Ulnar New Year Mutation # 513 Attrition Warfare
Brood War
General
It's March 3rd CasterMuse Youtube Recent recommended BW games Soma Explains: JD's Unrelenting Aggro vs FlaSh TvZ is the most complete match up
Tourneys
[Megathread] Daily Proleagues BWCL Season 64 Announcement The Casual Games of the Week Thread [LIVE] [S:21] ASL Season Open Day 1
Strategy
Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Simple Questions, Simple Answers Zealot bombing is no longer popular?
Other Games
General Games
Battle Aces/David Kim RTS Megathread Nintendo Switch Thread Diablo 2 thread Path of Exile Online Quake Live Config Editor Tool
Dota 2
The Story of Wings Gaming 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 Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread UK Politics Mega-thread NASA and the Private Sector Things Aren’t Peaceful in Palestine
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Just Watchers: Why Some Only…
TrAiDoS
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2239 users

The Big Programming Thread - Page 679

Forum Index > General Forum
Post a Reply
Prev 1 677 678 679 680 681 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.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 18 2015 19:14 GMT
#13561
Si, senor. That's surprising. I was under the impression the large majority of SEs used C or C++.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-11-18 19:50:01
November 18 2015 19:48 GMT
#13562
Well, the reason schools like teaching C is because it teaches you a lot about memory management the hard way, and it's also really good at teaching you about data structures. My school used C as well.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 18 2015 22:31 GMT
#13563
On November 19 2015 04:14 WarSame wrote:
Si, senor. That's surprising. I was under the impression the large majority of SEs used C or C++.

I suggest you look through a bunch of job offers of employers in your region and/or employers you'd like to work for and find out what languages they are hiring for. Job offers in the future (when you actually apply for one) might not ask for the same languages anymore, but there will always be an old code base that at least needs to be maintained.
If you have a good reason to disagree with the above, please tell me. Thank you.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 18 2015 22:51 GMT
#13564
In my area it's all Java/C#/Web Suite. Those are more of software development jobs vs. actual SE though.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Cyx.
Profile Joined November 2010
Canada806 Posts
November 19 2015 02:49 GMT
#13565
On November 18 2015 17:30 Manit0u wrote:
Nice. Just out of curiosity, was my answer to him any good? I'd like for someone obviously more knowledgeable in C than me to give a comment on this little monster I've created. I really need to work my C-foo back up a bit

http://www.teamliquid.net/forum/general/134491-the-big-programming-thread?page=677#13538

Well, I'll bite :D the only thing that's a little tricky in this is the Counters_{create,destroy} functions, and in my opinion using those at all here is a major no-no. You don't need to allocate the struct Counters on the heap, you're destroying it right away anyways - let the compiler do the work for you, put it on the stack. Then pass &counters to all Counters_test_* functions instead of counters.

Also, your naming is pretty damn weird in my experience C programmers tend to pick either PascalCase or snake_case (pretty infrequently camelCase) but either way, pick one and stick with it lol
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-11-19 08:06:57
November 19 2015 08:04 GMT
#13566
On November 19 2015 11:49 Cyx. wrote:
Show nested quote +
On November 18 2015 17:30 Manit0u wrote:
Nice. Just out of curiosity, was my answer to him any good? I'd like for someone obviously more knowledgeable in C than me to give a comment on this little monster I've created. I really need to work my C-foo back up a bit

http://www.teamliquid.net/forum/general/134491-the-big-programming-thread?page=677#13538

Well, I'll bite :D the only thing that's a little tricky in this is the Counters_{create,destroy} functions, and in my opinion using those at all here is a major no-no. You don't need to allocate the struct Counters on the heap, you're destroying it right away anyways - let the compiler do the work for you, put it on the stack. Then pass &counters to all Counters_test_* functions instead of counters.

Also, your naming is pretty damn weird in my experience C programmers tend to pick either PascalCase or snake_case (pretty infrequently camelCase) but either way, pick one and stick with it lol

The function names would throw me off a bit if I was reading that. The function is called test but it also increments a pointer value rather than returning anything. Also yeah, I'm working in C but I like the advice given. The only thing I'd change is wrapping the second code in an inc_time() function.
Manit0u
Profile Blog Joined August 2004
Poland17682 Posts
November 19 2015 10:53 GMT
#13567
Heh, it's been a while since I did anything in C. I guess I'm too sullied by OOP now
Time is precious. Waste it wisely.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
November 19 2015 13:00 GMT
#13568
On November 19 2015 07:31 spinesheath wrote:
Show nested quote +
On November 19 2015 04:14 WarSame wrote:
Si, senor. That's surprising. I was under the impression the large majority of SEs used C or C++.

I suggest you look through a bunch of job offers of employers in your region and/or employers you'd like to work for and find out what languages they are hiring for. Job offers in the future (when you actually apply for one) might not ask for the same languages anymore, but there will always be an old code base that at least needs to be maintained.


That is definitely true. On the other hand, maintaining legacy code is hell. Fixing code you wrote 6 month ago yourself is already terrible, fixing code others wrote 6 years ago can kill you.
tofucake
Profile Blog Joined October 2009
Hyrule19193 Posts
November 19 2015 15:11 GMT
#13569
My codebase is 24 years old :D
Liquipediaasante sana squash banana
Manit0u
Profile Blog Joined August 2004
Poland17682 Posts
November 19 2015 15:45 GMT
#13570
We have one developer who's working with Delphi. Part of the reason he got hired
Time is precious. Waste it wisely.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 19 2015 17:42 GMT
#13571
On November 19 2015 22:00 Morfildur wrote:
Show nested quote +
On November 19 2015 07:31 spinesheath wrote:
On November 19 2015 04:14 WarSame wrote:
Si, senor. That's surprising. I was under the impression the large majority of SEs used C or C++.

I suggest you look through a bunch of job offers of employers in your region and/or employers you'd like to work for and find out what languages they are hiring for. Job offers in the future (when you actually apply for one) might not ask for the same languages anymore, but there will always be an old code base that at least needs to be maintained.


That is definitely true. On the other hand, maintaining legacy code is hell. Fixing code you wrote 6 month ago yourself is already terrible, fixing code others wrote 6 years ago can kill you.

It's rare to get a job where you don't have to work with old code in one way or another. Better accept that possibilty and be prepared for it than ignoring it.
If you have a good reason to disagree with the above, please tell me. Thank you.
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-11-19 17:52:38
November 19 2015 17:47 GMT
#13572
Am I the only one who actually enjoys refactoring code? Every time I refactor my own code it feels like I just lost 100 pounds. It does suck tho when it's just completely fucked up from the core and it's better to just rewrite it.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 19 2015 17:56 GMT
#13573
On November 20 2015 02:47 Itsmedudeman wrote:
Am I the only one who actually enjoys refactoring code? Every time I refactor my own code it feels like I just lost 100 pounds of weight. It does suck tho when it's just completely fucked up from the core and it's better to just rewrite it.

I actually do like refactoring if I get the time to do it properly. Sadly that's usually not the case because stuff needs to get done.
Rewriting legacy code (that is in use) from scratch is usually a bad idea beacuse by the time you're done rewriting you'll be faced with a huge amount of incompatabilities that stem from bugs in the legacy code (that have been worked around) AND your own code. It's better to develop a plan how to refactor the legacy code in small steps and then do those one by one.
If you have a good reason to disagree with the above, please tell me. Thank you.
Nemphis
Profile Joined August 2011
Belgium1 Post
November 19 2015 21:05 GMT
#13574
On November 17 2015 05:46 tofucake wrote:
Show nested quote +
On November 17 2015 05:06 WarSame wrote:
What are your opinions on the best Javascript IDE? Writing it normally is kinda painful. I tried WebStorm and it looked good but it costs money. What are good free options?

At my company devs use a mix of Sublime (me and another guy), Atom (one guy), and something else (other guy on a different project). I personally love Sublime, and you can get some extensions to make autocompletes and code-aware upgrades.


I personally really like atom, but if you want an editor for web-based stuff, you could give brackets a try.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
November 19 2015 22:26 GMT
#13575
On November 18 2015 22:35 Faust852 wrote:

I was wondering, should I take a Client-Server type of approach, like the Server side is handling the Model-Controler type of things, and a second part, the Client, just handling the View and sending request to the Controler on the Server ?

Yes this sounds good


And is the networking part be handled by the Model, or by the Controler ?

All the logic should be handled by controllers, models are just there to hold values.
The harder it becomes, the more you should focus on the basics.
Faust852
Profile Joined February 2012
Luxembourg4004 Posts
November 20 2015 18:09 GMT
#13576
On November 20 2015 07:26 sabas123 wrote:
Show nested quote +
On November 18 2015 22:35 Faust852 wrote:

I was wondering, should I take a Client-Server type of approach, like the Server side is handling the Model-Controler type of things, and a second part, the Client, just handling the View and sending request to the Controler on the Server ?

Yes this sounds good

Show nested quote +

And is the networking part be handled by the Model, or by the Controler ?

All the logic should be handled by controllers, models are just there to hold values.


Thank you
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2015-11-21 00:26:21
November 21 2015 00:24 GMT
#13577
On November 18 2015 17:30 Manit0u wrote:
Show nested quote +
On November 18 2015 11:27 phar wrote:
+ Show Spoiler +

On November 17 2015 18:12 Itsmedudeman wrote:
I meant something that could look like


if(count == 500) {
s++;
if(s > 59) {
m++;
s = 0;
if(m > 59) {
h++;
m = 0;
if(h > 12)
h = 0;
}
}
}

I could probably think of a better example where it just looks unreadable, but you get my point.


In that instance it sounds like you're trying to replicate some timer logic. The answer to that specific domain then is to use a proper library to handle clock state for you, instead of re-inventing the wheel.


Or, if say you're working in embedded C on a microcontroller (having personally written something roughly like that in embedded C before lol), maybe you don't have access to a proper clock library. But you can structure it more cleanly:

int const ticks_per_second = 500;
...
// I don't know how your system is, but might be that one or more of these
// are modified in a volatile context (interrupt, w/e). change as needed
volatile int counter;
volatile int seconds;
volatile int minutes;
volatile int hours;

...

if(counter % ticks_per_second == 0) {
increment_seconds();
}

...

increment_seconds() {
seconds = (seconds + 1) % 60;
if (!seconds) { // I'm lazy shoot me
increment_minutes();
}
}

...
so on and so forth




Now in a better situation you build up a proper time library, which doesn't even keep track of seconds, minutes, hours individually. Just calculate that shit on the fly when you need it:

int const ticks_per_second = 500;
...
// Now we store only counter, and derive everything else.
volatile int counter;

int getSeconds() {
return counter / ticks_per_second;
}

int getMinutes() {
...


Now I realize this doesn't answer your general case, but usually if you get wonky logic you may be able to abstract something out.


Nice. Just out of curiosity, was my answer to him any good? I'd like for someone obviously more knowledgeable in C than me to give a comment on this little monster I've created. I really need to work my C-foo back up a bit

http://www.teamliquid.net/forum/general/134491-the-big-programming-thread?page=677#13538


Sorry I didn't see it earlier. Without more details then yea, generally breaking the incrementing out into smaller readable chunks helps. This isn't really a C-specific concern though, you'd find the same problem in Java, C++, etc. Idk about the other wrappers, my C is too rusty.

I was just pointing out the fact that it looked like embedded timer code, and thus you might not actually need all those variables incremented every time.
Who after all is today speaking about the destruction of the Armenians?
Acrofales
Profile Joined August 2010
Spain18224 Posts
November 21 2015 01:12 GMT
#13578
On November 20 2015 07:26 sabas123 wrote:
Show nested quote +
On November 18 2015 22:35 Faust852 wrote:

I was wondering, should I take a Client-Server type of approach, like the Server side is handling the Model-Controler type of things, and a second part, the Client, just handling the View and sending request to the Controler on the Server ?

Yes this sounds good

Show nested quote +

And is the networking part be handled by the Model, or by the Controler ?

All the logic should be handled by controllers, models are just there to hold values.

In this case I agree, but in general, I would say that your model exists to abstract away from your values. If you store the time in milliseconds, but are only ever interested in whether it is morning, afternoon or night, that is "logic" that your model should do. Your model should provide the appropriate and necessary information. Often that's just passing on values, but it can require computation.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
November 21 2015 23:54 GMT
#13579
Is this an accurate statement:

In Java, an interface is a collection of methods that will be used by any class that implements the interface.
Prillan
Profile Joined August 2011
Sweden350 Posts
November 22 2015 00:01 GMT
#13580
On November 22 2015 08:54 travis wrote:
Is this an accurate statement:

In Java, an interface is a collection of methods that will be used by any class that implements the interface.

You're correct, if you mean "has to be implemented by" instead of "will be used by".

I'd write something like: An interface is a collection of method signatures that has to be implemented in all classes that implement the interface.
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Prev 1 677 678 679 680 681 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 17h 2m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 174
StarCraft: Brood War
Britney 18835
Sea 15428
Calm 8962
GuemChi 1968
Tasteless 305
Hyuk 239
actioN 205
Leta 146
Dewaltoss 84
PianO 74
[ Show more ]
Mong 67
ToSsGirL 47
Pusan 39
Free 27
Backho 18
sSak 18
GoRush 10
910 3
Dota 2
XaKoH 474
NeuroSwarm86
League of Legends
JimRising 573
Counter-Strike
Stewie2K961
m0e_tv625
Super Smash Bros
C9.Mang0353
Other Games
summit1g8304
WinterStarcraft236
Liquid`RaSZi152
Mew2King107
RuFF_SC228
Organizations
Other Games
gamesdonequick799
Counter-Strike
PGL227
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH623
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki11
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo2120
• Stunt664
Upcoming Events
PiGosaur Cup
17h 2m
Replay Cast
1d 1h
Replay Cast
1d 16h
The PondCast
2 days
KCM Race Survival
2 days
WardiTV Winter Champion…
2 days
Replay Cast
2 days
Ultimate Battle
3 days
Light vs ZerO
WardiTV Winter Champion…
3 days
Classic vs Nicoract
herO vs YoungYakov
ByuN vs Gerald
Clem vs Krystianer
Replay Cast
3 days
[ Show More ]
CranKy Ducklings
4 days
WardiTV Winter Champion…
4 days
MaxPax vs Spirit
Bunny vs Rogue
Cure vs SHIN
Solar vs Zoun
Replay Cast
4 days
Sparkling Tuna Cup
5 days
WardiTV Winter Champion…
5 days
Replay Cast
5 days
Replay Cast
6 days
Monday Night Weeklies
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-03-02
PiG Sty Festival 7.0
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
Spring Cup 2026
WardiTV Winter 2026
Nations Cup 2026
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025

Upcoming

ASL Season 21: Qualifier #1
ASL Season 21: Qualifier #2
ASL Season 21
Acropolis #4 - TS6
Acropolis #4
IPSL Spring 2026
CSLAN 4
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
NationLESS Cup
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
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...

Advertising | Privacy Policy | Terms Of Use | Contact Us

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