Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 415 416 [417] 418 419 ... 796

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

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #6240 on: September 05, 2014, 01:49:43 am »

On the other hand, if you're in Software Development then it's not unreasonable for you to be in it because you enjoy the job. You'd be programming anyway, regardless of whether you were employed or not, and all they do by paying you is get you to focus on their problems instead (which ideally should be of interest to you).

The amount of money you make is a factor when looking at a job, but by no means the only factor. And if they stop giving you interesting problems to solve, or if the work just stops interesting you, or if you stop continuously learning and developing yourself, then it's a good time to switch jobs (Or become a manager and accept that you're exchanging programming for stability and higher pay).

Oracle from this point of view could be a great learning opportunity which would help you score even better jobs in the future, even if you're only there for a year or two.
« Last Edit: September 05, 2014, 05:10:02 am by MorleyDev »
Logged

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6241 on: September 05, 2014, 03:53:36 pm »

So I'm working on a proper Agora Web Client, and I'm making it by using liveconnect to link an applet into javascript code- this is easier than making javascript that directly connects to the java server. But now I need to figure out how to use the BSON in the java in the javascript. You'd think there'dbe an easy way to unpack it into JS objects, but it doesn't appear there is. Should I just continue to use it as java objects? That'd probably work out, for the most part.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6242 on: September 05, 2014, 07:21:27 pm »

There's got to be a JavaScript library for parsing BSON into JavaScript objects.  If not, can you do some translation in Java to only present true JSON to JavaScript?  Depending on what you're doing you might be able to repack dates as strings or integer timestamps and byte arrays as encoded strings maybe.
Logged
Through pain, I find wisdom.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6243 on: September 05, 2014, 08:10:31 pm »

I looked, and I found no java library for parsing the java BSON into JSON. I'm probably going to just pass the lava objects to javascript, and use them there. eventually they unwind to strings and numbers anyway.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Maklak

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6244 on: September 06, 2014, 02:01:11 pm »

Can someone please help me figure out the one true way of slicing a perl script into several files? I don't much care for object orientation, I just want to clump similar things together in files, then call functions and use global variables from other files. I have something that works, but am unhappy with it. BTW, are sircular requires legal in perl (foo.pl requires bar.pl which requires foo.pl)?

File prog.pl
Spoiler (click to show/hide)

File lib/inc.pl
Spoiler (click to show/hide)

I guess I might as well stick with "package main;" everywhere to not have to use package names in fronf of stuff.

Then there are those @EXPORT arrays, but they look wierd.

Sorry for the noobish question, but I've read several tutorials on packages in perl and still have this problem.
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6245 on: September 06, 2014, 03:27:31 pm »

Can someone please help me figure out the one true way of slicing a perl script into several files? I don't much care for object orientation, I just want to clump similar things together in files, then call functions and use global variables from other files. I have something that works, but am unhappy with it. BTW, are sircular requires legal in perl (foo.pl requires bar.pl which requires foo.pl)?

File prog.pl
Spoiler (click to show/hide)

File lib/inc.pl
Spoiler (click to show/hide)

I guess I might as well stick with "package main;" everywhere to not have to use package names in fronf of stuff.

Then there are those @EXPORT arrays, but they look wierd.

Sorry for the noobish question, but I've read several tutorials on packages in perl and still have this problem.
The best thing in the world would be if someone were to make a tutorial about how to do this with every possible question. I tend to feel extremely dumb when I come to a new language, and it's the ONE thing I can't figure out, and the ONE thing that I rarely find documentation on. It might be a case of me simply just being dumb, of course, or only getting interested in languages that don't make this obvious. Both of these are possibilities. However, I find it a dumb situation when I can [complicated thingy] in a language and not figure out how to split it into different files.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6246 on: September 06, 2014, 04:00:44 pm »


About your "our" comment: "our" does not actually define a variable, it simply makes the global variable $foo::zm available as "$zm" in the local (lexical) context. Since you have two different local contexts (two files), you need to use "our" both times so you can use "$zm" both times.

Here's some module theory, all about circular references and loading order: First of all you need some some background info to "use" and "require":
Code: [Select]
require Foo::Bar;
translates to
Code: [Select]
eval(getModuleFileContents("Foo/Bar.pm")) unless isAlreadyLoaded("Foo/Bar.pm");

and
Code: [Select]
use Foo::Bar @args;
translates to
Code: [Select]
BEGIN {
  require Foo::Bar;
  Foo::Bar::import(@args) unless !defined *Foo::Bar::import{CODE};
}

Circular loading is perfectly legal, but in that case you shouldn't ever rely on loading order, because it can change for the slightest of reasons.
For example, here's what could go wrong:
Code: (Foo.pm) [Select]
package Foo;
require Bar;
our $foo = 3;
Code: (Bar.pm) [Select]
package Bar;
require Foo;
our $bar = $Foo::foo + 2;
Code: (main1.pl) [Select]
require Foo;
require Bar;
print $Bar::bar;
Code: (main2.pl) [Select]
require Bar;
require Foo;
print $Bar::bar;
These two programs have different results: main1.pl prints 2, and main2.pl prints 5. That is because in main1.pl, the line "our $bar = $Foo::foo + 2;" is called before the line "our $foo = 3;".

To avoid such shenanigans, you have to take care when writing the static code for a module (static code is the code outside subroutines): A module's static code may never ever assume any modules to be loaded that it is in a circular loop with. Defining subroutines is always okay, since the subroutines won't be executed until all modules are loaded, but the static code should never depend upon its circularly dependent modules.

So basically, here's how a multi-file program is structured:
* 1 main executable file. This file is the one that gets run, and it shall never ever be require'd.
* Lots of .pm files. These should only contain subroutine definitions and some simple variable initializations:
Code: (Example Foo.pm) [Select]
package Foo;
use Bar; ## Bar uses Foo too, so we need to be careful
use SomeLib; ## SomeLib is definitely not dependent on Foo, so we can use it

$a = 1; ## Perfectly fine
$b = SomeLib::blah(); ## Fine: Since SomeLib doesn't need Foo, we know that SomeLib is already loaded by now
$c = Bar::bar(); ## WRONG: We don't know if Bar's been loaded yet, so we may not use Bar's stuff

sub foo {
  my $k = $a;
  my $p = SomeLib::bluh();
  my $n = Bar::bar(); ## CAUTION: Since Bar is being used, this subroutine is "non-static" (it should not be called in Foo's static code).
  return ($k, $p, $n);
}

sub fooo {
  foo(); ## CAUTION: Since foo is a non-static function, this makes fooo a non-static function too.
}

sub noot {
  return SomeLib::bleh() + 4; ## This subroutine is perfectly harmless; we may call it in Foo's static code. Keep in mind though that we are still not allowed to use it in Bar's static code due to the circular dependency.
}

foo(); ## WRONG
fooo(); ## WRONG
noot(); ## OKAY

1;

Oh, and by the way, so you don't trip over this: Never use Exporter twice in the same package (even in different files), it WILL have unexpected issues unless you know exactly what Exporter is doing, and it wouldn't really ever be necessary anyway.
Logged

Maklak

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6247 on: September 07, 2014, 01:19:18 am »

Thanks for answering part of my question, MagmaMcFry, but it doesn't solve my problem.

I'm also pretty sure this is illegal code in perl under use strict:
$a = 1; ## Perfectly fine
Every time I do this, perl complains until I put a "my " or "our " in front of first use of $a.

Oh well, maybe I'll figure it out with trial and error, but it is so frustrating :( At least I got function calls right. I think. 

Other than that, explaining that require loads a file once and that variable declarations can't use functions from circular references was good.

EDIT: Well, I guess I figured it out, more or less and Exporter is the way to do it in perl after all. Now I can finally go back to my old project and see about finishing it.

Main.pl:
Spoiler (click to show/hide)

Out.pm:
Spoiler (click to show/hide)


Output:
>perl -w main.pl
Var=one Counter=1
Var=two Counter=1
Var=three Counter=2
« Last Edit: September 07, 2014, 01:50:57 am by Maklak »
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral

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 #6248 on: September 08, 2014, 06:13:36 pm »

So, I haven't had time to do any programming for the last few months, since I started my new job,
I'm just working all the time, and not making enough money,

So I decided to join the Air Force as a programmer,  here soon I'll be programming military software. 
If they accept me that is,
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.

Squeegy

  • Bay Watcher
  • I don't really have any answers for you.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6249 on: September 09, 2014, 01:48:01 am »

I notice you guys don't have a Python tutorial.

Do you want one?
Logged
I think I'm an alright guy. I just wanna live until I gotta die. I know I'm not perfect, but God knows I try.
Kobold Name Generator
⚔Dueling Blades⚔
Fertile Lands
The Emerald Isles

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #6250 on: September 09, 2014, 03:35:59 am »

It probably wouldn't hurt to have one. There's loads of tutorials/docs/etc for Python already, though.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

hops

  • Bay Watcher
  • Secretary of Antifa
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6251 on: September 09, 2014, 04:36:52 am »

Never enuff Dakka tutorial.
Logged
she/her. (Pronouns vary over time.) The artist formerly known as Objective/Cinder.

One True Polycule with flame99 <3

Avatar by makowka

Maklak

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6252 on: September 09, 2014, 11:26:59 am »

Any pointer where to start programming in ASP.NET Web Froms Visual Studio 2012? My boss wants me to learn it.
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6253 on: September 09, 2014, 11:33:43 am »

asp.net-tutorials.com/basics/introduction/ uses vs 2012 express, close enough.
Logged

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6254 on: September 09, 2014, 02:56:19 pm »

I'm having a lot of trouble figuring out how to access the error messages for an applet I' trying to get working. I'm using xampp to test the thing, running on a linux computer, and I've tried four different programs that I'd hoped might give me access to the error logs- Oracle Java 8 Mission Control, Oracle Java 8 console, Oracle Java 8 web start, Oracle Java 8 visual VM. none of these have given me access to the error logs, and I don' know why. I'm not entirely sure whether my program is even showing up on the lists - I see some plugin thing that might be it, but I'm not certain. I'm afraid it might not be showing up due to being run with xampp?

Yeah, I have no idea, please advise.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler
Pages: 1 ... 415 416 [417] 418 419 ... 796