• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:06
CEST 16:06
KST 23:06
  • 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
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
ZeroSpace Early Access is Now Live!17Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters2Balance hotfix patch 5.0.16b (July 16)84Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
August World Ranking Watchlist: Serral back to #1? How would you feel about frequent/monthly balance patches for SC2? Balance hotfix patch 5.0.16b (July 16) Clem: "I don't have that much hope in Blizzard" Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
[M] (2) Industrial Park New Map Maker - Looking for Advice - Love or Hate
External Content
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
Animated Gateway BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion HORROR STARCRAFT MOVIE How Famous was FlaSh before his Debut?
Tourneys
[Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers PvT advise for noobs Fighting Spirit mining rates Creating a full chart of Zerg builds
Other Games
General Games
Path of Exile ZeroSpace Early Access is Now Live! General RTS Discussion Thread ZeroSpace at Steam NextFest - Last free demo Nintendo Switch Thread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Artificial Intelligence Thread Russo-Ukrainian War Thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Hello guys!
LIN1s
Role of Gaming on Mental Hea…
TrAiDoS
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 13193 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
Poland17798 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
Poland17798 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
Poland17798 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
Kung Fu Cup
11:00
2026 Week 16
IntoTheiNu 1493
WardiTV643
RotterdaM548
Ryung 479
TKL 218
Rex141
SteadfastSC134
EnkiAlexander 33
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Serral 1119
RotterdaM 548
Ryung 479
TKL 218
Rex 141
SteadfastSC 134
BRAT_OK 53
RushiSC 10
trigger 7
StarCraft: Brood War
Calm 4822
Rain 2806
Jaedong 1627
Horang2 1202
EffOrt 624
BeSt 513
Light 426
firebathero 422
Soulkey 347
Rush 246
[ Show more ]
hero 233
Stork 228
Snow 208
ggaemo 194
ZerO 189
Soma 178
Last 137
Zeus 124
Mong 104
Hyun 88
sorry 85
Dewaltoss 82
Pusan 76
Leta 64
[sc1f]eonzerg 54
NaDa 49
ToSsGirL 35
Movie 33
JYJ 31
JulyZerg 28
yabsab 22
Hm[arnc] 19
GoRush 19
Sacsri 17
Sexy 17
Aegong 16
Noble 16
Nal_rA 16
Rock 14
IntoTheRainbow 13
ajuk12(nOOB) 12
zelot 8
Terrorterran 6
Dota 2
qojqva1678
XaKoH 311
syndereN265
XcaliburYe181
420jenkins13
League of Legends
KnowMe42
Counter-Strike
fl0m3376
Other Games
FrodaN4246
B2W.Neo725
hiko668
Lowko575
Mlord384
uThermal293
Liquid`LucifroN170
Pyrionflax141
ArmadaUGS127
DeMusliM125
ToD93
CosmosSc2 25
Trikslyr21
ZerO(Twitch)14
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 16 non-featured ]
StarCraft 2
• StrangeGG 39
• poizon28 2
• Kozan
• Migwel
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2123
• WagamamaTV374
League of Legends
• Nemesis2262
• TFBlade693
Upcoming Events
OSC
9h 55m
CrankTV Team League
20h 55m
Replay Cast
1d 9h
CrankTV Team League
1d 20h
Korean StarCraft League
2 days
Afreeca Starleague
2 days
RSL Revival
2 days
Serral vs SHIN
herO vs Solar
Online Event
3 days
Replay Cast
3 days
RSL Revival
3 days
Clem vs ByuN
Rogue vs Lambo
[ Show More ]
OSC
3 days
WardiTV Weekly
4 days
Sparkling Tuna Cup
5 days
PiGosaur Cup
6 days
The PondCast
6 days
Kung Fu Cup
6 days
Liquipedia Results

Completed

Proleague 2026-07-21
HSC XXIX
Eternal Conflict S2 E3

Ongoing

CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
ASL Season 22: Qualifier #1
ASL Season 22: Qualifier #2
CSLAN 4
ASL Season 22
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 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.