• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 01:21
CET 07:21
KST 15: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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets3$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)15Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1823
StarCraft 2
General
Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets SC2 All-Star Invitational: Jan 17-18 When will we find out if there are more tournament SC2 Spotted on the EWC 2026 list? Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) $25,000 Streamerzone StarCraft Pro Series announced WardiTV Winter Cup WardiTV Mondays SC2 AI Tournament 2026
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes
Brood War
General
[ASL21] Potential Map Candidates Potential ASL qualifier breakthroughs? A cwal.gg Extension - Easily keep track of anyone BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Beyond All Reason Nintendo Switch Thread Awesome Games Done Quick 2026! Mechabellum Stormgate/Frost Giant Megathread
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Trading/Investing Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
My 2025 Magic: The Gathering…
DARKING
Physical Exercise (HIIT) Bef…
TrAiDoS
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1839 users

The Big Programming Thread - Page 947

Forum Index > General Forum
Post a Reply
Prev 1 945 946 947 948 949 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.
Acrofales
Profile Joined August 2010
Spain18180 Posts
February 19 2018 21:45 GMT
#18921
A silly SQL issue popped up in the last 15 minutes of work, I didn't solve it and it's driving me nuts thinking about it. Anybody got any ideas?


SELECT ev.id, user.name, floor((timestamp - <starttime>)/10000) as bin, ev.details
FROM Events ev LEFT JOIN Users user ON ev.userId = user.id
WHERE user.id = <userid> AND timestamp > <starttime> AND timestamp < <endtime>

Returns a pretty list of events (for the test user I was checking: 736 in total. Among them, nothing in bin 278.


SELECT user.name, floor((timestamp - <starttime>)/10000) as bin, COUNT(*) as eventsinbin
FROM Events ev LEFT JOIN Users user ON ev.userId = user.id
WHERE user.id = <userid> AND timestamp > <starttime> AND timestamp < <endtime>
GROUP BY bin

Returns a pretty list of bins and counts of events in them. Bin 278 has 43 events in it

WHY?!
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
Last Edited: 2018-02-19 22:48:36
February 19 2018 22:04 GMT
#18922
Events.id is an identity key or can it be NULL?

Edit: Nevermind, you're not joining on Events.id anyway. Does the second SELECT actually work? user.name isn't in the aggregate.
Average means I'm better than half of you.
Acrofales
Profile Joined August 2010
Spain18180 Posts
February 19 2018 22:46 GMT
#18923
On February 20 2018 07:04 WolfintheSheep wrote:
Events.id is an identity key or can it be NULL?

Primary key for the events table
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
February 19 2018 22:51 GMT
#18924
On February 20 2018 07:46 Acrofales wrote:
Show nested quote +
On February 20 2018 07:04 WolfintheSheep wrote:
Events.id is an identity key or can it be NULL?

Primary key for the events table

See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it.

Are you still getting back 736 total events with the second query?
Average means I'm better than half of you.
Acrofales
Profile Joined August 2010
Spain18180 Posts
February 19 2018 23:03 GMT
#18925
On February 20 2018 07:51 WolfintheSheep wrote:
Show nested quote +
On February 20 2018 07:46 Acrofales wrote:
On February 20 2018 07:04 WolfintheSheep wrote:
Events.id is an identity key or can it be NULL?

Primary key for the events table

See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it.

Are you still getting back 736 total events with the second query?

Because I select only one user name it works.

I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
February 20 2018 01:45 GMT
#18926
On February 20 2018 08:03 Acrofales wrote:
Show nested quote +
On February 20 2018 07:51 WolfintheSheep wrote:
On February 20 2018 07:46 Acrofales wrote:
On February 20 2018 07:04 WolfintheSheep wrote:
Events.id is an identity key or can it be NULL?

Primary key for the events table

See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it.

Are you still getting back 736 total events with the second query?

Because I select only one user name it works.

I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin.

Well, without a set ORDER BY results are sorted by retrieval time, which by data is entirely arbitrary. Definitely don't assume one ID is blank by default return order.
Average means I'm better than half of you.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2018-02-20 02:49:38
February 20 2018 02:39 GMT
#18927
On February 19 2018 19:26 nunez wrote:
Show nested quote +
On February 18 2018 12:48 phar wrote:
On February 15 2018 19:33 nunez wrote:

in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.

The gcc AST tends to be a less exact representation of the actual source code compared to clang. So if you're e.g. building a tool to refactor all of a given thing, gcc might yield you some missing pieces.

Not a big deal for most use cases.

you are comparing gcc / clang as compiler front-ends in the context of writing a compiler. spinesheath was comparing compilers in the context of using a compiler. the former is not a use-case in a discussion of the latter, it's irrelevant, and so is the level of abstraction in the AST.

in any case: can you give examples of how GCC 'completely fucked with' the AST and caused you pain? what kind of tool did you try to write?
I'm not talking about writing a compiler, I know almost nothing about that area.

My specific case in mind is various types of refactoring on a codebase that is ~O(hundred million) LoC.

It simply is not possible to do in gcc. Gcc's ast is not complete, and it removes references to variables on occasion. For a trivial example, see the (obviously hella biased) clang/llvm page on comparison: https://clang.llvm.org/comparison.html.

See here for some similar discussion:

https://lwn.net/Articles/629316/

Again, not really a concern for most use-cases.
Who after all is today speaking about the destruction of the Armenians?
Acrofales
Profile Joined August 2010
Spain18180 Posts
February 20 2018 11:02 GMT
#18928
On February 20 2018 10:45 WolfintheSheep wrote:
Show nested quote +
On February 20 2018 08:03 Acrofales wrote:
On February 20 2018 07:51 WolfintheSheep wrote:
On February 20 2018 07:46 Acrofales wrote:
On February 20 2018 07:04 WolfintheSheep wrote:
Events.id is an identity key or can it be NULL?

Primary key for the events table

See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it.

Are you still getting back 736 total events with the second query?

Because I select only one user name it works.

I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin.

Well, without a set ORDER BY results are sorted by retrieval time, which by data is entirely arbitrary. Definitely don't assume one ID is blank by default return order.

I knew that, but from what I was looking at in the list they seemed incremental. Turns out they were not, and the events I was looking for were hidden somewhere else. Crisis resolved
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
February 20 2018 18:24 GMT
#18929
On February 20 2018 20:02 Acrofales wrote:
Show nested quote +
On February 20 2018 10:45 WolfintheSheep wrote:
On February 20 2018 08:03 Acrofales wrote:
On February 20 2018 07:51 WolfintheSheep wrote:
On February 20 2018 07:46 Acrofales wrote:
On February 20 2018 07:04 WolfintheSheep wrote:
Events.id is an identity key or can it be NULL?

Primary key for the events table

See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it.

Are you still getting back 736 total events with the second query?

Because I select only one user name it works.

I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin.

Well, without a set ORDER BY results are sorted by retrieval time, which by data is entirely arbitrary. Definitely don't assume one ID is blank by default return order.

I knew that, but from what I was looking at in the list they seemed incremental. Turns out they were not, and the events I was looking for were hidden somewhere else. Crisis resolved

I've found that half my issues are resolved by assuming I'm a dumbass.
Average means I'm better than half of you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 20 2018 19:16 GMT
#18930
On February 20 2018 11:39 phar wrote:
Show nested quote +
On February 19 2018 19:26 nunez wrote:
On February 18 2018 12:48 phar wrote:
On February 15 2018 19:33 nunez wrote:

in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.

The gcc AST tends to be a less exact representation of the actual source code compared to clang. So if you're e.g. building a tool to refactor all of a given thing, gcc might yield you some missing pieces.

Not a big deal for most use cases.

you are comparing gcc / clang as compiler front-ends in the context of writing a compiler. spinesheath was comparing compilers in the context of using a compiler. the former is not a use-case in a discussion of the latter, it's irrelevant, and so is the level of abstraction in the AST.

in any case: can you give examples of how GCC 'completely fucked with' the AST and caused you pain? what kind of tool did you try to write?
I'm not talking about writing a compiler, I know almost nothing about that area.

My specific case in mind is various types of refactoring on a codebase that is ~O(hundred million) LoC.

It simply is not possible to do in gcc. Gcc's ast is not complete, and it removes references to variables on occasion. For a trivial example, see the (obviously hella biased) clang/llvm page on comparison: https://clang.llvm.org/comparison.html.

See here for some similar discussion:

https://lwn.net/Articles/629316/

Again, not really a concern for most use-cases.

i referred to your hypothetical code transformation tool as a compiler. did you try to write this tool yourself?
conspired against by a confederacy of dunces.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
February 21 2018 07:05 GMT
#18931
Let's say I was doing vectorized operations with large arrays. My output goes into another, bigger array.

Sometimes the output creates a duplicate, but according to some secondary criteria I will only want to save one of each given output - I don't want duplicates. But i have to discern which to keep. It's probable there will be many duplicates for each output.

So which would be more efficient

1) do all vectorized operations, storing all my output in the huge array. Then sort the array, then filter out the bad duplicates.

2.) save all outputs to a map, along with their index in the array, and check every new output against the map. if it's a duplicate, only keep it if it is the one I want, and if so - remove the old one.


If I was using lists I would go with 2.....
Acrofales
Profile Joined August 2010
Spain18180 Posts
February 21 2018 08:45 GMT
#18932
Depends on lots of things, your data, the programming language, the compiler, your hardware, what you do afterwards with your outcomes, etc.

I'd do whatever is easiest. If that runs into tractability problems, then start optimizing.
Neshapotamus
Profile Blog Joined May 2006
United States163 Posts
Last Edited: 2018-02-21 18:00:03
February 21 2018 17:59 GMT
#18933
On February 21 2018 16:05 travis wrote:
Let's say I was doing vectorized operations with large arrays. My output goes into another, bigger array.

Sometimes the output creates a duplicate, but according to some secondary criteria I will only want to save one of each given output - I don't want duplicates. But i have to discern which to keep. It's probable there will be many duplicates for each output.

So which would be more efficient

1) do all vectorized operations, storing all my output in the huge array. Then sort the array, then filter out the bad duplicates.

2.) save all outputs to a map, along with their index in the array, and check every new output against the map. if it's a duplicate, only keep it if it is the one I want, and if so - remove the old one.


If I was using lists I would go with 2.....


The function is called unique. You should have some built-in matrix function that does that.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2018-02-21 22:23:03
February 21 2018 21:59 GMT
#18934
On February 21 2018 04:16 nunez wrote:
Show nested quote +
On February 20 2018 11:39 phar wrote:
On February 19 2018 19:26 nunez wrote:
On February 18 2018 12:48 phar wrote:
On February 15 2018 19:33 nunez wrote:

in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.

The gcc AST tends to be a less exact representation of the actual source code compared to clang. So if you're e.g. building a tool to refactor all of a given thing, gcc might yield you some missing pieces.

Not a big deal for most use cases.

you are comparing gcc / clang as compiler front-ends in the context of writing a compiler. spinesheath was comparing compilers in the context of using a compiler. the former is not a use-case in a discussion of the latter, it's irrelevant, and so is the level of abstraction in the AST.

in any case: can you give examples of how GCC 'completely fucked with' the AST and caused you pain? what kind of tool did you try to write?
I'm not talking about writing a compiler, I know almost nothing about that area.

My specific case in mind is various types of refactoring on a codebase that is ~O(hundred million) LoC.

It simply is not possible to do in gcc. Gcc's ast is not complete, and it removes references to variables on occasion. For a trivial example, see the (obviously hella biased) clang/llvm page on comparison: https://clang.llvm.org/comparison.html.

See here for some similar discussion:

https://lwn.net/Articles/629316/

Again, not really a concern for most use-cases.

i referred to your hypothetical code transformation tool as a compiler. did you try to write this tool yourself?


Ah gotcha, no it's definitely not a compiler. It relies on AST info extracted from the compiler but can't itself compile code. There's ~dozens of people working on this at my place. Aside from a few of the tools nobody writes them by themselves, it's always a team effort.

I wish I was smart enough to write this by myself lol, maybe I would be able to employ myself ha.

Also it is not a hypothetical tool lol, it works and is in active use. We're still mucking with it always, and will be using it or a similar tool more in the future, but we do use it now too.

It will become a tricky problem if we ever start supporting codebases that explicitly use gcc, icc etc. We'll see what happens then, idk.
Who after all is today speaking about the destruction of the Armenians?
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 21 2018 23:42 GMT
#18935
our compiler-concepts differ.
conspired against by a confederacy of dunces.
Silvanel
Profile Blog Joined March 2003
Poland4740 Posts
February 22 2018 09:22 GMT
#18936
So i have two parts of my test Application. One written in C# the other (main) in Python. Whats the best way to exchange data between them? I need both parts of app to talk to each other in "close" to real time conditions (the max delay i can allow i think is around 1s).
Pathetic Greta hater.
Acrofales
Profile Joined August 2010
Spain18180 Posts
Last Edited: 2018-02-22 10:33:40
February 22 2018 10:32 GMT
#18937
On February 22 2018 18:22 Silvanel wrote:
So i have two parts of my test Application. One written in C# the other (main) in Python. Whats the best way to exchange data between them? I need both parts of app to talk to each other in "close" to real time conditions (the max delay i can allow i think is around 1s).

The easiest alternative I can think of is to simply open a socket-based connection between the two processes: it's not the fastest form of communication, but 1s is an eternity.
Excludos
Profile Blog Joined April 2010
Norway8230 Posts
February 22 2018 14:04 GMT
#18938
So (I might have mentioned this earlier) our firm doesn't really have any testing policy. Our only testing is done in the form of manually checking that shit works after coding. While this will work to some extent, it's not a super good practice.

So one of my colleagues came up with the idea to run a workshop with everyone to teach people how to set up proper tests and to apply some good practices. The conversation with the boss went as follows:

"No".
"Why not?"
"We don't have time right now".
"When will we have time for this?"
"Well everything is a bit unstable at the moment. If we get everything more stable then we'll have ti-" "DO YOU NOT SEE THE PROBLEM HERE?!"
phar
Profile Joined August 2011
United States1080 Posts
February 22 2018 16:15 GMT
#18939
On February 22 2018 08:42 nunez wrote:
our compiler-concepts differ.

Ok sure, possibly because I know almost nothing about building an actual compiler.
Who after all is today speaking about the destruction of the Armenians?
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 22 2018 18:55 GMT
#18940
On February 22 2018 23:04 Excludos wrote:
So (I might have mentioned this earlier) our firm doesn't really have any testing policy. Our only testing is done in the form of manually checking that shit works after coding. While this will work to some extent, it's not a super good practice.

So one of my colleagues came up with the idea to run a workshop with everyone to teach people how to set up proper tests and to apply some good practices. The conversation with the boss went as follows:

"No".
"Why not?"
"We don't have time right now".
"When will we have time for this?"
"Well everything is a bit unstable at the moment. If we get everything more stable then we'll have ti-" "DO YOU NOT SEE THE PROBLEM HERE?!"

Aaaahhh, I remember having a similar conversation once. Good times....
The harder it becomes, the more you should focus on the basics.
Prev 1 945 946 947 948 949 1032 Next
Please log in or register to reply.
Live Events Refresh
PiGosaur Cup
01:00
#64
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft531
Livibee 163
StarCraft: Brood War
Britney 28531
Stork 425
BeSt 141
EffOrt 52
Mind 28
Noble 22
Sacsri 15
ZergMaN 15
Icarus 12
Bale 8
Dota 2
LuMiX1
League of Legends
JimRising 737
C9.Mang0528
Super Smash Bros
hungrybox369
Mew2King109
Other Games
summit1g6963
XaKoH 207
RuFF_SC284
minikerr46
Organizations
Other Games
gamesdonequick2535
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH71
• intothetv
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• RayReign 24
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Rush1444
• Lourlo1109
• Stunt394
Other Games
• Scarra2760
• Shiphtur168
Upcoming Events
WardiTV Invitational
5h 39m
The PondCast
1d 3h
OSC
1d 5h
OSC
2 days
All Star Teams
2 days
INnoVation vs soO
sOs vs Scarlett
uThermal 2v2 Circuit
3 days
All Star Teams
3 days
MMA vs DongRaeGu
Rogue vs Oliveira
Sparkling Tuna Cup
4 days
OSC
4 days
Replay Cast
5 days
[ Show More ]
Wardi Open
5 days
Liquipedia Results

Completed

Proleague 2026-01-13
Big Gabe Cup #3
NA Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
OSC Championship Season 13
Underdog Cup #3
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

Escore Tournament S1: W4
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Thunderfire SC2 All-star 2025
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 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.