Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

boeman posted:

I definitely don't see why that would be the case.

The Fortran standard dictates that the division of two integers returns the integer nearest the actual result, and between said result and zero.

Adbot
ADBOT LOVES YOU

UZR IS BULLSHIT
Jan 25, 2004

Avenging Dentist posted:

The Fortran standard dictates that the division of two integers returns the integer nearest the actual result, and between said result and zero.

Ok. I didn't realize those numbers were considered integers by default. Thanks.

tef
May 30, 2004

-> some l-system crap ->
edit: mmnnnggmmngn ignore this

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





I want to migrate TCP connections from one machine to another (transparently). I know I can use tun/tap to get at the raw packets, but then I have to implement my own TCP/IP stack which is kind of a downer. Is there a c library around (preferably MIT or BSD licensed) that will make this easier, or a documented api already available?

(Yes, proxy blah blah, I know. Not gonna work for this).

tablebreaker
Dec 4, 2002

I let Andrew earn his RedWings
Here's a quick question: How can I run a script/whatever that will allow a text editor (eg Notepad++) to search and select all text between <div id="here"> and </div>, and delete all other text? Bonus points if it could do this with multiple sections-- keep <title>*</title> in addition to the div "here"...

Does this make sense? Thanks for any help...

Wreckus
Dec 15, 2007

From birth, man carries the weight of gravity on his shoulders. He is bolted to earth. But man has only to sink beneath the surface and he is free.
Is there a Windows utility that can compile python 3.1.1 to an exe? The only one I can find only works for 2.6.

FSMC
Apr 27, 2003
I love to live this lie
I've just got a pickit 3 with with a PIC18F45K20 demo board. After some hassle I've managed to get MPLab IDE working and am able to program to it. I'm programing in C. I've just got a few questions/concerns

1. Are there any good tutorials or guides for programing C on a PIC.
2. Do the rules change due to the very limited capabilities of a PIC compared to computer. e.g. should I start using global variables? How much should I sacrifice usual readability and convenience for performance.

Most of the tutorials I've found are quite old. I can't find any real decent resources.

Any other advice?

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Unparagoned posted:

Any other advice?

Try also posting your question in this thread over in the DIY forums. Some of the folks there are really into low-level digital hardware.

Inverse square
Jan 21, 2008
Ah but you see I was an 06 lurker
This question is more about the life of the programmer than programming. I'm teaching myself to program at the moment, I started in January. I'm a first year Maths and Philosophy student. Would I be wasting my time if I were to try to look for someone who would hire me as a programmer, if I got good, over the summer? I'm after experience as much as I am money (perhaps more).

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Inverse Square: Learning to program is time consuming and requires a great deal of dedication- don't expect to become an expert in a few months. That said, if you know what you're doing it's entirely possible to land a programming job without a CS degree. I have coworkers with backgrounds in everything from geography to mechanical engineering.

Pick tools and languages that line up with what you'd be interested in doing. Do you fancy yourself an applications programmer? Learn Java or C#. (Processing can offer a gentler introduction to Java if you don't want to leap into OOP headfirst.) Web programming more your style? Pick up some Javascript and Python or PHP. Gain some familiarity with source control systems like SVN or Git.

Start putting together a portfolio of projects to show to potential employers- this is how you demonstrate your skills. Something interesting and creative that demonstrates you can design algorithms and write clean, well-organized code will go a lot farther than clicking together a blog in Rails.

Inverse square
Jan 21, 2008
Ah but you see I was an 06 lurker
Don't worry, I know I'm in for a long haul. I know that by summer I'm not going to be a good programmer. I just wondered whether people ever temporarily hire for low-level jobs or internships, like with engineering. My particular area of interest is games and my language is C++, but I'd be fine with any kind of experience.

spiritual bypass
Feb 19, 2008

Grimey Drawer

Inverse square posted:

games and C++

You won't make it doing that without a really solid grounding in CS.

But yeah, companies do hire interns and inexperienced programmers occasionally. At present, though, it's hard enough for experienced programmers to find work. Your best bet at finding a paying gig is web applications.

All kinds of unqualified people tend to slip into those roles.

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!

Unparagoned posted:

I've just got a pickit 3 with with a PIC18F45K20 demo board. After some hassle I've managed to get MPLab IDE working and am able to program to it. I'm programing in C. I've just got a few questions/concerns

...

Any other advice?

If you want high performance on a PIC, you absolutely need to learn to code in assembler, even if you're going to use C eventually. Otherwise, you'll have no clue what your compiler is doing when you hit a performance problem.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
You'd be better off scoring an unpaid internship. Asking for money in this kinda economy is rough pieces, especially considering you're inexperienced.

Inverse square
Jan 21, 2008
Ah but you see I was an 06 lurker

rt4 posted:

You won't make it doing that without a really solid grounding in CS.

But yeah, companies do hire interns and inexperienced programmers occasionally. At present, though, it's hard enough for experienced programmers to find work. Your best bet at finding a paying gig is web applications.

All kinds of unqualified people tend to slip into those roles.
Heh, that sounds sardonic. I wouldn't want to make the world a less professional place here. Mkay, so I won't bother trying to find an interesting summer job.

Uhh... drat though, do I need a CS degree to get any job based around C++ or games programming? Even in these enlightened times? In my degree is Maths with Philosophy - the philosophy is an addendum, and it contains the opportunity to do some CS modules, one of which is actually about C++. I have the resources to not need to go straight into paid work once I leave uni, and like I say, I'm prepared to work hard.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Degrees don't mean poo poo in technology (generally). The proof is all in your experience, plain and simple. But if you don't go through CS classes, chances are you won't learn the things you need to do be a successful programmer. You're more than welcome to prove us wrong, but don't be all talk and no action. Being a good programmer is all about experience and doing actual poo poo.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
You will be entirely unable to work on such a performance-sensitive project as a AAA game engine if you don't have a solid foundation of CS fundamentals. Graph theory, data structures and algorithms, discrete math generally, computer architecture, operating systems basics. Your Math degree may cover some of this in depth but will almost certainly be shallow with respect to DS&A and very shallow to barren on architecture. Additionally, you're going to lack breadth in other CS topics and programming experience generally.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Theory makes you a better programmer. Experience makes you a better programmer. Mix and simmer for 6-10 years. repeat.

Game engines can be pretty complicated, and high-end games touch nearly every facet of CS. Artificial intelligence, computer graphics, physics simulation, procedural animation... you name it. A framework like Unreal3 contains most of the functional parts of an operating system.

If you're *really* interested in making games, have you considered switching majors?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Just to temper the "CS degree is a must" crowd: while everything people are saying is true, you're not going be working on engine stuff straight out of a CS degree unless your skills are far in excess of the average graduate. As an example, a guy I graduated with had his heart set on working in the gaming industry, and the best job he could get was in QA. So, that's what he does. :smith:

Most people that I've met in the gaming industry started out either doing QA or tool work, which is far less sexy than what you seem to be interested in.

Now, that said, at least you're a math major, so when you'll leave you'll be right in the right headspace to look at physics stuff or graphics. Have you contemplated at least a minor in CS, which will let you hit the core data structures / algorithms / numerical methods classes?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Another note is that every programmer who works on games hates their life vehemently

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Everyone in school who doesn't know poo poo about how real life works dreams of working on sexy poo poo. Working on sexy poo poo in a very specific industry like video games and being inexperienced... It's just not looking realistic, at all.

But if you're serious, feel free to channel your burning youth into learning and doing all that's absolutely necessary to making it happen. Or scale it back some.

"I want to be an unpaid web production intern." Much more realistic.

Inverse square
Jan 21, 2008
Ah but you see I was an 06 lurker
General reply: I make games in my spare time; currently using Game Maker, but the point of this is that I want to be more ambitious. The only reason I would want to work in programming for other games would be to supplement my own. Boy I'm giving far more information in this thread than I thought I would be, but whatever, you're all being very helpful.

So yeah, programming for actual games is not necessarily a must. It's certainly not the ultimate goal. It's just that I need to be a better programmer. Are there any places you can imagine that have a lower bar for entry but can help you improve?

spiritual bypass
Feb 19, 2008

Grimey Drawer

Inverse square posted:

Are there any places you can imagine that have a lower bar for entry but can help you improve?

Web applications, seriously.
Also, don't take anyone's programming advice at face value, especially for web stuff. There's tons and tons of people using sticks to dig holes because they either don't know that shovels exist or think they're too difficult to use.

yatagan
Aug 31, 2009

by Ozma

rt4 posted:

There's tons and tons of people using sticks to dig holes because they either don't know that shovels exist or think they're too difficult to use.

There are just as many people using laser guided military grade titanium super-shovels to see what the ground is made of when all they need to do is go poke it with a stick.

Inverse square
Jan 21, 2008
Ah but you see I was an 06 lurker
Just had a look at the flexibility of my degree, and I wouldn't be able to do much CS without giving up Philosophy, which isn't going to happen.

More fun plan though: I'll just sneak into CS lectures and be half arsed about the official stuff. Might even do CS assignments every so often. Guess I'll have to quit a few societies though...

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

yatagan posted:

There are just as many people using laser guided military grade titanium super-shovels to see what the ground is made of when all they need to do is go poke it with a stick.

In web programming? No, there really aren't. (This is where you're gonna say something like "lol JSP" and then everyone else points out that some people like software that actually scales.)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Inverse square posted:

Just had a look at the flexibility of my degree, and I wouldn't be able to do much CS without giving up Philosophy, which isn't going to happen.

More fun plan though: I'll just sneak into CS lectures and be half arsed about the official stuff. Might even do CS assignments every so often. Guess I'll have to quit a few societies though...

You do realize that you're basically asking "how do I become a good enough programmer to work in a field with one of the highest barriers to entry without any formal training?" It's not that this can't be done; but if you have to ask how to learn stuff on your own, then your chances of succeeding are slim to none.

Keep in mind that this comes from someone who majored in mathematics and minored in philosophy, and is currently writing frameworks for computer simulations. For those keeping score, I filled in the gaps in my CS background by reading (and programming a lot). Though I still do have a few gaps to fill.

EDIT: Seriously, if you want to be a good enough programmer to do X, start writing programs (esp. wildly overambitious ones). You don't need to get an internship to learn this stuff. All you'll learn at an internship is "version control loving owns" and possibly "every bug tracker is a piece of poo poo".

Avenging Dentist fucked around with this message at 18:44 on Feb 15, 2010

Inverse square
Jan 21, 2008
Ah but you see I was an 06 lurker

Avenging Dentist posted:

You do realize that you're basically asking "how do I become a good enough programmer to work in a field with one of the highest barriers to entry without any formal training?" It's not that this can't be done; but if you have to ask how to learn stuff on your own, then your chances of succeeding are slim to none.
Yes, I know it's hard. It's just that I was expecting for there to exist tricks of the trade that you only really get in employment, and so see if I couldn't combine personal study with a temp job. I guess not, or not efficiently, which is annoying.

I suppose I did need to re-evaluate my course of action though. I'm currently reading "C++ A beginner's guide" and "Beginning Programming for Dummies", which seemed like common sense to me although BPfD isn't very interesting. My uni has a pretty high ranking for its CS course, so assuming I can follow it I should be able to get quite a lot out. Thanks.

1337JiveTurkey
Feb 17, 2005

One of the big risks of learning to program by yourself is that there's not anyone else around to point out established solutions, provide feedback and to keep you from picking up bad habits. With practice it's possible to reach that point of self-reflection where you can look back at your code and see what went right and what didn't. However a lot of people never do reach that point and end up writing most of the content of the Coding Horrors thread. It compiles and technically produces the correct answer at least some of the time but it's slow, buggy and wouldn't exist if there was some sort of feedback mechanism.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Any recommendations for books to get me started into fractals?

I don't see anything in my ACM virtual bookshelf.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

1337JiveTurkey posted:

One of the big risks of learning to program by yourself is that there's not anyone else around to point out established solutions, provide feedback and to keep you from picking up bad habits. With practice it's possible to reach that point of self-reflection where you can look back at your code and see what went right and what didn't. However a lot of people never do reach that point and end up writing most of the content of the Coding Horrors thread. It compiles and technically produces the correct answer at least some of the time but it's slow, buggy and wouldn't exist if there was some sort of feedback mechanism.

That's why you write massively overambitious projects that ultimately end with you coding yourself into a corner if you're not good enough yet.

raminasi
Jan 25, 2005

a last drink with no ice
I have started trying to teach myself Haskell (via Project Euler), but I still haven't quite wrapped my brain around the "Haskell way." (I am posting this here because there isn't a Haskell thread.) For example...

code:
memoized_fib :: Int -> Integer
memoized_fib =
   let fib 0 = 0
       fib 1 = 1
       fib n = memoized_fib (n-2) + memoized_fib (n-1)
   in  (map fib [0 ..] !!)
Why does this memoize? I don't understand why the recursive definition doesn't cause reinvocation of map.

1337JiveTurkey
Feb 17, 2005

Avenging Dentist posted:

That's why you write massively overambitious projects that ultimately end with you coding yourself into a corner if you're not good enough yet.

That just weeds out the ones who aren't ambitious enough to cause some serious damage.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

GrumpyDoctor posted:

I have started trying to teach myself Haskell (via Project Euler), but I still haven't quite wrapped my brain around the "Haskell way." (I am posting this here because there isn't a Haskell thread.) For example...

code:
memoized_fib :: Int -> Integer
memoized_fib =
   let fib 0 = 0
       fib 1 = 1
       fib n = memoized_fib (n-2) + memoized_fib (n-1)
   in  (map fib [0 ..] !!)
Why does this memoize? I don't understand why the recursive definition doesn't cause reinvocation of map.

It's a little complicated, but the Haskell report promises that any implementation of Haskell will maximize sharing in functions like that one.

Consider this implementation:
code:
all_fibs :: [Integer]
all_fibs = 0 : 1 : [ (all_fibs !! n) + (all_fibs !! (n + 1)) | n <- [0..] ]

fib :: Int -> Integer
fib = (all_fibs !!)
In this case, Haskell internally stores the definition of all_fibs as something like:
code:
all_fibs = 0 : 1 : <code to make remaining elements>
If someone requires, say, the fifth element, then Haskell will need to evaluate that code. Because there is only a single all_fibs list, when it evaluates the code, it changes the internal definition of all_fibs to the newly-evaluated version, because there's no reason not to:
code:
all_fibs = 0 : 1 : 1 : 2 : 3 : <code to make remaining elements>
Note that it doesn't evaluate any further than it needs to.

If someone requires the fifth element again, then Haskell no longer has to evaluate code to find it*, instead only looking at the modified definition of all_fibs and finding the fifth element directly.

Haskell is allowed to make these runtime changes to function definitions because the language requires you to program in a referentially pure manner, which is to say, there is no difference between a value, and a name which evaluates to that value. Thus, evaluations can be cached by the runtime.

Now, the fib function I wrote above is just indexing into all_fibs, so it's trivially memoized by the above transformation.

As to your version, it's just using let notation to move the definition of all_fibs so that it's hidden:
code:
fib :: Int -> Integer
fib = (all_fibs !!)
  where
    all_fibs = 0 : 1 : [ (all_fibs !! n) + (all_fibs !! (n + 1)) | n <- [0..] ]
This is just a scoping change using a let-binding, so it doesn't change the generated code at all.
Then replacing the list comprehension with its definition:
code:
fib :: Int -> Integer
fib = (all_fibs !!)
  where
    all_fibs = 0 : 1 : map get_fib [0..]
    get_fib n = (all_fibs !! n) + (all_fibs !! (n + 1))
Again, this is just replacing the list comprehension with its definition and giving a name to the internal function with a let-binding, so it doesn't change the generated code at all.
Then generalizing that definition:
code:
fib :: Int -> Integer
fib = (all_fibs !!)
  where
    all_fibs = map get_fib [0..]
    get_fib 0 = 0
    get_fib 1 = 1
    get_fib n = (all_fibs !! (n - 2)) + (all_fibs !! (n - 1))
This does change the generated code, but only trivially in that we have moved some logic into get_fib instead of using concrete constructors in all_fibs. The sharing property is preserved, because there is still only a single list.
And, finally, folding the definition of all_fibs:
code:
fib :: Int -> Integer
fib = (map get_fib [0..] !!)
  where
    get_fib 0 = 0
    get_fib 1 = 1
    get_fib n = fib (n - 2) + fib (n - 1)
This does not change the generated code, because we are just using let-binding to inline the definition of all_fibs.

While you're getting a hang of when sharing is happening, I'd advise you to use lots of let bindings and intermediate names for values. For me, at least, it helps to see what computations are being shared. There's also a hackage package vacuum which can graph the internal state of the heap and show you directly what values are being shared, which you may find helpful.

* By "evaluate code" here I mean "perform additional reductions in the code graph representing your program", which is to say, there may be runtime overhead associated with walking the memoized definition of all_fibs, but it is entirely contained within the runtime system itself and is not "actual program code". This is sort of a technical point that you probably don't have to care about.

6174
Dec 4, 2004

rt4 posted:

Any recommendations for books to get me started into fractals?

I don't see anything in my ACM virtual bookshelf.

I can't say from personal experience, but I've been recommended SuperFractals by Barnsley by a professor (one of those incidental comments like "Oh hey, that is a good book if you ever want to learn about the subject"). It is on my list of books to check out when I have some free time, but be aware from what I've seen it assumes a pretty healthy math background.

raminasi
Jan 25, 2005

a last drink with no ice

ShoulderDaemon posted:


This is hugely helpful, thanks. To be honest I thought that the answer was going to be a lot more complicated than "the runtime will aggressively share things." (Don't take that to mean that I didn't understand anything else you were saying.)

raminasi fucked around with this message at 08:35 on Feb 16, 2010

shrughes
Oct 11, 2008

(call/cc call/cc)

GrumpyDoctor posted:

This is hugely helpful, thanks.

Ok, now explain to yourself why this doesn't memoize:
code:
memoized_fib :: Int -> Integer
memoized_fib = \n ->
     let fib 0 = 0
         fib 1 = 1
         fib n = memoized_fib (n-2) + memoized_fib (n-1)
     in (map fib [0 ..] !!) n
And similarly for this:

code:
memoized_fib :: Int -> Integer
memoized_fib =
     let fib 0 = 0
         fib 1 = 1
         fib n = memoized_fib (n-2) + memoized_fib (n-1)
     in (\n -> (map fib [0 ..] !!) n)

Vanadium
Jan 8, 2005

I want to throw my hands into the air and scream about the monomorphism restriction, but I am not entirely sure

raminasi
Jan 25, 2005

a last drink with no ice

shrughes posted:

Ok, now explain to yourself why this doesn't memoize:
code:
memoized_fib :: Int -> Integer
memoized_fib = \n ->
     let fib 0 = 0
         fib 1 = 1
         fib n = memoized_fib (n-2) + memoized_fib (n-1)
     in (map fib [0 ..] !!) n
And similarly for this:

code:
memoized_fib :: Int -> Integer
memoized_fib =
     let fib 0 = 0
         fib 1 = 1
         fib n = memoized_fib (n-2) + memoized_fib (n-1)
     in (\n -> (map fib [0 ..] !!) n)

Is it not just that you can't share the results of anonymous functions? (How could you?) That seems too simple.

Adbot
ADBOT LOVES YOU

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Here's a thread on StackOverflow, how do I deter decompilation of my program?. A handful of answers recommend compiling with full optimizations. My question is... What does that mean? How does that prevent one from decompiling a program? (Of course not literally, just making it harder, right?)

I guess I'm not familiar with what side effects optimizations have to code rather than straight up compiling. :confused:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply