• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 19:14
CET 01:14
KST 09:14
  • 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
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win0Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down23ISSL (IntoTheTV x SOOP SC2 League): Premier7Weekly Cups (October 12-18): 5.0.17 era begins1
StarCraft 2
General
[D] Hacker peak in sc2 ? No more SC2 streamers on team liquid? Liquibets sc2 season 30 Evil Geniuses - shutting down Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win
Tourneys
SC4ALL: II Venue Change Announcement! Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays ISSL (IntoTheTV x SOOP SC2 League): Premier Stellar Fest TWO the Moon (Dec 16-20)
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps Starcraft 2 Advance [D] the control group Simple Questions/Answers
External Content
Mutation # 550 Graveyard Shift The PondCast: SC2 News & Results Mutation # 549 Endless Sparkles Mutation # 548 Shining Bright
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Rollback Netcode in Brood War SC4ALL: II Venue Change Announcement! Ziemie's Starcraft 1 Prequel Campaign 🇺🇦 Ukrainian StarCraft:BroodWar community reborn
Tourneys
[$1250] International ShieldBattery League [Megathread] Daily Proleagues Small VOD Thread 2.0 KCM Race Survival 2026 Season 4
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Deus Ex 3!? Mobile Legends: Bang Bang Armies of Exigo - YesYes?
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Dating: How's your luck? Trading/Investing Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread
Fan Clubs
Fan Club Resource Thread Reynor Fan Club The Flash Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 9548 users

The Big Programming Thread - Page 545

Forum Index > General Forum
Post a Reply
Prev 1 543 544 545 546 547 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.
zzdd
Profile Joined December 2010
United States484 Posts
Last Edited: 2014-11-10 22:42:32
November 10 2014 22:42 GMT
#10881
On November 11 2014 07:14 Cynry wrote:+ Show Spoiler +

relevant code in the .c
int             get_next_line(int const fd, char **line)
{
int ret;
static t_list *files;
t_list *cursor;
t_file *new_file;

ret = 0;
if (files)
{
cursor = files;
while (cursor && cursor->content
&& ((t_file *)cursor->content)->fd != fd)
cursor = cursor->next;
if (cursor->content && ((t_file *)cursor->content)->fd == fd)
ret = ft_read_file(fd, cursor->content, line);
}
else
{
if (!(files = (t_list *)ft_memalloc(sizeof(*files))))
return (-1);
if (!(new_file = (t_file *)ft_memalloc(sizeof(*new_file))))
return (-1);
cursor = ft_lstnew(new_file, sizeof(*new_file));
((t_file *)cursor->content)->fd = fd;
((t_file *)cursor->content)->left_over = 0;
ft_lstadd(&files, cursor);
ret = ft_read_file(fd, cursor->content, line);
}
return (ret);
}

in the .h
#ifndef GET_NEXT_LINE_H
# define GET_NEXT_LINE_H

# define BUFF_SIZE 32
# define EOF "\n"

#include <string.h>

typedef struct s_list
{
void *content;
size_t content_size;
struct s_list *next;
} t_list;

typedef struct s_file
{
int fd;
char *left_over;
} t_file;

The segfault happens with the second call to get_next_line, when if (files) is checked and the program tries to access cursor->content->fd.

files is never set to anything?
Cynry
Profile Blog Joined August 2010
810 Posts
Last Edited: 2014-11-10 23:09:04
November 10 2014 22:59 GMT
#10882
You got me closer and some more errors to corret :D Thanks !

Edit : and after 5 more minutes of debugging I got it working, merci beaucoup !
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
November 10 2014 23:03 GMT
#10883
On November 11 2014 07:42 zzdd wrote:
Show nested quote +
On November 11 2014 07:14 Cynry wrote:+ Show Spoiler +

relevant code in the .c
int             get_next_line(int const fd, char **line)
{
int ret;
static t_list *files;
t_list *cursor;
t_file *new_file;

ret = 0;
if (files)
{
cursor = files;
while (cursor && cursor->content
&& ((t_file *)cursor->content)->fd != fd)
cursor = cursor->next;
if (cursor->content && ((t_file *)cursor->content)->fd == fd)
ret = ft_read_file(fd, cursor->content, line);
}
else
{
if (!(files = (t_list *)ft_memalloc(sizeof(*files))))
return (-1);
if (!(new_file = (t_file *)ft_memalloc(sizeof(*new_file))))
return (-1);
cursor = ft_lstnew(new_file, sizeof(*new_file));
((t_file *)cursor->content)->fd = fd;
((t_file *)cursor->content)->left_over = 0;
ft_lstadd(&files, cursor);
ret = ft_read_file(fd, cursor->content, line);
}
return (ret);
}

in the .h
#ifndef GET_NEXT_LINE_H
# define GET_NEXT_LINE_H

# define BUFF_SIZE 32
# define EOF "\n"

#include <string.h>

typedef struct s_list
{
void *content;
size_t content_size;
struct s_list *next;
} t_list;

typedef struct s_file
{
int fd;
char *left_over;
} t_file;

The segfault happens with the second call to get_next_line, when if (files) is checked and the program tries to access cursor->content->fd.

files is never set to anything?


It's very rare that you ever really want to use the static keyword in a function or local scope. It's basically the same as moving the declaration into the global scope, which is usually clearer that only one instance of that variable exists. Otherwise, the code looks fine at my glance.

Set a breakpoint at the line it's segfauling and check the cursor and the fd it's trying to access. It looks like it might be going off of the list into random memory, then when you try to look up the fd, you end up in protected memory and segfault.

If you arent using a debugger, then just printf everything in the while loop.
Any sufficiently advanced technology is indistinguishable from magic
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
Last Edited: 2014-11-11 13:40:46
November 11 2014 12:58 GMT
#10884
he guys, Im currently following a community college level app development study and my school is inviting companies in my area so we can get an internship in our last semester.

any tips?

edit, something I did left out was that I have to hold a presentation about a social media website that I made with a group (well.. its more that I did 30% of the work, 1 guy the rest and the others 0 lines of code) are there anythings I should focus on or try to avoid in my presentation?
The harder it becomes, the more you should focus on the basics.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
November 11 2014 16:43 GMT
#10885
--- Nuked ---
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-11-12 08:21:11
November 12 2014 03:23 GMT
#10886
did a quick (and prolly inaccurate) comparison of some different variant implementations. only dispatch, is timed. construction on mine (heap based) is way slower, but only occupies as much memory as it needs to hold the value type it is instantiated with. the implementation of core is amazingly cool i think.

stack based
      jason
      core
      boost
heap based
      jeh

+ Show Spoiler +
#include<iostream>
#include<functional>
#include<memory>
#include<vector>
#include<type_traits>
#include<seq/sequence.hpp>
#include<abstract/abstract.hpp>
#include<abstract/deconstruct.hpp>
#include<../cppcon14/variant.h>
#include<../core/include/core/variant.hpp>
#include<boost/variant.hpp>
#include<seq/seq.hpp>
#define BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS 5
#include<boost/variant/multivisitors.hpp>
#include<time.h>
#include<random>
#include<pthread.h>

long operator-(const timespec& end,const timespec& start)
{
if ((end.tv_nsec-start.tv_nsec)<0) {
return 1000000000+end.tv_nsec-start.tv_nsec;
} else {
return end.tv_nsec-start.tv_nsec;
}
}


const int N=100000;
const int M=2;

std::random_device rd;
std::default_random_engine e1(rd());
std::uniform_int_distribution<int> dist(0,M-1);

template<int i> struct type{};

template<template<class...> class,class> struct variant_maker;

template<template<class...> class variant,int... index>
struct variant_maker<variant,seq::integer_sequence<index...>>{ using output=variant<type<index>...>; };

template<template<class...> class variant>
using make_variant=typename variant_maker<variant,seq::integer_range<0,M>>::output;

using abstract_t=make_variant<jeh::abstract>;
using jason_variant_t=make_variant<cppcon14::variant::variant_t>;
using core_variant_t=make_variant<core::variant>;
using boost_variant_t=make_variant<boost::variant>;

struct unary_t:boost::static_visitor<void>{
using fn1_t=void();
template<class T>
void operator()(const T&){}
};
unary_t unary;
struct binary_t:boost::static_visitor<void>{
using fn2_t=void();
template<class T,class U>
void operator()(const T&,const U&){}
};
binary_t binary;
struct tetriary_t:boost::static_visitor<void>{
template<class... T>
void operator()(const T&...){}
};
tetriary_t tetriary;

timespec t0,t1;

template<class variant,int i>
variant random_maker(){ return variant((type<i>())); }

template<class variant>
using random_makers_t=std::array<variant(*)(),M>;

template<class variant,int... I>
constexpr random_makers_t<variant> random_makers(const seq::integer_sequence<I...>&){
return {random_maker<variant,I>...};
}

template<class variant>
variant make_random(){
static constexpr auto make_randoms
=random_makers<variant>(seq::integer_range<0,M>());
return make_randoms[dist(e1)]();
}

template<class predicate,class variant>
using dispatch_enabler=std::enable_if_t<std::is_same<variant,predicate>::value,long>;

template<class variant>
dispatch_enabler<jason_variant_t,variant>
timed_unary_dispatch()
{
auto var=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
cppcon14::variant::apply(unary,var);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}

template<class variant>
dispatch_enabler<variant,abstract_t>
timed_unary_dispatch()
{
auto var=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
jeh::deconstruct<void>(unary,var);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}

template<class variant>
dispatch_enabler<variant,core_variant_t>
timed_unary_dispatch()
{
auto var=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
var.visit(unary);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}

template<class variant>
dispatch_enabler<variant,boost_variant_t>
timed_unary_dispatch()
{
auto var=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
boost::apply_visitor(unary,var);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}

template<class variant>
long unary_test(){
std::vector<long> times;
for(int i=0;i<N;++i){
times.push_back(timed_unary_dispatch<variant>());
}
return std::accumulate(std::begin(times),std::end(times),0)/times.size();
}

template<class variant>
dispatch_enabler<variant,boost_variant_t>
timed_binary_dispatch()
{
auto var0=make_random<variant>();
auto var1=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
boost::apply_visitor(binary,var0,var1);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}


template<class variant>
dispatch_enabler<variant,jason_variant_t>
timed_binary_dispatch()
{
auto var0=make_random<variant>();
auto var1=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
cppcon14::variant::apply(binary,var0,var1);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}


template<class variant>
dispatch_enabler<variant,abstract_t>
timed_binary_dispatch()
{
auto var0=make_random<variant>();
auto var1=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
jeh::deconstruct<void>(binary,var0,var1);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}

template<class variant>
long binary_test(){
std::vector<long> times;
for(int i=0;i<N;++i){
times.push_back(timed_binary_dispatch<variant>());
}
return std::accumulate(std::begin(times),std::end(times),0)/times.size();
}

template<class variant>
dispatch_enabler<variant,abstract_t>
timed_tetriary_dispatch()
{
auto var0=make_random<variant>();
auto var1=make_random<variant>();
auto var2=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
jeh::deconstruct<void>(tetriary,var0,var1,var2);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}
template<class variant>
dispatch_enabler<variant,boost_variant_t>
timed_tetriary_dispatch()
{
auto var0=make_random<variant>();
auto var1=make_random<variant>();
auto var2=make_random<variant>();
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0);
boost::apply_visitor(tetriary,var0,var1,var2);
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t1);
return(t1-t0);
}

template<class variant>
long tetriary_test(){
std::vector<long> times;
for(int i=0;i<N;++i){
times.push_back(timed_tetriary_dispatch<variant>());
}
return std::accumulate(std::begin(times),std::end(times),0)/times.size();
}


int main(){

std::cout<<"\n---------- unary visit ----------\n\n";
std::cout<<" jason: "<<unary_test<jason_variant_t>()<<std::endl;
std::cout<<" core: "<<unary_test<core_variant_t>()<<std::endl;
std::cout<<" jeh: "<<unary_test<abstract_t>()<<std::endl;
std::cout<<" boost: "<<unary_test<boost_variant_t>()<<std::endl;
std::cout<<"\n------------------------------------\n\n";


std::cout<<"---------- binary visit ----------\n\n";
std::cout<<" jason: "<<binary_test<jason_variant_t>()<<std::endl;
std::cout<<" boost: "<<binary_test<boost_variant_t>()<<std::endl;
std::cout<<" jeh: "<<binary_test<abstract_t>()<<std::endl;
std::cout<<"\n------------------------------------\n\n";

std::cout<<"---------- tetriary visit ----------\n\n";
std::cout<<" boost: "<<tetriary_test<boost_variant_t>()<<std::endl;
std::cout<<" jeh: "<<tetriary_test<abstract_t>()<<std::endl;
std::cout<<"\n------------------------------------\n\n";

}


removed output as it was misleading. i have run it more and varied the the number of types involved in abstraction.
i think final verdict is boost being consistently faster in all cases, core has the slight upper hand on the other two.
jasons is consistently a bit slower than jeh in binary dispatch, but everyone usually within 10 ns of eachother (~220-260 ns).

presonally i'd use the core one (if i wasn't biased towards my own).
conspired against by a confederacy of dunces.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2014-11-12 10:59:57
November 12 2014 10:40 GMT
#10887
for a class i have to come up with an idea to research with regards to Distributed Systems....

last night i came up with a draft abstract....by sheer willpower and luck lol :D

have a read and comment if you want....i cant ask any specific questions right now coz im TIRED!

+ Show Spoiler +

(intro)
The Actor model of concurrent processing was inspired by the idea that the core of all computing is the passing of messages. With this as a basis, a decoupling of the sender and receiver of messages allows processes (or Actors) in the Actor model to operate asynchronously. This works to avoid the locking that is required when threads attempt to access data within a traditional shared-state model of concurrent processing.

(abstract)
The Actor Model is an emerging methodology that offers an alternative approach to the traditional shared-state model of parallel programming. Although much debate surrounds the usefulness of the Actor Model in real-world application, this debate tends to surround issues of architectural design rather than runtime performance. This paper aims to evaluate the performance of the Actor Model by measuring the execution time of a scalable multi-threaded application and then comparing this with a similar build based on a traditional shared-state model.


i guess the main obvious questions/steps are

a) how has this been done before? (i doubt it has been done with javascript implementation)
b) how can it be implemented?
c) how can it be implemented in a non-trivial fashion?

for example, will two similar trivial applications in the same programming language but using different code structure show any difference in performance to one another? (feel free to comment on this because I don't know the answer).

how can i make my application scalable to try to uncover differences in performance?

c) how can it be measured?

ok so im not that tired apparently lol


Edit (copy pasta):

With regards to my Final Year Project that several of you advised me on, I firstly proposed to my tutor that I look at a subject in cloud computing but he seemed to immediately dislike the topic, or perhaps he disliked that I hadn't yet come up with something in particular yet and time was ticking...

I then told him about my idea for an anime recommendation website that allows users to generate compositions of anime image covers in order to share these as customised recommendations in JPG form to friends.

He heartily encouraged me to go ahead with it, and since he's the one giving me the grade at the end of the day I couldn't argue too much about it being trivial.

Looking at a few (7?) historic 1st-class projects at Portsmouth, it looks like they get the marks from having solid reports rather than being anything technically magical, so I'm feeling confident about it. I'll put extra work into critically evaluating my design choices, maybe look at bonus functionality, and should get a decent mark.

Maybe I'll post here again with a few questions/ideas with regards to this another time!
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
November 12 2014 11:08 GMT
#10888
On November 12 2014 01:43 Nesserev wrote:
Show nested quote +
On November 11 2014 21:58 sabas123 wrote:
he guys, Im currently following a community college level app development study and my school is inviting companies in my area so we can get an internship in our last semester.

any tips?

edit, something I did left out was that I have to hold a presentation about a social media website that I made with a group (well.. its more that I did 30% of the work, 1 guy the rest and the others 0 lines of code) are there anythings I should focus on or try to avoid in my presentation?

Giving presentations is something that you learn by doing, and of course, you have to know what you're talking about.
The only advice that I could give is:
- make a proper presentation, and keep the viewer in mind
- try not to use live demo's, but rather show everything through step-by-step images or clean videos, and offer hands-on experience afterwards with guidance (if necessary)

Well, you probably will also have the opportunity to present your resume + portfolio. So:
- make a nice resume in LaTeX, use a template; it'll definitely look better than 99.5% of all resumes out there
- make a simple website to present your portfolio of work

thank you!

I will follow your advice.
The harder it becomes, the more you should focus on the basics.
MichaelEU
Profile Joined February 2011
Netherlands816 Posts
November 12 2014 11:56 GMT
#10889
Something that helps improving your presentations is recording yourself and then criticizing yourself (and having others criticize you). It's brutal, but it really works. You'll notice your quirks, pacing, tone of your voice, things you didn't notice stand out, things you thought were glaring are fairly subdued.

Other basic tips: use a lot of different hand gestures, vary your tone, use an image on every slide.
世界を革命する力を!― znf: "Michael-oniichan ( *^▽^*)ノ✩キラ✩"
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
November 12 2014 14:10 GMT
#10890
Fuck xml (in context of reading/writing config files for various Java stuff). Seriously.

/rant
Time is precious. Waste it wisely.
Khalum
Profile Joined September 2010
Austria831 Posts
November 12 2014 14:48 GMT
#10891
On November 12 2014 23:10 Manit0u wrote:
Fuck xml (in context of reading/writing config files for various Java stuff). Seriously.

/rant


Wait what? You don't like having a metric shitton of overhead for even the simplest data serialization? Weirdo.
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
Last Edited: 2014-11-12 15:32:13
November 12 2014 15:30 GMT
#10892
I need to distract myself from this. I can't take it any more...

Poll: Which one do you use?

if (false == somwevar) (1)
 
6%

if (somevar == false) (17)
 
94%

18 total votes

Your vote: Which one do you use?

(Vote): if (false == somwevar)
(Vote): if (somevar == false)



Which and why?

Personally, I prefer to write/see the variable being evaluated before what it's being compared to. Makes more sense syntactically for me as it feels more natural.
Time is precious. Waste it wisely.
delHospital
Profile Blog Joined December 2010
Poland261 Posts
November 12 2014 15:39 GMT
#10893
On November 13 2014 00:30 Manit0u wrote:
I need to distract myself from this. I can't take it any more...

Poll: Which one do you use?

if (false == somwevar) (1)
 
6%

if (somevar == false) (17)
 
94%

18 total votes

Your vote: Which one do you use?

(Vote): if (false == somwevar)
(Vote): if (somevar == false)



Which and why?

Personally, I prefer to write/see the variable being evaluated before what it's being compared to. Makes more sense syntactically for me as it feels more natural.

if (!somevar)
devilesk
Profile Joined May 2005
United States140 Posts
November 12 2014 15:48 GMT
#10894
On November 13 2014 00:39 delHospital wrote:
Show nested quote +
On November 13 2014 00:30 Manit0u wrote:
I need to distract myself from this. I can't take it any more...

Poll: Which one do you use?

if (false == somwevar) (1)
 
6%

if (somevar == false) (17)
 
94%

18 total votes

Your vote: Which one do you use?

(Vote): if (false == somwevar)
(Vote): if (somevar == false)



Which and why?

Personally, I prefer to write/see the variable being evaluated before what it's being compared to. Makes more sense syntactically for me as it feels more natural.

if (!somevar)


I prefer this as well.
www.devilesk.com/dota2
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
November 12 2014 16:43 GMT
#10895
On November 13 2014 00:39 delHospital wrote:
Show nested quote +
On November 13 2014 00:30 Manit0u wrote:
I need to distract myself from this. I can't take it any more...

Poll: Which one do you use?

if (false == somwevar) (1)
 
6%

if (somevar == false) (17)
 
94%

18 total votes

Your vote: Which one do you use?

(Vote): if (false == somwevar)
(Vote): if (somevar == false)



Which and why?

Personally, I prefer to write/see the variable being evaluated before what it's being compared to. Makes more sense syntactically for me as it feels more natural.

if (!somevar)


I meant it in a more general way. Used false just as an example. This can as well be null, 'somestring' etc.
Time is precious. Waste it wisely.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2014-11-12 16:55:34
November 12 2014 16:52 GMT
#10896
x == 0
For the same reasons.

Though I'm forced to do the opposite at work (for comparision against null). In C#. For C++, 0 == x is less error prone (won't compile if you write 0 = x), but in C# this only really matters in fringe cases.
If you have a good reason to disagree with the above, please tell me. Thank you.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
November 12 2014 18:25 GMT
#10897
(false == somevar) makes no logical sense in normal langauges?
The harder it becomes, the more you should focus on the basics.
Vorenius
Profile Blog Joined December 2010
Denmark1979 Posts
Last Edited: 2014-11-12 18:42:03
November 12 2014 18:41 GMT
#10898
On November 13 2014 03:25 sabas123 wrote:
(false == somevar) makes no logical sense in normal langauges?

Well, unless you are Yoda.

False the variable is.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2014-11-12 18:51:53
November 12 2014 18:43 GMT
#10899
Haha was confused for a second about the "if (someboolean == false)".
But yeah, I use: if (blabla == "Hahaha") too. It never works too, I wonder why. Probably something to do with Java. (huehueuglylanguagehue).

Edit: Btw, trolling aside. There is a case to be made for if ("Hahaha".equals(someString)). Allows someString to be null and the comparison doesn't throw a NullPointerException. It may hide a bug though if you weren't expecting a null pointer ;D
Regis
Profile Joined December 2010
Poland109 Posts
November 12 2014 18:58 GMT
#10900
yoyo anyone here use Delphi?
Prev 1 543 544 545 546 547 1032 Next
Please log in or register to reply.
Live Events Refresh
PSISTORM Gaming Misc
09:00
FSL season 12 opener: HM vs ST
Freeedom13
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SpeCial 25
StarCraft: Brood War
Britney 7748
Dota 2
PGG 215
League of Legends
Doublelift4592
JimRising 703
Counter-Strike
jkaem74
Other Games
summit1g9002
gofns8726
Grubby2221
shahzam444
PiGStarcraft308
C9.Mang0259
Day[9].tv237
syndereN189
XaKoH 97
Maynarde68
Fuzer 64
NeuroSwarm53
ViBE41
Railgan20
KnowMe19
PPMD19
JuggernautJason3
Organizations
Other Games
gamesdonequick318
BasetradeTV176
Counter-Strike
PGL89
[ Show 18 non-featured ]
StarCraft 2
• Hupsaiya 63
• RyuSc2 37
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Laughngamez YouTube
• Migwel
StarCraft: Brood War
• HerbMon 34
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis3286
• Jankos3195
• Scarra895
Other Games
• imaqtpie624
• Day9tv237
• Shiphtur173
Upcoming Events
IntoTheTV X SOOP
10h 46m
Reynor vs Solar
ByuN vs SHIN
Clem vs MaxPax
herO vs Rogue
IPSL
16h 46m
WorsT vs nOmaD
Dewalt vs andersOn
AI Arena Tournament
18h 46m
IntoTheTV X SOOP
1d 10h
IPSL
1d 16h
Azhi_Dahaki vs ggnore13
Double vs WIZARD
Replay Cast
1d 22h
Replay Cast
2 days
Sparkling Tuna Cup
3 days
WardiTV Invitational
3 days
YoungYakov vs Lambo
SHIN vs TBD
Percival vs Shameless
Solar vs TBD
PiGosaur Cup
4 days
[ Show More ]
The PondCast
5 days
KCM Race Survival
5 days
WardiTV Invitational
5 days
Liquipedia Results

Completed

Proleague 2026-11-05
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
Calamity Cup Div. A Season 8
IEM Beijing 2026
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026

Upcoming

Sector 951
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Underdog Cup 2026 Div 2-3
PGL Bucharest 2027
BLAST Bounty Winter 2027
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 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.