• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 00:23
CET 06:23
KST 14:23
  • 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 - Playoffs Preview0RSL 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
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
Which season is the best in ASL? [ASL20] Ask the mapmakers — Drop your questions BW General Discussion FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread The Perfect Game Path of Exile Nintendo Switch Thread Should offensive tower rushing be viable in RTS games?
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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1212 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
Poland17490 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
Next event in 6h 37m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 281
RuFF_SC2 188
SortOf 46
StarCraft: Brood War
actioN 397
PianO 159
Noble 47
Icarus 9
NotJumperer 1
Dota 2
monkeys_forever525
XaKoH 3
League of Legends
JimRising 724
Counter-Strike
Coldzera 1437
Other Games
summit1g13603
WinterStarcraft529
C9.Mang0337
Organizations
Other Games
gamesdonequick1036
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Hupsaiya 92
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki22
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1119
• Stunt456
Upcoming Events
Wardi Open
6h 37m
StarCraft2.fi
11h 37m
Replay Cast
18h 37m
The PondCast
1d 4h
OSC
1d 10h
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 18h
Korean StarCraft League
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ]
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
OSC
4 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
5 days
StarCraft2.fi
6 days
PiGosaur Monday
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
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

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 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.