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
Fly
Nov 3, 2002

moral compass

IntoTheNihil posted:

None at all. I'm brand new to programming but very interested in finding my niche.
I would avoid any niche for long.

Adbot
ADBOT LOVES YOU

hexadecimal
Nov 23, 2008

by Fragmaster

IntoTheNihil posted:

Thanks for the info Dijk.


None at all. I'm brand new to programming but very interested in finding my niche.

Well, if you really want to get serious, you should probably start with C++. It is harder to learn than Java but it will teach you how to also deal with dynamic memory which is something all programmers should know, imo.

Java is a good learning language too, however, it just won't force you to do some things.

Feel free to IM me on ICQ for any questions.

vvvvvvvv Yea you're right.

hexadecimal fucked around with this message at 05:55 on Jan 14, 2009

Dijkstracula
Mar 18, 2003

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

I disagree. There's no reason to know anything about the C memory model if you're learning Java to become a Java developer. Yes, it's something that everyone should know about in a perfect world, but given that he's starting from first principles I think it's best to choose a level of abstraction and stick with it. He can always come back to the lower-level stuff if he so chooses.

One of the good things about Java is that it does force you to code in a certain way; with C++, your methology can range from "procedural programming with iostreams" to "C with classes" to "Java-style OOP where most everything is a class" to "template metaprogramming and C++0x draft standard wankery" and everything in between. Given that he doesn't have an instructor guiding him, a more restricted language is probably what he needs, and the fact that he's looking at Java jobs is the icing on the cake in my view.

zootm
Aug 8, 2006

We used to be better friends.
So good I posted it twice apparently.

zootm fucked around with this message at 11:56 on Jan 14, 2009

zootm
Aug 8, 2006

We used to be better friends.

IntoTheNihil posted:

Sorry to spam up this thread with even more questions but I've recently discovered how huge the Java market really is. Even around my city there's multiple high paying jobs for Java programmers. Can anyone tell me the pros and cons of the language and some general learning info? I messed with it a bit before and even though people say it's simple I couldn't grasp much.
I think you should probably note that although there's a lot of Java work around, a large amount of it is tedious grunt work that will eat your soul. This is the consequence of Java being big in 'enterprise', and can apply to other things too, notably .NET.

That said if you can deal with that and dig to find what you want (or dream of sleeping on a bed of money) it's not a terrible language to learn. Follow the tutorial as people have said, direct questions to the Java thread on here.

Incidentally I do think that everyone should learn more than one language, but I think that C++ is only the best language at teaching you C++. For other concepts there's almost certainly a better choice which will teach you it in a clearer way.

tef
May 30, 2004

-> some l-system crap ->
Please don't rely on hexadecimal for help.

If you want accurate answers, you're better off posting in the relevant threads.
Hexadecimal is frequently corrected by people who can program in c++.


If you are new to programming, I would learn something like Python, Ruby or Perl. They're a lot easier to pick up than java, and often easier to use straight away.

If you're hardcore - learn scheme, you will learn a lot more but I would say one of the more mainstream dynamic languges might be more approachable.

OO is best learned once you have programs to structure. Java and C# are mutually intelligable dialects, so don't worry too much about picking one or the other.

Overall, you will spend more time learning libraries than you will languages.

Standish
May 21, 2001

IntoTheNihil posted:

Sorry to spam up this thread with even more questions but I've recently discovered how huge the Java market really is. Even around my city there's multiple high paying jobs for Java programmers. Can anyone tell me the pros and cons of the language and some general learning info? I messed with it a bit before and even though people say it's simple I couldn't grasp much.
Pros:
  • popular, widely used, lots of jobs as you said
  • the standard language libraries are quite good (for the most part)
  • Compared to C/++ the Java Virtual Machine prevents whole classes of errors and security holes such as buffer overflows, heap corruption etc.
  • automatic garbage collection saves a load of time (it's not a magic bullet though)
  • Compared to C#/.NET the cross-platform support is a lot better, I know there's Mono but it's very much a second-class citizen.
Cons:
  • stupidly verbose
  • Swing - the GUI is 99% the same as a native app, but that last 1% is really noticeable
  • JRE version hell due to occasional lapses in backward compatibility
Not actually a con despite popular belief: OMG JAVA IS SO SLOW YOU GUYS.

Standish fucked around with this message at 13:41 on Jan 14, 2009

Liquid Silk
Feb 20, 2007

by Tiny Fistpump
Hi guys, I have a PROLOG program to do, a stupid Eliza type program, and I have various standard replies to keywords,

such as animals;

code:
animal_member(X) :- member(X,[dog, dogs, cat, cats, puppy, puppies, 
kitten, kittens, wolf, wolves]).
pattern(List, ['do you have an interest in animals']):- member(X, List), animal_member(X).
or happy feelings;

code:
 
happy_member(X) :- member(X, [happy, love, loves, adores, good, nice, fun]).
pattern(List, ['It is a good thing you are feeling positive']):- member(X, List), happy_member(X).
Welp, I fixed it... my answer if anyone cares, put above the two sample of code:

code:
hapdog_member(X,Y) :- member(X,[happy, love, loves, adore, adores, good, nice, fun]), member(Y,[dog, dogs, cat, cats, puppy, puppies, kitten, kittens, wolf, wolves]).
pattern(List,['I am glad you are feeling positive towards animals']) :- member(X, List), member(Y, List), hapdog_member(X,Y).

Liquid Silk fucked around with this message at 17:38 on Jan 14, 2009

tef
May 30, 2004

-> some l-system crap ->

Liquid Silk posted:

Hi guys, I have a PROLOG program to do,

:toot:

quote:

a stupid Eliza type program, and I have various standard replies to keywords, such as animals;

code:
animal_member(X) :- member(X,[dog, dogs, cat, cats, puppy, puppies, 
kitten, kittens, wolf, wolves]).
pattern(List, ['do you have an interest in animals']):- member(X, List), animal_member(X).

Traditionally, this would look something like this:
code:
animal(dog).
animal(dogs).
animal(cat).
animal(cats).
animal(puppy).
...

pattern(List,['animals blah']) :- member(X, List), animal(X).
And it would be faster too - prolog indexes predicates.


quote:

I now have to have a specific, distinct response if the input contains happy feelings AND animals. Anyone have any tips? Tia.

code:
pattern(List,['animals and love']) :- member(X, List), animal_member(X), member(Y,List), happy_member(Y).
pattern(for just happy).
pattern(for just animal).

quote:

Edit: I'm sure this is going to be really easy an answer, but I've been racking my brains and trying all sorts of complications, that I'm going crazy.

Don't try and write an optimal solution, write a simple one first.

I would probably do something* like this:
code:
happy(joy).
happy(love).
....

animal(dog).
animal(cat).

contains_happy(List) :- member(X,List), happy(X).
contains_animal(List) :- member(X,List), animal(X).

pattern(List,['i love animals']) :- contains_happy(List), contains_animal(List).
* Actually I would do something like this:
code:
word(joy, happy).
word(love, happy).
...
word(dog, animal).
word(cat, animal).
...

contains(List,Type) :- member(X, List), word(X, Type).

contains_all(List, []).
contains_all(List, [Type|Tail]) :- contains(List, Type), contains_all(List,Tail).

pattern([happy, animal], ['I love horses! best of all the animals']).

response(List, Answer) :- pattern(Types, Answer), contains_all(List, Types).
But the previous solution would probably be faster :v:

tef fucked around with this message at 17:41 on Jan 14, 2009

Yeast Confection
Oct 7, 2005
A bit of an HTML question... I'm wondering, is it possible to launch an SSH session from a link?

I know it's possible to open a telnet session by using telnet://some.host.ip.address but I haven't been able to find a similar way of starting as SSH session.

Is there even a way to launch an ssh client from a link? For example...
code:
<a href="file:///c:/program files/sshclient/ssh.exe">Launch SSH session</a>
but then there's the matter of having to use a command line parameter to open an ssh session to a specific host... Any suggestions? Google is eluding me on this one.

Liquid Silk
Feb 20, 2007

by Tiny Fistpump

tef posted:


Thanks... you were right... I keep forgetting about that the position is v. important...

Avenging Dentist
Oct 1, 2005

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

Susietron posted:

A bit of an HTML question... I'm wondering, is it possible to launch an SSH session from a link?

I know it's possible to open a telnet session by using telnet://some.host.ip.address but I haven't been able to find a similar way of starting as SSH session.

Is there even a way to launch an ssh client from a link? For example...
code:
<a href="file:///c:/program files/sshclient/ssh.exe">Launch SSH session</a>
but then there's the matter of having to use a command line parameter to open an ssh session to a specific host... Any suggestions? Google is eluding me on this one.

Write a URL protocol handler.

Deadpan Science
Sep 6, 2005

by angerbeet
I have a question that' not really about programming, but it's something I've been wondering about. How do most companies keep their employees from stealing their programs and selling them? It seems like this would be a big problem, especially for small software development businesses that don't have the money to hire a lawyer to constantly file suit against former employees.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
No one who writes software for a company would ever voluntarily use that software.

Scaevolus
Apr 16, 2007

Dijkstracula posted:

One of the good things about Java is that it does force you to code in a certain way; with C++, your methology can range from "procedural programming with iostreams" to "C with classes" to "Java-style OOP where most everything is a class" to "template metaprogramming and C++0x draft standard wankery" and everything in between.
Giving people a big hammer labeled "OOP" instead of a set of (perhaps mysterious) tools is not really a good thing.

For learning, maybe, but this guy is asking about Java because he sees lots of jobs for Java programmers.

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

No one who writes software for a company would ever voluntarily use that software.

Emphasis mine.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Deadpan Science posted:

I have a question that' not really about programming, but it's something I've been wondering about. How do most companies keep their employees from stealing their programs and selling them? It seems like this would be a big problem, especially for small software development businesses that don't have the money to hire a lawyer to constantly file suit against former employees.

Any software company that writes shrink-wrappable software — i.e. software that can be sold prepackaged to businesses or consumers — is going to be large enough to keep a lawyer on retainer. Smaller companies usually write software that's targeted to individual clients, which is inherently difficult to sell black-market, unless the original client was the government and you're committing treason. You could at best steal your company's framework code and use it to satisfy contracts, but you'd be surprised at how inbred local programming circles can be, and if you're caught once....

EDIT: and of course you'd never voluntarily use it yourself.

TagUrIt
Jan 24, 2007
Freaking Awesome
(There doesn't seem to be a linux environment thread, so I'm tossing this here.)

In linux, are multiple consecutive slashes permitted in a file path (specifically in C if that makes any difference)? Experience says yes (`ls ////////////home` is the same as `ls /home`), but I don't want to jump the gun and make my little toy breakable.

If it is allowed in the paths, when concatenating several parts of a path, is it reasonable to insert a "/" between the parts?

"/home" + "me/Documents/" + "lol.txt" -> "/home/me/Documents//lol.txt"

POKEMAN SAM
Jul 8, 2004

TagUrIt posted:

(There doesn't seem to be a linux environment thread, so I'm tossing this here.)

In linux, are multiple consecutive slashes permitted in a file path (specifically in C if that makes any difference)? Experience says yes (`ls ////////////home` is the same as `ls /home`), but I don't want to jump the gun and make my little toy breakable.

If it is allowed in the paths, when concatenating several parts of a path, is it reasonable to insert a "/" between the parts?

"/home" + "me/Documents/" + "lol.txt" -> "/home/me/Documents//lol.txt"

It's not hard to check that the end of "/home" and the beginning of "me/Documents/" only has one slash between them, but yeah it's fine to have extra slashes in your path.

shrughes
Oct 11, 2008

(call/cc call/cc)

Deadpan Science posted:

I have a question that' not really about programming, but it's something I've been wondering about. How do most companies keep their employees from stealing their programs and selling them? It seems like this would be a big problem, especially for small software development businesses that don't have the money to hire a lawyer to constantly file suit against former employees.

Writing code is the easy part; knowing what to write is the hard part. People take the latter with them all the time.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
What tools should I look into for taking video from a USB webcam and doing something useful with the data like persistent object detection? I noticed MATLAB has some video capture stuff built in. Anybody have any good resources on that sort of thing?

magicalblender
Sep 29, 2007
The Windows SDK has the Directshow API. It's a "media streaming architecture"- I'm pretty sure you can use it for framegrabbing.

There's also Windows Image Acquisition. I think it's intended for scanners and digital cameras, but you could probably use it to get still frames from a webcam.

I don't know about persistent object detection, though. I'm working on a webcam project myself, so I'm also interested in getting pointed towards some useful resources.

zootm
Aug 8, 2006

We used to be better friends.
On Linux I think Video4Linux is used, which I've used before and wasn't particularly painful. Apparently GStreamer wraps it which might be a more useful abstraction though.

If you feel like using Java for a cross-platform style thing, JMF supports video capture and a whole host of other nonsense. I have a vague recollection of it being one of those frameworks that takes a little work to grasp its design but being pretty easy to use beyond that.

zootm fucked around with this message at 01:47 on Jan 17, 2009

Jo
Jan 24, 2005

:allears:
Soiled Meat
What data structure exists to do the following:
- Quickly return the set of all points (2D) inside a given rectangle.
- Quickly return the closest point to a given point.

QuadTrees seem like the right choice, but are better options available?

Avenging Dentist
Oct 1, 2005

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

Jo posted:

What data structure exists to do the following:
- Quickly return the set of all points (2D) inside a given rectangle.
- Quickly return the closest point to a given point.

QuadTrees seem like the right choice, but are better options available?

If you're just dealing with sets of points, why not use a fixed-size grid? It's way easier to implement, and in the case of point sets, it'll probably be faster because you won't have to descend/ascend through a tree. Hell, with points, you don't even have to worry about them overlapping multiple blocks in the grid.

Jo
Jan 24, 2005

:allears:
Soiled Meat

Avenging Dentist posted:

If you're just dealing with sets of points, why not use a fixed-size grid? It's way easier to implement, and in the case of point sets, it'll probably be faster because you won't have to descend/ascend through a tree. Hell, with points, you don't even have to worry about them overlapping multiple blocks in the grid.

Isn't the cost of descending/ascending trees recouped by the amount of information one can ignore?

Avenging Dentist
Oct 1, 2005

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

Jo posted:

Isn't the cost of descending/ascending trees recouped by the amount of information one can ignore?

For point sets, no. Quadtrees are designed for sets of objects with a wide variety of sizes.

Jo
Jan 24, 2005

:allears:
Soiled Meat

Avenging Dentist posted:

For point sets, no. Quadtrees are designed for sets of objects with a wide variety of sizes.

I see. In my defense, though, Wikipedia does make mention of the 'point quadtree'. http://en.wikipedia.org/wiki/Quadtree

Fake edit: http://www.omgitswebsite.com :3:

Jo fucked around with this message at 00:54 on Jan 19, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Point quadtrees might offer a performance boost in a subset of cases, mostly those where points are tightly clustered in specific regions of space.

However, it would probably be better to actually test if fixed-size grids are fast enough because they're really easy to implement. There are a ton of optimizations for them though, like storing objects in two one-dimensional lists (one for x and one for y) and then taking the intersection of x_list[x] and y_list[y].

Avenging Dentist fucked around with this message at 01:07 on Jan 19, 2009

Mikey-San
Nov 3, 2005

I'm Edith Head!

IntoTheNihil posted:

None at all. I'm brand new to programming but very interested in finding my niche.

You will not find your niche for several years. Enjoy it while it lasts. :)

ndrz
Oct 31, 2003

Is there any software like http://www.viemu.com/ that is free? Basically, I want VS to feel like vi, and I want to be able to edit within VS, instead of having vim and VS open.

I only want it for VS2005, but I haven't been able to find anything that is free and does the same thing. Even cheaper would be nice, but $100 is a lot considering I'm a student and only use this for classes.

fyreblaize
Nov 2, 2006

Your language is silly
I have a quick AspectJ question-

I have an aspect that modifies System.out.print. The pointcut cant be written that way because its an object and not a class, so I have it as
code:
* java.io.PrintStream.print(..)
What do I need to add in the advice to make sure it only applies to System.out and not other forms of PrintStream?

redphoenix11
May 9, 2007

I've got a question about x86 Assembly. I'm trying to open a file using a filename passed in the through the command line. The reference book I have, Professional Assembly Language by Richard Blum has an example that looks like this:

movl %esp, %ebp
movl $5, %eax
movl 8(%ebp), %ebx
movl $00, %ecx
movl $0444, %edx
lcall $0x27,$0
test %eax, %eax
js badfile

But %ebx's contents wind up being the name of the program followed by some garbage characters, and the call to open returns an EFAULT error in %eax. This happens when I run my code that's using this and in the provided example. I'm not sure if it's the system I'm using, which is a Sun box with Solaris 10 and an AMD processor or if there's something really obvious that I'm missing.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
It looks like PAL is written against (some version of) the Linux kernel; syscalls on Solaris are not going to follow the same protocols as syscalls on Linux. You will need to either (1) find a Linux system to test these examples on or (2) learn how to convert Linux syscalls into Solaris ones.

I assume this code listing is for main. The code you've listed seems to be passing the second argument directly to open as the filename argument; that doesn't type-check, as the second argument should be a char**, and open wants a char* there. I think if you followed that instruction with movl 4(%ebx), %ebx then you might get the right result, aside from the whole syscall-convention mess.

Alternatively, this might be for start; I'm not sure what the initial memory layout is for start on Linux.

rjmccall fucked around with this message at 07:05 on Jan 21, 2009

redphoenix11
May 9, 2007

The syscall convention there is for Solaris and not for Linux because I changed that. Also, I rechecked my notes and apparently in Solaris arguments for syscalls are pushed onto the stack. I made a simple app in C that opens up a file passed in the through the command line and gcc gave me this as the assembly:

pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
subl $24, %esp
pushl $0
movl 12(%ebp), %eax
pushl 4(%eax)
call open <- I can't do this since I can't go through the C library at all for what I'm doing

I changed my code to this:

pushl %ebp
movl %esp, %ebp
pushl $0
movl 12(%ebp), %ebx
movl 4(%ebx), %ebx
movl $00, %ecx
movl $0444, %edx
movl $5, %eax
lcall $0x27,$0x0

Now eax holds 2 no matter what file I pass in, even though ebx contains the proper input now. Also, despite what I said above, pushing all the arguments onto the stack continued to have eax contain EFAULT (14) every time. So now I'm totally confused. :(

redphoenix11 fucked around with this message at 09:55 on Jan 21, 2009

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
This may not lessen your confusion, but why are you expecting %eax to contain errno? I'm honestly not certain where errno is going to be, but %eax should have the return value from open, i.e. either a file descriptor or -1. That said, 2 doesn't sound right; I would expect 3.

Your best reference for this would be to disassemble libc, look for _open, and see what it does.

EDIT: I scanned the OpenSolaris source, and it does look as if all system calls are made with the syscall number in %eax and the arguments on the stack. Can you post the code you tried with that?

rjmccall fucked around with this message at 11:21 on Jan 21, 2009

redphoenix11
May 9, 2007

Sure, this is what I got:

pushl %ebp
movl %esp, %ebp
pushl $440
pushl $0
movl 12(%ebp), %ebx
movl 4(%ebx), %ebx
push (%ebx)
movl $5, %eax
lcall $0x27,$0x0

And when I run truss, this is how the call to open gets invoked:

open("", 0670, 01001074670) Err#14 EFAULT

So the function IS getting called. Looks like the stack pointer is in the wrong place or something like that.

EDIT: Made two changes

pushl %ebp
movl %esp, %ebp
pushl $440
pushl $0
movl 12(%ebp), %ebx
movl 4(%ebx), %ebx
push %ebx
subl $4,%esp
movl $5, %eax
lcall $0x27,$0x0

And truss reported this:

open("test.txt", O_RDONLY) = 3

Looks like it's working now. I'm not quite sure why the stack pointer was off though...

redphoenix11 fucked around with this message at 12:00 on Jan 21, 2009

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
First off, you need that to be $0440 (or 0444, whatever), it's octal. Second, I think you just want pushl %ebx (or for that matter, pushl 4(%ebx) instead of the line above). Third, you're right, it looks like you need the return address to be the top of the stack; good luck on that one.

EDIT: or hey, maybe you don't need that third one; but I bet you used to and there's some crazy binary-compatibility going on.

EDIT 2: Ignore that bit about binary compatibility. It's obviously just a gap left for the convenience of writing syscall C stubs; i.e. you can implement open as simply:

code:
  movl $5, %eax
  lcall $0x27, $0
  ret

rjmccall fucked around with this message at 12:17 on Jan 21, 2009

redphoenix11
May 9, 2007

I made the tweaks you suggested and it's working now. Also, I read that the last push is to provide a dummy return address for the syscall, which I guess the subl instruction accomplishes as well. eax holds the error codes or the fd if it works, which is why it was returning 14 or 2 when it wasn't working.

Of course, I have a shitton of coding left, but at least I have a good handle on it. Thanks a lot!

redphoenix11 fucked around with this message at 12:37 on Jan 21, 2009

Adbot
ADBOT LOVES YOU

Waldorf Sixpence
Sep 6, 2004

Often harder on Player 2
I am absolutely horrified by MATLAB and all of its components. I'm having some issues writing an m-file for a specific logistic function which needs to graph multiple iterations of population growth and map it as a cobweb diagram. To save asking a horrific number of questions in this thread given that I'm new to programming and every answer I get is bound to just evoke more :downs: from me, would anyone familiar with MATLAB be happy to chat with me over an IM program of their choice?

Thanks in advance.

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