• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 05:22
CET 11:22
KST 19:22
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
RSL Offline Finals Info - Dec 13 and 14! StarCraft Evolution League (SC Evo Biweekly) RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread ZeroSpace Megathread The Perfect Game Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
Physical Exertion During Gam…
TrAiDoS
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1770 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
Poland17496 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
Poland17496 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
Poland17496 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
The PondCast
10:00
Episode 74
CranKy Ducklings25
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 153
ProTech51
StarCraft: Brood War
Britney 27305
GuemChi 1411
Horang2 1168
actioN 531
Jaedong 449
BeSt 356
Mini 274
firebathero 273
EffOrt 209
Hyuk 158
[ Show more ]
Dewaltoss 149
Light 102
Hyun 100
Killer 89
Pusan 89
Sharp 86
Snow 80
Last 76
Larva 61
hero 61
Barracks 52
Rush 49
ggaemo 48
Shine 45
Sacsri 44
sorry 40
ToSsGirL 29
ZerO 19
soO 18
Noble 17
Shinee 14
Bale 14
NaDa 11
Hm[arnc] 5
Dota 2
NeuroSwarm91
League of Legends
JimRising 411
C9.Mang0218
Reynor75
Counter-Strike
olofmeister1409
shoxiejesuss638
Super Smash Bros
Westballz11
Other Games
summit1g12111
ceh9596
WinterStarcraft546
Happy407
crisheroes386
Mew2King50
KnowMe40
ZerO(Twitch)3
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 604
Other Games
gamesdonequick506
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• LUISG 30
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota256
League of Legends
• Jankos1904
Upcoming Events
OSC
5h 38m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
13h 38m
Korean StarCraft League
1d 16h
CranKy Ducklings
1d 23h
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
2 days
WardiTV 2025
3 days
[ Show More ]
OSC
3 days
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
3 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
4 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
5 days
StarCraft2.fi
6 days
Tenacious Turtle Tussle
6 days
The PondCast
6 days
Liquipedia Results

Completed

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

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

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

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.