About Me

Programming has always been one my favourites and I deeply enjoyed system programming until I came to know about this ERP thing.  Since then my focus in programming has been on finding ways to develop business applications more efficiently.

 

I blog on http://BahmanM.com.

 

Latest Site Updates

Comment Some strategies for dealing with scaffolding
The default assumption of a Factor install is that you'll be doing all your work in the ./work tree under the installation point.  This is not an assumption I'm personally comfortable with (and it's one that will flatly break if you install Factor anywhere outside of $HOME !).   The recommended approach to working outside the Factor installation tree is to add any subdirectories you'll be working through in the file $HOME/.factor-roots , one line per directory.  For example my .factor-roots file looks like this: /home/michael/Development/Factor/projects This allow me now to type things like "/home/michael/Development/Factor/projects" "my-project" scaffold-vocab when I want to open a new project and to have that directory searched when I start USE: / USING: vocabularies.   That being said, it's a bit verbose and error-prone that way.  So instead here's my $HOME/.factor-rc file: USING: editors.textadept kernel namespaces helpers ; This loads a bunch of things that I plan on using every time.  The last item, helpers, is the interesting one.  In /home/michael/Development/Factor/projects/helpers/helpers.factor I have the following code: USING: kernel namespaces tools.scaffold ; IN: helpers ! Build scaffolding somewhere other than the Factor source tree. : new-project ( vocab -- ) [ "/home/michael/Development/Factor/projects" ] dip scaffold-vocab ; This permits me to type "my-project-name" new-project in the listener instead of the long and error-prone command given before.   There's one minor point of annoyance: you'll have to either type USE: helpers in the listener when you start or you'll have to use the auto-loader (and its annoying message) the first time you use anything in the helpers package.  I haven't found a way around that one yet.   Note that any helper words you'd like can be defined in this file.
Comment Re: Editor Support
Textadept support is now officially part of trunk on the main repository.   YFL's CLI is already benefitting the community of the selected language! 
Comment Editor Support
This thread will be a catch-all place for people to share integration tips and techniques between Factor and their favourite text editor.   I'll start with adding Textadept as an editor for Factor.
Adding Textadept Support to Factor
The "Common Learning Initiative" project of #yfl has selected Factor as the language we're going to jointly learn. Factor has some nice tooling for supporting external text editors. Textadept isn't one of these. Until now.
Comment Re: Baby steps into Stack Hell
Don't forget, using F2 in the listener will reload all the vocabs you are using. So for those who use Vim or Textadept or whatever, working on code, you just need to save and press F2 in the listener to have your code reloaded and available for you.
Comment Re: Baby steps into Stack Hell
If you need to see how the code you're writing (or that someone else has written) works, there's a "UI walker" (search on that in the Browser) tool that acts as an OK debugger.  It takes some getting used to, but it's not that tough.   Where normally in the Listener you'd type <my code here> followed by Enter to execute the code, replacing the Enter with Ctrl+W instead launches the walker.   Given the pretty dire straits of Factor's documentation and the lack of commenting in most Factor code, the walker is a much-needed tool.
Comment Re: Baby steps into Stack Hell
In the Factor documentation, the chain Factor documentation > Factor handbok > Factor cookbook > Factor philosophy leads to an article you should leave open for reference while you're learning Factor.  It won't make much sense at the beginning, but as you learn more it makes more sense and it's definitely good for directing your self-education.
Comment Baby steps into Stack Hell
Why Concatenative Programming Matters gives us a function/word that illustrates some of the strengths of the paradigm: countWhere .  Getting this word working is not trivial.   First, to test the general logic, let's count all the numbers between 1 and 5 that are greater than 2:   { 1 2 3 4 5 } [ 2 > ] filter length .   As expected we get 3 as the output * .  Good.   Now, making this into a word should be as simple as: : countWhere ( x x -- x ) filter length ; Type that into the REPL, however, and you'll find the difference between Forth and Factor: Factor doesn't like the fact that you're using a word expecting a quotation (read: closure) this way.  It wants you to make the word "inline".   All combinators (words taking code as input) must be inlined in Factor.  Other words may be inlined as an optimization, but combinators must be.  filter is itself a combinator, so applying filter to a parameter makes our own word a combinator.  So let's fix this: : countWhere ( x x -- x ) filter length ; inline There.  Now the compiler didn't choke.  Let's try it: { 1 2 3 4 5 } [ 2 > ] countWhere . And there we go!  We have our countWhere word!   Of course there's no point to this: { 1 2 3 4 5 } [ 2 > ] count . This is lesson #2 to be derived: Factor has a huge library.  What you need is probably already in there.  And it's probably done in a smarter way than you chose to do it as well: : count ( ... seq quot: ( ... elt -- ... ? ) -- ... n ) [ 1 0 ? ] compose map-sum ; inline Why is that smarter?  It doesn't build an interim sequence and thus only steps over one sequence instead of two.   (The meaning of that funky stack declaration is for later explanation.  As soon as I figure it out myself!)   * Explanation: { 1 2 3 4 5 } pushes an array onto the stack. [ 2 > ] pushes a quotation (think "closure" kinda/sorta) onto the stack. filter applies the quotation to each element of the array keeping only those elements for which the predicate returns t.  It pops the array and quotation off the stack and pushes the new array in its place. length pops the (new) array off the stack and puts its length in its place. . prints the value at the top of the stack: the length. Forth users are likely, by this point, both having a flash of recognition as well as an uncontrollable drooling reflex as they see how much more flexible the Factor stack is.
Comment Re: Helpful links to get you started
For a bit of a theoretical underpinning to concatenative programming in general, and its relationship to functional programming in particular:  http://evincarofautumn.blogspot.com/2012/02/why-concatenative-programming-matters.html
Comment Some observations...
One thing that has always impressed me with Factor is just how easy it is to build.  I have the System From Hell™ sometimes – a system that seems to strain build systems to the breaking point for unfathomable reasons.  (I can't ever get LuaDist built, for example, despite loads of help from the guy making it.)   I've never had Factor's build screw up.   It's a pleasant change.
Comment Helpful links to get you started
Installing, building... http://factorcode.org/ http://concatenative.org/wiki/view/Factor/Requirements http://concatenative.org/wiki/view/Factor/Building%20Factor   Documentation start here: http://docs.factorcode.org/content/article-cookbook.html Then dive in here. (Good luck) http://docs.factorcode.org/content/article-handbook.html   Further reading Starting Forth: http://www.forth.com/starting-forth/sf1/sf1.html Thinking Forth: http://thinking-forth.sourceforge.net/  
Time to 'Fess Up
I played a little joke a while back and now it's time to both 'fess up and to explore some of the sadly all-too-explicable reactions to it.
Comment Re: Propose a language
Shen It's a lisp I've come across recently. Haven't played a lot with it yet, but I find it's approach to macros trully amazing. Also, it's got a lot of things we all love from functional languages like pattern matching and a type system simpler and more powerful than that of haskell. At least that's what I've seen so far.   Scala Oh well... I consider haskell vastly superior but I'd like to be able to use FP for android apps.   Prolog Although I don't see a practical use for it yet, I've been wondering how this alien language actually manages to do the job.   Clojure Same reason as scala, but traditional-lisps-style.   ARM Asm Yeah, count me on that stuff. I have an ARM board so I can get cracking on real hardware.   Forth Even though I'm not very fond of variable-less stack-based languages because if you miss a single stack manipulation all your stack goes to hell, and keeping track of data in stack is VERY VERY stateful, I'm still interested in it to program MCUs, so I'd like to go deep into forth kernels construction for that matter.   Erlang Oh well, got to admit it, last time I checked I wasn't too into FP, but I have the feeling I should check it out. Also so I can help with dingd1ng.   Smalltalk Even though I ostensibly already know Smalltalk, I'd still love to play with it again. I'm betting I'm totally rusty at it at the moment. It's been around 5 years since I last used it for some minor task. It woud be nice to use Gnu SmallTalk though, just so we can actually use it for shell scripting.   Mercury I don't really know a thing about it, but everyone here seems very interested in it. I'm curious what's the fuss is all about: if it get's voted for the quarter, I'll dig in ;-D
Comment Re: Propose a language
We have 3 languages that stick out: ARM Assembler, Factor and Mercury. I'm going to set up a poll to pick a final one out of these three. You can find it here .
Poll Final Language for Spring 2013
Comment Re: Propose a language
  C ore Erlang It's at the heart of Erlang.   C lojure Lisp like functional programming style with a large library ecosystem.     Mercury Logic programming language that can generate code for other languages as well.   Julia A high level very high performance language for technical computing with distributed parallel execution.      S malltalk Just curious to see what concepts every other OOP language screwed up to hell and back.   ARM Assembler All the fun of learning assembler for the next generation of micro processors.   Lambda Calculus  One of the oldest programming language theories, would like to better understand it.    Meta Programming (Any Functional Language) I like to investigate different approaches to meta programming, I don't believe any functional language has it exactly right yet; so they all apply.
Comment Re: Propose a language
TXL Even though its website uses Comic Sans, I've always been interested by the many tools there are around source transformation and this thing looks quite fun to play with.   Coq Because I hate writing tests, and proving some code is correct looks  funnier . I also think that dependently-types can be quite useful to reason about languages like Erlang which are both strong and dynamic.   MetaOCaml Everyone here knows I like OCaml a lot, even though I just played with it in university. MetaOCaml adds a new construct to represent and compile code at runtime, they called that staged programming and I think it's a really beautiful way to metaprogramming.   Mercury You need to be stupid to not want to learn an interesting language for which there is a core committer to harass on your favorite IRC channel.   Factor Because I've never learned a concatenative language.   Lucid Synchrone Because I've never learned a data-flow language.   ReactiveML Because reactive programming looks interesting for some kind of problems.
Mercury's "Time to Hello World"
There's an interesting metric for language accessibility (and therefore, by extension, often its popularity) called "Time to Hello World". Mercury's "Time to Hello World" is abysmal. In this blog entry I will analyse both why it is so bad and what can be done to improve it.
Comment Re: Propose a language
The languages I'd like to learn, in no particular order: Factor: because it's a Forth-alike that could break the concatenative style out of its self-imposed ghetto of small embedded systems. ARM Assembler: Because it's slick, it's cool and because I'm going to be working on ARM-based systems soon. Orc : Because it looks like a very interesting approach to parallelism and concurrency. TXL : Who wouldn't be interested in a language this wonky? Curry : Prolog isn't the only model of logic programming?! Who knew? The languages I'd like to learn better, again in no particular order: Mercury: I really, really, really want to use this for serious applications. Prolog (especially dialects like Ciao or Logtalk or Lambda Prolog ): It's the ur-father of logic programming. And it's surprisingly relevant even now. Can't go wrong with knowing it well. Lua: Coolest little scripting language around. Nothing stands out as unique to it. It is, however, insanely competently crafted. The languages I'd like to relearn, still in no particular order: Forth: I used to do a lot of this, but the language has developed a lot (not necessarily in positive directions, mind!) since. I'd like to "modernize". Rexx: I played with this a lot on OS/2 and always kinda liked it. I'd like to get good at it. Tcl: The original embeddable scripting language. Has many features to recommend it, along with many flaws that drive people nuts. It is an interesting approach to language design, however.
Comment Re: Propose a language
Previously Michael T. Richter wrote: The languages I'd like to learn, in no particular order: Factor ARM Assembler   +1 to ARM Assembler. It never occured to me, but yeah, that'd be interesting.
Comment Re: Propose a language
Previously Bahman Movaqar wrote: FORTH The language was so unorthodox and strange to me that learning the language turned into an exciting challenge for me. Learning Forth has almost no business value (AFAIK) but it's definitely a fun thing to do which may teach you a few important things about software design.   SMALLTALK I don't know the language myself but from what I read here and there it seems like a good candidate for writing business applications (if that interests you), specially considering the frustration most programmers have with Java (but still they have to stick to it because the only other viable choice is .NET). Much of the awesomeness of Smalltalk, in my opinion, has to do with the environment in which one runs code. Objects and classes live in the same environment with the IDE. You can programatically create classes, which are objects, and their code shows up in the code browser, for instance. If an exception happens, it's easy to actually change the code and resume from that point. It's easy to change a class while the program is running, although there may be some tricky aspects to it (if you add stuff to the constructor, making sure the old objects also run the new code, for example).
Comment Re: Propose a language
FORTH The language was so unorthodox and strange to me that learning the language turned into an exciting challenge for me. Learning Forth has almost no business value (AFAIK) but it's definitely a fun thing to do which may teach you a few important things about software design.   SMALLTALK I don't know the language myself but from what I read here and there it seems like a good candidate for writing business applications (if that interests you), specially considering the frustration most programmers have with Java (but still they have to stick to it because the only other viable choice is .NET).
Comment Re: Propose a language
- Tcl: I feel like it's a name everyone's heard, but perhaps not many know about. Its approach to metaprogramming is quite interesting. 0 Special forms, and more of a run-time feel to its metaprogramming. Some flaws, but still surprisingly interesting. http://tcl.tk   - Kernel: A Lisp centered around the idea of everything being first class, including macro-like things. Apparently similar to fexprs, but with lexical scoping.  http://web.cs.wpi.edu/~jshutt/kernel.html . Different approach from Tcl. I think I prefer Tcl's approach to some extent, but I suspect it could be translated to Kernel to some extent.
Comment Re: Propose a language
I propose 3 languages:   - Factor: Because I want to get my head around this once and for all. http://factorcode.org/ - Racket: Lisp done right. Exploring this together should be a lot of fun. http://racket-lang.org/ - Mercury: Combines a lot of things I like in programming. (And we have Boney to help us out if we get stuck!) http://www.mercury.csse.unimelb.edu.au/   I was going to include Ada, but I'll save that for the next season.
Comment Propose a language
Simply list the languages you'd like to learn. Perhaps include a little motiviation as to why and in case of more "obscure" or lesser known languages, add the link to the home page.
Poll Language Poll
I need some guidance. Tell me which of these languages I should cover next.
Have Designer, Will Travel
Making custom digital hardware used to be difficult and expensive. No longer. It's time for us to realise that we live in the age of custom hardware being within reach of the ordinary.
Review: Learn You Some Erlang for Great Good!
This book, although labelled "A Beginner's Guide", belongs on the bookshelf of anybody who is a serious user of Erlang (with the possible exception of those who made the language or who have used it for decades).
Review: Textadept
Something which only a year ago would have seemed impossible has happened: I've found a text editor to replace Vim. Here's why.
Two Turing Machines
For fun I wrote two universal Turing machines: one in Prolog, one in Mercury. This led me to some observations about type systems and their spheres of utility.