+
+ is HQ9+ with two differences: there are no "H", "Q", or "9" instructions, and all characters that are not + are explicitly ignored.
Instructions
Unlike some languages, + is relatively simple to learn, even for non-programmers. It has only one instruction, +, which increments the program's accumulator. All others are ignored.
Examples
Increment the accumulator once:
+
Increment it five times:
+++++
Wow, what a useful language!
Computational class
+ is a push-down automaton, as the + instruction simulates pushing to a stack. The initial state can also be a halt state, and the only state, and a + instruction can loop back to the initial/halt/only state, pushing a value to the stack as it does so.
Interpreters
Perl
60 bytes
my$r=$ARGV[0];open my$z,'<',$r or die$!;my$c=()=<$z>=~/\+/g;
XENBLN
17 bytes, 12 characters
$a0ŽIÍ=x„+äa
Lua
Reads program from given file name.
local args = {...}
local file = io.open(args[1],"r")
local counter = 0
while true do
local nLine = file:lines()()
if not nLine then
break
end
if string.find(nLine,"+") then
local _, count = string.gsub(nLine,"+","+")
counter = counter + count
end
end
file:close()
Shorter, less… stupid. Reads program from input.
local counter = 0 repeat local c = io.read(1) if c == '+' then counter = counter + 1 end until not c
Even shorter. Requires input to terminate before execution starts. Entire program is stored in memory, so beware long programs.
local counter = #io.read("*a"):gsub("[^%+]","")
><>
Reads code from input
>i:01-=?v00. v &0r+1< >:"+"=?!v&1v ^ ~;!?:<&+<
A second version
0&01. >i:0(?;"+"=?v ^ &+1&<
Python 3
a = 0
c = input()
for char in c:
a += 1 if char == "+" else 0
The one-liner:
(a:=0,[a:=a+(_=='+')for _ in input()])
Shorter:
input().count("+")
C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i = 0;
string s;
getline(cin, s);
for(int pstf = 0; pstf < s.length(); pstf++)
{
if(s[pstf] == '+') i++;
}
cout << i;
return 0;
}