Author Topic: F# the new lisp?  (Read 8739 times)

0 Members and 1 Guest are viewing this topic.

DraxJDM

  • Newt
  • Posts: 47
F# the new lisp?
« on: September 22, 2012, 08:11:10 AM »
hey all

I am just starting to learn some programming for autocad and the question like many have, where do i start.

After looking around a bit i find lisp to be the best way to go.
Why, because of a few things. It is easy to learn, you don't have to recode for different versions of autocad like in .NET (is something i find back very often as draw back for .NET)
And then i found some things to F#, a special this slide show  http://secretgeek.net/content/fsharp_leonb.pdf]  at slide 82 it is presentend as the replacement for lisp.

The question, is there anyone of you that is looking in to F#?

Greetz john

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: F# the new lisp?
« Reply #1 on: September 22, 2012, 08:22:46 AM »
The question, is there anyone of you that is looking in to F#?

Speak to gile, he is our resident F# fanatic  :lol:

gile

  • Gator
  • Posts: 2519
  • Marseille, France
Re: F# the new lisp?
« Reply #2 on: September 22, 2012, 12:03:55 PM »
Hi,

I'm not really "fanatic" nor the single one here to have shown some interest for F#.
I like F# because I like the "functional way of thinking" and also the concision and elegance provided by the F# syntax.
IMO, F# has also its defaults:
  • it's quite confidential, AFAIK, we're only very few trying to use F# programming for AutoCAD (the only ones I know: kaefer, Bobby C. Jones, Jeff H and I here at TheSwamp and Kean Walmsley).
  • the F# runtime isn't istalled with the .NET Framework (at least until Framework 4.0) and needs a separated installation to run F# assemblies.
  • F# does not provide a visual editor to build GUIs as other .NET languages do.

Anyway, learning F# won't be, IMO, really easier than learning any other .NET language, AFAIK, all the F# guys named upper had a .NET knowledge (C# or VB) before they started with F#.
AutoLISP stays the easiest way to begin programming AutoCAD.

About the slide #82 in the slide show you linked, I don't think it means that F# is a replacement for LISP, but that LISP (not strictly AutoLISP) is still the reference when talking about functional programming.
Speaking English as a French Frog

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #3 on: September 22, 2012, 01:13:13 PM »
About the slide #82 in the slide show you linked, I don't think it means that F# is a replacement for LISP, but that LISP (not strictly AutoLISP) is still the reference when talking about functional programming.
Yep, even Python (which was supposed to be "Lisp without the parentheses") has some features missing which are available to full-blooded lisps (note AutoLisp is definitely not one of those). BTW, Kean has a blog on how to get Python (or rather IronPython = with DotNet) working as an interpreted language inside AutoCAD. I think there are quite a few IDE's available for Python including GUI designers (e.g. QT / wxWigets) - especially in the Linux world.

Gile: Would a F# "assembly" still need recompilation if a newer version of DotNet is required? Like has happened recently with 2013 and C#/VB.Net? Or is it interpreted from source instead of IL? Sorry, I've only glanced over it a bit - and my impression was that you still had to compile to a DLL file in order to use it. Maybe I missed something.

And of course as per the new DotNet class design from ADesk: it won't matter what language you use if they decide to do so again. You would still need to modify your source (at least) in order to use the new class structure and/or add extra references. Even lisp would not be immune to such a change - though ADesk hasn't changed the lisp library much (only added to instead of altering), maybe the biggest reason that lisp lasted so long: The old stuff still works - no need for recoding.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

gile

  • Gator
  • Posts: 2519
  • Marseille, France
Re: F# the new lisp?
« Reply #4 on: September 22, 2012, 02:56:46 PM »
Irne,

F# is a ".NET first class language" as C# or VB, and is compiled in IL in the generated assembly.
The inconvenient about F# I talked upper is due to the using of specific libraries which requires the F# runtime to be installed for the Just in Time compilation from IL.
As for the other .NET languages, there's no need to recompile an assembly built against the Frameowrk 2.0 to use it with newer framworks. The successive .NET framworks are supposed to be like layers added to the previous ones to insure compatibility.

About the AutoCAD .NET API, a little "break" occurs with A2010 which concerned very few class implementation and requiered to rewrite some codes, but most of the apps I wrote for A2007 (Framework 2.0) still work with all versions to A2012 without any change in the code or recompilation wathever the source language.
With A2013, this is a major break due to a "big split" in the AutoCAD referenced libraries which requires to recompile the assemblies even if there's non change in the code (which is the case most of the time).

I don't know much about Python and don't know why it is compared to LISP, but AFAIK it's certainly not for the same reasons as for F#.
As LISP, python is dynamically typed but I don't think it's a functional language. On the other hand, as LISP, F# provides an encourage functional programmaing but is very staticly typed (more than C#).
« Last Edit: September 22, 2012, 03:02:58 PM by gile »
Speaking English as a French Frog

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

gile

  • Gator
  • Posts: 2519
  • Marseille, France
Re: F# the new lisp?
« Reply #6 on: September 23, 2012, 04:36:33 AM »
If you have some time to watch some video, I'd recommand:
- An Introduction to Microsoft F# by Luca Bolognese, the funiest F# presentation I saw
- Developping for AutoCAD using F# by Kean Walmsley.

You can try F# without installing anything with Try F#.
Speaking English as a French Frog

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #7 on: September 23, 2012, 12:55:49 PM »
While talking about F# and functional languages, is there anybody here who's worked with Allegro CL?
There's an express version available. If it's any good, I might give it a try...
Greetings to all of you.

DraxJDM

  • Newt
  • Posts: 47
Re: F# the new lisp?
« Reply #8 on: September 23, 2012, 01:08:08 PM »
to Kerry

no that is not my post ..
going to read it now ..


Gille

i have seen the video from Luca..
really like that one ...
for the moment I'm searching the web for examples with Blocks and attributes ( my personal greatest intrest for writing a program)

John
« Last Edit: September 23, 2012, 01:13:01 PM by john »

gile

  • Gator
  • Posts: 2519
  • Marseille, France
Re: F# the new lisp?
« Reply #9 on: September 23, 2012, 01:27:22 PM »
john,

As I said, you won't find so much AutoCAD F# samples (very very much less than LISP ones...).

One more time, if you're newby with programmation, start with LISP. It's much more easier and, most of the time, really enough powerfull.
Speaking English as a French Frog

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #10 on: September 23, 2012, 02:29:39 PM »
One more time, if you're newby with programmation, start with LISP. It's much more easier and, most of the time, really enough powerfull.

Also very useful is extending lisp with LispFunctions. I'm using them all the time to extend and improve old lisp code. Also, using LispFunctions, there's no need to use DCL or OpenDCL. You can write your dialogs in any .net language and pass data back and forth between .net and lisp code.
From lisp, you can also use the com api.

DraxJDM

  • Newt
  • Posts: 47
Re: F# the new lisp?
« Reply #11 on: September 23, 2012, 02:39:46 PM »
thx for the reply you all

I'm gonna follow Gile's advise and just use lisp... i know it is powerfull enough
to my by the few examples of F# is have seen it looks like easy to learn .. and maybe moor future proof

G.R.  what do you mean with extending lisp with lispfunctions? do you mean visual lisp?

sorry I'm just to new to all this...

 
just a axample of what i have found on the net for autoccad an F#
http://bobbycjones.wordpress.com/2009/05/12/more-f-adventures-you-win-some-you-lose-some/
http://bobbycjones.wordpress.com/2009/05/06/manipulating-polylines-in-autocad-with-f-%E2%80%93-part-i/
« Last Edit: September 23, 2012, 03:36:36 PM by john »

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #12 on: September 23, 2012, 03:33:58 PM »
John,
So called "LispFunctions" are written using the .net api.
They are functions you write using VB.net or C# and  which may then be called from lisp same as any other function written in lisp itself.
If you want more information on that topic, see the AutoCAD .net Developers Guide or do a Google search for "AutoCAD .net api lispfunctions" or something like that.
To write them, you'll need to learn the .net api as well. If I were you, if as you wrote, you decide to go for lisp, just start with lisp proper. There's no need to to start with the .net api all at once. Take it easy, easy does it.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #13 on: September 23, 2012, 06:08:46 PM »
While talking about F# and functional languages, is there anybody here who's worked with Allegro CL?
There's an express version available. If it's any good, I might give it a try...
Greetings to all of you.
I haven't tried Allegro CL, though what I've read seems quite good. Another you could also try is LispWorks. They've got a free-to-try version with some restrictions, but the nice thing is they've got a GUI-IDE which produces windows / dialogs / etc in a system independent way: I think they use wxWidgets, which means no matter to what OS you compile it to (Win/Linux/OSX) the actual GUI uses the OS's native stuff. Not sure if Allegro also has such a GUI designer, but I know both can at least compile to native code - though I'm not too sure how they do it. If it's like GNU-CL then all it basically does is link the entire CL library into the EXE file (i.e. the EXE is several megs in size no matter what it actually does).

At the moment I'm using ECL a bit, there's a version which is incorporated inside Qt: EQL. But I'm using wxWidgets myself - just because it's directly using native code instead of Qt's libraries. Though I do like Qt's posibilities: it's like the difference between Java's AWT and NetBeans. Or if you don't mind not having a GUI designer, then ECL has an interactive LispIDE (written in DotNet).

All those lisps are actually in the family of Common Lisp. CL is not necessarily a "functional" language. Not that you "can't" write functional, it's just that CL doesn't "suggest" functional instead of imperative like F# does. And CL does not necessarily handle recursion well (since its spec does not require tail-recursion-optimization). If you want a "more-functional" lisp, then look towards the Scheme branch - tends to prefer functional code and ensures optimal recursion. Though the libraries are much less extensive than CL's.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #14 on: September 23, 2012, 11:59:45 PM »
to irneb,

Thanks for the reply.
I'll have a look at LispWorks.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #15 on: September 25, 2012, 02:12:41 AM »
Glad to help, though I fear you're going down the same path I have: After seeing just what a Lisp "should" be, AutoLisp feels so inadequate afterwards!  ::)

It's in the same line as the F# video - showing the difference between writing the stock analyser in C# as opposed to F#. You usually have to do a lot more in ALisp than CL, or worse you simply cannot do something in AL which is a breeze in CL. What really blew my mind was how easily CL writes FFI's (foreign function interface) to link to outside libraries, it's near automatic.

What I have to say though, the biggest time saving is not necessarily the language itself, it's usually the libraries which come with it. E.g. C# would be a disaster of a language if you did not have access to all the DotNet libraries - actually it might even be more cumbersome to use than C/C++ without those things. E.g. the piping in F# is actually inherent in Lisp (it's just that the "pipe" goes from inside to outside as the functions return their result to the calling function), and then one step further to general structures like the map in F# which is equivalent to mapcar in Lisp, and then lastly you get to the full blown libraries which are usually specific to the "System" (in AutoLisp this would be the AutoCAD specific functions). This is the major reason I prefer CL over Scheme, in Scm you usually have to write those "library" functions from scratch (if you cannot find some open-source which someone else is kind enough to share), while in CL there's very little which is left out of the normal CL base (stuff like native file/folder-access is built into CL but not SCM).
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: F# the new lisp?
« Reply #16 on: September 25, 2012, 02:42:54 AM »
I found F# difficult due to the imposed constraints of formatting.
This topic summarizes code indentation guidelines for F#. Because the F# language is sensitive to line breaks and indentation, it is not just a readability issue, aesthetic issue, or coding standardization issue to format your code correctly. You must format your code correctly for it to compile correctly.


gile, I agree that Luca Bolognese is a funny speaker ... some of his LINQ presentations were excellent.

//-------------

I haven't investigated it for a few years, but I recall there being several attempts to develop a lisp .net API.

Personally I'm quite happy with Visual Lisp and C#  ...

« Last Edit: September 25, 2012, 02:53:01 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #17 on: September 27, 2012, 05:14:24 AM »
Anyone read this before? http://landoflisp.com/

Scroll down to the comic strip at the bottom of that page ... it's funny ... in a sad sense  :?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

GUIDO ROOMS

  • Guest
Re: F# the new lisp?
« Reply #18 on: October 17, 2012, 03:52:03 PM »
Anyone read this before? http://landoflisp.com/

Scroll down to the comic strip at the bottom of that page ... it's funny ... in a sad sense  :?

Hey irneb,
I've ordered the book from amazon.de and it arrived yesterday.
Think it's a good book.
Although it's meant for beginners, it covers quite a number of more advanced topics.
Well written. Just the right amount of simplification, no baby talk. Good explanations.
Puts a lot of stress on precisely those topics which make lisp special & different.
Best to use it together with a more formal text like "Common Lisp The Language".

Another thing. I've been downloading and testing lisp development systems.
I kept the express versions of both Allegro CL and LispWorks. Their ide's are just acceptable.
All the rest were fossils compared to which the Visual Lisp ide is a gem :lmao:
For example, I'm using an azerty keyboard and clisp.exe didn't even recognize it: all my function
keys and other special keys like ins, del etc... returned gibberish.

Greetings,
have a nice one.

JasonB

  • Newt
  • Posts: 38
  • perfectionist trapped inside the mind of an idiot.
Re: F# the new lisp?
« Reply #19 on: October 17, 2012, 06:08:40 PM »
Bricscad uses OpenLisp http://christian.jullien.free.fr/ as the base for its LISP engine. You can download installer for a number of OS.

I have Land of Lisp too. Have found it quite useful to look at lisp from a more general viewpoint, and how some of these approaches could be used with AutoLisp. AutoLisp forked off at quite an early stage in LISP development and has missed out on much of what came after,  which books like this highlight.

I think it is interesting as to how things evolve with time. IMHO the growing number of AutoCAD emulators with Lisp engines, and the growing use of multiple OS platforms (iPads, android, linux), positions Lisp in very good position through its portability.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: F# the new lisp?
« Reply #20 on: October 18, 2012, 07:16:19 AM »
Very intressting thread, I work with Lisp not so long but I think so too it´s easy to learn the basic more complicate is when Autolisp functions get mixed with visualLisp function. In viewing from Kean I´m impressed that F# have also a powerful compiler or give fast feeback if something is wrong in the code.

gile

  • Gator
  • Posts: 2519
  • Marseille, France
Re: F# the new lisp?
« Reply #21 on: October 18, 2012, 03:42:48 PM »
Very intressting thread, I work with Lisp not so long but I think so too it´s easy to learn the basic more complicate is when Autolisp functions get mixed with visualLisp function. In viewing from Kean I´m impressed that F# have also a powerful compiler or give fast feeback if something is wrong in the code.

Yes, F# is fun, but take care, as I said, the F# learning curve is almost as long as for other .NET languages (C# and VB) and there're very much fewer code samples in F# than in C# or VB (a fortiori for AutoCAD).
F# interactive (which is equivalent to the Visual LISP Console) do not work with external libraries as AutoCAD's ones.
Speaking English as a French Frog

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #22 on: October 19, 2012, 12:50:49 AM »
Yep, the biggest issue I have with C#/VB.Net is you can only test your code modifications by re-compiling the entire thing. With Lisp/F# (or other interpretive languages) it's possible to "quickly" have a piece of code you're trying out run in the console - to see if it works and if it does what you're expecting, before you go and change everything in your project.
 
BTW, if you want some similar functionality for C#/VB.N, you could try using this: http://www.codeproject.com/Articles/6113/Dot-Net-Script
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: F# the new lisp?
« Reply #23 on: October 19, 2012, 05:51:15 AM »
Yeah nice link. :-o

I was beginning with C# 1 year ago, it is funny to do all forms and visualisation things but I was looking for more a practical side to do something with the Autocad API do own command ...
I allready have fun with OpenDCL to make nice menu or optic details.
Now I have seen the Kean documentation and think I  continue with C# first. :ugly:


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: F# the new lisp?
« Reply #24 on: February 18, 2014, 05:15:28 AM »
Sorry to revive this zombie thread ... it's just that I saw another thing which might make people move from VB.Net/C# into F# instead: http://simontylercousins.net/does-the-language-you-use-make-a-difference-revisited/

Finally, some apples - to - apples comparison.  ;-)
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.