Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm basically just getting started with programming. The problem I have with progressing is that I have a hard time learning stuff just for the sake of knowing them - I do better when there's a problem to be solved or a task to be completed so I can learn 'on the job'.

So I'm interested in starting some interesting project. I know the basics of Python, Java, Matlab and some C++ aswell and I know enough about microcontrollers to make LED blink etc.

The type of stuff I'm looking for is for example scraping some weather forecast site (with Python) and outputting the chance of rain to a LCD display, or a program that makes chrome open and log in to facebook if I say "HAL, time for facebook", or more generally, a program that reads serial/USB input, looks for certain sequences and sends instructions to some other program if it finds one.

Do you open some kind of shared stream in which one program reads and one writes? What do I need to read up on to do accomplish this myself? I have no experience with linux or the linux terminal, but looking over peoples shoulders makes me suspect that's what people use. Is that correct?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

The topic you are looking for is Inter-Process Communication (IPC). On Linux and other systems there are dozens of ways to do IPC. Byte-oriented streams (files, sockets) are one way. The one to use depends on what services/systems you want to interact with, and how you want to interact with them.

D-Bus is a message-bus system that is a de-facto standard on modern Linux systems, particularly for communication between desktop applications and operating system services. You can have a look at this list to get an idea of the kinds of services you can access via D-Bus, and there are bindings for Python and Java.

share|improve this answer
    
Your assuming that there are multiple independent programs that can talk to each other, which way over-complicates things on single system –  TheLQ Jun 29 '13 at 23:46

This would be solved with a "controller" application that has 2 parts

  • Reading input from somewhere - Maybe it displays a GUI. Maybe it hooks into the OS and waits for an event. Maybe it connects to a giant red physical button and waits for the user to press it. Regardless of how or what (read language specific docs for that), it listens and waits for input.
  • Executing a task based on input - Now that it has input, it has to do something with it. This is an incredibly broad area where you can open a browser, shutdown the computer, or post to twitter what your toaster is doing, etc.

I know this is very general advice, but you haven't specified exactly what you want to do. Each situation will require different solutions, but they will all use that basic pattern

share|improve this answer
    
Yeah it's the controller application I'm curious about. Do I basically read the input, write the input to a text file somewhere and basically have the task executer program continuously scan the text file for new input? I thought that maybe there were some neater way that was generally used. –  Benjamin Lindqvist Jun 29 '13 at 11:08

What is normally done, rather than scraping websites, is to use a service which provides an API. A great place to start learning this kind of thing might be to grab yourself a Raspberry Pi and get on the forums. Those API's could be used to get content (like weather info) or to post content (tweeting perhaps.)

If you want code samples on how to access a specific API then most providers have code samples in a variety of languages including the ones listed.

As for OS. The main effort in the Pi concentrates on Linux, although you can get proper operating systems to run on it too (there are a couple of flavours of BSD and RiscOS if they float your boat.) For speech, I'm not sure what the state is on speech recognition in Linux. I know it has been embedded into the Microsoft stack since Windows 2000 (you just need to enable it and training it helps too) so you may want to look at coding on a variety of platforms.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.