Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 247 248 [249] 250 251 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 841164 times)

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3720 on: January 23, 2013, 11:54:27 am »

I've always preferred the syntax "int* a". My reasoning is that "int" is also a type, and "int*" is a type, as far as I care.
Logged

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3721 on: January 23, 2013, 11:56:52 am »

Yeah, but the syntax doesn't actually /work/ like that and it doesn't /mean/ that and conceptualizing it that way can easily result in unexpected results.

That's the syntax problem I'm talking about.

If the language is going to encourage you to write things in certain ways to keep them straight in your head (and most C++ programmers do write it that way) then it should at least treat it that way. It doesn't. It's poor syntax.

Although the constant re-use of the * to mean similar but not identical things is also bad, as Sky pointed out.
« Last Edit: January 23, 2013, 11:58:26 am by GlyphGryph »
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3722 on: January 23, 2013, 12:11:01 pm »

Glad to know I'm not the only person who gets confused by pointers. I'm taking C again just so I can try and figure those things out this time.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #3723 on: January 23, 2013, 12:54:47 pm »

Personally I've took to not declaring multiple variables on a single line. This and a few other problems solved. But yeah that's one of the syntax flaws in C++ and an annoying one at that.

Then again I almost never use naked pointers any more...
« Last Edit: January 23, 2013, 01:00:29 pm by MorleyDev »
Logged

olemars

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3724 on: January 23, 2013, 01:57:51 pm »

(But yeah, it definitely seems to be that the older a programmer is, the more likely they are to value a foolish "conciseness" over something like "clarity" - there are still plenty of youngsters who do the same, though)

Many somewhat senior programmers, and especially aging professors, learned their programming during this era. There simply weren't space for variable names longer than 3 characters.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3725 on: January 23, 2013, 02:48:38 pm »

Yes, functionally identical because they are all
"int*a".

However, "int* a, b" does not do what the syntax would seem to imply, because the "*" isn't actually tied to the int, it's a dereference and tied to the variable, so it results in "int(*a),b".

just do int *a, *b; doesn't that work?
or better yet, don't initiate more than one variable per line.

one thing I don't like about c++ syntax, is in string streams it uses << instead of >>
logically >> makes more sense, because it would then follow the same logic as other streams,
cin>>x>>y;  loads x and y into the cin stream,  (not very technical terms here but you get what I mean)
ifstream inData;
inData>>x>>y;

but loading variables or values into a stringstream uses the opposite convention.
stringstream potato;
potato << x << y;
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3726 on: January 23, 2013, 03:19:57 pm »

one thing I don't like about c++ syntax, is in string streams it uses << instead of >>
logically >> makes more sense, because it would then follow the same logic as other streams,
cin>>x>>y;  loads x and y into the cin stream,  (not very technical terms here but you get what I mean)
ifstream inData;
inData>>x>>y;

but loading variables or values into a stringstream uses the opposite convention.
stringstream potato;
potato << x << y;

Wait what? It's always ">>" when the right-hand side is written to, and "<<" when the right-hand side is read from. How is that confusing?
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #3727 on: January 23, 2013, 03:22:53 pm »

The "<<" and ">>" thing seems obvious to me. It shows the direction data 'flows'. cin >> x >> y shows the data from the cin going into the x and y. stringstream << x << y shows the data going into the stringstream. It's an output stream after all, the output is just the in-memory string and not the console or a file.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3728 on: January 23, 2013, 04:41:18 pm »

yeah, nevermind, I'm just tired and dumb and had to do a stringstream and it seemed backwards to me for some reason,
and when I typed that comment I wasn't thinking just wanted to complain.
this is why you don't stay up for 30-40 hours then decide to do some programming.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3729 on: January 23, 2013, 09:31:12 pm »

Relevant: http://stackoverflow.com/questions/6990726/correct-way-of-declaring-pointer-variables-in-c-c

Also, it's not poor syntax if people's conceptual interpretations of a certain styles don't mesh with it, especially if there's no conceptual interpretation inherently assigned to the syntax other than its function. Actually, this is probably the best idea--conceptualize in a phrase or sentence what the lexer is reading and the parser is parsing: whether it's int* a, int * a, or int *a; you're going to get "An integer pointed at by a."
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3730 on: January 23, 2013, 09:49:56 pm »

Also, I thought int* was a type? The compiler often reports "cannot convert <int*> to <int&>", iting the type as int*.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Immortal

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3731 on: January 23, 2013, 11:58:08 pm »

Hey guys. I don't want to interrupt, but what was with the hate on Java earlier? You program it, easy graphics, and it runs everywhere no problem, and everyone has java. If I'm making games I use java. Robotics/real programming I used c++ though.
Logged

Killjoy

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3732 on: January 24, 2013, 03:13:25 am »

Hey guys. I don't want to interrupt, but what was with the hate on Java earlier? You program it, easy graphics, and it runs everywhere no problem, and everyone has java. If I'm making games I use java. Robotics/real programming I used c++ though.
I don't think anyone really "hates" java. But nobody really likes it either.
The language has barely evolved in its 20~ year existence. It still lacks a lot of cool features found in more modern languages like C#.
Then there is Java security practices, the last one allowed an attack to fully take control of the victim PC just by visiting a webpage. It was so severe that Homeland Security asked users to uninstall Java. Then there is the fact that the Java installer come with optional opt out trashware (The ask toolbar). But both trashware and security concerns might have something to do with Oracle. You never know..

Other than that. Yeah you are right, Java is fine for almost any task today. It is also pretty portable.
I am not quite sure what you mean by real programming. I can assure you that Java can be used for just as real programming as any language. Performance is actually really good on my PC. For a few tasks the JVM optimizes the code to run even faster than my native code (Before I do some extra work). Unless you are working within some extreme memory budget, or are confined to one platform, I don't even see the reason not to use something like Java.
Logged
Merchants Quest me programming a trading game with roguelike elements.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3733 on: January 24, 2013, 03:59:46 am »

I don't think anyone really "hates" java.
*Raises hand* I do!
Did I tell you about the time we got my dads old Blu-Ray player, and it took 2 minutes to start up from power off? (We don't do "standby", environmentalists and all)
Checked the back of the machine and sure enough, there it was. A cup of coffee-logo with "Powered by Java". Immediately returned the stupid thing.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3734 on: January 24, 2013, 04:12:54 am »

Hey guys. I don't want to interrupt, but what was with the hate on Java earlier? You program it, easy graphics, and it runs everywhere no problem, and everyone has java. If I'm making games I use java. Robotics/real programming I used c++ though.
I don't think anyone really "hates" java.
You haven't seen the horrors I have seen: http://www.cs.rit.edu/~ark/pj.shtml
This makes me die on the inside each time I see it. http://www.cs.rit.edu/~ark/pj/lib/edu/rit/smp/fractal/MandelbrotSetSmp2.shtml
Quote
...snip...
new ParallelTeam().execute (new ParallelRegion()
            {
            public void run() throws Exception
                {
                final int thr = getThreadIndex();
                final ArrayList<Long> chunk_t1_thr = chunk_t1[thr];
                final ArrayList<Long> chunk_t2_thr = chunk_t2[thr];

                execute (0, height-1, new IntegerForLoop()
                    {
                    public void run (int first, int last)
                        {
...snip...
Why can't we just use boost::threads with C++ ;_;

In other news, the most classes you take with RIT's CS department, the more annoyed at their 'custom solutions' and Stupid Computer Trickstm you will become.
Logged
Pages: 1 ... 247 248 [249] 250 251 ... 796