• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 12:48
CEST 18:48
KST 01:48
  • 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
Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12TL.net Map Contest #22 - Voting & Ladder Map Selection7Code S Season 2 (2026) - RO8 Preview7[ASL21] Finals Preview: Two Legacies21
Community News
Weekly Cups (June 8-14): Clem and Solar double, PTR tested0RSL: S6 Finals played at BlizzCon 202611Douyu Cup 2026: $20,000 Legends Event (June 26-28)10[BSL22] Non-Korean Championship from 13 to 28 June4Weekly Cups (May 25-31): Clem doubles, 2v2 circuit heads toward finale0
StarCraft 2
General
Daily SC2 Player Grid - feedback wanted TL Poll: How do you feel about the 5.0.16 PTR balance changes? Code S Season 2 (2026) - RO8 Preview Updates to The Core/Core Lite for v5.0.16? RSL: S6 Finals played at BlizzCon 2026
Tourneys
GSL CK #4 20-21th June Crank Gathers Season 4: BW vs SC2 Team League Douyu Cup 2026: $20,000 Legends Event (June 26-28) Maestros of The Game 2 announcement and schedule ! Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[G] Having the right mentality to improve
Custom Maps
Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
Mutation # 530 One For All The PondCast: SC2 News & Results Mutation # 529 Opportunities Unleashed Mutation # 528 Infection Detected
Brood War
General
BW General Discussion vespene.gg — BW replays in browser Where is EffOrt? BGH Auto Balance -> http://bghmmr.eu/ Quality of life changes in BW that you will like ?
Tourneys
[Megathread] Daily Proleagues [ASL21] Grand Finals [BSL22] Grand Finals - Sunday 21:00 CEST Escore Tournament StarCraft Season 2
Strategy
Simple Questions, Simple Answers Relatively freeroll strategies Creating a full chart of Zerg builds Why doesn't anyone use restoration?
Other Games
General Games
ZeroSpace Megathread Stormgate/Frost Giant Megathread Nintendo Switch Thread Beyond All Reason Total War: Warhammer 40K
Dota 2
Looking for a Dota Mentor 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
TL Mafia
Vanilla Mini Mafia
Community
General
The Games Industry And ATVI US Politics Mega-thread UK Politics Mega-thread Russo-Ukrainian War Thread [H]Internet/Gaming Cafe Tips and Tricks
Fan Clubs
The HerO Fan Club! The herO Fan Club!
Media & Entertainment
Movie Discussion! [Req][Books] Good Fantasy/SciFi books [TV/BOOK] *SPOILERS* Game of Thrones Discussion [Manga] One Piece
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion Cricket [SPORT] NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Facing Challenges in Mobile App Development
TL Community
The Automated Ban List
Blogs
Does Workplace Frustration D…
TrAiDoS
An Exploration of th…
waywardstrategy
I'm an arrogant trash talke…
FlaShFTW
Gauntlet SC2: A Retrospectiv…
Ctone23
Why RTS gamers make better f…
gosubay
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7325 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
Poland17768 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
Hyrule19221 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
Poland17768 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
Spain18317 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 12m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Serral 2231
trigger 110
BRAT_OK 70
SHIN 49
RushiSC 42
CosmosSc2 40
MindelVK 11
StarCraft: Brood War
Shuttle 2290
Mini 1391
Sea 1197
Horang2 684
Soulkey 642
EffOrt 597
Light 407
BeSt 377
ggaemo 315
Snow 188
[ Show more ]
hero 183
Sharp 118
sorry 61
Aegong 30
Free 27
Rock 24
910 22
Terrorterran 19
Sacsri 17
GoRush 13
ajuk12(nOOB) 9
soO 9
IntoTheRainbow 9
Dota 2
qojqva2319
Counter-Strike
fl0m1873
byalli381
Super Smash Bros
Mew2King85
Other Games
Grubby2361
hiko750
B2W.Neo741
Dendi654
ceh9378
DeMusliM288
Beastyqt288
KnowMe173
XaKoH 145
C9.Mang0127
ArmadaUGS107
QueenE57
Trikslyr43
Dewaltoss27
Organizations
Dota 2
PGL Dota 2 - Main Stream3310
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• poizon28 25
• Kozan
• Migwel
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• HerbMon 5
• FirePhoenix4
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• lizZardDota2165
League of Legends
• TFBlade828
Other Games
• Shiphtur177
• tFFMrPink 16
Upcoming Events
The PondCast
17h 12m
WardiTV Spring Champion…
18h 12m
OSC
20h 12m
OSC
1d 7h
CranKy Ducklings
1d 17h
WardiTV Spring Champion…
1d 18h
WardiTV Spring Champion…
2 days
GSL
2 days
Maru vs ShoWTimE
Classic vs Reynor
herO vs Lambo
Solar vs Clem
BSL22 NKC (BSL vs China)
3 days
XuanXuan vs Jaystar
Mihu vs Messiah
eOnzErG vs Dewalt
Bonyth vs Jaystar
TerrOr vs Messiah
XuanXuan vs Mihu
eOnzErG vs Jaystar
Replay Cast
3 days
[ Show More ]
WardiTV Spring Champion…
3 days
GSL
3 days
Patches Events
4 days
BSL22 NKC (BSL vs China)
4 days
Dewalt vs Messiah
Bonyth vs Mihu
TerrOr vs XuanXuan
eOnzErG vs Messiah
Jaystar vs Mihu
Dewalt vs XuanXuan
Bonyth vs TerrOr
Replay Cast
4 days
WardiTV Weekly
4 days
Sparkling Tuna Cup
5 days
Liquipedia Results

Completed

Proleague 2026-06-16
uThermal 2v2 2026 Main Event
Heroes Pulsing #1

Ongoing

IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
CSCL: Masked Kings S4
YSL S3
BSL 22 Non-Korean Championship
SCTL 2026 Spring
Maestros of the Game 2
WardiTV Spring 2026
Murky Cup 2026
Heroes Pulsing #2
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1

Upcoming

CSL 2026 Summer (S21)
CSLAN 4
Blizzard Classic Cup 2026
Kung Fu Cup 2026 Grand Finals
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
HSC XXIX
Douyu Cup 2026
BCC 2026
Heroes Pulsing #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
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.