• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 13:15
CET 19:15
KST 03:15
  • 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 - 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[ASL20] Finals Preview: Arrival13
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation12Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
Mech is the composition that needs teleportation t RotterdaM "Serral is the GOAT, and it's not close" RSL Season 3 - RO16 Groups C & D Preview [TLMC] Fall/Winter 2025 Ladder Map Rotation TL.net Map Contest #21: Winners
Tourneys
RSL Revival: Season 3 Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle What happened to TvZ on Retro? SnOw's ASL S20 Finals Review BW General Discussion Brood War web app to calculate unit interactions
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET
Strategy
PvZ map balance Current Meta Simple Questions, Simple Answers How to stay on top of macro?
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread Clair Obscur - Expedition 33 Beyond All Reason
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread Artificial Intelligence Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2038 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
Poland17433 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
Hyrule19152 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
Poland17433 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
Spain18117 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
IPSL
17:00
Ro16 Group D
ZZZero vs rasowy
Napoleon vs KameZerg
Liquipedia
PSISTORM Gaming Misc
15:55
FSL teamleague CNvsASH, ASHvRR
Freeedom33
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Railgan 184
IndyStarCraft 110
BRAT_OK 47
MindelVK 29
EmSc Tv 13
StarCraft: Brood War
Britney 25290
Calm 2532
Shuttle 775
Stork 341
firebathero 288
Dewaltoss 113
Barracks 68
Mong 61
Rock 43
Shine 18
Dota 2
Gorgc5830
qojqva1713
Dendi963
Counter-Strike
ScreaM1084
byalli378
Heroes of the Storm
Khaldor535
Liquid`Hasu237
Other Games
Beastyqt573
DeMusliM291
Hui .222
Fuzer 215
Lowko213
Trikslyr46
CadenZie18
Organizations
Dota 2
PGL Dota 2 - Main Stream8971
Other Games
EGCTV625
gamesdonequick359
StarCraft 2
angryscii 24
EmSc Tv 13
EmSc2Tv 13
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• HappyZerGling 71
• HeavenSC 61
• printf 5
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• Kozan
• IndyKCrew
StarCraft: Brood War
• Airneanach42
• HerbMon 6
• Michael_bg 3
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2455
• WagamamaTV359
• Ler79
League of Legends
• Nemesis2825
Other Games
• imaqtpie1125
• Shiphtur313
Upcoming Events
OSC
45m
davetesta15
BSL 21
1h 45m
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
15h 45m
RSL Revival
15h 45m
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
17h 45m
Cure vs herO
Reynor vs TBD
WardiTV Korean Royale
17h 45m
BSL 21
1d 1h
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
1d 1h
Dewalt vs WolFix
eOnzErG vs Bonyth
Replay Cast
1d 4h
Wardi Open
1d 17h
[ Show More ]
Monday Night Weeklies
1d 22h
WardiTV Korean Royale
2 days
BSL: GosuLeague
3 days
The PondCast
3 days
Replay Cast
4 days
RSL Revival
4 days
BSL: GosuLeague
5 days
RSL Revival
5 days
WardiTV Korean Royale
5 days
RSL Revival
6 days
WardiTV Korean Royale
6 days
IPSL
6 days
Julia vs Artosis
JDConan vs DragOn
Liquipedia Results

Completed

Proleague 2025-11-14
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
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
BLAST Open Fall 2025

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 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...

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.