• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:55
CET 14:55
KST 22:55
  • 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
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation4Weekly 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
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest
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
BW General Discussion FlaSh on: Biggest Problem With SnOw's Playstyle Terran 1:35 12 Gas Optimization BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile Dawn of War IV
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
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! 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: 1356 users

The Big Programming Thread - Page 831

Forum Index > General Forum
Post a Reply
Prev 1 829 830 831 832 833 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.
phar
Profile Joined August 2011
United States1080 Posts
January 27 2017 18:07 GMT
#16601
On January 28 2017 00:03 travis wrote:
Is it ok if I come to this thread with questions related to my "discrete structures" course? It isn't programming, but it is computer science.


Yea sure. If you have decent math background that course is gonna be aggravatingly boring. If you've not had a proof based math course (analysis, algebra, etc), then it should be pretty important.


On January 28 2017 00:23 mantequilla wrote:
Why do you need them (vim emacs) when nearly everything has a good IDE that's tailored specifically to whatever you do?

never used/installed them just asking.

I used to use IDE pretty much exclusively until I started working on codebases that were so large that the IDE all grind to a halt on a routine basis. It would be awesome if visual studio or something scaled well enough (and in practice, you can kinda hack in plugins to eclipse to make some operation bareable, especially if you're only working on the same specific tiny subsection of code, and not syncing often).
Who after all is today speaking about the destruction of the Armenians?
Silvanel
Profile Blog Joined March 2003
Poland4733 Posts
January 27 2017 18:20 GMT
#16602
On January 28 2017 03:04 Acrofales wrote:
Show nested quote +
On January 28 2017 02:52 Silvanel wrote:
Well the obvious answer is that a text editor can be used for many things besides developing. Many devices run Linux/QNX with basic text editors so if You are in need of editing some config file quickly its very handy.

I will give You an example:
I am working with embedded device that is running QNX. I need to change some paramteres inside config file on device. Now i can change conifguration of my ethernet card, remount the devices file system then copy the config file to shared folder edit it on my comp and copy edited file back. Takes about 2 minutes.
Or i can open this file in vi (which is part of QNX devices build) and edit it on device itself. Takes about 20 seconds.

I mean You dont need tu use Vi/Vim or whatever as Your IDE but knowing it just helps (sometimes).

Or you can open it in nano/pico/whatever, and not have to know that you first have to hit "a" (or "i") to be able to type at all, then esc to get back to normal mode, and then :wq to save and quit. And one of those is equally or more likely to be installed on a bare linux system than vi (let alone vim or emacs).

vim/emacs is useful for editing code, because you actually have to switch files and do complicated edit operations. not because you have to edit some random file in your /etc directory.

I don't know anything about QNX, so I assume you actually need vi for that. But that seems overly specific for a university course


This is overly specific even for real life jobs. I mean i didnt check the data but i have a feeling that embedded jobs are minority on the market. I just felt like sharing a story
Pathetic Greta hater.
Manit0u
Profile Blog Joined August 2004
Poland17429 Posts
January 27 2017 22:07 GMT
#16603
Ehh... You guys are not hipster enough!

There is only one true editor
Time is precious. Waste it wisely.
deus.machinarum
Profile Joined September 2011
Austria658 Posts
Last Edited: 2017-01-28 11:00:45
January 28 2017 10:58 GMT
#16604
On January 26 2017 20:58 Silvanel wrote:
So i have a C question. What exactly is difference between:

a = a + 1 and a = a++
+ Show Spoiler +

??
more specifically why:


#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a = a + 1 ;

} while ( a <20 );

return 0;
}

and

#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a = a++ ;

} while ( a <20 );

return 0;
}

give different results? (The latter creates an endless loop)


Edit:Nevermind got an answer myself, spoilered so evidence of my stupidity is not forgoten.


Could someone help me figure out why the second version results in an endless loop:
to me it seems like the operations carried out should be a = a(thus retaining the original value, not advancing the loop)
but THEN the "++" should be happening and the value stored in a(which at this point should be a = a, i.e. the unchanged a) should be incremented before being used in the predicate.
Why does the "++" get lost?

edit to clarify:
my understanding is that the value in a is the original not yet incremented value at the end of the line "a = a++;" but after that, in the while() it should already have been incremented
Nothing worth having comes easy.
Silvanel
Profile Blog Joined March 2003
Poland4733 Posts
Last Edited: 2017-01-28 11:10:35
January 28 2017 11:05 GMT
#16605
Cause in C,

x = a++ will increase value of a by one but return value before increment whereas
y = ++a will increase value of a by oneand return value after increment

Edit:
Cause if You do soemthing like a = a++ the increment is lost as i understand it. The assiagned value is value before increment so nothing relevant really happens.
Pathetic Greta hater.
Biolunar
Profile Joined February 2012
Germany224 Posts
January 28 2017 11:09 GMT
#16606
On January 28 2017 19:58 deus.machinarum wrote:
Show nested quote +
On January 26 2017 20:58 Silvanel wrote:
So i have a C question. What exactly is difference between:

a = a + 1 and a = a++
+ Show Spoiler +

??
more specifically why:


#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a = a + 1 ;

} while ( a <20 );

return 0;
}

and

#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a = a++ ;

} while ( a <20 );

return 0;
}

give different results? (The latter creates an endless loop)


Edit:Nevermind got an answer myself, spoilered so evidence of my stupidity is not forgoten.


Could someone help me figure out why the second version results in an endless loop:
to me it seems like the operations carried out should be a = a(thus retaining the original value, not advancing the loop)
but THEN the "++" should be happening and the value stored in a(which at this point should be a = a, i.e. the unchanged a) should be incremented before being used in the predicate.
Why does the "++" get lost?

edit to clarify:
my understanding is that the value in a is the original not yet incremented value at the end of the line "a = a++;" but after that, in the while() it should already have been incremented


int a = 5;
a = a++;
assert(a == 5);

The postfix increment first returns the old value, that is 5, then it increments it. The assignment has not yet been done at this point in time! a has the value 6 but the increment operator returned the value 5. Now a gets assigned to the returned value (here: 5).
What is best? To crush the Zerg, see them driven before you, and hear the lamentations of the Protoss.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
January 28 2017 11:10 GMT
#16607
On January 28 2017 19:58 deus.machinarum wrote:
Show nested quote +
On January 26 2017 20:58 Silvanel wrote:
So i have a C question. What exactly is difference between:

a = a + 1 and a = a++
+ Show Spoiler +

??
more specifically why:


#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a = a + 1 ;

} while ( a <20 );

return 0;
}

and

#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a = a++ ;

} while ( a <20 );

return 0;
}

give different results? (The latter creates an endless loop)


Edit:Nevermind got an answer myself, spoilered so evidence of my stupidity is not forgoten.


Could someone help me figure out why the second version results in an endless loop:
to me it seems like the operations carried out should be a = a(thus retaining the original value, not advancing the loop)
but THEN the "++" should be happening and the value stored in a(which at this point should be a = a, i.e. the unchanged a) should be incremented before being used in the predicate.
Why does the "++" get lost?

edit to clarify:
my understanding is that the value in a is the original not yet incremented value at the end of the line "a = a++;" but after that, in the while() it should already have been incremented


a++ returns a copy of a before the increment. The ++ increases the original value, but not the copy that afterwards gets assigned back to a.
deus.machinarum
Profile Joined September 2011
Austria658 Posts
January 28 2017 11:13 GMT
#16608
ok I get that because the value of the return is put into a different variable/memory location but after x = a++ happened the value in a should also have been incremented, right?

so, going back to the original code, "whenever" the ++ happens it should increment the value stored in a after the whole statement is done or maybe the result of the ++ is thrown out because it is not returned?
Nothing worth having comes easy.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2017-01-28 11:19:58
January 28 2017 11:18 GMT
#16609
On January 28 2017 20:13 deus.machinarum wrote:
ok I get that because the value of the return is put into a different variable/memory location but after x = a++ happened the value in a should also have been incremented, right?

so, going back to the original code, "whenever" the ++ happens it should increment the value stored in a after the whole statement is done or maybe the result of the ++ is thrown out because it is not returned?


a = a++ is exactly the same as

int temp = a;
a = a + 1;
a = temp;


deus.machinarum
Profile Joined September 2011
Austria658 Posts
January 28 2017 11:28 GMT
#16610
On January 28 2017 20:18 Morfildur wrote:
Show nested quote +
On January 28 2017 20:13 deus.machinarum wrote:
ok I get that because the value of the return is put into a different variable/memory location but after x = a++ happened the value in a should also have been incremented, right?

so, going back to the original code, "whenever" the ++ happens it should increment the value stored in a after the whole statement is done or maybe the result of the ++ is thrown out because it is not returned?


a = a++ is exactly the same as

int temp = a;
a = a + 1;
a = temp;




ok thx, that cleared it up for me

also thx to everyone taking time to respond
Nothing worth having comes easy.
Hanh
Profile Joined June 2016
146 Posts
January 28 2017 13:35 GMT
#16611
On January 28 2017 20:18 Morfildur wrote:
Show nested quote +
On January 28 2017 20:13 deus.machinarum wrote:
ok I get that because the value of the return is put into a different variable/memory location but after x = a++ happened the value in a should also have been incremented, right?

so, going back to the original code, "whenever" the ++ happens it should increment the value stored in a after the whole statement is done or maybe the result of the ++ is thrown out because it is not returned?


a = a++ is exactly the same as

int temp = a;
a = a + 1;
a = temp;




Sorry, but that's actually incorrect. The semantics of this statement is *undefined*, because = does not introduce a sequence point.
Acrofales
Profile Joined August 2010
Spain18114 Posts
January 28 2017 20:24 GMT
#16612
But why would you ever type a = a++; (except as a typo from ignorance)? The whole point of a++ is that it's shorthand for incrementing by 1. So if you use ++, you write it:

#include <stdio.h>

int main () {
int a = 10;
do {
printf("Value of a: %d\n", a);
a++ ;

} while ( a <20 );

return 0;
}

And voila, it works fine. The moment you start writing things with a = <do something with a>, you have to worry about operator precedence (in fact, any time you use multiple operators you have to think about that).
fmod
Profile Blog Joined November 2013
Cayman Islands330 Posts
January 28 2017 21:00 GMT
#16613
It's funny how so many of these programming discussions are about the ++ operator... Which is one of the least interesting parts of programming. Instead of concentrating on cool/weird syntax people should focus more on solving actual problems.
I don't particularly like you.
Buckyman
Profile Joined May 2014
1364 Posts
Last Edited: 2017-01-28 21:28:10
January 28 2017 21:27 GMT
#16614
Did y'all know that Java enums can implement interfaces? Simply declare the interface and add the extra methods to the enum and each member of the enum implements it.


public enum Mode implements Iterable{
ON, OFF, STANDBY;

public Iterator iterator() {
return null;
}
}


Are there any common design patterns where this is useful?
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
January 28 2017 21:37 GMT
#16615
On January 29 2017 06:00 fmod wrote:
It's funny how so many of these programming discussions are about the ++ operator... Which is one of the least interesting parts of programming. Instead of concentrating on cool/weird syntax people should focus more on solving actual problems.

Trying to solve problems without understanding the syntax you're using only creates more problems.

It's like asking why someone would bother learning English when they should just start writing novels.
Average means I'm better than half of you.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
January 28 2017 21:39 GMT
#16616
The ++ operators should never have been created in the first place. The potential for legitimate use is greatly outweighed by people trying to be "clever" and failing hard.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17429 Posts
Last Edited: 2017-01-29 00:38:52
January 28 2017 22:34 GMT
#16617
On January 29 2017 05:24 Acrofales wrote:
But why would you ever type a = a++; (except as a typo from ignorance)? The whole point of a++ is that it's shorthand for incrementing by 1. So if you use ++, you write it:

#include <stdio.h>

int main() {
int a = 10;
do {
printf("Value of a: %d\n", a);
a++ ;

} while ( a <20 );

return 0;
}

And voila, it works fine. The moment you start writing things with a = <do something with a>, you have to worry about operator precedence (in fact, any time you use multiple operators you have to think about that).



#include <stdio.h>

int main(void)
{
int a = 10;

do {
printf("Value of a: %d\n", a);
} while (a++ < 20);

return 0;
}


That's how you do it (if you really want to use the ++ operator)
Time is precious. Waste it wisely.
Silvanel
Profile Blog Joined March 2003
Poland4733 Posts
January 28 2017 22:47 GMT
#16618
Well, i am learning C. I started playing with code (changing and looking what happenes) was surprised with endless loop at first. Dont You guys play with code when You are learning something?

I am suprised it got so much attention
Pathetic Greta hater.
RoomOfMush
Profile Joined March 2015
1296 Posts
January 28 2017 23:20 GMT
#16619
On January 29 2017 06:27 Buckyman wrote:
Did y'all know that Java enums can implement interfaces? Simply declare the interface and add the extra methods to the enum and each member of the enum implements it.

Show nested quote +

public enum Mode implements Iterable{
ON, OFF, STANDBY;

public Iterator iterator() {
return null;
}
}


Are there any common design patterns where this is useful?

Enums are just regular old classes with some additional rules applied to them (only private constructors for example) but the added benefit of a few neat compiler-magic features. Each enum constant is actually its own annonymous class and can re-implement most methods as it chooses. The equals, hashCode and ordinal methods (and probably some others too) for enums are final though.

Where is this useful? Well, I can imagine default-methods in Java8 being pretty useful for enums. On top of that it might help you structure your program better with clearly defined API's. Enums could be used as static final instances of an interface but you may construct more instances dynamically with another class.
Manit0u
Profile Blog Joined August 2004
Poland17429 Posts
Last Edited: 2017-01-29 00:51:50
January 29 2017 00:50 GMT
#16620
On January 29 2017 06:39 spinesheath wrote:
The ++ operators should never have been created in the first place. The potential for legitimate use is greatly outweighed by people trying to be "clever" and failing hard.


It's useful when you want to replace for loops with while loops (which is done behind the scenes by the compiler anyway, since for is just an alias for while). It saves you but a line of code compared to the proper while loop, but if your project will have thousands of those, it's thousands of lines saved.

ex:


for (int i = 0; i < 10; i++) {
// do stuff
}

// ^ translates to
int i = 0;

while (i < 10) {
// do stuff
i += 1;
}


Now, I prefer to write it this way:

int i = 0;

while (i++ < 10) {
// do stuff
}


I prefer to use while over for whenever I can, mostly because I like to declare and initialize all the variables at the beginning of a function. Makes it easier to debug later on, even if it isn't the most efficient thing to do.
Time is precious. Waste it wisely.
Prev 1 829 830 831 832 833 1032 Next
Please log in or register to reply.
Live Events Refresh
Kung Fu Cup
12:00
2025 Monthly #3: Day 1
Reynor vs GuMihoLIVE!
ByuN vs ShoWTimE
RotterdaM523
TKL 182
Rex146
IntoTheiNu 103
SteadfastSC88
Liquipedia
OSC
11:30
Mid Season Playoffs
Cure vs SpiritLIVE!
Krystianer vs Percival
WardiTV446
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 523
Reynor 227
TKL 182
Rex 146
SteadfastSC 88
StarCraft: Brood War
Calm 4495
Rain 2923
Bisu 2701
Hyuk 2015
Horang2 1304
Flash 797
Soma 464
Backho 369
Stork 340
Rush 261
[ Show more ]
Pusan 197
Last 133
Soulkey 115
JulyZerg 104
Barracks 79
hero 58
sSak 33
zelot 31
Aegong 28
sas.Sziky 24
Killer 23
Terrorterran 11
Noble 9
Hm[arnc] 7
Dota 2
Gorgc2155
qojqva1591
Dendi1136
XcaliburYe181
BananaSlamJamma86
Counter-Strike
olofmeister911
allub158
Super Smash Bros
Mew2King127
Other Games
B2W.Neo990
hiko295
DeMusliM285
Pyrionflax260
Sick170
Fuzer 164
Hui .86
QueenE46
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Adnapsc2 9
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 1641
• WagamamaTV400
League of Legends
• Nemesis1689
• TFBlade702
Upcoming Events
Tenacious Turtle Tussle
9h 5m
The PondCast
20h 5m
RSL Revival
20h 5m
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
22h 5m
WardiTV Korean Royale
22h 5m
PiGosaur Monday
1d 11h
RSL Revival
1d 20h
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
1d 22h
CranKy Ducklings
2 days
RSL Revival
2 days
herO vs Gerald
ByuN vs SHIN
[ Show More ]
Kung Fu Cup
2 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
3 days
RSL Revival
3 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
3 days
WardiTV Korean Royale
3 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
4 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
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
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
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
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.