• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:42
CEST 11:42
KST 18:42
  • 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 TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
BSL 2025 Warsaw LAN + Legends Showmatch0Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Soulkey on ASL S20 ASL TICKET LIVE help! :D BW General Discussion NaDa's Body A cwal.gg Extension - Easily keep track of anyone
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues BSL 2025 Warsaw LAN + Legends Showmatch
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Borderlands 3 General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1577 users

The Big Programming Thread - Page 679

Forum Index > General Forum
Post a Reply
Prev 1 677 678 679 680 681 1031 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
Poland17341 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
Hyrule19087 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
Poland17341 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
Spain18050 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 18m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Rex 2
StarCraft: Brood War
Calm 5699
Bisu 731
Hyuk 162
HiyA 96
Hyun 96
sorry 86
ToSsGirL 84
Dewaltoss 82
Pusan 77
Light 74
[ Show more ]
Soma 60
actioN 56
Mini 49
ZerO 32
BeSt 30
Nal_rA 28
soO 27
Liquid`Ret 26
Sharp 24
Rush 19
Free 16
SilentControl 10
Dota 2
singsing1508
XcaliburYe237
boxi98170
League of Legends
JimRising 381
Counter-Strike
olofmeister1583
shoxiejesuss629
allub166
Other Games
XaKoH 143
NeuroSwarm75
Trikslyr15
Organizations
Other Games
gamesdonequick599
StarCraft: Brood War
lovetv 593
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1421
• Stunt679
Other Games
• WagamamaTV81
Upcoming Events
RSL Revival
18m
Maru vs Reynor
Cure vs TriGGeR
Rex2
Map Test Tournament
1h 18m
The PondCast
3h 18m
RSL Revival
1d
Zoun vs Classic
Korean StarCraft League
1d 17h
BSL Open LAN 2025 - War…
1d 22h
RSL Revival
2 days
BSL Open LAN 2025 - War…
2 days
RSL Revival
3 days
Online Event
3 days
[ Show More ]
Wardi Open
4 days
Monday Night Weeklies
4 days
Sparkling Tuna Cup
5 days
LiuLi Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.