|
|
This is the programming languages item. This item is for the discussion of programming languages: design, implementation, differences, etc. Programming languages are the tools that we use to create computer applications. They define how we communicate with the computer and get it to perform some task. There are many different languages that follow several different paradigms: Procedural imperative languages, where you use the procedure as the basic unit of work, and procedures consist of statements and tell the computer what to do. Then there are object oriented imperative langauges, where the abstract idea of an "object" is the organizing principle: objects combine data and operations that act on that data into one logical unit, may support hierarchies of objects (e.g., an insect is an organism, and a fly is a specific type of insect. Flys, then, inherent the characteristics of insects in addition to their own). Then there are functional systems, where functions that implement expressions without side effects are the fundamental organizing unit of the program - similar to mathematic functions and expressions. Then there are logic systems where assertions are made and presented to predicate systems that consult dictionaries of "knowledge" and decide what to do. Many different languages implement these paradigms, combine them, extend them. Language design and the means by which programs written in languages are executed by computers are fundamental to our understand of programming and, when generalized and abstracted, to our very understanding of computation.
3 responses total.
Is there a programming language that can concisely do what shell commands ls and find do? In rewriting a Perl script that gathers data on all Grex user gopher holes, I realized how much heavy lifting is being done by the shell commands ls and find. For example, a list of all user gopher directories is concisely generated with the command 'ls -d /?/?/*/public_gopher'. If I have more conditions for selecting files, find can do it in a single line. As long as I'm on a Unix-like system, I can get by using these commands for file-system intensive tasks, but I'm curious if there's any programming language that incorporates functionality like ls and find with a similarly compact syntax.
Well, the heavy lifting you describe (matching glob patterns) is really done by the shell in this case. The shell, in turn, is implemented in terms of the "normal" filesystem API: opendir, readdir, closedir, etc. Most programming languages give you access to those functions and you can implement whatever you like on top of them. Find uses (or can use) something called `fts` or `ftw` (file tree (search|walk)) to do its thing. See opendir(3), fts(3), ftw(3) for the C side of things. All of the "usual suspects" have interfaces of varying levels of abstraction to these, and similarly with file globbing. Some random links: Go: https://golang.org/pkg/path/filepath/ Perl: http://perldoc.perl.org/File/Find.html Python: https://docs.python.org/3/library/os.html#os.scandir Ruby: https://ruby-doc.org/core-2.2.2/Dir.html Tcl: http://wiki.tcl.tk/1474 Rust: https://doc.rust-lang.org/std/fs/fn.read_dir.html Etc....
Thank you. Those are some powerful tools.
Response not possible - You must register and login before posting.
|
|
- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss