Computer Hope

Software => Computer programming => Topic started by: Linux711 on October 05, 2010, 12:59:00 PM

Title: What can't batch files do?
Post by: Linux711 on October 05, 2010, 12:59:00 PM
I am making a small programming language. I want to know what you can't do with batch files and what you don't like about them.
Title: Re: What can't batch files do?
Post by: Salmon Trout on October 05, 2010, 02:29:28 PM
Coming from most programming languages to the Windows NT batch scripting language, I think you would notice the lack of floating point arithmetic, arrays, Boolean operators, any kind of structure, the slow execution speed, and a kind of overall crudity. I am sure others can add to that list. That being said, there is very little that I dislike about it. I just don't expect it to do things it wasn't designed or optimised for. Visual Basic Script is a step in the right direction, and Powershell even more so. I think bash is more elegant and flexible.

see here for an overview of shell scripting (batch files are shell scripts)

http://en.wikipedia.org/wiki/Shell_script




Title: Re: What can't batch files do?
Post by: ghostdog74 on October 05, 2010, 08:01:50 PM
I am making a small programming language.
"a small programming language" and "a small program" has different meanings.

Quote
I want to know what you can't do with batch files and what you don't like about them.
batch (cmd.exe)
1) doesn't support arrays/hashes/dictionaries, those advanced data structures you see in languages like Python/Perl/PHP/Ruby.
2) doesn't do floating point arithmetic.
3) doesn't do date arithmetic
4) poor in string/text file manipulation facilities. Many LOC to do simple stuff.
5) quirks in handling special characters, assigning command output back to variable needs a for loop
6) slow in execution, especially if there are multiple calls to system tools..
7) poor shell expansion, not as flexible as other shells such as bash,(etc)
8) ugly syntax. Why the heck do we need the extra "%" in variables....  %a%%b%%c%  or %%a%%b%%c
9) cmd.exe command line can only support up to 9 arguments . (correct me if i am wrong)
10) talking about commonly used tools
     a) pre installed FTP client not suited for automation, you need to create extra file for the commands
     b) find, findstr doesn't support extended regex
     c) sort cannot sort by numeric, or by fields or .... seriously not comparable to GNU sort for example
11) etc

If you want to program, use a programming language.
Title: Re: What can't batch files do?
Post by: ErikAlbert on October 05, 2010, 10:09:21 PM
@Linux711,
Here you can get several "Microsoft Visual  .......... 2010 Express" languages for free to create your little program.
http://www.microsoft.com/express/Downloads/
Don't forget to register !!!
Good luck and make it work otherwise you and your little program will stare at eachother for a very long time.
MWUAHAHAHAHAHA.
Title: Re: What can't batch files do?
Post by: CBMatt on October 06, 2010, 03:51:10 AM
They certainly can't care for your children or cook your breakfast.  Had to learn that one the hard way.
Title: Re: What can't batch files do?
Post by: BC_Programmer on October 06, 2010, 03:56:09 AM
9) cmd.exe command line can only support up to 9 arguments . (correct me if i am wrong)
SHIFT can be used to "shift" arguments above %9 into range. It's sort of a confusing command, in some ways. usually I just do something like this:

Code: [Select]
:reloop
if %1!==! goto doneecho argument: %1
:SHIFT
goto reloop
:done
echo finished.

I'm sure there is probably also a way to parse them using for /f and accessing %*; but either way, it hardly compares to languages that provide the arguments as an array or give you the full string (because those latter languages usually have some built-in string manipulation that makes it a breeze to split).

"a small programming language" and "a small program" has different meanings.
/quote]

I would think, he knows this. It's not that hard to create a language interpreter/parser, especially when you are just making one up.
Title: Re: What can't batch files do?
Post by: ghostdog74 on October 06, 2010, 05:39:56 AM
Quote from: BC_Programmer
I would think, he knows this. It's not that hard to create a language interpreter/parser, especially when you are just making one up.
i was thinking in the line of an actual programming language. Not a parser
Title: Re: What can't batch files do?
Post by: BC_Programmer on October 06, 2010, 06:44:38 AM
i was thinking in the line of an actual programming language. Not a parser

ah, I see. Come to think of it, even if they are creating the lexical/grammatical analyzer/parser or whatever they should kind of be looking at other languages other then batch for a reference point of what features to include; any semi-modern language designed today should probably have:
Occasionally, you have "exceptions" to these rules; C is still well used for low-level development, like drivers and the like, and it hardly has any of the above mentioned features. The reason it is so popular is simply because it supports pointers and requires manual memory management, which are often necessities when it comes to interfacing with the driver model as well as hardware devices.

C++ supports most of these as well, but you would have to pore through about 5 thousand pages of language documentation to see where they were defined and learn the various arcane syntaxes, and what animals need to be sacrificed, in order to use them.

Main question: what will this language be used for? Or is it just a "playaround" sort of project, where you learn about a few of the caveats of language design?
Title: Re: What can't batch files do?
Post by: Linux711 on October 06, 2010, 09:31:35 AM
Quote
I think you would notice the lack of floating point arithmetic, arrays, Boolean operators, any kind of structure, the slow execution speed, and a kind of overall crudity.

I will keep those in mind. The only one of those that I don't plan doing is arrays.

Quote
"a small programming language" and "a small program" has different meanings.

I know. That's why I didn't say small program.

Quote
They certainly can't care for your children or cook your breakfast.

Really? I was going to make it interface with USB and use it power a hot plate and control a robot to cook the food.  ;D

Quote
Come to think of it, even if they are creating the lexical/grammatical analyzer/parser or whatever they should kind of be looking at other languages other then batch for a reference point of what features to include

I am asking about batch because this is a small project that will probably will never be like Python or .NET. I just want to make sure it's better than batch because I think batch is probably the worst programming language ever designed (or not designed).

Quote
It's not that hard to create a language interpreter/parser
Quote
i was thinking in the line of an actual programming language. Not a parser

I don't understand the difference between interpreter/parser and programming language other than that a interpreter/parser is smaller. Is that the only difference?

Quote
Main question: what will this language be used for? Or is it just a "playaround" sort of project, where you learn about a few of the caveats of language design?

It will be used for anything that batch and vbscript can't do. It is also a "playground" project. One that I plan to finish though and be somewhat usefull. I plan to make it as intuative as possible because I will probably give it to some of my friends, that want to be able to program, but don't want to actually have to "think" about it.
Title: Re: What can't batch files do?
Post by: Salmon Trout on October 06, 2010, 10:00:54 AM
I think batch is probably the worst programming language ever designed (or not designed).

1. It is not a programming language.
2. it evolved between about 1981 and the present as a shell scripting language for MS-DOS and Windows.

If you blame it for not being QBasic or Turbo Pascal or C that is your mistake caused by ignorance.


Title: Re: What can't batch files do?
Post by: ghostdog74 on October 06, 2010, 10:06:53 AM
I know. That's why I didn't say small program.

what i really meant to ask is, are you programming something using a programming language, OR are you actually wanting to start creating your own programming language. That's why I have doubts about your statement
Quote from: Linux711
I am making a small programming language.
gives me the impression that you want to start creating a programming language from scratch ( like what Gosling do to create Java)
Title: Re: What can't batch files do?
Post by: BC_Programmer on October 06, 2010, 10:21:59 AM
I am asking about batch because this is a small project that will probably will never be like Python or .NET. I just want to make sure it's better than batch because I think batch is probably the worst programming language ever designed (or not designed).
whitespace (http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29),Brainfuck (http://en.wikipedia.org/wiki/Brainfuck), and any number of other esoteric programming languages notwithstanding. I suppose languages like scheme and lisp, while relatively popular among educators can be noted here for being almost wholly unused for programming outside of classrooms.


Quote
I don't understand the difference between interpreter/parser and programming language other than that a interpreter/parser is smaller. Is that the only difference?
no.... all Programming languages have an interpreter/parser; something has to turn the programming language into something the computer can work with. Such as- for example, translating a string like "5+5" and then interpreting that and giving back the result of 5 10. the scope of the language itself is wholly irrelevant, except perhaps when it comes to the complexities of the parser; for example, a C# parser/evaluator/lexical analyzer will be more complicated then a BASIC one, because the former has a lot more  to deal with. likewise, a C++ parser/interpreter/etc will be even more complicated, because of the bajillion special cases and the need for backtracking in some instances.

Quote
It will be used for anything that batch and vbscript can't do. It is also a "playground" project. One that I plan to finish though and be somewhat usefull. I plan to make it as intuative as possible because I will probably give it to some of my friends, that want to be able to program, but don't want to actually have to "think" about it.

aye, that's how BCScript (useless to anybody but me since I STILL haven't documented it) started. You might be able to get some ideas from BASeParser.NET (http://bc-programming.com/downloads/downloads.php?DlID=12), at least as far as the basic concepts of expression evaluation go; Try to avoid copying too much, that version has a few bugs that I have since worked out and haven't yet reuploaded a new zip. usually, the actual language itself more or less "evolves" as part of the evaluation syntax. Although I doubt that happens in languages that are properly designed from the ground up. On the other hand, I doubt you'll be submitting it as a new ECMA specification, so really there is a such thing as overthinking things.

Like I said- mine started years ago as a curious exploration type of project; my original incarnations didn't support Arrays or accessing arrays via subscripts, or any of that jazz, so when I wrote a graphing application around them I used all sorts of disgusting hacks that worked but pretty much gutted the parser from the outside in. At some point, I decided to rewrite it, and was able to apply the various problems I had with the original (which was a hacked version of one I found online) and make a more extensible library. And then when I rewrote it yet again as a starting project in C# I was able to apply even more Object theory and features from that language into it, and so forth.

The original version was only used in two of my programs; a 2-D and 3-D (D3D) Function graphing application, and my original attempt at an arkanoid clone (where I used it for "blockscripts" whereby the level editor allowed you to create your own custom blocks using a special language). At some point, however, I realized how stupid it was and switched it to the ActiveX Scripting host, which is a lot more flexible. Basically, it's important to know that you are pretty much "reinventing the wheel" for the most part, and not to be discouraged when you realize that, say, Visual Basic script is still a lot more flexible then your language; unless you can create a language that provides sweeping changes to the way programs are written, or something. It's a great way to learn about interpreters and compilers, though.


gives me the impression that you want to start creating a programming language from scratch ( like what Gosling do to create Java)

um... yes. now that we are all on the same page...

Title: Re: What can't batch files do?
Post by: Salmon Trout on October 06, 2010, 10:39:58 AM
translating a string like "5+5" and then interpreting that and giving back the result of 5

Don't you mean 7?
Title: Re: What can't batch files do?
Post by: BC_Programmer on October 06, 2010, 10:46:15 AM
Don't you mean 7?

clearly! :P

EDIT: fixed  ;)
Title: Re: What can't batch files do?
Post by: Linux711 on October 06, 2010, 12:07:33 PM
The language is interpreted, not compiled because I don't know enough about assembly language to do that. It is written in C and currently the source is about 20KB and the exe 13KB. I am nowhere near completing it. It is going to be a language like the older dialects of BASIC where every line starts with a command (no line numbers). The parser is very simple. It tokenizes by spaces and ignores tabs so that code can be indented. I don't intend to spend much time on the parser. I want to spend the time on adding features to the language.
Title: Re: What can't batch files do?
Post by: BC_Programmer on October 06, 2010, 12:44:58 PM
parsing is a prerequisite for language features...