POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Teach yourself C++ in 21 strange malfunctions Server Time
29 Jul 2024 18:23:59 EDT (-0400)
  Re: Teach yourself C++ in 21 strange malfunctions  
From: Invisible
Date: 19 Apr 2012 04:17:25
Message: <4f8fca15$1@news.povray.org>
>> Did you know that there's a program called Djinn which can take any
>> Haskell type signature and generate Haskell source code for it, if
>> it's possible to write it without recursion?
>
> AFAIK, the hindley-milner type system is turing complete, so it's not
> surprising at all.

Basic Hindley-Milner isn't Turing-complete, no. Add a few extensions and 
it can be /made/ Turing-complete, however.

> So, if you want you may indeed just provide
> mind-boggling complex types and let djinn extract the program behaviour
> from that, just as a C++ programmer can go overkill and write with
> templates a compile-time lisp interpreter
>
> It's all feasible, just not very useful.

Not really.

Suppose I have two Maybe values, and I want a utility function to pick 
the first one which has a value in it. I run Djinn and say

   select ? Maybe x -> Maybe x -> Maybe x

It immediately replies

   select a b =
     case a of
       Nothing -> b
       Just c  -> Just c

which is the correct way to do this. (Although ever so slightly more 
verbose than necessary.)

Now actually there are /several/ possible functions with this type 
signature, and in a sense it's just a fluke that Djinn happens to have 
picked the one I wanted. However, this is not exactly a "mind-boggling 
complex type". Actually it's a pretty damned /simple/ type. :-P

So far I've fed all sorts of stuff into Djinn, and mostly it produces 
the code I wanted. The killer limitation is that it can't handle 
recursion. You can't have recursive types, you can't generate recursive 
code. That's a pretty big limitation. But for simple boilerplate that 
just involves lots of type conversions, it works great!

>> - Allow you to compile the whole project with one keypress.
>
> that's only useful for languages still in the old edit-compile-test
> cycle... ;)

Compiling a program is a useful way to check for errors, even if you 
don't intend to actually /run/ it. (Well, it is if you aren't coding in 
C anyway...)

> in any case, even humble C can do that, provided a Makefile is ready.
> heck, Makefiles are language-agnostic even...

Makefiles only work on Unix. :-P But hey, you can write a simple script 
to build your project under Windows.

The /real/ problem, of course, is that you have to open a command 
window, CD to the right folder, and type in "make program1" or whatever. 
This takes significantly longer than pressing F7 (or whatever).

Heck, KDevelop lets you have the terminal window embedded right there in 
the text editor, and it /still/ takes longer switching back and forth 
between windows than it would to just jab a key.

>> - Display a summary of what entities are defined in each file, what
>> their types are, whether they're public or private, etc.
>
> For C/C++ that's as easy as simply taking a look at each header file. :)

...and skipping over all the preprocessor directives, comments, inline 
functions, and other cruft. :-P

>> - Let you navigate to each entity in the list.
>
> ever heard of exhuberant C-tags?

What are "tags"?

>> - Run the document extraction tool.
>
> what's wrong with man? ;)

Oh Jesus, where do I even *start* with that??

>> - Easily launch your application.
>
> like ./out ?

Sure, once you take your hands off the keyboard and onto the mouse to 
switch from the text editor window to the command prompt window. :-P

> well, I'm stopping now.

...that's not what it looks like from here. ;-)

>> - Integrate with the debugger. Let you single-step through your code.
>> Let you create watches, inspect variables in scope, drill down through
>> complex data structures.
>
> you are not even talking like a haskeller anymore! Is there such a
> haskell debugger?

Yes, there is. OK, it doesn't actually /frigging work properly/, but it 
exists. And has a horrifyingly bad UI, BTW. Mainly because trying to do 
interactive program exploration using a CLI is really unintuitive.

>> Tell me, how do any of these things stop being useful if your
>> programming language isn't object-oriented?
>
> They are all very useful and none requiring a bloated and costly IDE.
> Intellisense is the only really thing useful in such IDEs, and, like I
> said, it's only really useful for OO languages.

Bloated I'll give you. But costly? Do you have any idea how many free 
IDEs there are?

Basically, what you've just said is "you can recreate some of the 
features of an /integrated/ development environment by manually linking 
tools together yourself". Sure, you can, it's just harder.

For the most part, I use a non-integrated development environment when 
I'm coding Haskell. That doesn't mean I don't see the value in something 
like Leksah.

An IDE is way, way more than just code completion.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.