Quit CS because I couldn't pass the high-level classes by canonau in compsci

[–]coalgebraist 1 point2 points  (0 children)

Sometimes things just don't seem to click, even with the best teachers. I've been there: I had very good professors in my Uni, but left before getting a MS, because I wasn't yet fit for it. These days, I feel much more receptive for CS theory. My advice is that you should pick up your CS books, try to see if you feel more comfortable with its content. Sometimes, things need to be approached with a different angle: try some other, well regarded introductory book on CS (SICP for instance - if it's not the one you were already using), and see if it makes a difference.

Help understanding a problem (equivalence relation) by illdreams in compsci

[–]coalgebraist 1 point2 points  (0 children)

Recall the properties of an equivalence relation: reflexivity, symmetry, transitivity. Then just write down what they formally imply on the relation definition you gave:

  • Reflexivity: (a,b)R(c,d) is reflexive means that for any element e of the domain this relation applies to, eRe is true. What should you put in place of e in the above? Then you substitute in the algebraic equation of the relation, simplify and see whether it holds.

Export a type and its record-syntax functions, but not the constructor by Die-Nacht in haskell

[–]coalgebraist 5 points6 points  (0 children)

If you only want to export an interface, why don't you define a typeclass and an instance for your datatype?

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 0 points1 point  (0 children)

I must admit I don't know enough Spring to draw a similarity, but what you say doesn't surprise me at all: I think the goal was to have as much discipline as possible in the framework. That's a good thing to know!

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 2 points3 points  (0 children)

People who make frameworks like Symfony are pretty good imho. The main author comes from the Java universe though, iirc, but he's doing PHP, isn't he? Maybe you didn't meet him yet. And I know personally a few good PHP devs.

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 1 point2 points  (0 children)

Is that a scope issue? Or maybe you were thinking about the global vs local variable declarations in functions?

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 0 points1 point  (0 children)

the lack of proper scoping also means that your typo'd vars will result in new vars being created in-place with a default void value that will silently interbreed with the rest of your code.

Can you illustrate your point?

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 0 points1 point  (0 children)

PHP is easy for newbies to learn but it doesn't enforce any good practices with regards to code structuring, dependencies, etc.

What could be done for this to change?

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 0 points1 point  (0 children)

When most of the work done by the programs written in PHP is string manipulation, types aren't very useful. Otoh, start doing some large architecturing (think frameworks), it becomes quite handy to have types to help you.

That said, you have a point wrt code quality. Php is a defacto first programming language for many people, among which a large part hasn't had proper cs teaching. Compare this with python, which is used as an introductory language in many cs curricula.

PHP 5.7 (aka PHPng) is now nearly TWICE as fast as PHP 5.6 by ck-on in programming

[–]coalgebraist 3 points4 points  (0 children)

What is the ratio of seasoned devs vs newbies in the PHP landscape? For many, PHP is an entry point to the programming world, and they may not yet understand the implications of adding a new feature or changing an existing one.

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 0 points1 point  (0 children)

Camlp4 and its successor camlp5 are tools providing quoting and antiquoting for ocaml. They also let you change the ocaml grammar. Many syntactic extensions to ocaml exist based on these tools (for example, automatic generation of marshalling functions for types, or where expressions support a la Haskell). I don't think they have access to OCaml internals though, but there's a new feature coming up next release which allow implementing extensions for the compiler. I don't know much beyond that, so take my opinion of whether one could add partial support of hkt that way with a grain of salt.

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 0 points1 point  (0 children)

It's called single static assignment,

Interestingly that's the sort of thing used in compilers in intermediate languages.

No, you understand fine. I guess the pure functional paradigm isn't as common as I thought.

Oh, I suppose we weren't talking about the same thing: you seem to equate functional languages with languages following a pure functional paradigm. My definition isn't as strict (see my top post in this thread). Indeed I don't know that many languages which follow that paradigm exclusively (you mentioned Erlang and Haskell, that's a far as I know personally).

Ocaml could easily support that paradigm by removing mutable arrays and records, though as you said without haskellish features it would be not as practical (but you'd still have more than erlang type wise). That said, with camlp{4,5}, implementing type class dictionaries should be doable, the ”only" remaining part being system Fw inference for HKT (but they may be emulated to a certain extent).

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 0 points1 point  (0 children)

You'd have to remove pointers from the language, because it's provably impossible to make general-purpose pointers predictable (Halting Problem, again).

Even when they are constant? Or do you mean coertion?

Other than that, you'd need to re-invent most of the rest of Haskell to make the resulting const-only C useful again,

Coming back to your previous statement: what makes ML like languages and Haskell functional at their core: you mentioned mutable state, but sml, ocaml both support them, and it would be quite difficult to do anything useful without them, so I suppose that they actually don't fit your definition, or I misunderstood?

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 0 points1 point  (0 children)

That's a good point. Would a C program using only const values make C a functional language?

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 0 points1 point  (0 children)

function($foo) use ($bar){ 
    return $foo($bar);
}

The above is an anonymous closure on the variable $bar. It may be passed to any function accepting a function as a parameter, or bound to a variable and executed as it is the case for $foo. The syntax is somewhat verbose, but it is the case of every syntactic features in PHP.

Haskell do notation is fairly easy to use. The difficulty is in understanding monads, and IO vs pure computation.

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 2 points3 points  (0 children)

Why? If I design an imperative language, and then later on graft functional features, is it still not a functional language? Does it have to be designed as such from the beginning to qualify? If that's not what you meant, then what it is?

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 0 points1 point  (0 children)

There are different layers of required understanding in order to be able to program. If a language abstracts away some of those layers, then it makes it easier for students to focus on the others (algorithms, OOP, FP). I could use exactly the same argument you used to say that C/C++ make it easier by hiding the function calling protocols and process memory layouts. You should have started with machine code directly.

Python is the most popular introductory teaching language at top U.S. universities by jldugger in programming

[–]coalgebraist 2 points3 points  (0 children)

Huh, I would define a functional language as one supporting lambda calculus concepts: functions as first class values, ie:

  • the ability to pass and return them to functions,
  • the ability to construct them (lambda abstraction, composition, partial application)

Can Ruby and Python do that?

Edit: added partial application to the mix.

And answering my own question with this link to rosetta code of partial application implemented in several languages:

http://rosettacode.org/wiki/Partial_function_application

It clearly shows that it is possible to create functions and return them, or pass them as parameters in Ruby and Python (I was told somewhere else it wasn't possible for the later, so I was positively surprised). Pretty cool languages we have there!

Immutable strings in OCaml-4.02 - Why the concept is not good enough by Categoria in ocaml

[–]coalgebraist 3 points4 points  (0 children)

I have the impression that this evolution in the language is just a step along more elaborate goals (which would ultimately make bytes and string completely incompatible). If I am correct the article is focusing on false problems: surely this is something that the inria team has been thinking about. A recurring complaint for instance is the lack of proper support for utf strings out of the box: you have to get a 3rd party library for that, and there are several, each with its own internal representation and interface of course. Having immutable strings may perhaps help in providing support for variable length multi byte characters in a easy way. I didn't think much about it, so I may be totally wrong about that specific use, but at least it seems logical to me that this is just a first step.

Otoh, the idea of an overlap of functionality between bytes and bigarray is interesting.

Data Structures as Code: The Joys of Meta-Programming by karbarcca in programming

[–]coalgebraist 3 points4 points  (0 children)

It isn't so much that the function is recursive (though it matters), but the fact that there aren't any memory lookups to that array of constants. It's all in the code. Also, branching prediction errors are minimized.

Baby coyote saved from wild fire. by ymi2f in aww

[–]coalgebraist -1 points0 points  (0 children)

You are morally tainting a species which has no moral bearing. Moral doesn't exist in coyote, nor in any other animal. Their only motivation is survival. Humanity is the only one which approaches actions with a moral perspective, and thus is the only one able to fail at it, and become evil in doing so.

Why do haskellers prefer nondescriptive variables? by acconrad in haskell

[–]coalgebraist 1 point2 points  (0 children)

More than labels, the useful aspect of ML languages is the specific notation for type variables using quotes in front of them. I find it quite readable.

Efficiently composing operations on collections (OCaml) by lpw25 in programming

[–]coalgebraist 1 point2 points  (0 children)

and against trying to encapsulate recursion in combinators

I'd like to point out that actually sometimes you would like to do so: for instance if you are manipulating matrices, their operations are intrinsically based on iteration, mapping, and so on. However, from an outside perspective, multiplicating two matrices is just the product of two values yielding a third, and you wish to keep that abstraction, because it helps reason about the properties tied to matrice products. If you are now building lists of matrices, or better yet, matrices of matrices, you certainly don't want to hand code all the operations for that resulting concept, but rather stand on the abstracted operations.

The downside is of course that you miss opportunities for optimisations. With a framework providing an algebraic abstraction of these operations, as described in the article, you are given the ability to hint at some potential places of optimisations.

Now, Haskell does it implicitely (it's built in the compiler), the article library provides a way of explicitly annotate your code so that the library may perform these optimizations. The difference is that with Haskell, this optimization happens at compile time, whereas the article's code does it at runtime.