• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:21
CEST 19:21
KST 02:21
  • 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
[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists16[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0
Community News
2026 GSL Season 1 Qualifiers17Maestros of the Game 2 announced92026 GSL Tour plans announced15Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid24
StarCraft 2
General
Maestros of the Game 2 announced 2026 GSL Tour plans announced Team Liquid Map Contest #22 - The Finalists MaNa leaves Team Liquid Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
2026 GSL Season 1 Qualifiers INu's Battles#14 <BO.9 2Matches> Sparkling Tuna Cup - Weekly Open Tournament GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 522 Flip My Base The PondCast: SC2 News & Results Mutation # 521 Memorable Boss Mutation # 520 Moving Fees
Brood War
General
ASL21 General Discussion Data needed ASL21 Strategy, Pimpest Plays Discussions Pros React To: ASL S21, Ro.16 Group C BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[ASL21] Ro16 Group D [Megathread] Daily Proleagues [ASL21] Ro16 Group C Escore Tournament StarCraft Season 2
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Dawn of War IV Diablo IV Nintendo Switch Thread Total Annihilation Server - TAForever Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread McBoner: A hockey love story Cricket [SPORT]
World Cup 2022
Tech Support
Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1493 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
Poland17733 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
Big Brain Bouts
17:00
#113
PiG vs DeMusliM
Reynor vs Bunny
RotterdaM665
IndyStarCraft 103
Liquipedia
RSL Revival
17:00
Season 5 Europe Qualifier
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 665
IndyStarCraft 103
UpATreeSC 91
StarCraft: Brood War
Britney 7892
EffOrt 1780
Soma 726
Stork 379
Snow 372
ggaemo 362
firebathero 175
Hyun 121
Barracks 54
JYJ 54
[ Show more ]
sSak 51
soO 37
BRAT_OK 29
Free 24
Rock 20
Terrorterran 15
scan(afreeca) 14
Shine 13
Sacsri 6
Dota 2
Gorgc6020
qojqva1539
Counter-Strike
byalli492
Super Smash Bros
Mew2King52
Other Games
singsing1523
Grubby1383
B2W.Neo1157
FrodaN801
ArmadaUGS153
QueenE141
Liquid`VortiX129
Fuzer 92
KnowMe66
Liquid`LucifroN58
Trikslyr54
Dewaltoss53
C9.Mang029
Organizations
Dota 2
PGL Dota 2 - Main Stream10566
StarCraft 2
ComeBackTV 469
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• intothetv
• Kozan
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• IndyKCrew
StarCraft: Brood War
• 80smullet 14
• FirePhoenix4
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV364
League of Legends
• Jankos1552
Counter-Strike
• Nemesis1238
Other Games
• imaqtpie478
• Shiphtur167
Upcoming Events
Replay Cast
6h 39m
WardiTV Map Contest Tou…
17h 39m
Classic vs SHIN
MaxPax vs Percival
herO vs Clem
ByuN vs Rogue
Ladder Legends
21h 39m
uThermal 2v2 Circuit
21h 39m
BSL
1d 1h
Sparkling Tuna Cup
1d 16h
WardiTV Map Contest Tou…
1d 17h
Ladder Legends
1d 21h
BSL
2 days
CranKy Ducklings
2 days
[ Show More ]
Replay Cast
2 days
Wardi Open
2 days
Afreeca Starleague
2 days
Soma vs hero
Monday Night Weeklies
2 days
Replay Cast
3 days
Replay Cast
3 days
Afreeca Starleague
3 days
Leta vs YSC
Replay Cast
5 days
The PondCast
5 days
KCM Race Survival
5 days
Replay Cast
6 days
Replay Cast
6 days
Escore
6 days
Liquipedia Results

Completed

Proleague 2026-04-23
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Escore Tournament S2: W4
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W5
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 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.