What are some macro systems in Non-Lisp languages? [closed] - syntax

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've used Scheme and Clojure, I've played a lot with their macro systems and the lisp syntax(lack of syntax) possiblities.
However I haven't found many other languages with macro systems as sophisticated and useful as those in languages with Lisp syntax.(I don't count C/C++)
Are there some notable examples?

Dylan also has a macro system, and doesn't have the classic Lisp-like, fully-parenthesized syntax.
Allegedly Mathematica. I haven't used it myself, though as per this answer, it's quite a bit more confusing than Lisp/Scheme macros.
Depending on how you define "macro system", Template Haskell might count too.

Of Algol dialects with macros (meta programming capabilities) I can think of Nemerle and Perl6. That means it's not impossible to have powerful macros in Algol dialects, but it's always very difficult compared to any LISP dialect because Algol syntax seldom resemble it's own AST tree like LISP dialects do.

My language, Slate, has a macro system at Lisp's level but manages it with Smalltalk-style syntax. In particular, we manage to be hygienic by default (but can capture) and avoiding CONS cells means that our AST nodes are data types that can define code-walking recursive methods, which means that code-walking and transformation is much easier than in Lisp.
But, plenty of newer languages (I intend to evaluate Rust and Julia) have some form of syntactic macro, so there will be more examples to choose from.

Related

Compiler for Bash [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am taking a Compiler Design course in my undergraduate studies. As a part of the learning process, I'd have to develop the compiler for a language.
Can a compiler be written for Bash?
Would it be more difficult than designing a compiler for a regular programming language, like C/C++ and thus outright inconceivable, at least for a newbie?
Can a compiler be written for Bash?
Yes. (Existence proof - shc.)
If yes, how?
That's the hard part.
POSIX shell languages are very different to typical programming languages because of the effects of things like backticks, variable substitution, quoting, and so on.
You could ignore this and implement a "bash like" language, either leaving out the difficult features, or treating them in a way that doesn't conform to POSIX behavior.
Then ... there is the problem of how to generate something that is executable. Again, that is possible (see above), but if your aim is to be faster than a regular shell then you need to do things like emulating the behavior of common Linux commands in the compiled code. That is a huge task.
I'm not saying this is a bad project, but you will need to do a lot of work, including:
finding, reading and (fully) understanding the POSIX shell specs
researching how to implement a parser that deals with POSIX idiosyncracies
figuring out which linux commands need to be implemented directly, and
figuring out how to deal with the ones that you don't; e.g. all the complexity of pipelines.

books / ways to learn data structures and algorithms? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm a self taught Ruby on Rails engineer, and I'm looking to improve my CS understanding. However, most books about data structures and algorithms are written in Java/C/C++/etc, which I don't know. Is there text on these topics using Ruby? Or do you feel Java is similar enough to Ruby that I could survive through a book?
Is there any recommended text for someone coming from my background?
P.S. Recently I've been looking at Objective C, so I'm not completely blind to statically typed languages.
There's a bunch of books on algorithms that are not tied to specific language. Check
http://www.amazon.com/Algorithms-Sanjoy-Dasgupta/dp/0073523402
http://www.amazon.com/Introduction-Algorithms-Thomas-H-Cormen/dp/0262033844
I also recommend fundamental, still non-finished classics
http://www.amazon.com/Computer-Programming-Volumes-1-4A-Boxed/dp/0321751043
If you are jumping into Obj-C it might actually be very worth your time to learn C first. Objective C is very closely related to C minus the odd syntax of Obj-C. In that case you may want to consider K and R which is considered the bible of C to learn that first which will get you started with it to teach you the basics of C and data structures you can later expand on. Also, in case you are learning Objective C to program iOS you may want to be on the cutting edge and learn Swift since Apple is moving to Swift for the future. It is much easier actually and closer to Ruby!
Good luck.

Algorthms or data structure books in scheme [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
There are very good books on Data Structures and/or algorithms featuring languages like C, C++ or Python. A particular example is "Data Structures Using C and C++ by Yedidyah Langsam, Moshe J. Augenstein and Aaron M. Tenenbaum".
In similar vein, are there books on data structures and/or algorithms in scheme programming language?
To add to Chris Jester-Young's answer you have SICP as videoes lectures as well, taught by the authors of the book. It's worth the time! The Scheme standard has changed a little since then, but if you use DrRacket you may be interested in a SICP compatibility module which is really easy to install.
Purely functional data structures (PDF), also available as a book in book stores. It's language agnostic and the code of the book is in ML, but it says it can easily be ported to strict evaluation language, like Scheme.
Yes, Structure and Interpretation of Computer Programs, more commonly known as SICP.

Are there any code DRYer tools out there? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have a large code base and there is lots of repeated, or nearly repeated code all over the place, it's about as unDRY as code can get, but tracking the "duplicates" is hard, so I was wondering if there are any tools for finding potential DRYable code, something like a diff tool or a Hamming distance analizer, don't need language specific knowledge or anything like that.
So any clues as too a tool like this?
Clone Detective for Visual Studio
If you're working in ruby, then you can try this.
Duplo (open source) works in C, C++, Java, C# and
VB.Net. I tried it once, and it found enough duplicated code to keep me employed for a long time.
I've heard of Simian (commercial) but have not tried it.
I use Simian in VS. It's pretty good, not great.
Clone Dr from Semantic Designs is a commercial product that finds duplicate code in a large number of different programming languages. http://www.semdesigns.com/Products/Clone/index.html
Large companies can afford this product. Individuals ... not so much. I wish there were some open source projects out there like this. Might be a fun project to work on. If we only knew of a community of programmers with some time on their hands ...
Semantic Designs' CloneDR find exact and near-miss duplicate clones based on the langauge structure, so it isn't fooled by whitespace changes or line breaks, inserted/changed comments, or even modified variable names.
It leverages production parser front ends to work with C, C++, C#, Java, COBOL, PHP, Python, Fortran, Ada, ...
There are a number of example Clone analysis reports at the web site for various languages.

Do you know any ruby lexers I could use in an application? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I would need lexers for as many programming languages I could get, and I would need them to be written in ruby. Do you know any?
Would RACC be useful to you?
You can combine it with REX to generate your lexer.
RACC is not a lexer. It is a parser generator.
REX is a lexer, and it is ready made, it is a ruby implementation of lex.
Theres another lexer for ruby.
I think it's called ruby-lex.
This might not fit you, but can I suggest you to take a look at Pygments for Python? I understand it might fall outside the scope of your question but this tool has support for a ton of languages and it provides a command-line tool so you can call it from Ruby.
Albino is a small Ruby wrapper for using Pygments from Ruby: http://gist.github.com/82824

Resources