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
shrughes
Oct 11, 2008

(call/cc call/cc)

xPanda posted:

Is that correct?

Yes. The listeners and connectors should must not have the CA's secret key. They'll need to have the CA certificate though.

Adbot
ADBOT LOVES YOU

baquerd
Jul 2, 2007

by FactsAreUseless

shrughes posted:

The listeners and connectors should must not have the CA's secret key.

I want to see this made though, you could bill it as a self-authenticating modular client that does whatever it does and pretends it still has security.

Lurchington
Jan 2, 2003

Forums Dragoon
For what you're talking about, I heard a co-worker talking about Fabric for running remote commands.

link with other info

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm looking for a recommendation for an image processing library. I want to be able to detect large roughly quadrilateral-shaped areas against a background, crop out sections of the images, find straight lines of some length, rotate images, and glue all this together with a scripting language - preferably Python or maybe Perl. I know some of this is doable with ImageMagic, so I don't need a one stop shop for everything, but I'd like something to deal with what I'd consider the hard parts: finding boundaries and lines.

In case it matters, I'm looking at automatically taking a very large picture of a full side of a newspaper broadsheet (think a single piece of newspaper size paper, not just the contents of Page N), finding the actual sheet against the background, finding each page, and correcting for the angle that the picture was taken at by rotating each page (now dealing with Page N instead of the full sheet) as needed.

BigRedDot
Mar 6, 2008

OpenCV has python bindings

http://opencv.willowgarage.com/documentation/python/index.html

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Nice - thanks!

einTier
Sep 25, 2003

Charming, friendly, and possessed by demons.
Approach with caution.
yeah, never mind.

einTier fucked around with this message at 06:53 on Aug 25, 2010

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I almost made a thread out of this because it can turn into a pretty big discussion, but I'll try my luck here instead.

One of the things I ask interview candidates (C# application design, mostly) is an example of when they would use inheritance over composition. Nobody has given me a really good answer (they aren't necessarily supposed to get it 'right', it's just for discussion), and to be honest I'm not sure I have one myself. So, with the exception of deriving from third party base classes where required, where would you use inheritance over composition?

TasteMyHouse
Dec 21, 2006
I'm a fairly new programmer, and I'm working my way through project Euler. I just completed problem 18, where you must find the maximal sum travelling down through a triangle of numbers. I solved it (in python) using a brute force method, but I know that my style is completely god awful. The code gets the job done, but it's really unreadable, and in general I know there must be a better way to go about doing what I did.

I represented the triangle as a list-of-lists. This way, instead of being an equilateral triangle, its a right triangle-- thus the choice of moving to the left or to the right is now the choice of moving straight down or moving to the right. So, I used two nested loops. The inner loop reads a string of 0s and 1s to decide how it is going to traverse through the triangle -- a string of all 0s would just loop straight down summing up the first entries of each list in the list-of-lists. anytime a '1' is found, the index being used on the inner-list is incremented.

The outer loop systematically generates these strings of 0 and 1, so that the inner loop loops through all possibilities. The largest of all the loop-sums is printed.

Whats happening isn't very complicated, but it seems really roundabout, clunky, nooobish etc. Is there a more normal way, stylistically, to do this kind of iteration? Because this really just seems off.

Code is here:
http://pastebin.com/8zdCC66n

tools.intTOstrbin(x) is a function that takes a number and returns a string representing the number in binary. I can post that code too, but it's pretty simple and honestly I feel like I shouldn't be using a string like this anyway.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Orzo posted:

I almost made a thread out of this because it can turn into a pretty big discussion, but I'll try my luck here instead.

One of the things I ask interview candidates (C# application design, mostly) is an example of when they would use inheritance over composition. Nobody has given me a really good answer (they aren't necessarily supposed to get it 'right', it's just for discussion), and to be honest I'm not sure I have one myself. So, with the exception of deriving from third party base classes where required, where would you use inheritance over composition?
Never, except for when you have to. If it's possible to do something via composition, doing it via inheritance probably doesn't result in a sensible class hierarchy.

shrughes
Oct 11, 2008

(call/cc call/cc)

TasteMyHouse posted:

Whats happening isn't very complicated, but it seems really roundabout, clunky, nooobish etc. Is there a more normal way, stylistically, to do this kind of iteration? Because this really just seems off.

Yeah, you just use recursion. Pseudocode follows:

code:
var maxSum = -infinity
def walkPaths(table, row, column, sumSoFar):
    if (row == table.length):
        maxSum = max(maxSum, sumSoFar)
    else:
        walkPaths(table, row + 1, column, sumSoFar + table[row][column])
        walkPaths(table, row + 1, column + 1, sumSoFar + table[row][column])

walkPaths(myTable, 0, 0, 0)

print maxSum
That's not the most algorithmically efficient solution but it is slightly more efficient than yours. Yours will take ~(table.length * 2^(table.length)) time, while recursion will take ~(2^(table.length)) time.

A more efficient solution will take ~((table.length)^2) time, i.e. an amount of time proportional to the size of the input.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
TasteMyHouse,

In addition to what shrughes said, when you get to problem 67, you're going to need the 'more efficient solution' that shrughes mentioned. But you might as well use it for this problem too if you're trying to learn. I won't give away the exact methodology, but to steer you in the right direction, you may wish to visit this: http://en.wikipedia.org/wiki/Dynamic_programming

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Plorkyeran posted:

Never, except for when you have to. If it's possible to do something via composition, doing it via inheritance probably doesn't result in a sensible class hierarchy.
I tend to agree, which is why it makes for a good interview question--every time someone gives an example of using inheritance I just ask them why they don't abstract the behavior into a composed class. But surely there's a proper place for it? Anyone?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
This post is full of spoilers, so don't read if you want to figure it out yourself.
A better solution to that problem is start at the row last-1, and last. You then compare the position below and the position below+1 and add the greater of them to the current one. I probably said that in a retarded way, so this example will help clear it up. Looking at the last two rows in the problem:

63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23

You add the greater of 04 and 62 to 63, which gives you 125. You repeat for everything number left in the row until your row last-1 equals the following:

125 164 102 95 112 123 165 128 166 109 122 147 100 54

You repeat this process all the way to the top and you'll know the answer.

illves
Dec 22, 2005

НЕТ!
I've got a CS theory question (formal language theory stuff). I don't know anywhere besides here or the small math questions thread over in SAP, and I'm not lucking out over there. If this is wildly inappropriate I'm sorry. But, a cross-post:

Under what conditions is the infinite union of languages a regular language?

The regular languages aren't closed under infinite union in general because e.g. 01 ∪ 0011 ∪ 000111 ∪ ... = 0^n1^n is context-free. But it's fine to take the infinite union of certain sets to get a regular language in the end (e.g. w^1 ∪ w^2 ∪ w^3 ∪ ... = ww*). So what has to hold about each of those languages you're taking the union of if you want to get a regular language in the end?

This is related to my research which mostly cares about infinite compositions of rational relations, but these are related ideas. Basically I have a rational relation R and I want to know when R^1 ∪ R^2 ∪ R^3 ∪ ... is rational itself. (Denoting n-fold composition with ^.) Yell at me if this does not immediately follow from my question.

shrughes
Oct 11, 2008

(call/cc call/cc)

IlluminatusVespucci posted:

Under what conditions is the infinite union of languages a regular language?

"When it's regular."

You can make any language with an infinite union of regular languages.

IlluminatusVespucci posted:

So what has to hold about each of those languages you're taking the union of if you want to get a regular language in the end?

You probably already know this, but it's not what has to hold about each of the languages. There are no rules that an individual language must follow for the union to be a regular language.


IlluminatusVespucci posted:

This is related to my research which mostly cares about infinite compositions of rational relations, but these are related ideas. Basically I have a rational relation R and I want to know when R^1 ∪ R^2 ∪ R^3 ∪ ... is rational itself. (Denoting n-fold composition with ^.) Yell at me if this does not immediately follow from my question.

Isn't R* = R^0 ∪ R^1 ∪ R^2 ∪ R^3 ∪ ... ? And that's rational (by definition).

Since R is rational and R* is rational, we know that RR*, which equals R^1 ∪ R^2 ∪ R^3 ∪ ..., is rational.

BigRedDot
Mar 6, 2008

Orzo posted:

I tend to agree, which is why it makes for a good interview question--every time someone gives an example of using inheritance I just ask them why they don't abstract the behavior into a composed class. But surely there's a proper place for it? Anyone?

The only time that comes to mind is when you require runtime polymorphism. I will also usually allow for inheriting from small concrete mixins, as well. Lastly in c++ private inheritance is just syntactic sugar for composition, so if you prefer that stylistically I suppoe that's fine. Of course, there's never a reason for ten level deep inheritance hierarchy spaghetti, the kind I see so much of at work. :(

Death by Cranes
May 3, 2006

These Blockbuster bombs don't go off unless you hit them ju-u-u-u-st right.
Edit: No matter, the reason was my AWESOME webhosting company SUUUUUCCCKKKSSS rear end!!!

Maybe I should look around for a new one, one where I'm allowed more than 1 database.
Any suggestions?

Death by Cranes fucked around with this message at 15:40 on Aug 30, 2010

Alfalfa
Apr 24, 2003

Superman Don't Need No Seat Belt
I am setting up a squeeze page that mimics this http://100newclients.com/ (with permission). Mine can be found at - http://houston-baseball-training.com/email.html

How do I set up the video box on the right hand side to do what that one does? I have the video and know I need to use flash some how, but I have no clue how to use Flash.

Also if someone would be interested in doing this for me since I assume it wouldn't take you that long compared to me, I would be more than happy to throw a few bucks your way.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

Orzo posted:

I tend to agree, which is why it makes for a good interview question--every time someone gives an example of using inheritance I just ask them why they don't abstract the behavior into a composed class. But surely there's a proper place for it? Anyone?

The only time I've seen it used where composition doesn't make sense: sharing implementation commonalities across several 'objects'. The most recent example I've seen was the PageRank implementation in JUNG (in Java). PageRank has a long inheritance chain: PageRank extends PageRankWithPriors extends AbstractIterativeScorerWithPriors extends AbstractIterativeScorer.
The basest class implements all the common stuff you see in iterative algorithms: calculating the rate of change and comparing that against your epsilon, performing the each step until you meet your epsilon criteria or have passed the maximum amount of steps, etc. The biggest problem with inheritance is that you can't ever alter the inheritance chain easily. However, that's not an issue when you set off to implement specific algorithms: you're never going to be told that you have to change how PageRank works.
"Oh Dave, I was talking to Sales and we've decided that we don't want a few of these iterative algorithms to have a maximum amount of steps. We just want PageRank to run forever if that's what it takes."

I've never written something like this though, so I'm mostly using my imagination. I've always used composition.

Sock on a Fish
Jul 17, 2004

What if that thing I said?
I always feel like I'm doing something wrong when I'm making function calls many levels deep in a program's execution and have to pass the parameters from function to function to function just so they'll be available when I need them.

Am I missing something? I know I should avoid globals, but I don't know of another way around this. Maybe singletons? My preferred language is Python.

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
If you've truly got global state, globals are not an evil thing, but from the sounds of it your problem is that you're writing the wrong functions.

Sock on a Fish
Jul 17, 2004

What if that thing I said?

Otto Skorzeny posted:

If you've truly got global state, globals are not an evil thing, but from the sounds of it your problem is that you're writing the wrong functions.

Well, for instance right now the parameters that I'm passing down are needed to invoke a web service. The program constructs and sends emails with attachments, and I've made it so that each instance of the Email object can just send() itself. Each Email owns one or more EmailItem objects that represent attachments, and the attachments come from a webservice that the EmailItem uses to populate itself with data. So, I have to pass details about the web service to the class that builds the list of Email objects, then to the Email object, and then to the EmailItem object. The web service details don't differ for any object instance.

It's definitely possible I'm going about this wrong, I've got close to no professional training in software design.

illves
Dec 22, 2005

НЕТ!

shrughes posted:

You probably already know this, but it's not what has to hold about each of the languages. There are no rules that an individual language must follow for the union to be a regular language.

EDIT: Oh I see what you meant. Yes, obviously I mean what has to hold of each language in the infinite union and they're relationship to one another.

Like a sufficient condition is that the languages are all concatenations of one another (as this would be L* or L+). I'm looking for either a) the necessary conditions or b) a broader sufficient condition (since L* is useless for my purposes as far as I can tell).

quote:

Isn't R* = R^0 ∪ R^1 ∪ R^2 ∪ R^3 ∪ ... ? And that's rational (by definition).

Sorry, that was my abuse of notation. I was using ^ to denote n-fold composition of a single relation, not concatenation. E.g. R^4 = R ∘ R ∘ R ∘ R = R(R(R(R)))). Sorry if I misunderstand you.

My real ultimate goal is to find a class S within the rational languages such that for every R in S the following infinite union is rational: R ∪ R ∘ R ∪ R ∘ R ∘ R ∪ ∪ R ∘ R ∘ R ∘ R ∪ ...
I'm thinking of this as a first step but maybe that helps clarify what I want.

illves fucked around with this message at 18:55 on Aug 30, 2010

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Smugdog Millionaire posted:

The only time I've seen it used where composition doesn't make sense...
I'm not really familiar with this particular set of classes or what they do, so maybe I'm not following correctly, but why would this be a bad place to use composition again? It looks like there's some sort of hideous inheritance structure and these 'shared implementation commonalities' could easily be a separate class. Or the shared code could be the main client class with the derived details being the composed strategies.

baquerd
Jul 2, 2007

by FactsAreUseless

Alfalfa posted:

I am setting up a squeeze page that mimics this http://100newclients.com/ (with permission). Mine can be found at - http://houston-baseball-training.com/email.html

How do I set up the video box on the right hand side to do what that one does? I have the video and know I need to use flash some how, but I have no clue how to use Flash.

Also if someone would be interested in doing this for me since I assume it wouldn't take you that long compared to me, I would be more than happy to throw a few bucks your way.

http://forum.videohelp.com/threads/255412-How-to-convert-to-Flash-FLV-Video-and-add-it-on-your-homepage

edit: I noticed he has an interactive feature that mutes the volume and obscures the picture until you enter your email, that makes it more complicated than a straight flv, you'll need to get the Macromedia Flash program ($$$) or hire this out, bit more than a couple bucks to integrate it all together though.

baquerd fucked around with this message at 18:55 on Aug 30, 2010

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Sock on a Fish posted:

Well, for instance right now the parameters that I'm passing down are needed to invoke a web service. The program constructs and sends emails with attachments, and I've made it so that each instance of the Email object can just send() itself. Each Email owns one or more EmailItem objects that represent attachments, and the attachments come from a webservice that the EmailItem uses to populate itself with data. So, I have to pass details about the web service to the class that builds the list of Email objects, then to the Email object, and then to the EmailItem object. The web service details don't differ for any object instance.

It's definitely possible I'm going about this wrong, I've got close to no professional training in software design.
If the objects in between don't conceptually give a drat about the stuff you're passing along, then there's a problem. If they're all contributing in some way then I suppose that's all right, but it would be best if the little bits that contribute to the whole could theoretically be used to contribute to something else too.

Sock on a Fish
Jul 17, 2004

What if that thing I said?

Rocko Bonaparte posted:

If the objects in between don't conceptually give a drat about the stuff you're passing along, then there's a problem. If they're all contributing in some way then I suppose that's all right, but it would be best if the little bits that contribute to the whole could theoretically be used to contribute to something else too.

Yeah, the guy that builds the list of emails shouldn't have any knowledge of what web service gets used to pull attachments, but the way I've designed this it either has to or else I need to use globals. Would a better way be to not have the Email objects build themselves, but rather move up a level in the chain and feed each email into an object that's aware of the web service and adds the appropriate attachment?

Are there any guides on general design principles like this? I read Clean Code awhile back and ended up with much, much better code as a result. I'd really like to improve further. I used to regularly have functions with like 16 arguments.

CapnAndy
Feb 27, 2004

Some teeth long for ripping, gleaming wet from black dog gums. So you keep your eyes closed at the end. You don't want to see such a mouth up close. before the bite, before its oblivion in the goring of your soft parts, the speckled lips will curl back in a whinny of excitement. You just know it.
How dangerous is the " character (that's a quotation mark, not two singlequotes) in regards to SQL injection attacks? I'm bumping up against some previously-written anti-hacking code that's disallowing any quotation marks in the query string or form fields, and after giving myself a very brief crash course I don't know why. I know why ' is dangerous, but " ought to be okay, right? What's the danger?

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

CapnAndy posted:

How dangerous is the " character (that's a quotation mark, not two singlequotes) in regards to SQL injection attacks? I'm bumping up against some previously-written anti-hacking code that's disallowing any quotation marks in the query string or form fields, and after giving myself a very brief crash course I don't know why. I know why ' is dangerous, but " ought to be okay, right? What's the danger?

Your question, while well-intended, is ultimately the wrong one to ask.

You don't want to filter out metacharacters yourself. You don't actually want to filter at all, actually - you want to use prepared statements/parameterized queries - but if you must do escaping, use your vendor's supplied escaping function.

e: cf. http://bobby-tables.com/ for how to do this in practically any language with practically any database; feel free to ignore the xkcd schlock, but the info itself is fine

Blotto Skorzany fucked around with this message at 22:31 on Aug 30, 2010

CapnAndy
Feb 27, 2004

Some teeth long for ripping, gleaming wet from black dog gums. So you keep your eyes closed at the end. You don't want to see such a mouth up close. before the bite, before its oblivion in the goring of your soft parts, the speckled lips will curl back in a whinny of excitement. You just know it.

Otto Skorzeny posted:

Your question, while well-intended, is ultimately the wrong one to ask.

You don't want to filter out metacharacters yourself. You don't actually want to filter at all, actually - you want to use prepared statements/parameterized queries - but if you must do escaping, use your vendor's supplied escaping function.

e: cf. http://bobby-tables.com/ for how to do this in practically any language with practically any database; feel free to ignore the xkcd schlock, but the info itself is fine
We're doing stored procedures already, actually. This is from before my time, so all I've got is the following shreds of a story: We were using stored procedures, we somehow got hacked by SQL injection anyway, the guy before me wrote this cute little function that examines form field and query string inputs and kicks to an error page if it deems anything suspicious. Which is all well and good, but it thinks a single " is suspicious and I sorta need those in my querystring now. I don't get how that's a threat, but I'm not gonna go "oh okay delete it then" in this case because my knowledge is imperfect and I'm dealing with security issues.

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
Stored procedures != prepared statements

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Sock on a Fish posted:

Yeah, the guy that builds the list of emails shouldn't have any knowledge of what web service gets used to pull attachments, but the way I've designed this it either has to or else I need to use globals. Would a better way be to not have the Email objects build themselves, but rather move up a level in the chain and feed each email into an object that's aware of the web service and adds the appropriate attachment?

Are there any guides on general design principles like this? I read Clean Code awhile back and ended up with much, much better code as a result. I'd really like to improve further. I used to regularly have functions with like 16 arguments.
This stuff can get real subjective. My own view is not to have the Email objects send themselves. I don't know what to think of them building themselves. It often works well to think of objects in terms of how similar things are used in life, or at least how they would work in some way mechanically or physically. In that respects, an email wouldn't write itself, so I would leave the finer points of its construction to something else, but the object should be able to contain everything that makes up an email. Then other things would make them, fill them in, and manage moving them around.

You talk a lot about building Email objects, so maybe look at design patterns like the Builder pattern or a Factory pattern for some idea on how to write objects expressly for making GBS threads out other objects. In the past I've recommended people look at a lot of programming design patterns to get an idea of what good design is generally like.

Somebody that's decent enough with design will see most patterns and think, "no poo poo!" which is probably a good thing. It's also easy to go overkill with them, so only look at them for inspiration for what you need to do. However, if you've been used to ad hoc programming then do one in anal detail sometime just to see what it's like to stick to a design like that. You can see what it's like to take something abstract like that and make it into code, and the kind of nagging questions that'll won't pop up the first time until you're halfway through. Then you'll start to get an idea up front of structured ways of doing things, and then you're thinking in terms of design.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

Orzo posted:

I'm not really familiar with this particular set of classes or what they do, so maybe I'm not following correctly, but why would this be a bad place to use composition again? It looks like there's some sort of hideous inheritance structure and these 'shared implementation commonalities' could easily be a separate class.
http://jung.sourceforge.net/doc/api/edu/uci/ics/jung/algorithms/scoring/PageRank.html
It's significantly more convenient to use inheritance than composition. Inheritance gives you specific slots to fit your derived functionality and you don't have to repeat the same code.
I'm imagining the PageRank object having a private PageRankWithPriors object and you essentially copy all the methods into the PageRank class that do nothing but call the inner object. That's a lot of pointless boilerplate and doesn't really get you anything. Your class still has a compile-time dependency on the 'base class'.

Orzo posted:

Or the shared code could be the main client class with the derived details being the composed strategies.
My understanding of this approach would be having an interface corresponding to the derived class, then require an instance implementing that interface be given to the 'base class'. You gain a little separation and you can compose them at run-time, I guess. I don't see the value in that though.
Just from a keyboard pounding standpoint, I much prefer new PageRank() to
code:
new AbstractIterativeScorer(new AbstractIterativeScorerWithPriors(new PageRankWithPriors(new PageRank())))
I also think it makes more sense to expose a PageRank algorithm instead of requiring people to instantiate the implementation chain themselves. When you need to score some graph with PageRank you don't think to yourself, "well I'll use an iterative algorithm I suppose. And it'll need priors. Oh PageRankWithPriors fits the bill. And I might as well use the default prior values that the PageRank class gives me."
You think "I bet PageRank will be useful, I'll use that."

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I know you provided a link to the API but I don't really have time to read all of that right now, perhaps someone who is already familiar with it can illustrate what I'm trying to say better. The link you've provided doesn't seem to show which inherited methods are public and which aren't, so I'm having trouble seeing the actual interface of each level. It looks completely bloated though, classes should not be doing anywhere near as much as PageRank appears to be.

Hopefully I can take a look at it more tonight. Or maybe you can provide a more abstract example which illustrates your side of the argument directly.

ScaerCroe
Oct 6, 2006
IRRITANT
I just learned that I need to learn Fortran, and fast. Today was the first day in my two of my grad level astronomy courses, and both courses are strongly rooted in the use of fortran. I have taken two programming classes in undergrad, C++ and Python.

1) I have done some googling, and I saw that one astro professor recommended the g77 compiler instead of a newer one for relative ease of use, but the article was from 2000 or something. Good idea? Some other students said they had been using this for research.

2) Should I buy a book, or are the online manuals helpful enough that I can learn its useful properties?

litghost
May 26, 2004
Builder

ScaerCroe posted:

I just learned that I need to learn Fortran, and fast. Today was the first day in my two of my grad level astronomy courses, and both courses are strongly rooted in the use of fortran. I have taken two programming classes in undergrad, C++ and Python.

1) I have done some googling, and I saw that one astro professor recommended the g77 compiler instead of a newer one for relative ease of use, but the article was from 2000 or something. Good idea? Some other students said they had been using this for research.

2) Should I buy a book, or are the online manuals helpful enough that I can learn its useful properties?

It really depends on what you need to be doing. As an example, if you need to do lots of interfacing between Fortran and C, I don't think a book is really gonna help you (because different compilers/OS/etc), but places online can explains the details.

It also matters which version of Fortran you are working with. For example standard F77 has 0 dynamic memory management. F90 and on have some forms.

It also matters if you are compiling in a "strict" enviroment. Strict means 72 character column maximum, no ! comments, first 5 characters are control characters only, etc. If you are in a non-strict environment you will have potentially 130-150 character column maximum, ! comments, and other stuff.

It is worth noting Fortran programmers LOVE GOTO statements, because there is no WHILE loop in F77, and some compilers do not have a for loop construct. Look to BASIC here!

Oh, and the type system by default is implicitly typed based on the first character of the variable name!

Welcome to hell.

Bottom line, you need to determine what dialect of Fortran you will be working with. You could just convince them to use f2c and get over Fortran, but that is unlikely.

F77 standard

Decent summary of F77

The wide weird world of Fortran format statements

litghost fucked around with this message at 06:32 on Sep 1, 2010

Dijkstracula
Mar 18, 2003

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

litghost posted:

Welcome to hell.
Now, the flip side is that F90/95 is actually not that terrible, so if you can possibly get away with using gfortran and a semi-modern language implementation, for God's sake, do it.

good luck, scientific code :suicide:

litghost
May 26, 2004
Builder

Dijkstracula posted:

Now, the flip side is that F90/95 is actually not that terrible, so if you can possibly get away with using gfortran and a semi-modern language implementation, for God's sake, do it.

good luck, scientific code :suicide:

But why would you write NEW code in Fortran? Any code that requires using Fortran is in F77 anyways (at least in my corner of the world). Of course you could port it to F90, but the problems with F77 (implicit variables, massive global state, non-typed interfaces, no modules, etc) don't go away without a rewrite.

Adbot
ADBOT LOVES YOU

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Without knowing the language, I'd generally recommend getting a book up front for learning a language despite a multitude of sources online. I like to get a book that is in some way definitive of the language that I examine in isolation of a computer so that I can generally grok the nature of the language and the style of programming in it.

I don't know if others learn a language in a similar way. But I am also pretty frustrated with what I feel like is a bunch of people that learned a little C in college applying that same procedural methodology to every new language they see. As a simple example, I'll find a lot of people at work not going anywhere near a foreach kind of loop in any of the newer languages because it never crossed their mind that such a thing could possibly exist and be useful.

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