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
luxxx
Oct 20, 2012

tef posted:

Lisp dialects have been used in industry many times. Lisps seeming lack of popularity is often down to more social factors.


Syntax would be a start. Also enough of a language so people stop having to implement their own inside of it.


Yeah, I do need more laughs about a 100 year language that went out of its way to strip out unicode support.

I could use some more laughs about a language developed by a Lisp pioneer millionaire who has repeatedly mentioned that he'll work on char encoding when its convenient.

Furthermore, having to implement my own language is more like "getting" to implement my own language. When I start a project, I think about what my program needs at the conceptual level, and I build tools to help me develop the next level of the program. Bottoms up development is a wonderful paradigm, and maybe it's not suited for C/C++ IT employees.

Adbot
ADBOT LOVES YOU

Opinion Haver
Apr 9, 2007

luxxx posted:

Bottoms up development is a wonderful paradigm, and maybe it's not suited for C/C++ IT employees.

I can feel the smugness radiating from this sentence.

Also jesus christ how do you release a language that doesn't support Unicode?

Opinion Haver fucked around with this message at 17:32 on Oct 21, 2012

tef
May 30, 2004

-> some l-system crap ->

yaoi prophet posted:

I can feel the smugness radiating from this sentence.

Also jesus christ how do you release a language that doesn't support Unicode?

Simple - especially when the actual language (mzscheme) supports unicode. You just strip it out!

code:
; Converts utf8 chars between 128 and 255 to ascii char or string.
; Not able to convert every char; generates X if can't.  Probably not
; the ultimate solution.  The Right Thing would be to preserve these
; chars, instead of downgrading them to ascii.  To do that, would have
; to convert them to unicode.  E.g. ellipsis in unicode is #x2026,
; euro sign is #x20ac.  

; In Mzscheme: (display (integer->char #xE9))

; Then have to figure out how to print them back out, both in forms 
; and in pages.  Presumably do the reverse translation and &-escape them.

; For much of this range, unicode and utf8 agree.  233 is e-acute in
; both.  It's chars like 133 that are a problem.  So perhaps as a
; start try preserving e.g. 233.

; This would be faster if I made a macro that translated it into
; a hashtable or even string.

(def latin1-hack (i)
  (if (is i 128)      "EUR"    ; euros
      (is i 133)      "..."
      (<= 145 i 146)  #\'
      (<= 147 i 148)  #\"
      (is i 151)      "--"     ; long dash
      (is i 154)      #\S
      (is i 155)      #\>
      (is i 156)      "oe"
      (is i 158)      #\z
      (is i 159)      #\Y
      (is i 162)      #\c      ; cents
      (is i 163)      "GBP"    ; pounds
      (is i 165)      "JPY"    ; yen
      (is i 166)      #\|
      (is i 171)      "<<"
      (is i 187)      ">>"
     (<= 192 i 197)  #\A
      (is i 198)      "AE"
      (is i 199)      #\C
      (<= 200 i 203)  #\E
      (<= 204 i 207)  #\I
      (is i 209)      #\N
      (<= 210 i 214)  #\O
      (is i 215)      #\x
      (is i 216)      #\O
      (<= 217 i 220)  #\U
      (is i 221)      #\Y
      (is i 223)      "ss"
      (<= 224 i 229)  #\a
      (is i 230)      "ae"
      (is i 231)      #\c
      (<= 232 i 235)  #\e
      (<= 236 i 239)  #\i
      (is i 241)      #\n
      (<= 242 i 246)  #\o
      (is i 247)      #\/
      (is i 248)      #\o
      (<= 249 i 252)  #\u
      (in i 253 255)  #\y
      #\X
      ))

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:29 on Apr 28, 2019

tef
May 30, 2004

-> some l-system crap ->

luxxx posted:

I could use some more laughs about a language developed by a Lisp pioneer millionaire

Paul graham isn't a lisp pioneer. Sussman, Steele, et al, they pioneered lisp. Graham wrote a (good, so i'm told) book on lisp. The hero worship you have is nice, but misplaced. Besides, Guy Steele is dreamy :swoon:

But really, it isn't really developing a language when you throw out three revisions of your scheme macros. I'm not trying to say that the bar is higher, but when you announce 'the hundred year language', expectations are slightly higher.

(ps, you do know they couldn't find anyone who could maintain yahoo stores in lisp, so they rewrote it in perl for maintainability)

luxxx posted:

who has repeatedly mentioned that he'll work on char encoding when its convenient.

Yep. It's not like there are plenty of examples of why the approaches of 'let developers get unicode right', 'we'll make it a library', or 'we'll fix it later', cause pain, suffering and chaos. (Hint: I'm being sarcastic, pretty much every language stands an example of problems with not getting strings right)

Making arc support unicode is actually not as hard as you'd think, as the underlying language (racket/mzscheme) has reasonable support for it already. He went out of his way to remove support for unicode, and with a bit of handwaving suggested that 7 bits should be enough for anyone.

When you start with the adventurous goal of a hundred year language, not being casually racist against grubby non ascii pure foreigners is a good start.

luxxx
Oct 20, 2012

yaoi prophet posted:

I can feel the smugness radiating from this sentence.

Also jesus christ how do you release a language that doesn't support Unicode?

I agree, it was a bit smug, but probably not the smugness you're thinking.

Everyone knows that certain languages just aren't good at certain things. I use Lisp for a lot, but I know that it's no Excalibur. What I meant by that remark was that people from different coding backgrounds might see Lisp as silly or inefficient merely because they have not been exposed to bottom up or they don't know how to visualize a problem "the Lisp way". It was retaliatory, not instigative.

ToxicFrog
Apr 26, 2008


luxxx posted:

I've always hated the JVM. I really don't like working with Java methods, and I like the ideas that Clojure is putting into action, but using macros alongside long Java methods kinda hurts me. Lisp and Java are two completely different paradigms.

You can do a great deal in Clojure without ever needing to touch Java directly, which is one of the things I like about it - deployment is easy (lein uberjar, upload, done) and I get all of the advantages of targeting the JVM without ever needing to actually use Java.

In cases where you do need to call Java methods directly, it's easy to wrap in a small library that gives you a more pleasant interface (and in many cases someone else has already done so).

Crazy Legs
Nov 6, 2010
Would it be useful for me to learn COBOL? I remember reading about how there's a shortage of COBOL programmers who can maintain the legacy systems in companies, which are written in COBOL.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
If you want a really terrible job that isn't any easier to get or better paying than a decent job then learning COBOL is a good idea.

Kenishi
Nov 18, 2010
Programming is a hobby to me but I'm hoping to make it a career someday. I'm always looking to improve my self as a programmer and yesterday I ran across something that made me wonder something.

I wrote this piece of code which is part of a routine to build an SQL request dynamically based on check boxes.

Abstracted out since unicode doesn't work well in a code block
Python code:
HUMAN = 2
NONE = 4       
def buildStr(self,s_flags):  # s_flags are a bitwise conditional
	str = "s="
	if s_flags & self.HUMAN: # Search for Humans?
		str += u"H"
		if s_flags & self.NONE: # Search for Nons?
			str += u"OR s='N'"
	else: # Humans not checked
		if s_flags & self.NONE: # Search for Nons?
			str += "'N'"
		else:
			str += "''"
	return str
Part of Python allows for minimalism either through tertiary if's or lambda functions. I feel like there might be a more elegant way to implement this sort of thing, but I can't see it. But it led me to a question.

Which is better in programming, readability or elegance?

I think the above is easily readable, though a bit unsightly. Where as a lambda tertiary if function would be compact but not so much readable unless you knew how it worked.

Doctor w-rw-rw-
Jun 24, 2008

Kenishi posted:

Part of Python allows for minimalism either through tertiary if's or lambda functions. I feel like there might be a more elegant way to implement this sort of thing, but I can't see it. But it led me to a question.

Which is better in programming, readability or elegance?

I think the above is easily readable, though a bit unsightly. Where as a lambda tertiary if function would be compact but not so much readable unless you knew how it worked.

Readability and elegance sometimes (often? always?) go hand in hand. Elaborate syntax or language tricks aren't necessarily a part of that, though. That code you wrote is neither maintainable nor particularly readable. Rather, mapping over a list of flags to turn them into "s=?" then joining a list of them with (in python): " OR ".join(flaglist) would be more elegant, as a one-member list would be joined by nothing, whereas a list of flags would be joined by " OR ". and would be of the form "s=?", i.e. "s=H OR s=N".

Your code also does s=H OR s='N' - why the difference in quoting? Bug?

EDIT: here's some code which, if you understand Python, is slightly more straightforward, and much more concise:
Python code:
>>> foo = " or ".join(("s="+x for x in ["H", "N"]))
>>> foo
's=H OR s=N'
EDIT 2: If you don't know .join() or list comprehensions / generator expressions, then you should learn them. They're powerful and without them Python loses a lot of its expressiveness - not that fancy syntax is the point, but it's a small layer between you and understanding code expressed in a functional manner. It's hard for me to explain at the moment, so I hope someone else will chime in.

Also, careful when making SQL statements. If available, use prepared statements, and mold your queries to use them. If not, then be very careful and use whatever SQL escaping provisions are available, and be wary of any of your own code that deals with that.

Doctor w-rw-rw- fucked around with this message at 02:32 on Oct 22, 2012

Thermopyle
Jul 1, 2003

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

Yeah, readability, elegance (whatever that means), and conciseness are only loosely coupled.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Not speaking directly on the code, the modelling of "human" or "none" is confusing to me.

coaxmetal
Oct 21, 2010

I flamed me own dad

Kenishi posted:

Which is better in programming, readability or elegance?

Just addressing this part, but I don't really like the notion of "elegant" code.
I mean, there is nothing inherently wrong with writing code that can be described as elegant,
but often, when people say "elegant" they mean using fancy tricks that are often neither good for readability nor performance.

Code should be correct, readable, and fast (enough). Mostly in that order. Elegant isn't really part of that at all, unless it serves one of those other things.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Everybody likes their own elegant code when they write it, but very few people like it as much when they come back in six months and have to make a change. Readability and maintainability trump almost everything else.

tef
May 30, 2004

-> some l-system crap ->

Kenishi posted:

Which is better in programming, readability or elegance?

Elegant programs are generally readable. You want to focus on clarity, simplicity and generality. You seem to have confused elegance with 'writing clever code that's a few lines shorter'. Most programs are going to look boring, and that's ok. It makes them a bajillion times easier to debug.

If you want to ask if your code is elegant, really you should be asking "have I written enough code to make what i'm doing clear and obvious".

quote:

I think the above is easily readable, though a bit unsightly. Where as a lambda tertiary if function would be compact but not so much readable unless you knew how it worked.

Trying to cram everything into a line is fun, but it's often just showboating. As for the use of bitfields...

If you only have a few options, I'd use named arguments instead of bitfield flags. i.e build_query(...,human=True, none=False), with sensible default values. Another alternative is to use a set/list of strings - i.e build_query(...., set("human")). Another alternative is a namedtuple, i.e

code:
>>> from collections import namedtuple
>>> query_options = namedtuple('query_options','human none')
>>> o = query_options(human=True, none=False)
>>> o.human
True
>>> o.none
False

Doctor w-rw-rw-
Jun 24, 2008

ultrafilter posted:

Everybody likes their own elegant code when they write it, but very few people like it as much when they come back in six months and have to make a change. Readability and maintainability trump almost everything else.


Ronald Raiden posted:

Code should be correct, readable, and fast (enough). Mostly in that order. Elegant isn't really part of that at all, unless it serves one of those other things.

To me, code must be correct, readable, and maintainable for me to consider it elegant at all. Using the latest language trick or technique adds complexity and it only really makes sense to do so in service of one of the other factors, like Raiden says.

Kenishi
Nov 18, 2010

Doctor w-rw-rw- posted:

EDIT: here's some code which, if you understand Python, is slightly more straightforward, and much more concise:
Python code:
>>> foo = " or ".join(("s="+x for x in ["H", "N"]))
>>> foo
's=H OR s=N'
EDIT 2: If you don't know .join() or list comprehensions / generator expressions, then you should learn them. They're powerful and without them Python loses a lot of its expressiveness - not that fancy syntax is the point, but it's a small layer between you and understanding code expressed in a functional manner. It's hard for me to explain at the moment, so I hope someone else will chime in.

Also, careful when making SQL statements. If available, use prepared statements, and mold your queries to use them. If not, then be very careful and use whatever SQL escaping provisions are available, and be wary of any of your own code that deals with that.
Wow that method wasn't what I was thinking about, but it works quite well and its simple. I don't use .join() a lot in my coding but I do know about it.

Suspicious Dish posted:

Not speaking directly on the code, the modelling of "human" or "none" is confusing to me.
Ya, well I cut down much of the code to a small block that showed essentially what I was trying to do.

tef posted:

If you want to ask if your code is elegant, really you should be asking "have I written enough code to make what i'm doing clear and obvious".
Must the code be clear in the absence of documentation/commenting?

----

Thanks for the input everyone.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Generally, if you need a comment explaining how some code works, that code is way too clever and you should simplify it.

And then write a comment explaining it, because chances are it'll still too clever for you once you come back to it in a month.

raminasi
Jan 25, 2005

a last drink with no ice

GregNorc posted:

Hi...
I'm pretty sure there's no R thread, so I thought this was the best place.

There actually is an R thread but it's in a place you probably didn't look.

tef
May 30, 2004

-> some l-system crap ->

Kenishi posted:

Must the code be clear in the absence of documentation/commenting?

Yes.

The Introduction of SICP posted:

Programs must be written for people to read, and only incidentally for machines to execute.

Comments should explain the intent of code, rather than the workings. Sometimes, you have to explain the workings, because you're invoking deep magic, awkward work arounds, or very very low level code. Then you write it as clean as you can, and then comment things too. If you're writing in assembly, you should be writing more comments than code (by size).

Most of the time though, the code should explain how and what your are doing, comments should generally be why you are doing it, or why the code has to be terrible.

(Aside: The code base I am working on has a few categories of comments - swearwords, apologies, and explanations of unfortunate schenanigans to get things to work. (including my favourite, "take that! third party components. try and poo poo over stdout now!"))

The Elements of Programming Style posted:

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Commenting to explain what code does is usually a sign you're trying to showboat, or confuse people. They are a code smell.

The Linux Coding Standard posted:

Comments are good, but there is also a danger of over-commenting. NEVER
try to explain HOW your code works in a comment: it's much better to
write the code so that the _working_ is obvious, and it's a waste of
time to explain badly written code.

Generally, you want your comments to tell WHAT your code does, not HOW.
Also, try to avoid putting comments inside a function body: if the
function is so complex that you need to separately comment parts of it,
you should probably go back to chapter 6 for a while. You can make
small comments to note or warn about something particularly clever (or
ugly), but try to avoid excess. Instead, put the comments at the head
of the function, telling people what it does, and possibly WHY it does
it.

A major problem with comments is that they frequently outlast the code they were written for. Code gets changed, and comments lag behind. Comments in the wild are often misleading, rather than helpful.

If you're looking for a good, short book written by well tempered programmers, I would highly recommend reading "The Practice Of Programming" by Kernighan and Pike.

tef fucked around with this message at 08:10 on Oct 22, 2012

Carthag Tuek
Oct 15, 2005

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



Kenishi posted:

Thanks for the input everyone.

SQL also has an IN operator, so if you have many items, it might be more elegant to do like this:

SELECT ... WHERE column IN (a, b, c);

Works like Python's "in" with lists.

coaxmetal
Oct 21, 2010

I flamed me own dad
Also, if you are using python to generate SQL, it might be worth looking at sqlalchemy. It has a sql expression language that is all python, and you can't use it without the ORM. I can't really speak to it's performance vs prepared statements though, other than it probably isn't as good.

e: that was supposed to be "can" use without the ORM

coaxmetal fucked around with this message at 16:24 on Oct 22, 2012

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Ronald Raiden posted:

Also, if you are using python to generate SQL, it might be worth looking at sqlalchemy. It has a sql expression language that is all python, and you can't use it without the ORM. I can't really speak to it's performance vs prepared statements though, other than it probably isn't as good.

You can use it without the ORM.

Catalyst-proof
May 11, 2011

better waste some time with you

Ronald Raiden posted:

Also, if you are using python to generate SQL, it might be worth looking at sqlalchemy. It has a sql expression language that is all python, and you can't use it without the ORM. I can't really speak to it's performance vs prepared statements though, other than it probably isn't as good.

SQLSoup, originally part of SQLAlchemy, is a less 'heavy' ORM with a psuedo Python DSL:

Python code:
>>> from sqlalchemy import or_, and_, desc
>>> where = or_(db.users.name=='Bhargan Basepair', db.users.email=='student@example.edu')
>>> db.users.filter(where).order_by(desc(db.users.name)).all()
[
    MappedUsers(name=u'Joe Student',email=u'student@example.edu',
        password=u'student',classname=None,admin=0),
    MappedUsers(name=u'Bhargan Basepair',email=u'basepair@example.edu',
        password=u'basepair',classname=None,admin=1)
]

coaxmetal
Oct 21, 2010

I flamed me own dad

Suspicious Dish posted:

You can use it without the ORM.

oh, yeah. THat's what I meant to say. But apparently I said "can't" instead of "can".

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:29 on Apr 28, 2019

Kenishi
Nov 18, 2010

Carthag posted:

SQL also has an IN operator, so if you have many items, it might be more elegant to do like this:

SELECT ... WHERE column IN (a, b, c);

Works like Python's "in" with lists.
Modified my program to use this, this works great. Never knew about this op.

Ronald Raiden posted:

Also, if you are using python to generate SQL, it might be worth looking at sqlalchemy. It has a sql expression language that is all python, and you can't use it without the ORM. I can't really speak to it's performance vs prepared statements though, other than it probably isn't as good.

e: that was supposed to be "can" use without the ORM
This is just a small project of mine using SQLite so I don't think it needs anything too extreme. I only ever touch the database 2-3 times in the program. I may look into it in the future though since I have never worked (or heard of) with ORM stuff before and it seems like something good to learn a bit about.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Hey Goons,

I'm trying to decide which book to pickup that will be code independent, and help me learn core programming concepts.

Here are two books I'm down to, can anyone recommend one?

Pragmatic Programmer: http://www.amazon.com/Pragmatic-Pro...s=code+complete

or

Code Complete 2nd Edition: http://www.amazon.com/Code-Complete...ete+3rd+edition

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Knyteguy posted:

Hey Goons,

I'm trying to decide which book to pickup that will be code independent, and help me learn core programming concepts.

Here are two books I'm down to, can anyone recommend one?

Pragmatic Programmer: http://www.amazon.com/Pragmatic-Pro...s=code+complete

or

Code Complete 2nd Edition: http://www.amazon.com/Code-Complete...ete+3rd+edition

Pragmatic Programmer is more concise and to the point.

a cat
Aug 8, 2003

meow.
What if someone pays me to program a bot to basically log into a website and do bot things - things ranging from kind of tame things like responding to private messages automatically to blatently abusive stuff like spawning a army of facebook users to like things all at once or whatever.

Automation like this seems to be against the terms of service of basically every website these days. Is it true that this isn't clearly illegal, I just have to worry about being sued? And in either case, do I, as the programmer have to worry or just the person paying me?

Do these websites generally send a cease and desist or at least make some attempt to stop me (ie block my ip address) before sueing me into oblivion, or would it be dumb to count on this.

Do companies like Facebook regularly sue small time abusers of their TOS and you just don't hear about it?

I just did a small web-bot project for someone and found it really fun... I'm just checking if I should right away give up ever hoping to work on stuff like that before I get in trouble, or if I'm worrying too much.

a cat fucked around with this message at 05:54 on Oct 24, 2012

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
^Thank you I'll be ordering Pragmatic Programmer.

jjttjj posted:

What if someone pays me to program a bot to basically log into a website and do bot things - things ranging from kind of tame things like responding to private messages automatically to blatently abusive stuff like spawning a army of facebook users to like things all at once or whatever.

Automation like this seems to be against the terms of service of basically every website these days. Is it true that this isn't clearly illegal, I just have to worry about being sued? And in either case, do I, as the programmer have to worry or just the person paying me?

Do these websites generally send a cease and desist or at least make some attempt to stop me (ie block my ip address) before sueing me into oblivion, or would it be dumb to count on this.

Do companies like Facebook regularly sue small time abusers of their TOS and you just don't hear about it?

I just did a small web-bot project for someone and found it really fun... I'm just checking if I should right away give up ever hoping to work on stuff like that before I get in trouble, or if I'm worrying too much.

I'm not a lawyer but if you label it proof of concept I'd imagine you'd be OK as long as you're not the one performing abusive actions. Makers of DDOS software generally aren't the ones targeted, but the people DDOSing are. Throwing a warning in there somewhere that your software is only to be used as proof of concept may help :shrug:

There are cases where this isn't true (WoW Glider) however but in that particular case he was selling his software for real money. Higher courts never ruled on it either; he gave up because legal fees probably got crazy over the few years he was fighting it.

tef
May 30, 2004

-> some l-system crap ->

Knyteguy posted:

Hey Goons,

I'm trying to decide which book to pickup that will be code independent, and help me learn core programming concepts.

Here are two books I'm down to, can anyone recommend one?

Pragmatic Programmer: http://www.amazon.com/Pragmatic-Pro...s=code+complete

or

Code Complete 2nd Edition: http://www.amazon.com/Code-Complete...ete+3rd+edition

I'd recommend the practice of programming, over both of these.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

tef posted:

A major problem with comments is that they frequently outlast the code they were written for. Code gets changed, and comments lag behind. Comments in the wild are often misleading, rather than helpful.
This varies from codebase to codebase, but I'm of the opinion that if you write some decent tests and treat them as holy and sacrosanct, then whatever you write to fulfill / appease those tests should serve better than documentation unless it comes to documenting method calls in an API (ie. what Javadocs or Doxygen docs are good for and that's about it). Not that I'm saying TDD is quite correct, but that's just what unit tests are good for. Traditionally, every time I hit a bug, I write a test case for it so that regressions don't happen, and mark in the block that hits it with // HACK as a warning sign. This way, the only regression bugs I've hit though, admittedly, are documentation bugs (ironically, from auto-generating documentation over the manually written stuff and realizing my annotations and references are outdated from when I was hacking at 3 am).

Furthermore, deleting comments when they're outdated shouldn't be considered a faux pas when you're using version control - you can always get it back. Dead code and dead documentation should be pruned and weeded like your garden and lawn. It's healthy.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If you change some code, and that makes a comment outdated, just delete the loving comment.

If it's still important to have a comment there, the person reviewing your code (you are doing code reviews, right?) can just ask you to write one.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
This is half a programming question but mostly a hardware question, but I figured somebody has done this before. Has anybody ever tried to poll or be asynchronously notified of a wire signal change for something connected to a PC? We test some stuff here and in some scenarios the best we can get for notification are strobing some signal pins.

I'm thinking of getting a cheap-rear end microcontroller with old-school I/O ports and an RS-232 port, and just writing a program to poll the ports and send the pin changes over the RS-232 port. However, I'd prefer to get something off-the-shelf for this if possible. I don't necessarily want to maintain and deploy all these things.

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

Rocko Bonaparte posted:

This is half a programming question but mostly a hardware question, but I figured somebody has done this before. Has anybody ever tried to poll or be asynchronously notified of a wire signal change for something connected to a PC? We test some stuff here and in some scenarios the best we can get for notification are strobing some signal pins.

I'm thinking of getting a cheap-rear end microcontroller with old-school I/O ports and an RS-232 port, and just writing a program to poll the ports and send the pin changes over the RS-232 port. However, I'd prefer to get something off-the-shelf for this if possible. I don't necessarily want to maintain and deploy all these things.

You can do better than this, pretty much any uC will have some pins that you can configure to trigger an interrupt on a rising or falling edge. If you haven't done anything embedded before, and Arduino will work splendidly for this and you can write something up that will work in about twenty minutes. If you have an idea what you're doing with a microcontroller, there are much cheaper options, like the excellent MSP430 from TI. If you're comfortable making a simple LDO circuit on a breadboard and whatnot, you have a billion choices.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Otto Skorzeny posted:

You can do better than this, pretty much any uC will have some pins that you can configure to trigger an interrupt on a rising or falling edge. If you haven't done anything embedded before, and Arduino will work splendidly for this and you can write something up that will work in about twenty minutes. If you have an idea what you're doing with a microcontroller, there are much cheaper options, like the excellent MSP430 from TI. If you're comfortable making a simple LDO circuit on a breadboard and whatnot, you have a billion choices.
I've done microcontrollers but I was hoping not to have to basically make my own product here. We'd have to make a few of these and they'd have to be in a decent enough box to survive a fall on the floor. Stuff like that. So I'd rather get as much off-the-shelf as possible.

Hot Yellow KoolAid
Aug 17, 2012
RE: Goons who have taken a course in Algorithms...

I'm registered for a 300-level Algorithms course next quarter, but I haven't taken one of the prerequisites (300-level Discreet Mathematics). My college will probably allow me to take the course, but I don't want to screw myself later. Is there any way I could give myself a crash course in Discreet Math using text/online resources. I have 3 whole weeks during winter break, and I'm pretty sure I will only need a few days to rest/prepare for other classes. All the sections for required/elective CS courses that I still need have filled up, leaving Algorithms my only option (unless more opens later).

For reference, I've taken 2 quarters of calc, 1 quarter of linnear algebra, and 2 quarters of statistics.


Edit: There is also a potential option to take discreet math concurrently with algorithms, would this be preferable?

Hot Yellow KoolAid fucked around with this message at 18:38 on Oct 25, 2012

Adbot
ADBOT LOVES YOU

the littlest prince
Sep 23, 2006


Hot Yellow KoolAid posted:

RE: Goons who have taken a course in Algorithms...

I'm registered for a 300-level Algorithms course next quarter, but I haven't taken one of the prerequisites (300-level Discreet Mathematics). My college will probably allow me to take the course, but I don't want to screw myself later. Is there any way I could give myself a crash course in Discreet Math using text/online resources. I have 3 whole weeks during winter break, and I'm pretty sure I will only need a few days to rest/prepare for other classes. All the sections for required/elective CS courses that I still need have filled up, leaving Algorithms my only option (unless more opens later).

For reference, I've taken 2 quarters of calc, 1 quarter of linnear algebra, and 2 quarters of statistics.


Edit: There is also a potential option to take discreet math concurrently with algorithms, would this be preferable?

Never integrate while your partner is looking, it's rude. And frankly, disgusting.

The correct spelling is discrete.

Taking them concurrently would certainly be fine, it's terribly easy to be frank, and you could probably even just skip it altogether and pick it up during algorithms. But in the long term it's probably worth the time to take it.

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