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
double sulk
Jul 2, 2010

tef posted:

object orientation :v:

(no, really)

They try to teach how to structure programs before people understand the foundations.

You may enjoy http://www.htdp.org/2003-09-26/Book/ how to design programs. Once you have a more consistent grasp of programming concepts, it becomes much easier to pick up new languages.

Your logic there makes sense, and does pinpoint what I mean. The book I got even says it's good for people just starting out. However, it goes from Hello World, like I mentioned, to having you use all these functions that were not explained at all, all while designing programs themselves that are trying to do more complicated things instead of just explaining each element one at a time. It makes me feel stupid, but it might just be that they're poor writers. I might try to backtrack and go really slowly, but at least I have an actual class to go by for C++.

Adbot
ADBOT LOVES YOU

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

nielsm posted:

Already covered earlier:
C requires you to think about memory management ... from the beginning, ... int main() ...

Both of these necessities of C are considered features rather than bugs by a fairly large number of people, and incidentally you can get Pretty Freakin' Far through flow control and whatnot before you run into the former issue

Thermopyle
Jul 1, 2003

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

Otto Skorzeny posted:

Both of these necessities of C are considered features rather than bugs by a fairly large number of people, and incidentally you can get Pretty Freakin' Far through flow control and whatnot before you run into the former issue
Being a feature has little to no bearing on whether its good for a beginner to have to worry about it.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog
I think one should start with assembly. Thinking of the computer as a scriptable physical machine helps a lot of people who aren't abstract thinkers by default, and every programmer should know it anyway. It makes stuff such as pointers, stack vs. heap really basic and straightforward.

Of all the classes I took in college, the assembly ones were some of the most illuminating.

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
Feature rather than bug for a first language is what I meant there. There has historically been a large school of thought that a programmer should be cognizant of the fact his program is running on finite hardware from day zero (recall many CS programs started out as outgrowths of electrical engineering departments)

Zombywuf
Mar 29, 2008

It's also not the mass of cognitive overhead it's often claimed to be though. It could be better, and it would be great to have a C that just assumed the outer scope was main. The nice thing about C for teaching is that you can do a lot once you're over that hump without worrying about a lot of other complexities. I'd much rather explain for (init; condition; increment) than for var in xrange(start, end, step):.

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?

Smugdog Millionaire posted:

I think one should start with assembly. Thinking of the computer as a scriptable physical machine helps a lot of people who aren't abstract thinkers by default, and every programmer should know it anyway. It makes stuff such as pointers, stack vs. heap really basic and straightforward.

Of all the classes I took in college, the assembly ones were some of the most illuminating.

I have to disagree with this. Bluntly, ASM is not relevant for general programming on the desktop in a modern OS and would do more harm than good.

Less bluntly, plonking a novice in front of ASM is more likely to scare them than give them insight. It's also going to piss them off (because it takes a seemingly huge amount of effort to get a simple program running, never mind a GUI application) and is going to implant some ideas which, for other languages, are really bad habits (goto, labels, etc) and will have to be beaten out of them later. Many of the concepts they'd learn about they might never need again - if you're writing C# code why on earth would you be thinking about the instruction pointer and processor registers?

If a particular individual wants to learn more about the underlying mechanics or get into embedded systems then ASM is a great choice, but for introductory stuff C is as low level as you should ever need to go.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

rolleyes posted:

ASM is not relevant for general programming on the desktop in a modern OS and would do more harm than good.
Learning Prolog and Haskell also aren't relevant for general programming on the desktop, do you also think they shouldn't be taught except maybe in some senior-level esoteric class? Most programmers my age will tell you their first language was Logo or MS-BASIC or some such tripe completely irrelevant to general programming on the desktop (we turned out OK).

The purpose of teaching assembly first is not to give students a full four years of programming in the one language they can take to job interviews.

rolleyes posted:

Many of the concepts they'd learn about they might never need again - if you're writing C# code why on earth would you be thinking about the instruction pointer and processor registers?
I wouldn't be thinking about instruction pointers and x86 registers, but I could and would be thinking about MSIL and core .NET concepts since those are foundational to that language. I've seen many C# programmers surprised by some facet of the language that would not be surprising at all if they were familiar with what parts of the language are built on top of the CLR specification, and which parts flow directly from that specification.

rolleyes posted:

If a particular individual wants to learn more about the underlying mechanics or get into embedded systems then ASM is a great choice, but for introductory stuff C is as low level as you should ever need to go.

Any good programmer will want to learn more about the underlying mechanics. We can help them along by starting with the most basic and progressing to more abstract stuff from there.

If you're worried about bad habits, have C.S. students take a Lisp and Prolog classes right afterwards or maybe simultaneously.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Would agree that C is a bad starter language. It was the 'first' language I formally learned, as in taught from the ground up by a professor. I had taught myself Pascal and Basic (And Apple Basic! And Atari Basic!) before that so I had a handle on a lot of structures. However the entire makefile process was incredibly unintuitive, and requires you to not only understand the code you're writing (which you probably should), but also now anything you link in that you 'need' (curses.h how I hated you). I didn't 'get' a lot of functional/structural programming logic until I took a Miranda course later, which actually probably isn't too bad of an intro language.

I think ASM is about as useful to learn today as punch cards would have been in the 90s (for general purpose programming as opposed to say, embedded processor systems). Yes, simplify the thinking and teach a real appreciation of the granular nature of programming. And then never use it again.

JawnV6
Jul 4, 2004

So hot ...

Scaramouche posted:

Would agree that C is a bad starter language ... the entire makefile process was incredibly unintuitive, and

Yeah it's really easy to make a lovely course with C :v:

My first course started in C and they gave us all the boilerplate and started with updating small functions. Well, we "started" with Karel the Robot and moved to C afterwards, but it's not too hard to have an Intro class use C without all those stupid headaches your course was fraught with.

Thermopyle
Jul 1, 2003

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

Python is the best teaching language. FACTS.

Just kidding...sort of. I've slowly been teaching my completely non-technical wife Python and she's really enjoying it.

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?

Smugdog Millionaire posted:

:words:-y stuff

Let me try phrasing this differently. ASM is a fine language to learn about the underlying architecture, I just don't think it's the right thing to be diving straight into. To me Prolog falls under the same "not the right thing" heading but for a different reason: generally, people either intuitively get recursion or they have to work really hard to get their head around it. If you start with Prolog you risk alienating 50% of your intake in the first 2 weeks as they're sat there struggling with wrapping their minds around the logic and wondering what the hell they've got themselves into.

Here comes the car analogy:
Starting with ASM is like teaching someone to drive by building a car. Sure, they'll learn all sorts of things about spark plugs and alternators but, while it'll probably come in handy one day, none of it's strictly necessary to the actual task of driving.


I've always found that the style of learning which works best for me is to deconstruct things so maybe it's why I'm so against starting from the absolute bottom up.

qntm
Jun 17, 2009
I just started learning C today and it seems like the hardest part of the language is finding a compiler for Windows that isn't Visual Studio or bundled up inside a metric tonne of Unixy stuff.

nielsm
Jun 1, 2009



qntm posted:

I just started learning C today and it seems like the hardest part of the language is finding a compiler for Windows that isn't Visual Studio or bundled up inside a metric tonne of Unixy stuff.

Grab the Windows SDK from MS, it includes their C/C++ compiler, C# compiler and other build tools, but not Visual Studio. It also includes the MSBuild environment needed to build VC++ 2010 projects, without VC2010.

qntm
Jun 17, 2009

nielsm posted:

Grab the Windows SDK from MS, it includes their C/C++ compiler, C# compiler and other build tools, but not Visual Studio. It also includes the MSBuild environment needed to build VC++ 2010 projects, without VC2010.

Thanks for this. I was actually speaking rhetorically, I am using tcc by known crazy person Fabrice Ballard. I have no idea whether this compiler has bizarre quirks or lacks performance optimisations but it compiles "Hello world" without issue so it's working for me so far.

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
Look at the old Borland compilers and DJGCC/DJGPP too I guess, nb. your constraints are kinda weird (I feel the x/y problem might be lurking beneath the surface here but meh)

1337JiveTurkey
Feb 17, 2005

Smugdog Millionaire posted:

I think one should start with assembly. Thinking of the computer as a scriptable physical machine helps a lot of people who aren't abstract thinkers by default, and every programmer should know it anyway. It makes stuff such as pointers, stack vs. heap really basic and straightforward.

Of all the classes I took in college, the assembly ones were some of the most illuminating.

Beyond the objections other people have had, getting to the raw unabstracted physical machine is more or less impossible these days apart from certain embedded systems. Telling a neophyte programmer otherwise is going to screw with them when they're trying to wrap their heads around what's really happening at that level.

If they're developing in user mode the flat memory model and noncooperative multitasking mean what the student sees has nothing to do with the physical hardware. As far as the OS is concerned, a C or ASM program is just like some garbage collected VM that segfaults a lot. Going below that, any CISC processor and especially something like a modern x86 is pretty much a virtual instruction set with a dedicated hardware interpreter. The ISA is just a convenient lie which has more or less identical external behavior on several different microarchitectures.

Sure we can say that the processor fetches the instruction at the PC from memory, decodes it and then actually does something like move the value from EAX to EBX. Really it decodes the instructions en masse and sticks them in a reorder buffer from which it executes up to half a dozen operations in any order from that buffer at once using its 100+ real registers. That MOV just changes some physical register file pointers in the reorder buffer.*

Since everything we do is on top of some stack of abstractions, any student who's going to become a competent programmer needs to get used to get used to that stack, pronto. People who can't handle abstractions won't get programming beyond the most trivial toy programs until they can. So we start at a level of abstraction that lets them do useful things and then work our way both up and down from there.

*On microarchitectures where the PRF and ROB are separate. Ones where they're the same thing do it completely differently.

raminasi
Jan 25, 2005

a last drink with no ice
Was it this thread where someone linked that paper by that guy arguing against taking the von Neumann model for granted?

tef
May 30, 2004

-> some l-system crap ->
Gonna assume you mean backus' turing lecture: Can programming be liberated from the von Neumann style?

citeseer pdf link

Zombywuf
Mar 29, 2008

Which simply asserts that Von Neumann style is bad because beta-reduction is simpler than state transitions or something.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

1337JiveTurkey posted:

Since everything we do is on top of some stack of abstractions, any student who's going to become a competent programmer needs to get used to get used to that stack, pronto. People who can't handle abstractions won't get programming beyond the most trivial toy programs until they can. So we start at a level of abstraction that lets them do useful things and then work our way both up and down from there.

Is that how you were taught mathematics? Just jump into the basics of some middling-abstract stuff? Because if you're ever going to be a competent mathematician, you're going to have to get used to a stack of abstractions pronto.
Of course not. You learned that if you have one apple and add two apples, you now have three apples. Assembly is the same level of simple concreteness (move the value at X memory location to register Y, add registers Y and Z and put the sum back into Y, etc.) even if it's just another level of abstraction on top of your Intel.

qntm
Jun 17, 2009

Smugdog Millionaire posted:

Is that how you were taught mathematics? Just jump into the basics of some middling-abstract stuff? Because if you're ever going to be a competent mathematician, you're going to have to get used to a stack of abstractions pronto.
Of course not. You learned that if you have one apple and add two apples, you now have three apples. Assembly is the same level of simple concreteness (move the value at X memory location to register Y, add registers Y and Z and put the sum back into Y, etc.) even if it's just another level of abstraction on top of your Intel.

I don't know if you have a formal education in mathematics but if you don't you would probably be astounded to learn just how far up the stack you have to go from the basic axioms of set theory before you reach "if you have one apple and add two apples, you now have three apples".

Duke of Straylight
Oct 22, 2008

by Y Kant Ozma Post

qntm posted:

I don't know if you have a formal education in mathematics but if you don't you would probably be astounded to learn just how far up the stack you have to go from the basic axioms of set theory before you reach "if you have one apple and add two apples, you now have three apples".

What this guy said. There's no general rule that the most basic elements of a system that everything else can be constructed out of are the simplest parts for a human to understand, or the most appropriate parts to begin understanding the rest of the system from. Especially when the system under study can be built on several different bases, for instance understanding a functional programming language as on a lambda calculus basis, a Turing machine basis, or on the basis of what it does on actual hardware. You don't become a car mechanic by studying physical chemistry, a good education in mathematics doesn't start with abstract nonsense, and there's no reason to expect counting cycles in ASM to be a good introduction to programming either.

(FWIW, I'm of the school that university students in computer science should be taught in MMIX and Haskell. Maybe some Smalltalk if you're big on OO concepts. If you have a degree in computer science and you can't get up to speed in any common language within at most a week or so of intensive use (I'll give another week for learning C++), tell me where you studied so I can tell everyone to avoid the place. Programming languages are not the hard part of programming.)

baquerd
Jul 2, 2007

by FactsAreUseless

Duke of Straylight posted:

If you have a degree in computer science and you can't get up to speed in any common language within at most a week or so of intensive use (I'll give another week for learning C++), tell me where you studied so I can tell everyone to avoid the place. Programming languages are not the hard part of programming.)

On the other hand, you have large and complex APIs (even before third party frameworks) in the Java and .NET worlds that you will most definitely not master in a week. If you have graduated with 4 years of Haskell, you will be significantly behind your peers in applicable knowledge. Granted, I don't have the exact market share numbers of Haskell, can anyone help me out here?

spiritual bypass
Feb 19, 2008

Grimey Drawer
What do you do when you see a GPL project hosted on Google Code that has been releasing binaries for a while but has never published any code? I emailed the developer but haven't heard anything back from him and I can't find any complaint form to prod Google to do something about it.
I wanted to try to make a Linux port of what appears to be a pretty simple Windows program, but I can't do anything at all as it is and he's not even conforming to his own license.

shrughes
Oct 11, 2008

(call/cc call/cc)

baquerd posted:

On the other hand, you have large and complex APIs (even before third party frameworks) in the Java and .NET worlds that you will most definitely not master in a week. If you have graduated with 4 years of Haskell, you will be significantly behind your peers in applicable knowledge.

Nobody gets applicable knowledge of APIs from college.

Vanadium
Jan 8, 2005

He doesn't have to. The license doesn't apply to the dude who wrote the code, it's about the terms under which he allows you to redistribute it.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Maybe he doesn't have to license the code to himself, but Google Code requires all its projects to be open source.

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

qntm posted:

I don't know if you have a formal education in mathematics but if you don't you would probably be astounded to learn just how far up the stack you have to go from the basic axioms of set theory before you reach "if you have one apple and add two apples, you now have three apples".

The lambda calculus forms as powerful a foundation for mathematics as set theory and Church numerals are dead simple. Your move.

TasteMyHouse
Dec 21, 2006

Otto Skorzeny posted:

The lambda calculus forms as powerful a foundation for mathematics as set theory and Church numerals are dead simple. Your move.

try teaching them to first graders.

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
am I allowed to give the first graders drugs, and if so is acid kosher.

shrughes
Oct 11, 2008

(call/cc call/cc)

Otto Skorzeny posted:

The lambda calculus forms as powerful a foundation for mathematics as set theory and Church numerals are dead simple. Your move.

The lambda calculus is logically inconsistent.

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
Set theory's incomplete :v:

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
To get this thread back on topic, how about someone comes up with a simple program to decide the argument and then asks for help with it?

Butt Soup Barnes
Nov 25, 2008

I hope somebody here can help me, I've been pulling my hair out over this. Visual Basic by the way.

I want to populate a combobox from a Data Table that is getting its data from a SQL server. This is my code:

code:
Public Sub PopulateProgram()

        Dim objConnection3 As New SqlConnection("server=localhost\SQLEXPRESS;database=Dashboard;integrated security=true")
        Dim objDataAdapter3 As New SqlDataAdapter
        Dim objDataSet3 As New DataSet()

        strSchool = cboSchool.Text

        ' Set the SelectCommand properties..
        objDataAdapter3.SelectCommand = New SqlCommand()
        objDataAdapter3.SelectCommand.Connection = objConnection3
        objDataAdapter3.SelectCommand.CommandText = "SELECT [Program 1], [Program 2], [Program 3], [Program 4], [Program 5] FROM dbo.School WHERE School=@strSchool"
        objDataAdapter3.SelectCommand.CommandType = CommandType.Text
        objDataAdapter3.SelectCommand.Parameters.AddWithValue("@strSchool", strSchool)

        ' Open the database connection..
        objConnection3.Open()

        ' Fill the DataSet object with data..
        objDataAdapter3.Fill(objDataSet3, "Program")

        ' Close the database connection..
        objConnection3.Close()



        'populate cboProgram
        cboProgram.DataSource = objDataSet3.Tables("Program")
        cboProgram.DisplayMember = "Program"
        cboProgram.ValueMember = "Program 1"


    End Sub
As you can see, the Data Table "Program" is populated in the following manner:

code:
[Program 1]   [Program 2]   [Program 3]   [Program 4]   [Program 5]
However, the cboProgram.ValueMember can only populate from one column. So I need to reformat the Data Table to look like this:

code:
[Program 1]
[Program 2]
[Program 3]
[Program 4]
[Program 5]
Any ideas? Thanks in advance.

nielsm
Jun 1, 2009



You should probably normalise that database. Even just going for 1NF should solve your problem.

Ideally, your database should be structured like this:
code:
SCHOOL:
schoolId: integer primary key (optionally with auto-increment)
schoolName: string (optionally unique)

PROGRAM:
programId: integer primary key (opt. auto-increment)
programName: string (opt. unique)

SCHOOLPROGRAM:
schoolProgramId: integer primary key
schoolId: integer foreign key referencing SCHOOL
programId: integer foreign key referencing PROGRAM
That form will make it easy to query the database for all programs a single school offers without risking e.g. typoes in how a school's name is written for one programs, and it'd also allow for querying which schools offer equivalent programs, if there is such a thing.

You can also make this simpler structure, but it will require you to ensure each school's name is always written exactly the same:
code:
SCHOOLPROGRAM:
schoolProgramId: integer primary key
schoolName: string (you'll likely want an index on this)
programName: string (probably no index needed)
unique(schoolName, programName) constraint
Then you can use this query: SELECT programName FROM SchoolProgram WHERE schoolName = 'whatever' and get your list of programs offered by a school. As a bonus, you can have any number of programs for a school.


If changing the database schema isn't an option I don't think you'll be able to use data-aware controls for the job.

Butt Soup Barnes
Nov 25, 2008

nielsm posted:

You should probably normalise that database. Even just going for 1NF should solve your problem.

Ideally, your database should be structured like this:
code:
SCHOOL:
schoolId: integer primary key (optionally with auto-increment)
schoolName: string (optionally unique)

PROGRAM:
programId: integer primary key (opt. auto-increment)
programName: string (opt. unique)

SCHOOLPROGRAM:
schoolProgramId: integer primary key
schoolId: integer foreign key referencing SCHOOL
programId: integer foreign key referencing PROGRAM
That form will make it easy to query the database for all programs a single school offers without risking e.g. typoes in how a school's name is written for one programs, and it'd also allow for querying which schools offer equivalent programs, if there is such a thing.

You can also make this simpler structure, but it will require you to ensure each school's name is always written exactly the same:
code:
SCHOOLPROGRAM:
schoolProgramId: integer primary key
schoolName: string (you'll likely want an index on this)
programName: string (probably no index needed)
unique(schoolName, programName) constraint
Then you can use this query: SELECT programName FROM SchoolProgram WHERE schoolName = 'whatever' and get your list of programs offered by a school. As a bonus, you can have any number of programs for a school.


If changing the database schema isn't an option I don't think you'll be able to use data-aware controls for the job.

Bah, that's so much simpler how did I not think of that :psyduck:.

Thanks, I'll go ahead and change the database structure.

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?

Butt Soup Barnes posted:

Bah, that's so much simpler how did I not think of that :psyduck:.

Thanks, I'll go ahead and change the database structure.

Now you're aware of it, I'd suggest looking into one of the many database normalisation tutorials knocking around on the web. In most cases you'll want to be targeting 3rd normal form (usually written as 3NF) as it fits the vast majority of database requirements, but work up from the bottom. It shouldn't take you very long, the concept is actually very simple once you see a few examples.

Pollyanna
Mar 5, 2005

Milk's on them.


I'm using MATLAB to write a script that can recognize individual "clusters" of color based on shape and color, and count their number. I have a "tf = ismember(imf, P, 'rows');" line that calls up the 1x3 variable "P = impixel(a);", but this P vector has only a strict set of three numbers. I want ismember to look for pixels within a certain range of the P vector, such as plus-or-minus one SD of all the chosen values. How can I make ismember work with a range of values to find pixels that fall within a certain range?

Adbot
ADBOT LOVES YOU

Modern Pragmatist
Aug 20, 2008

Pollyanna posted:

I'm using MATLAB to write a script that can recognize individual "clusters" of color based on shape and color, and count their number. I have a "tf = ismember(imf, P, 'rows');" line that calls up the 1x3 variable "P = impixel(a);", but this P vector has only a strict set of three numbers. I want ismember to look for pixels within a certain range of the P vector, such as plus-or-minus one SD of all the chosen values. How can I make ismember work with a range of values to find pixels that fall within a certain range?

ismember is for exact matches only, which makes sense based on the name. Instead, you may want to do something like the following:

code:
cutoff_stdev = 0.1 % Or however you want to compute it

% Find the difference from the reference for each [R,G,B]
difference = abs(imf - repmat(P,[size(imf,1),1]));

% Figure out cases where R, G, and B are all less than the cutoff
tf = sum(difference <= cutoff_stdev,2) == 3
There may be a more elegant solution, but it does what you want.

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