• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:46
CEST 20:46
KST 03:46
  • 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
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
Reynor: GSL Loss Wasn't About Preparation Format12[IPSL] Spring 2026 Grand Finals - This Weekend!5Weekly Cups (July 6 - 12): Protoss strike back12BSL Season 22 Full Overview & Conclusion8BSL Season 22 Full Overview & Conclusion8
StarCraft 2
General
5.0.16 patch for SC2 goes live (8 worker start) Is the larve respawn broken? BGE Stara Zagora to be held again in June 2025 Weekly Cups (July 6 - 12): Protoss strike back Serral wins HomeStory Cup 29
Tourneys
WardiTV Summer Cup 2026 GSL CK #5 Race War RSL Revival: Season 6 - Qualifiers and Main Event HomeStory Cup 29 Vespene Cup #1 — $300+ USD, July 10
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together Mutation # 532 Nuclear Family
Brood War
General
Recommended FPV games (post-KeSPA) Pros Debate: Zerg Unfairly Nerfed? (ASL S22 map) BGH Auto Balance -> http://bghmmr.eu/ Etiquete rules in Asl? screpdb: new Starcraft reporting tool
Tourneys
[IPSL] Spring 2026 Grand Finals - This Weekend! Escore Tournament - Season 3 [Megathread] Daily Proleagues [ASL22] Wildcard Qualifier
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Path of Exile Stormgate/Frost Giant Megathread Summer Games Done Quick 2026!
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
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread UK Politics Mega-thread YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion! Series you have seen recently...
Sports
2024 - 2026 Football Thread MLB/Baseball 2023 McBoner: A hockey love story Tennis[sport] Formula 1 Discussion
World Cup 2022
Tech Support
Simple Questions Simple Answers FPS when play League Of Legend on laptop How to clean a TTe Thermaltake keyboard?
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Poker (part 2)
Nebuchad
The Experiences We Want and …
TrAiDoS
An Exploration of th…
waywardstrategy
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8310 users

The Big Programming Thread - Page 396

Forum Index > General Forum
Post a Reply
Prev 1 394 395 396 397 398 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.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
November 18 2013 19:09 GMT
#7901
On November 18 2013 23:32 Manit0u wrote:
For Java I would use NetBeans. Worked much better for me than Eclipse ever did.


Any reasoning behind choosing NetBeans over Eclipse?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2013-11-18 20:19:13
November 18 2013 20:18 GMT
#7902
--- Nuked ---
Yoshi-
Profile Joined October 2008
Germany10227 Posts
November 18 2013 20:25 GMT
#7903
It is pretty much irrelevant whether you use ++i, i++ or i+=1, as a single statement(as in this case), all do exactly the same.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 18 2013 20:25 GMT
#7904
On November 19 2013 04:09 darkness wrote:
Show nested quote +
On November 18 2013 23:32 Manit0u wrote:
For Java I would use NetBeans. Worked much better for me than Eclipse ever did.


Any reasoning behind choosing NetBeans over Eclipse?


Most companies use Eclipse, I haven't been to one that uses Netbeans. Netbeans is much more intuitive IMO but I would lean how to use Eclipse if you plan on doing Java for a living.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Cyx.
Profile Joined November 2010
Canada806 Posts
November 18 2013 20:30 GMT
#7905
On November 19 2013 05:25 Yoshi- wrote:
It is pretty much irrelevant whether you use ++i, i++ or i+=1, as a single statement(as in this case), all do exactly the same.


++i and i += 1 will get translated into the same thing assembly-wise - saying i++ is the same is wrong though, it creates a temporary to hold the return value (pre-incremented i) and thus is slower ^^ it's pretty nitpicky but it's an easy habit to get into to type ++i instead of i++ unless you REALLY need the pre-increment value of i, and it can have some impact on performance of something big if it's in a deeply nested main loop.
Yoshi-
Profile Joined October 2008
Germany10227 Posts
Last Edited: 2013-11-18 20:45:13
November 18 2013 20:37 GMT
#7906
On November 19 2013 05:30 Cyx. wrote:
Show nested quote +
On November 19 2013 05:25 Yoshi- wrote:
It is pretty much irrelevant whether you use ++i, i++ or i+=1, as a single statement(as in this case), all do exactly the same.


++i and i += 1 will get translated into the same thing assembly-wise - saying i++ is the same is wrong though, it creates a temporary to hold the return value (pre-incremented i) and thus is slower ^^ it's pretty nitpicky but it's an easy habit to get into to type ++i instead of i++ unless you REALLY need the pre-increment value of i, and it can have some impact on performance of something big if it's in a deeply nested main loop.

Most of the time that is pretty much irrelevant, and most compilers will most likely realize whether the temporary is actually needed or not.

E: yea just tested it, both create the same assembly code.
bangsholt
Profile Joined June 2011
Denmark138 Posts
Last Edited: 2013-11-18 20:43:38
November 18 2013 20:42 GMT
#7907
On November 19 2013 05:30 Cyx. wrote:
Show nested quote +
On November 19 2013 05:25 Yoshi- wrote:
It is pretty much irrelevant whether you use ++i, i++ or i+=1, as a single statement(as in this case), all do exactly the same.


++i and i += 1 will get translated into the same thing assembly-wise - saying i++ is the same is wrong though, it creates a temporary to hold the return value (pre-incremented i) and thus is slower ^^ it's pretty nitpicky but it's an easy habit to get into to type ++i instead of i++ unless you REALLY need the pre-increment value of i, and it can have some impact on performance of something big if it's in a deeply nested main loop.


Premature optimization much? Also unless you actually *use* the value (which the compiler can statically determine) it won't make any difference

EDIT: What Yoshi- said :D
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-11-18 22:35:53
November 18 2013 20:46 GMT
#7908
On November 18 2013 23:32 Manit0u wrote:
For Java I would use NetBeans. Worked much better for me than Eclipse ever did.

Edit: Also,

Show nested quote +
On November 13 2013 06:57 EscPlan9 wrote:
Really should just initialize the loop variable inside the loops. Cleans up the code a bunch:


#include <stdio.h>

int main()
{
int array[10][10];
int count;

for ( int i = 0; i<10; ++i )
{
for (int j = 0; j<10; ++j )
{
array[i][j] = count;
count++;
}
}

for (int i = 0; i<10; ++i )
{
for (int j = 0; j<10; ++j )
{
printf( "%d", array[i][j] );
printf( " " );
}
printf("\n");

}
}




I don't think you should be using "++i" statements for incrementation in a for loop. I'm of the opinion that they did a great job in Python with eliminating the ++ and -- operators (both pre- and post-) and leaving just += and -=. So much more consistent.


There's a reason Python didn't include increment operators, but its not because of consistency. Its because it messes with mutability, and you can't self assign. In a dynamic language that supports all kinds of overrides this is important.

While in the case of a loop it doesn't matter, understanding the difference between prefix/postfix incremental operators and augmented assignment is kind of important, as they all do different things. You may have a hard time fixing bugs otherwise.

EDIT: Sorry I projected that a bit strongly, consistency [POLS] is a decent side effect of it though I do miss it from time to time.

To explain further, if they said it was for consistency then it has less to do with using it than it does with the actual implementation. Python can't modify an immutable object, so you can override += but you can't override ++ because ++ changes the state of the actual referenced object itself and you can't self assign an immutable object. So it would be the only operator you couldn't override and would behave differently to all other methods, which would be inconsistent.

@EscPlan9 As for cleaning up the code. Use functional decomposition, that's how you make clean code, tinkering with control flow only helps a little bit.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 18 2013 22:04 GMT
#7909
It will pretty much never make a difference, but ++i is strictly superior to i++ unless you explicitly need the behavior of i++. It is as fast or faster and easier to understand as you always know that you get i+1 for all calculations and not i for one and i+1 for another. Therefore it's a good habit to use ++i over i++ if you want either of the two. You might want to use other options though.
If you have a good reason to disagree with the above, please tell me. Thank you.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-11-18 22:20:15
November 18 2013 22:18 GMT
#7910
On November 19 2013 07:04 spinesheath wrote:
It will pretty much never make a difference, but ++i is strictly superior to i++ unless you explicitly need the behavior of i++. It is as fast or faster and easier to understand as you always know that you get i+1 for all calculations and not i for one and i+1 for another. Therefore it's a good habit to use ++i over i++ if you want either of the two. You might want to use other options though.


I agree, though IMHO there should never be any code where the difference between ++i or i++ would cause a problem in your program. (got nothing against what you said, just wanna make a point about the effectiveness of the increment operator)

This would mean that you have two variables that need to be in sync with each other for whatever reason, which seems silly to me.

For example, I don't think there should ever be a time where this is necessary.

i = 1
a = ++i

<use a and i for different things, but the number needs to match>

In a complex business application there would never be a time where you would even want to use the increment operator as using iterators would always be a much cleaner way of doing things.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Cyx.
Profile Joined November 2010
Canada806 Posts
November 18 2013 23:10 GMT
#7911
On November 19 2013 07:04 spinesheath wrote:
It will pretty much never make a difference, but ++i is strictly superior to i++ unless you explicitly need the behavior of i++. It is as fast or faster and easier to understand as you always know that you get i+1 for all calculations and not i for one and i+1 for another. Therefore it's a good habit to use ++i over i++ if you want either of the two. You might want to use other options though.


This is pretty much my point too =) it's not premature optimization in the usual sense because it incurs absolutely no penalty to you when you write it or to people who read it later, in either time or clarity. It's just a good habit to get into. Like I said, pretty nitpicky... but once you've thought about it, why would you ever write the one that has the potential to be slower if there's literally no other difference between the two? Obviously it's not going to make or break anything, but if you don't care about the actual semantic difference, there's just no reason to write i++.
Manit0u
Profile Blog Joined August 2004
Poland17792 Posts
Last Edited: 2013-11-18 23:30:49
November 18 2013 23:28 GMT
#7912
On November 19 2013 05:25 sluggaslamoo wrote:
Show nested quote +
On November 19 2013 04:09 darkness wrote:
On November 18 2013 23:32 Manit0u wrote:
For Java I would use NetBeans. Worked much better for me than Eclipse ever did.


Any reasoning behind choosing NetBeans over Eclipse?


Most companies use Eclipse, I haven't been to one that uses Netbeans. Netbeans is much more intuitive IMO but I would lean how to use Eclipse if you plan on doing Java for a living.


Pretty much this, it was more intuitive and seemed to run smoother and faster overall. It was quite some time ago and I was pretty noob at it so NetBeans' code assist and other features were of great help. Anyway, I remember that doing Java in NetBeans was fun while Eclipse made me feel a bit lost.
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
November 19 2013 01:27 GMT
#7913
Is it generally bad to catch unchecked exceptions? I know it's a problem with the program's logic
phar
Profile Joined August 2011
United States1080 Posts
November 19 2013 01:52 GMT
#7914
There are some places where it's reasonable to catch all exceptions. For example if you have a complicated rpc server, your main entry point may want to catch Exception. That should be immediately followed by loudly logging said exception, probably incrementing bits for monitoring, and definitely returning a failure for your rpc.
Who after all is today speaking about the destruction of the Armenians?
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 19 2013 03:45 GMT
#7915
On November 19 2013 10:27 darkness wrote:
Is it generally bad to catch unchecked exceptions? I know it's a problem with the program's logic


Depends what you want to do with it, generally there should never be a need.

You also want to handle exceptions (in general) in a way that doesn't cause you to have code bloat, and methods spanning a mile long just to handle them.

That is if you're like me and prefer the new jersey style of coding.

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

You will find most inhouse software has no exception handling at all, and libraries will do it in a way that doesn't affect code complexity. If you can do validations or exception handling declaratively then that is a good time to do it, but if you have to put it in the main body of code, I would err on the side of not doing it unless it is super important.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 19 2013 08:24 GMT
#7916
If you can recover from any kind of exception and can't accept a program crash (like pretty much any kind of server - one request may fail due to an unlikely combination of circumstances, but the next request should work again), it is a good idea to catch everything.

It's also a good idea to always log all exceptions before you end the program.

Catching all exceptions anywhere else other than the root of the program is likely a bad idea.
If you have a good reason to disagree with the above, please tell me. Thank you.
3FFA
Profile Blog Joined February 2010
United States3931 Posts
November 20 2013 16:49 GMT
#7917
Hey guys. For a small project I'm doing in Java I want to create and assign to a 2D Array(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). The size is 21x3(ignoring the 0 row) and I want to have the 3 columns be assigned so that i=#of row and then the #of column is done like so:

(when i =a number between and including 2 and 10) column1 is i-1 column 2 is i+1 and column 3 is i+10 so for the number 2 the result would be [1][3][12].

(when i = a number greater than 11) column1 is i-1 column 2 is i+1 and column 3 is i-10 so for the 12th row the result would be [11][13][2].

(when i = 1) column 1 is 10 column 2 is 2 and column 3 is 11. [10][2][11]

(when i = 11) column 1 is 20 column 2 is 12 and column 3 is 1.

Any chance you guys know how I would assign to the array without doing each number individually and probably making a small mistake? Could I use a few different for loops to assign? I tried using for loops for it already but apparently while it was sintactically correct it terminated when I tried assigning.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
November 20 2013 17:07 GMT
#7918
First, I would say to just make your array the size you need, and access elements from 0, rather than having an extra element in each "column", and an extra "row". This might save you some grief if you start accessing things you shouldn't, and the way you're doing it seems weird. If you need to display the number, just add 1 to it.

You should be able to initialize everything with a loop for the first two cases, and then just doing it by hand for the two exceptions.

I can already spot one bug in your assignment however. Consider room 21. For room 21, according to your assingment, the array at that index should be [20][22][11]. However, room 22 does not exist.
you gotta dance
3FFA
Profile Blog Joined February 2010
United States3931 Posts
Last Edited: 2013-11-20 23:09:15
November 20 2013 23:09 GMT
#7919
(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.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Orome
Profile Blog Joined June 2004
Switzerland11984 Posts
November 21 2013 00:16 GMT
#7920
I'm somewhat confused on what you're trying to do exactly, could you share the code you have? Doesn't matter if it's incomplete or doesn't work.
On a purely personal note, I'd like to show Yellow the beauty of infinitely repeating Starcraft 2 bunkers. -Boxer
Prev 1 394 395 396 397 398 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
17:00
Mid Season Playoffs
MaxPax vs Solar
ByuN vs Cure
Shameless vs Lambo
SKillous vs Cham
Percival vs Harstem
ShoWTimE vs Krystianer
SteadfastSC244
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 417
elazer 279
SteadfastSC 244
UpATreeSC 145
BRAT_OK 71
mouzStarbuck 57
JuggernautJason20
EmSc Tv 19
MindelVK 18
StarCraft: Brood War
Calm 4752
Mong 176
Dewaltoss 108
910 30
scan(afreeca) 29
Noble 6
Dota 2
qojqva1907
Trikslyr60
League of Legends
KnowMe78
Counter-Strike
fl0m1820
ScreaM693
allub329
Heroes of the Storm
Liquid`Hasu253
Other Games
singsing1967
ceh91249
Liquid`RaSZi1009
B2W.Neo406
Beastyqt291
XaKoH 169
C9.Mang0167
RuFF_SC221
Organizations
Other Games
gamesdonequick2440
StarCraft 2
TaKeTV543
EmSc Tv 19
EmSc2Tv 19
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 21 non-featured ]
StarCraft 2
• Hupsaiya 77
• StrangeGG 52
• Reevou 7
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• blackmanpl 29
• HerbMon 15
• 80smullet 14
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Nemesis2948
• TFBlade757
• Scarra196
Other Games
• imaqtpie562
• Shiphtur373
Upcoming Events
Replay Cast
14h 14m
CrankTV Team League
16h 14m
WardiTV Qualifier
17h 14m
Epic.LAN
18h 14m
Big Brain Bouts
21h 14m
SHIN vs Elazer
Percival vs Nicoract
Reynor vs Lambo
Replay Cast
1d 5h
RSL Revival
1d 14h
Clem vs Lambo
Scarlett vs Cure
CranKy Ducklings
1d 15h
Epic.LAN
1d 18h
IPSL
1d 21h
Dragon vs Hawk
[ Show More ]
RSL Revival
2 days
Classic vs Trap
herO vs SHIN
Sparkling Tuna Cup
2 days
IPSL
2 days
Bonyth vs Ret
WardiTV Weekly
3 days
Monday Night Weeklies
3 days
PiGosaur Cup
5 days
The PondCast
5 days
Replay Cast
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Proleague 2026-07-13
HSC XXIX
Eternal Conflict S2 E2

Ongoing

IPSL Spring 2026
Acropolis #4
CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
Stake Ranked Episode 3
XSE Pro League 2026
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

Upcoming

Escore Tournament S3: W3
ASL S22 SEASON OPEN Day 1
Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E3
Logitech G Connect 2026
StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
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.