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
MrMoo
Sep 14, 2000

Jam2 posted:

An important factor is the authenticity of the experience.

What does this mean? Aged and tedious to use? For that go with one of the BSDs instead of Linux.

Adbot
ADBOT LOVES YOU

Jam2
Jan 15, 2008

With Energy For Mayhem

MrMoo posted:

What does this mean? Aged and tedious to use? For that go with one of the BSDs instead of Linux.
As I describe this, please keep in mind I don't know anything about Linux.

I don't want a flavor of Linux that attempts to mimic the Windows experience to the point of no longer being an environment useful for learning what makes Linux great.

Thus, I don't want an apologetic distro that attempts to convert a Windows user by offering sacrifices to make the transition more pleasant at the expense of something else.

MrMoo
Sep 14, 2000

Well generally you have your Unix or similar boxes and then remotely connect via PuTTY or other SSH program. Therefore you are not ever setting at a Linux or Unix desktop to do your work unless you really, really want to. Thus it doesn't matter whether you choose Fedora, Ubuntu, Debian, or whatever distribution.

Jam2
Jan 15, 2008

With Energy For Mayhem

MrMoo posted:

Well generally you have your Unix or similar boxes and then remotely connect via PuTTY or other SSH program. Therefore you are not ever setting at a Linux or Unix desktop to do your work unless you really, really want to. Thus it doesn't matter whether you choose Fedora, Ubuntu, Debian, or whatever distribution.

I will just run Fedora then. This as a VM is suitable for learning to program C?

I am asking basic questions because the road ahead is shrouded in mystery.

Jam2 fucked around with this message at 07:54 on Mar 18, 2011

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Since you're already using a MacBook, I feel obliged to point out that you can do C systems programming perfectly reasonably in Mac OS X, which provides a complete UNIX environment derived from FreeBSD.

But yes, you can use any Unix distribution you please to learn C.

Jam2
Jan 15, 2008

With Energy For Mayhem

rjmccall posted:

Since you're already using a MacBook, I feel obliged to point out that you can do C systems programming perfectly reasonably in Mac OS X, which provides a complete UNIX environment derived from FreeBSD.

But yes, you can use any Unix distribution you please to learn C.

What's the bare minimum needed to do exercises from "The C Programming Language?" What niceties are there for C in OS X?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Jam2 posted:

What's the bare minimum needed to do exercises from "The C Programming Language?" What niceties are there for C in OS X?

A compiler.

For Mac OS X, it's easiest to pop in your Mac OS X install disc and install the Developer Tools. That'll put gcc in your path and give you Xcode if you need some heavyweight text editing.

There aren't any specific niceties for C in Mac OS X with the possible exception of TextMate, a text editor. Though if you want some objects with your C, Mac OS X hosts the best Objective-C environment and libraries, so that's a tangental nicety.

raminasi
Jan 25, 2005

a last drink with no ice

PDP-1 posted:

In general I don't know the value of the constant C, it is a function of how the experiment producing this data is set up and will vary from measurement to measurement. The value of C is also 'big' in the sense that it accounts for about half the amplitude of the total signal so I can't just approximate it as zero. Whatever fitting algorithm I end up with will need to be able to solve for all three parameters independently.

I'll check out the libraries you mentioned later today - it looks like LINPACK/LAPACK can be used as long as you give credit to the folks who wrote it and that'd be fine with me. If I can plow through the documentation and get the libraries to hook into .NET this might be a solution.

I'm sure R could do the fitting, or for that matter I could just brute-force it with the Solver function in Excel, but I'd really like to integrate the curve fit into my program so the scientists working on this project can twiddle the knobs and settings on the system and watch the values change in near real time.

Thanks for the suggestions so far, and keep 'em coming.


semi-edit: I really only care about the value of B, the constants A and C are essentially throw-away fitting parameters. I could take the numerical derivative of f(x) which would get rid of the constant term and then do a semi log fit to df(x)/dx=A*B*exp(B*x) and get B from the slope of that line. Good idea or bad idea?

Numeric stuff is really not my thing but would this work be appropriate to do with Matlab (assuming it's in your budget)? Matlab can talk to .NET fine, and you can buy the capability to compile Matlab code into .NET assemblies.

It could be super overkill but I don't know the scope of what you're doing.

Scaevolus
Apr 16, 2007

PDP-1 posted:

f(x) = A*exp(x*B) + C
Can't this be simplified?

f(x) = A*exp(x)*exp(B) + C = D*exp(x) + C ?

edit: oh wait :downs:

Scaevolus fucked around with this message at 15:35 on Mar 18, 2011

Opinion Haver
Apr 9, 2007

Scaevolus posted:

Can't this be simplified?

f(x) = A*exp(x)*exp(B) + C = D*exp(x) + C ?

A*exp(x*B) is A*(exp(x))^B, not A*exp(x)*exp(B).

Jam2
Jan 15, 2008

With Energy For Mayhem

pokeyman posted:

A compiler.

For Mac OS X, it's easiest to pop in your Mac OS X install disc and install the Developer Tools. That'll put gcc in your path and give you Xcode if you need some heavyweight text editing.

There aren't any specific niceties for C in Mac OS X with the possible exception of TextMate, a text editor. Though if you want some objects with your C, Mac OS X hosts the best Objective-C environment and libraries, so that's a tangental nicety.

I've been looking into xcode. Am I cheating myself out of useful knowledge by going straight out of the gate to xcode and llvm instead of a traditional editor and gcc?

spiritual bypass
Feb 19, 2008

Grimey Drawer
In my opinion, the act of computer programming is far less interesting than having a working application. Use whatever tool gives you a decent product with the least effort (xcode)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The choice of editor is independent from the choice of compiler; feel free to use an LLVM-based compiler from the command line (where they'll be called llvm-gcc and clang).

Using XCode — really, any IDE — will indeed "cheat" you out of some knowledge: you won't learn how to manage your own build system, you won't learn how to use command-line development tools, etc. If part of this is an effort to capture "the experience", then you need to use an unintegrated text editor, write your own makefiles, learn how to drive gdb, etc. Furthermore, every time you find yourself doing something dull and repetitive — even something as simple as a multi-file search-and-replace — instead of brute-forcing it, figure out how to use existing command-line tools to do it for you. Usually that'll take a lot more time to achieve your immediate goal, but it's the only way you'll really learn to use those tools.

Once you've learned all that, though, don't feel like you have to keep using it just to spite XCode.

Modern Pragmatist
Aug 20, 2008
Where can I find some information on making design decisions for object oriented programming.

I am working on developing a codebase and I feel like at every step of the way I am second guessing how I should go about organizing my work. I have a very good idea of what I need, just not the best way to go about organizing it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

rt4 posted:

In my opinion, the act of computer programming is far less interesting than having a working application. Use whatever tool gives you a decent product with the least effort (xcode)

In my opinion, both are equally interesting. I get a lot of satisfaction out of just writing code whether or not it ever ends up in production.

MrMoo
Sep 14, 2000

Jam2 posted:

I've been looking into xcode. Am I cheating myself out of useful knowledge by going straight out of the gate to xcode and llvm instead of a traditional editor and gcc?

llvm offers a significantly more comprehensive set of warnings and errors than gcc, unless you really like stabbing yourself in the eye I'd recommend learning with that.

Jam2
Jan 15, 2008

With Energy For Mayhem
Gradually realizing I cannot apply the antiquated learning strategies of the natural sciences to learning to program.

It is really just about writing a lot of programs.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Jam2 posted:

Gradually realizing I cannot apply the antiquated learning strategies of the natural sciences to learning to program.

It is really just about writing a lot of programs.

I dunno if this is useful to you: The way I learned to code was literally through iteration. First type in some c64 basic magazine program that asks your name and tells you how old you are based on your birthday & todays date. Then fix typos, then make that program ask more questions, and keep state of previous questions. Then have it be able to save that state. Then write lovely adventure games in QBasic on school computers, weird platformers in Hypercard, etc, etc. Each step of the way was basically:

10 write some code
20 attempt compilation (or interpretation)
30 fix bugs
40 goto 10

35 if no immediate errors show up goto 45
45 print "it works!"

There's a lot to be said for thinking it all through & architecting, but that all comes after getting the gut feel for how computer makes sense of the stuff you write.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Modern Pragmatist posted:

Where can I find some information on making design decisions for object oriented programming.

I am working on developing a codebase and I feel like at every step of the way I am second guessing how I should go about organizing my work. I have a very good idea of what I need, just not the best way to go about organizing it.

What are you trying to model? Can you give the classes?

If not, have you tried making an UML diagram? What are your use cases? What are the actors?

ToxicFrog
Apr 26, 2008


Jam2 posted:

It is really just about writing a lot of programs.

Pretty much this.

Which tools you use can make it easier or harder, and there's important theory to be learned as well, but fundamentally, the way you become a good programmer is by programming.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Not really a question, but I imagine there are a lot of programmers in this thread who read code posted on the internet.

Lifehacker shared two Chrome extensions that automatically syntax highlight code on webpages. Code Highlight seems to do a good job highlighting code here on the SA forums...

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

ToxicFrog posted:

Pretty much this.

Which tools you use can make it easier or harder, and there's important theory to be learned as well, but fundamentally, the way you become a good programmer is by programming.

True, but if you just keep repeating bad habits you're not going to get any better.

There's a lot to be said for people who program in the old 'BASIC interpreter' style. Write a few lines, run it, change some stuff, run it again...

It's a good way to learn how things work but eventually you want to be able to avoid making mistakes in the first place. It reminds me of some story I heard about Bill Gates or Steve Wozniak, they were going to demo a product and they had forgotten to write the program to actually load the version of BASIC they were going to use. So on the plane, they wrote the program out in paper and pencil and it worked the very first try.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Bob Morales posted:

There's a lot to be said for people who program in the old 'BASIC interpreter' style. Write a few lines, run it, change some stuff, run it again...

I find myself doing this a lot when I don't know the API of some library I want to use.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

I saw comments in some code the other day at work that basically went like this:
code:
#  Insert junk data into the password since I heard smaller passwords are easier to decrypt
hash = Encrypt(junkdata+password)
This was using a standard method in Ruby. Am I correct in thinking in that correctly implemented encryption function, it's no more difficult to 'crack' a short message than a long message? What about a hashing function?

'abc' vs 'amuchlongerpassword'

litghost
May 26, 2004
Builder

Bob Morales posted:

I saw comments in some code the other day at work that basically went like this:
code:
#  Insert junk data into the password since I heard smaller passwords are easier to decrypt
hash = Encrypt(junkdata+password)
This was using a standard method in Ruby. Am I correct in thinking in that correctly implemented encryption function, it's no more difficult to 'crack' a short message than a long message? What about a hashing function?

'abc' vs 'amuchlongerpassword'

Well adding additional data to the password is typically called a salt and is useful in disrupting rainbow table methods. So really it has nothing to do with the length, so much as preventing pre-computation of the hash.

PS Hire someone who knows something about security. Whoever left that comment does not. I hope I never do business with your company.

Nippashish
Nov 2, 2005

Let me see you dance!
I'm looking for a C++ geometry library, preferably lightweight. Ease of use is significantly more important than speed.

The only operation that is absolutely essential right now is the ability to take a set of 3d points and test if a query point lies in their convex hull, but it would be nice to have a library for dealing with this kind of thing in general.

I've looked a bit at qhull and cgal, but they are both very complicated, and significantly more than what I really need.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Nippashish posted:

I'm looking for a C++ geometry library, preferably lightweight. Ease of use is significantly more important than speed.

I have no libraries to offer but that sounds like a fun-ish project that'd take a few nights' work, so I recommend you get on it and share what you come up with!

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Nippashish posted:

The only operation that is absolutely essential right now is the ability to take a set of 3d points and test if a query point lies in their convex hull, but it would be nice to have a library for dealing with this kind of thing in general.

The GJK algorithm would be useful for this problem and I'd bet you could Google up an implementation in C++ pretty quick.

If you just have a set of convex points Pi and some query point Q the algorithm boils down to trying to find some sub-set of Pi, call it Pj, where Pj-Q encloses the origin. If no subset exists then Q is not enclosed by Pi.

This guy gives a fairly clear, if long winded, explanation of how it works.

Modern Pragmatist
Aug 20, 2008

Carthag posted:

What are you trying to model? Can you give the classes?

If not, have you tried making an UML diagram? What are your use cases? What are the actors?

I guess the point of my question was to find a good reference that would help in generating the UML diagram etc. and understanding all of the associated terms.

A little more on what specifically I'm dealing with. I am essentially writing code for an image viewer. The basic components being:

1) Images: 2D image data OR a multi-dimensional stack of 2D images
2) Image Metadata
3) Regions of Interest (ROIs): Identified by coordinates and displayed as either polygons or masks. There can be an infinite number of regions defined per 2D image

An example of some of the issues that I am attempting to reason through:

1) Linking of data with display: Do you have a separate class (i.e. ImageWindow) that monitors the associated ImageStack for changes or do you have a show() method in each Image component of ImageStack?

2) Should ROIs be made an attribute of an Image or should you have ANOTHER container class that encapsulates an Image and its associated ROIs both as properties?

I hope that this clarifies the perspective that I am coming from.

Nippashish
Nov 2, 2005

Let me see you dance!

PDP-1 posted:

The GJK algorithm would be useful for this problem and I'd bet you could Google up an implementation in C++ pretty quick.

If you just have a set of convex points Pi and some query point Q the algorithm boils down to trying to find some sub-set of Pi, call it Pj, where Pj-Q encloses the origin. If no subset exists then Q is not enclosed by Pi.

This guy gives a fairly clear, if long winded, explanation of how it works.

I ended up finding this example in the cgal documentation which includes code to solve point-in-convex-hull problem so I decided to suck it up and go with that. I'll give GJK a look though, since it could come in handy later if I need to deal with intersecting volumes.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I could use a little bit of programming career help here. I think I'm really getting stuck having not worked with some kind of web MVC framework like a Java application server and the supporting gamut of things like Spring/Hibernate. Or for that matter even asp.net or django. I've doodled with a few of them in the most basic ways and I understand the general gist. But that's not going to get me hired anywhere either. Would it be wise to develop the expertise in one of these on my own? Or should I perhaps try getting one step ahead with things like cell phones?

My main languages are C++, Java, Python, and C#, if that helps. And I've done some basic stuff with databases, but not much with a library that tries to take care of the DB stuff for me. My perception is none of those technologies work fantastically the first time and being an expert there would be marketable.

very
Jan 25, 2005

I err on the side of handsome.
So I hear that unit testing is a thing that real grown-up programmers do...

How can I start unit testing in an environment that is seemingly hostile towards testing? I don't really have time to finish what I'm working on in the first place. Secondly, most of the classes that I want to test can only be instantiated through a de-serialization process that takes input from a hugely complicated asset build system. Needless to say, nobody really tests anything here.

We've got xunit with some stuff plugged into it, but if you invoke the existing tests, everything simply explodes because nobody has run them for years. The leads don't really care about this.

I'm positive that I've never written a single piece of code here that is testable, let alone tested.

Do I just ignore all of the code that I've already written and try to test new stuff? The problem with that is that I usually have no idea what I'm writing until I've written it (two or three times). How can I test the unknown?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

very posted:

Do I just ignore all of the code that I've already written and try to test new stuff?

Maybe unit tests are too painful for you to do without massive refactoring, but you could see if integration tests are easier to get off the ground. Testing's good, unit testing isn't always the most important kind.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

very posted:

Do I just ignore all of the code that I've already written and try to test new stuff? The problem with that is that I usually have no idea what I'm writing until I've written it (two or three times). How can I test the unknown?
What pokeyman said, plus sometimes you can get away with minor refactoring to isolate small chunks of logic that are testable. If it really is very complicated, don't waste tons of time refactoring the entire thing just so you can get more tests out. Definitely try to get an environment up where you can do integration testing, which can be even more valuable than unit tests in some cases.

For the type of code that you need to write 2 or 3 times before you know what you're doing, just ignore people who spew a TDD mantra at you, as they have likely never written anything where the challenge is architectural layout of classes rather than the implementation of said classes. TDD can be great but it's not always the best approach and it's okay to cover your code after writing it.

Sneftel
Jan 28, 2009

very posted:

How can I start unit testing in an environment that is seemingly hostile towards testing?
This book was specifically written to address your problem.

very
Jan 25, 2005

I err on the side of handsome.

Sneftel posted:

This book was specifically written to address your problem.

Thanks. This book looks great.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES
So I must be just googling the wrong terms or some poo poo, because I cannot for the life of me figure out how to get Mathematica to give me a column of a n x m array.

For example, in python, if I wanted just the first column of a n x m array, I just type in Array[:,0]. I'm sure there's an analog for this in Mathematica, but I just can't find it.... I'd rather not just write a lame loop to append about a million data points to make this the brute force way.

Thanks in advance.

EDIT: :doh: It figures as soon as I post this, I find the answer on stackoverflow. Thanks anyway!

The answer is Array[[All,1]] etc.

JetsGuy fucked around with this message at 00:02 on Mar 23, 2011

Contra Duck
Nov 4, 2004

#1 DAD

very posted:

So I hear that unit testing is a thing that real grown-up programmers do...

I won't repeat what everyone else has said but it was all good advice that I agree with. A couple of additional things though:

* From a technical side, have you looked into any mocking libraries? They might be able to take the complexity out of creating these objects in your framework. As long as you can resist the temptation to mock out everything, they can help you create useful tests in scenarios like yours.

* From a non-technical side:

quote:

We've got xunit with some stuff plugged into it, but if you invoke the existing tests, everything simply explodes because nobody has run them for years. The leads don't really care about this.

Unless you can change this attitude any tests you write will be worthless. It sounds like you really need a cultural change in the company more than anything and that sort of thing needs to come from the top down.

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
I'm working on a project in Max/MSP, and I've found a way to send reports to the Terminal. I know there is a way to get terminal to then output whatever is going on into a text file, but I don't know how. Any guides/advice out there? I'm a novice in programming in general.

Adbot
ADBOT LOVES YOU

TasteMyHouse
Dec 21, 2006

WrongWay Feldman posted:

I'm working on a project in Max/MSP, and I've found a way to send reports to the Terminal. I know there is a way to get terminal to then output whatever is going on into a text file, but I don't know how. Any guides/advice out there? I'm a novice in programming in general.

oh god you have my sympathies. I wouldn't wish Max/MSP on my worst enemy.

With that said, if you execute max from the command line you can just redirect its output to a text file. the syntax for doing so (in bash) is
programname > filename

that will take all of the program's terminal output and store it in that file. I assume you're on os x, but the syntax is the same on the windows command line too.

HOWEVER, why are you doing this? there's probably a built-in max object that handles whatever it is you're trying to do more elegantly

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