# A couple basic (hah) computer programming questions

**URL:** https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800
**Category:** Factual Questions
**Created:** [March 16, 2005, 1:33pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800 "2005-03-16T13:33:43Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Chairman\_Pow](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Chairman\_Pow](https://boards.straightdope.com/u/Chairman_Pow)
#### Post date: [March 16, 2005, 1:33pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/1 "2005-03-16T13:33:43Z")

</div>

OK, I should probably know better, but my experience with any sort of programming is making silly little games in Basic in the pre-Windows 3.1 days.

1. Does each language require a special editor, or can I use, say Notepad for any of them? If not, what sort of file would I save the work in? IIRC, Virtual Basic has it’s own GUI and but I’m not sure if that’s necessary to write programs in.

2. I assume that some languages are more efficient than others. Are there some languages that have specific areas that they’re designed for and won’t well for other applications (uh, poor choice of words. That is, is there a “financial” language that won’t make good games and vice versa?)?

3. How does one write a programming language? Do they need to know Binary? Do they use another language as a base?

I’m sure I’ll have some more silly questions as the day goes on. Thanks for your help.

---

<div class="post-metadata">

### Author: ![Chairman\_Pow](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Chairman\_Pow](https://boards.straightdope.com/u/Chairman_Pow)
#### Post date: [March 16, 2005, 1:35pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/2 "2005-03-16T13:35:26Z")

</div>

Oh, I should probably define what I’d consider a language: a syntax to create a stand alone application, not as a “customization” markup for an existing program: that is, I’d say that C++ is a language, but HTML isn’t. Java is, but XML isn’t.

Is this the correct way of looking at things?

---

<div class="post-metadata">

### Author: ![Sage\_Rat](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sage_rat/32/399_2.png) [@Sage\_Rat](https://boards.straightdope.com/u/Sage_Rat)
#### Post date: [March 16, 2005, 1:54pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/3 "2005-03-16T13:54:23Z")

</div>

> [@Chairman Pow](#):
>
> 1. Does each language require a special editor, or can I use, say Notepad for any of them? If not, what sort of file would I save the work in? IIRC, Virtual Basic has it’s own GUI and but I’m not sure if that’s necessary to write programs in.

Most do not require a special editor–but you do have to have either a compiler or an interpreting program which may or may not cost money. VB is a rare instance where the compiler only comes with a editor, and the editor packs in a lot of stuff secretly for the compiler. In general, I wouldn’t recommend VB for any application beyond a 5 second test app (if you already know how to use it and have a copy already installed.)

> [@](#):
>
> 1. I assume that some languages are more efficient than others. Are there some languages that have specific areas that they’re designed for and won’t well for other applications (uh, poor choice of words. That is, is there a “financial” language that won’t make good games and vice versa?)?

Yes. Every single language was designed to be better for certain tasks. The level at which that language is limited to only a single task will depend on the language.

> [@](#):
>
> 1. How does one write a programming language? Do they need to know Binary? Do they use another language as a base?

Compiled languages require that you know the instruction set of the underlying hardware. If you add in libraries of standard functions to your language, then you will also need to know how to interface with the OS and such.  
If you’re making an interpretted language, then you just need to know the language you are writing in, and again possibly the OS calls if you have a library of standard functionality.

> [@](#):
>
> I’m sure I’ll have some more silly questions as the day goes on. Thanks for your help.

No problem. =)

---

<div class="post-metadata">

### Author: ![Spectre\_of\_Pithecanthropus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/spectre_of_pithecanthropus/32/12343_2.png) [@Spectre\_of\_Pithecanthropus](https://boards.straightdope.com/u/Spectre_of_Pithecanthropus)
#### Post date: [March 16, 2005, 1:58pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/4 "2005-03-16T13:58:46Z")

</div>

You could write a program in, say, Java, using Notepad, and then use the DOS window to invoke the Java compiler, and then the Java virtual machine. IME, however, it’s more usual to use a language sensitive editor or integrated development environment. These have all sorts of bells and whistles to make writing and testing code easier.

Languages are either compiled or interpreted. To “write” a compiled language means essentially to develop a compiler for it. I don’t know much about how that’s done, but the general approach is to write logic to parse the incoming tokens, or “words” in the source code. That is, the program has to figure out what each symbol is supposed to mean in the context where it’s found. Then it writes out equivalent code in assembly or binary.

I know even less about how interpreters work.

---

<div class="post-metadata">

### Author: ![CandidGamera](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/candidgamera/32/2878_2.png) [@CandidGamera](https://boards.straightdope.com/u/CandidGamera)
#### Post date: [March 16, 2005, 2:04pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/5 "2005-03-16T14:04:43Z")

</div>

Sage Rat’s covered it pretty well, but I’m happy to chip in with two cents when and where I can. Many languages work with a text editor just fine for the writing, but need a compiler or interpreter to run. C, C++, Ada, Pascal, Fortran\*, Java, Lisp, PERL, Basic - you can use a text editor to write any of those, as I recall.

You (almost) have to have a GUI for the Visual languages - Visual C++, Visual Basic, etc. I say almost, because there may be a way for a true guru to specify on-screen object positions in the raw text format, but I’m unaware of it.

Though you dismiss HTML, and perhaps rightly so, one could use JavaScript to learn some rudiments of programming very easily - use a text editor to create, and your browser functions as an interpreter. No special software needed.

Now, I wonder what you’re trying to do exactly, so I can offer more specific help.

---

<div class="post-metadata">

### Author: ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)
#### Post date: [March 16, 2005, 2:23pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/6 "2005-03-16T14:23:36Z")

</div>

> [@CandidGamera](#):
>
> Sage Rat’s covered it pretty well, but I’m happy to chip in with two cents when and where I can. Many languages work with a text editor just fine for the writing, but need a compiler or interpreter to run. C, C++, Ada, Pascal, Fortran\*, Java, Lisp, PERL, Basic - you can use a text editor to write any of those, as I recall.

Nitpick: It’s Perl, not PERL. Yeah, I’m a Perl weenie.

Writing compilers is a bootstrapping problem. For instance, GCC, one of the most widely used C compilers, is written in C and can compile itself. Of course it wasn’t always so; the early versions required some other C compiler to compile it first. You can write a compiler in assembly or machine code, but with the exception of very few specialized applications, they are almost always written in some high-level language, very often C. (In fact, the standard Unix tools Lex and Yacc make generated abstract tokenizers and parser functions rather trivial, but I digress.)

> [@](#):
>
> Though you dismiss HTML, and perhaps rightly so, one could use JavaScript to learn some rudiments of programming very easily…

Very true, but HTML isn’t Javascript. 🙂 In fact, you don’t even need a web browser to run Javascript. The MacOS [Konfabulator](http://www.konfabulator.com/) package which lets you develop all sorts of neato desktop widgets provides a Javascript runtime, and all the widgets are written in Javascript.

---

<div class="post-metadata">

### Author: ![Lockz](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@Lockz](https://boards.straightdope.com/u/Lockz)
#### Post date: [March 16, 2005, 2:29pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/7 "2005-03-16T14:29:28Z")

</div>

I’ve made GUIs in Java before with nothing other than the straight text interface - it’s a required first-year computer science course where I went to university. Nothing too hard once you get used to it, although having a nice drag’n’drop interface would be appreciated.

---

<div class="post-metadata">

### Author: ![CandidGamera](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/candidgamera/32/2878_2.png) [@CandidGamera](https://boards.straightdope.com/u/CandidGamera)
#### Post date: [March 16, 2005, 2:36pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/8 "2005-03-16T14:36:53Z")

</div>

> [@friedo](#):
>
> Very true, but HTML isn’t Javascript. 🙂 In fact, you don’t even need a web browser to run Javascript. The MacOS [Konfabulator](http://www.konfabulator.com/) package which lets you develop all sorts of neato desktop widgets provides a Javascript runtime, and all the widgets are written in Javascript.

I never said HTML was JavaScript. I mention them in the same breath because they’re strongly intertwined, but wanted to make the point to the OP that they were distinct entities, one of them quite useful for his apparent purpose. And given the question as phrased, I think it’s much more likely he owns Internet Explorer or Mozilla Firefox than Konfabulator.

---

<div class="post-metadata">

### Author: ![CandidGamera](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/candidgamera/32/2878_2.png) [@CandidGamera](https://boards.straightdope.com/u/CandidGamera)
#### Post date: [March 16, 2005, 2:39pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/9 "2005-03-16T14:39:59Z")

</div>

> [@Lockz](#):
>
> I’ve made GUIs in Java before with nothing other than the straight text interface - it’s a required first-year computer science course where I went to university. Nothing too hard once you get used to it, although having a nice drag’n’drop interface would be appreciated.

And I’ve made GUIs in HTML/Javascript with a straight text interface. My comment about GUIs was specific to the Visual languages - which, when it comes to object positioning and the like, are often obfuscated.

---

<div class="post-metadata">

### Author: ![kellner](https://avatars.discourse-cdn.com/v4/letter/k/c2a13f/32.png) [@kellner](https://boards.straightdope.com/u/kellner)
#### Post date: [March 16, 2005, 3:15pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/10 "2005-03-16T15:15:00Z")

</div>

> [@Chairman Pow](#):
>
> Oh, I should probably define what I’d consider a language: a syntax to create a stand alone application, not as a “customization” markup for an existing program: that is, I’d say that C++ is a language, but HTML isn’t. Java is, but XML isn’t.
> 
> Is this the correct way of looking at things?

Make that “_programming_ language.” I think that is what you meant anyway, but the distinction is important. HTML and XML (and its individual document types) are definitely languages. Programming languages are languages for the description of algorithms. “stand alone application” is a bit problematic because all programs rely on something that executes them. Any definition would be arbitrary because there are so many shades of gray.

---

<div class="post-metadata">

### Author: ![Sage\_Rat](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sage_rat/32/399_2.png) [@Sage\_Rat](https://boards.straightdope.com/u/Sage_Rat)
#### Post date: [March 16, 2005, 4:02pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/11 "2005-03-16T16:02:51Z")

</div>

> [@CandidGamera](#):
>
> You (almost) have to have a GUI for the Visual languages - Visual C++, Visual Basic, etc.

Is there a Visual C++ language? I had thought that the “Visual” part was just the name of the package. …Though, thinking about it, the wizards for ATL certainly come up with some stuff that definitely isn’t C++ (but also not terribly visual.)

---

<div class="post-metadata">

### Author: ![Small\_Clanger](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Small\_Clanger](https://boards.straightdope.com/u/Small_Clanger)
#### Post date: [March 16, 2005, 4:11pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/12 "2005-03-16T16:11:33Z")

</div>

\<Questions=Chairman Pow\> Lots of good answers already, my additions:

> [@](#):
>
> 1. Does each language require a special editor.

No. Well, not really. Though you can in principle write C++/C#/Java as bare text files you will have a hard time, a decent IDE makes life much easier. Text files very quickly become unfeasible with non-trivial projects. AFAIK IDEs are not interchangable, it’s no good trying to use your favourite Java editing environment for C++, it will get confused.

> [@](#):
>
> 1. I assume that some languages are more efficient than others.

This is complicated – but yes. If you need something very quick write it in C/C++ better still Assembly. If you need it _written_ quickly on the other hand 🙂

> [@](#):
>
> Are there some languages that have specific areas that they’re designed for…

Yes. (ignoring markup languages) To talk to databases you use SQL (which no-one learns for fun). COBOL is/was used for business applications. I seriously doubt that anyone ever wrote a game in COBOL, and I don’t see how you could write onr in SQL. In the curly-brace languages C/C++/Java/C# and VB/Dephi you can write almost anything you want unless you want to talk to the hardware, then you’re down to C/C++ or Assembly.

> [@](#):
>
> 1. How does one write a programming language? . . Do they use another language as a base?

**friedo** covered this. I love the example that GCC is written in C and can be used to compile itself. Like using your own car to tow you home.

---

<div class="post-metadata">

### Author: ![Metacom](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Metacom](https://boards.straightdope.com/u/Metacom)
#### Post date: [March 16, 2005, 4:14pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/13 "2005-03-16T16:14:15Z")

</div>

> [@Spectre of Pithecanthropus](#):
>
> Languages are either compiled or interpreted.

Or both!

Common Lisp implementations usually have both an interpreter and a compiler. One implementation (CMUCL) has an interpreter, a native-code compiler, and a byte-code compiler/interpreter.

---

<div class="post-metadata">

### Author: ![Monstre](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Monstre](https://boards.straightdope.com/u/Monstre)
#### Post date: [March 16, 2005, 4:27pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/14 "2005-03-16T16:27:39Z")

</div>

And Java, too – (on both compiled and interpreted).

Java compiles to bytecode, then runs on the interpreter (Java Virtual Machine).

On this one:

> [@](#):
>
> 1. How does one write a programming language? . . Do they use another language as a base?

Are you asking about writing the compiler/interpreter for a new language? or developing the language itself?

Yes, on both counts. Many languages now have syntax that’s based around another language. Java syntax developed from C++ syntax, but changed some things to make life easier in many regards (i.e. eliminating pointer notation, for starter). And there have also been many advances in compilers, usually starting with the C compilers (optimization of code by the compiler, etc). This can be taken advantage of by other languages – for example, the Ada compiler on my school’s system translates Ada source code into a form where the C compiler (gcc) can finish the job and build the actual fully-compiled target.

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [March 16, 2005, 4:41pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/15 "2005-03-16T16:41:57Z")

</div>

> [@Spectre of Pithecanthropus](#):
>
> Languages are either compiled or interpreted.

And the difference between the two is quite simple: interpreted languages are interpreted by software, while compiled languages are interpreted by hardware.

> [@](#):
>
> I know even less about how interpreters work.

The details depend on the structure of the language, but the basics are pretty similar. First, you transform the input file of the program to some kind of data structure that you can execute and perform compile-time error checking. Then, you iterate over that data structure and execute the statements it contains.

I wrote a pretty simple XML-based scripting language that offered some basic features: commands, if-then logic, loops and variables. First, I had an XML parser read it into a tree structure, then I ran a DTD validator on it, and then I transformed that tree to a different tree that was a little easier to execute on.

The execute method was pretty straightforward: I traversed over every node in the tree and executed whatever was in there.

---

<div class="post-metadata">

### Author: ![Metacom](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Metacom](https://boards.straightdope.com/u/Metacom)
#### Post date: [March 16, 2005, 4:48pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/16 "2005-03-16T16:48:46Z")

</div>

> [@Monstre](#):
>
> And Java, too – (on both compiled and interpreted).

Er, no.

Usually when people say a given language implementation is “compiled” they mean it compiles to native code that is directly executed by a CPU. Usually when people say “interpreted” they mean there’s another program (an interpreter) that reads the source code and does what it says.

Java would best be described as “byte compiled.”

Common Lisp implementations can be any combination of compiled, interpreted, or byte-compiled. For example (I’ve done some trimming to make it cleaner):

```auto

* (load "simple.lisp")

* #'simple

#<Interpreted Function SIMPLE {58017D41}>

* (compile-file "simple")

; Compiling: /tmp/simple.lisp 16 MAR 05 11:00:29 am
; Compiling DEFUN SIMPLE: 
; Compilation finished in 0:00:00.

* (load "simple.x86f")

* #'simple

#<Function SIMPLE {580B8CB9}>

* (compile-file "simple" :byte-compile t)

; Compiling: /tmp/simple.lisp 16 MAR 05 11:00:29 am
; Byte Compiling DEFUN SIMPLE: 
; Compilation finished in 0:00:00.

* (load "simple.lbytef")

* #'simple

#<Byte function SIMPLE {580DBB89}>

```

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [March 16, 2005, 5:18pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/17 "2005-03-16T17:18:37Z")

</div>

> [@Metacom](#):
>
> Java would best be described as “byte compiled.”

I want to say that MS J++ has an option to generate a compiled binary from Java code, but as that’s non-standard, it’s questionable whether you want to count it.

---

<div class="post-metadata">

### Author: ![Metacom](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Metacom](https://boards.straightdope.com/u/Metacom)
#### Post date: [March 16, 2005, 5:53pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/18 "2005-03-16T17:53:15Z")

</div>

> [@ultrafilter](#):
>
> I want to say that MS J++ has an option to generate a compiled binary from Java code, but as that’s non-standard, it’s questionable whether you want to count it.

MS J++? What’s that? I can’t find it on [java.sun.com](http://java.sun.com). 😉

Good point. I usually try and seperate a language’s definition from its implementations, unless there’s a single canonical implementation (e.g., Perl, PL/SQL). I’m so used to using Sun’s version I forgot there are others.

FTR, gcj, the GNU Java compiler, also compiles Java to native code.

---

<div class="post-metadata">

### Author: ![Monstre](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Monstre](https://boards.straightdope.com/u/Monstre)
#### Post date: [March 16, 2005, 6:46pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/19 "2005-03-16T18:46:58Z")

</div>

> [@Metacom](#):
>
> Er, no.
> 
> Usually when people say a given language implementation is “compiled” they mean it compiles to native code that is directly executed by a CPU. Usually when people say “interpreted” they mean there’s another program (an interpreter) that reads the source code and does what it says.

Er, yes. The term “compile” doesn’t have to mean “down to native CPU instruction set”. And I was not using it in that way. I was not claiming that Java is compiled down to system-specific architecture. I was simply pointing out that the techniques of “compiling” and “interpreting” are both used in Java. The “javac” program from the J2SDK compiles the source code to an intermediate level (bytecode). The interpreter runs that code.

[And Sun calls their javac tool a compiler](http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html), so that term works fine for me.

---

<div class="post-metadata">

### Author: ![Metacom](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Metacom](https://boards.straightdope.com/u/Metacom)
#### Post date: [March 16, 2005, 7:07pm UTC](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800/20 "2005-03-16T19:07:08Z")

</div>

> [@Monstre](#):
>
> Er, yes. The term “compile” doesn’t have to mean “down to native CPU instruction set”.

Which is why I said:

> [@Metacom](#):
>
> Usually when people say a given language implementation is “compiled” they mean it compiles to native code that is directly executed by a CPU.

Instead of making a broader statement about what the word “compiles” means.

If you say a language is “compiled,” people are going to think you mean that the language gets compiled to native code. That’s just how the word is used in that situation.

If you don’t agree, we’ll just have to agree to disagree. But I’m right.

[Next page](https://boards.straightdope.com/t/a-couple-basic-hah-computer-programming-questions/294800.md?page=2)
