Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Athas
Aug 6, 2007

fuck that joker

hackbunny posted:

I just realized that I was confusing Haskell with Ocaml

How to tell them apart: OCaml has really bad syntax and non-overloaded operators, so you have to write '+.' to add floating point numbers. This is in contrast to another ML language, Standard ML, where '+' is overloaded and it somehow manages to be even worse.

Adbot
ADBOT LOVES YOU

Athas
Aug 6, 2007

fuck that joker

multigl posted:

i have strong opinions about sorting,

Any program is just a sort with a sufficiently complicated comparison operator. This is serious stuff.

Athas
Aug 6, 2007

fuck that joker

Lysidas posted:

i got used to making "load up in intellij and reformat code" step 0 of grading anything very quickly

Sure, let me just load up this gigantic loving monstrosity to do a thing that has been done by the sub-100k program indent(1) since the 80s[0].

[0]: If indent(1) is insufficient to reformat the code to be readabel, replace the students, not indent(1)[1][2].

[1]: Hey, this makes me think of something my beard isn't yet big enough for me to know: why is it Unix tradition to put manpage section indexes after program names when writing about them?

[2]: The [1] is not a manual section, but a footnote, like this one.

Athas
Aug 6, 2007

fuck that joker

prefect posted:

sometimes there are man pages in different sections with the same name, but they're written for different audiences/uses



code:
$ man -k '^printf'
printf               (1)  - format and print data
printf               (1p)  - write formatted output
printf               (3)  - formatted output conversion
printf               (3p)  - print formatted output
printf [builtins]    (1)  - bash built-in commands, see bash(1)
http://unix.stackexchange.com/questions/3586/what-do-the-numbers-in-a-man-page-mean

Yeah, but Unix weenies (like me) tend to do this for everything. Are people really going to be confused about what I mean by gcc if I do not write gcc(1)? Also when explicitly discussing a program.

Athas
Aug 6, 2007

fuck that joker

tef posted:

hi from fosdem

Hi back. Did you see anything horrible yet?

Athas
Aug 6, 2007

fuck that joker

rjmccall posted:

pre-ANSI C compilers usually didn't support passing or returning aggregates by value; ofc ANSI C is more than twenty-five years old, but...


I am implementing a programming language that compiles to C, and I was going to make the resulting functions return structs. Is this a bad idea? The idea is that the C code would be compiled alongside whatever program you want to use it in, so the same compiler.

I just never see C APIs return structs by value for some reason.

Athas
Aug 6, 2007

fuck that joker

rjmccall posted:

no, if you're generating c, it's fine. if you ever decide you want to do native compilation, even just partially (e.g. by emitting global assembly in your c output), it might make things a lot more awkward, and you might want to consider breaking abi at that point (if for no other reason than looking at your platform's calling convention and deciding you can do better, which in all odds you can)

I don't really care about ABI compatibility (the idea of my language is that it's used for a computational kernel, which you compile to C, and link with the rest of your C program), so I guess I'm good either way.

Athas
Aug 6, 2007

fuck that joker

sarehu posted:

Oh tef what's the name of the parsing algorithm where you maintain a stack of ASTs and it is

10 peel token off input
20 push token on the stack
30 collapse the stack if the ASTs make a tetris
40 goto 10

I assume it's a thing.

Sounds like SLR.

Athas
Aug 6, 2007

fuck that joker

Pollyzoid posted:

shows that I haven't used statically typed languages in ages.

I am sorry for your loss.

Athas
Aug 6, 2007

fuck that joker

rrrrrrrrrrrt posted:

library authors do all this to great effect

What is the periodic part in this so-called "periodic table"?

Athas
Aug 6, 2007

fuck that joker

tef posted:

4. prolog is a programming language

we can add in parameters to queries and facts in the database

member(X, List) :- head(List, X).
member(X, List) :- tail(List, T), member(X, T)

this says: X is a member of a List, if it is at the front of a list, or member of the tail of the list

:2bong:

5. Prolog is an imperative programming language.

You add a built-in predicate that succeeds while performing a side effect.

printButts([butt | Butts ]) :- !, print('found butt'), printList(Butts).
printButts([ _ | Butts ]) :- printButts(Butts)

"Practical" Prolog can be some really nasty poo poo. No idea why anyone would take something so beautiful and make it so nasty.

Athas
Aug 6, 2007

fuck that joker
Basically, if you want to learn Prolog, actually learn Datalog.

Athas
Aug 6, 2007

fuck that joker

Shinku ABOOKEN posted:

i havent used prolog but aren't head() and tail() algebraic types in this example? if you want to use a head() you have to have head() in your function (does prolog have functions?)
member(X, List) :- head(List, X).
member(X, List) :- tail(List, T), member(X, T)

Prolog does not have functions, only predicates. 'head(List, X)' means to see if you can take the head of List and unify it with X, which is done by checking all the rules for 'head'. There is probably only one such rule, and it looks like this:

head([X | _], X).

Athas
Aug 6, 2007

fuck that joker
The really dumb thing is using -Werror in production or distribution, precisely for the reason of code being broken by compiler upgrades.

Athas
Aug 6, 2007

fuck that joker

DaTroof posted:

i had a manager who quoted some statistic that the average web app gets completely rewritten every 18 months or something.

It's early, read "manager" as "teenager".

Seemed to fit.

Athas
Aug 6, 2007

fuck that joker
They are switching to F# as the introductionary language at my department.

It used to be SML.

Not sure whether I should be happy. Does F# work well on Mono?

Athas
Aug 6, 2007

fuck that joker
At least in Haskell, infix operators are a syntactical category by itself, so you will immediately know what is and is not an operator. And also <*> and <$> are pro names, and you are wrong if you think otherwise.

Anything, the thing about the syntactical category is that in SML, you can declare any token to be an operator.

infix butts
fun x butts y = x + y

But it gets even better, because you can have local infix declarations in let-blocks:

fun whatever a b c =
... lots of code ...
let infix x
fun f x g = ...
in
...
f x y (* So what does this mean now? *)

Of course, SML programmers abuse this (there is no "use" for this feature) constantly.

Athas
Aug 6, 2007

fuck that joker

Arcsech posted:

first:rest or similar is much clearer

The nice thing is that you can map over some list "xs" (or "params" or whatnot), and then call each specific element "x" (or "param"). Small touches.

Haskell is needs suiting, but it can definitely be abused. I like being able to have a "<|>" operator when writing parsers.

I maintain a 23k+ SLOC Haskell codebase, and I don't think it defines a single infix operator.

Athas
Aug 6, 2007

fuck that joker

sarehu posted:

  • Case-insensitivity and underscore-insensitivity in the identifier lookup syntax.

People are not laughing as much at this as they should be.

A cursory glance some time ago suggested that Nim might be interesting. Guess not. My language is saner.

Athas
Aug 6, 2007

fuck that joker

Soricidus posted:

it's very important because this way people who like CamelCase and people who like whatever_dumb_name_they_use_for_this_style can all do their preferred thing and it'll just work!

Yeah, it kind of makes sense if you get really drunk and/or high first.

Athas
Aug 6, 2007

fuck that joker

Tiny Bug Child posted:

i'll bite; why has the sperg programming hivemind decided this is bad?

Same things should look the same everywhere. There is no way this feature can be used for Good and not Evil.

Athas
Aug 6, 2007

fuck that joker

Gazpacho posted:

'I don’t think C gets enough credit. Sure, C doesn’t love you. C isn’t about love–C is about thrills. C hangs around in the bad part of town. C knows all the gang signs. C has a motorcycle, and wears the leathers everywhere, and never wears a helmet, because that would mess up C’s punked-out hair. C likes to give cops the finger and grin and speed away. Mention that you’d like something, and C will pretend to ignore you; the next day, C will bring you one, no questions asked, and toss it to you with a you-know-you-want-me smirk that makes your heart race. Where did C get it? “It fell off a truck,” C says, putting away the boltcutters. You start to feel like C doesn’t know the meaning of “private” or “protected”: what C wants, C takes. This excites you. C knows how to get you anything but safety. C will give you anything but commitment

In the end, you’ll leave C, not because you want something better, but because you can’t handle the intensity. C says “I’m gonna live fast, die young, and leave a good-looking corpse,” but you know that C can never die, not so long as C is still the fastest thing on the road.'

Why do people fetishize C to this degree? It is just a programming language. It is not particularly unsafe - it is even stronly typed! It is not some exotic, dangerous thing, it is one of the most mainstream and widely used languages you can get.

Using C does not make you a cool bad-rear end, it just makes you another C programmer out of tens of thousands.

Athas
Aug 6, 2007

fuck that joker

JewKiller 3000 posted:

C is not strongly typed in any meaningful way. in fact, C is the prototype example of a weakly typed language. there are implicit type conversions all over the place, and unsafe casting is the norm. a type in C is really just a way to tell the compiler how much memory it needs to allocate, and that's about it

There are not many implicit type conversions in C. It is strongly typed but with many ways to cheat the system. That just makes it unsound, not weak.

Athas
Aug 6, 2007

fuck that joker
Dynamic typing can be OK.

Implicit conversions can be OK.

But they are never OK together.

PHP is stupidly typed.

Athas
Aug 6, 2007

fuck that joker

comedyblissoption posted:

IEnumerable thunks in order to implement a lazy evaluation strategy. Lazy evaluation is much easier to compose 'good-enough' performant queries. As a simple example:

code:
var firstPositive = numbers.Where(x => x > 0).First();
This will only execute as much as it needs to until it finds the first candidate that passes the where clause.

So that means it will never evaluate in parallel? That would be weak.

Also that .NET GC sure is something. Look at all those #ifdefs - I count 62 different predicated symbols (including both DEBUG, _DEBUG, DEBUG_DestroyedHandleValue and DEBUG_WRITE_WATCH). I wonder how many permutations actually work.

Athas
Aug 6, 2007

fuck that joker

MeruFM posted:

is fold the same as reduce?

Usually nowadays I see fold being used for sequential folds, with reduce being used for folds with an associative binary operator with a neutral element (this is called a monoid in algebra). These can be trivially executed in parallel using tree reduction, which is not the case for any old fold.

But this is new terminology. Common Lisp uses just reduce, which is a straight left-to-right sequential fold.

Athas fucked around with this message at 16:26 on Jun 17, 2015

Athas
Aug 6, 2007

fuck that joker

Common Coder posted:

with regard to "good syntax" being a bad goal, this feature is not good and it's not useful. i suppose an alternative to this could be:

a = 1
# some time passes
a += 0.5 # a new variable whose value is copied from the first a, and then incremented by 0.5

Variable declaration is not the same as variable assigment, and 'a += 0.5' sure as hell better not be a variable declaration, especially not one that involves dubious implicit type conversions. What's the problem with putting 'var' in front when a variable is declared?

How do you handle type errors? You mentioned some stuff about picking the highest-precedence type (???), but what if that conflicts with a previous assumption/constraint? How do you deal with variables whose values/types are given by the return type of a function, maybe even by a recursive call?

Now, you can make a language without studying type theory, but only if you (0) make it dynamically typed, or (1) require liberal type annotations, and you seem to be going for neither. This is not an easy problem. My own language (purely functional, data-parallel, aggressive optimising compiler and aimed at GPU execution) is fully monomorphic and requires explicit function parameter/return type annotations, because the world really does not need another half-assed way of being clever about static types.

Athas
Aug 6, 2007

fuck that joker

Soricidus posted:

nah, designing languages is fun. who doesn't like messing with syntax?

No real language designer likes messing with syntax. It takes way too much effort for something that is totally superficial and ultimately mostly up to individual taste. And writing parsers for new grammars loving suck - either you use a parser generator and it loving sucks, or you use a parser combinator library and you don't get told about ambiguities and other problems, or you hand-write a parser and it still loving sucks.

Athas
Aug 6, 2007

fuck that joker

Volte posted:



I actually don't know if this works yet since I don't have an interpreter written for this type of graph, but this is the exp() function as computed using the IBM Cell SPU instruction set (since the code for that was already written using a similarly-purposed Haskell DSL -- I just ported it over to my library). Not too much to look at but it's gratifying to see it reified like that after existing only in my head for the past week. It's a 4-way SIMD architecture originally so that's why all the constants are actually four constants.

This looks cool. When do you think you can get some performance numbers? (My experience is that compiler work motivation is fragile if you don't have a code generator.)

Athas
Aug 6, 2007

fuck that joker

pepito sanchez posted:

R sucks and can't possibly have become popular if it wasn't easily applicable in data analysis. i gave up on R early on and started on python for DA. please tell me if i'm missing out on something other than a few loving libraries that make some computations a little faster. terrible programmer posting so please just tell me why R means a poo poo, because i see it taught at university and it tops out benchmarks like that still means anything et cetera

Some people like R (I used it a little) because it is better than Matlab. As in, it feels slightly more like a real language, and not just glue for getting library functions to stick to each other. But Python is even better for that purpose, so don't look back.

Athas
Aug 6, 2007

fuck that joker

Internet Janitor posted:

would there be actual interest in an APL/J/K thread in CoC, or would it just be pages and pages of "this is unreadable", "what's with the funny symbols", etc

Would read and participate! I have a colleague who works on a compiler for a statically typed APL dialect, and I hope to get involved at some point. It is an amazing language that I still do not understand fully.

Gazpacho posted:

arrays in haskell make me lol

Arrays in most languages make me lol, they all get it wrong! For example, Haskell's Data.Array lets you define the index space as all sorts of crazy things. The way you define an N-dimensional array is to define an array where an index is a tuple of N integers. But then you cannot efficiently perform partial indices, e.g. index that N-dimensional array with a single integer to get an (N-1)-dimensional array. Data.Vector isn't better as I remember it. And no, using arrays of arrays is not the same thing, we are not primitive C programmers here.

Arrays are surprisingly hard to get right, and I suspect they pretty much have to be a builtin to be both safe, performant, and expressive. (Fortran gets it right but gets so much more wrong.)

Athas
Aug 6, 2007

fuck that joker

gonadic io posted:

Last I checked, Data.Vector makes your index be an int and so disallows N-dimensional arrays completely unless you do the conversation yourself or have arrays of arrays.

Yes, so it's like C. It's efficient, but not terribly expressive.

gonadic io posted:

Have you seen Repa though? It's my understanding that it's based off of fortan's arrays and does allow efficient sectioning

Yeah, Repa is better, but it's very notationally and conceptually heavyweight (it really pushes the type system), so still not nearly as nice as arrays in true array languages. For example, if you have a two-dimensional array of integers, you should be able to map a function that takes a single-dimensional array and produces an integer, and end up with a single-dimensional array (just like you can do with a list or array-of-arrays). This is not terribly nice to express in Repa.

Athas
Aug 6, 2007

fuck that joker
The #1 thing I never understood about XML is why the XML tooling languages tend to have XML syntax. XML has some advantages, but surely as gently caress not that it is nice to write by hand.

Athas
Aug 6, 2007

fuck that joker
What exactly does a single-pass compiler imply? That you cannot have mutually recursive modules or what? You cannot in Haskell either, but I've never felt that as much of a restriction.

Athas
Aug 6, 2007

fuck that joker
Okay, that does suck rocks. So it's like Standard ML where mutually recursive types and functions have to be declared in a stupid explicit manner?

Athas
Aug 6, 2007

fuck that joker

fart simpson posted:

what languages are you referring to?

It sounds like SML (and other ML languages), whose top-level semantics are inspired/based on REPL-like interaction, even in files. This leads to all sort of amusing shenanigans, like being able to shadow top-level type declarations. And of course, have script-style side-effecting expressions that are evaluated when the file is included. This leads to amusing consequences/restrictions when you want to actually compile the code, none of which I can clearly remember.

It is a bad design. For all of its other warts, at least Haskell doesn't do it like that, but instead requires a traditional main function.

Athas
Aug 6, 2007

fuck that joker
Haskell slow.

Still use it.

Athas
Aug 6, 2007

fuck that joker

Dessert Rose posted:

it's a meaningless piece of paper, at best it's good for telling you whether someone with zero experience might be capable of doing the job. in a couple years, after they've gotten all the ivory tower bullshit pounded out of them

I'm okay with a preference for experience over education, but what kind of "ivory tower bullshit" is being taught in CS programs? I mean, knowledge that is actually harmful (or maybe just useless, but you make it sound like it has to be removed entirely)?

Athas
Aug 6, 2007

fuck that joker

Mr Dog posted:

Professional educators say Python is hard to teach on account of the indentation poo poo, which is rather disappointing.

I've been a TA in a course that was teaching first-year university science students to program in Python, and the indentation poo poo was not a problem. The biggest problem was getting the interpreter and whatever installed on Windows.

Side effects were also a little bit of a problem. Not the obvious ones about setting global variables, but the subtle ones where you pass lists by reference and then call mutating methods like append().

Also, stop using tabs in your Haskell.

Adbot
ADBOT LOVES YOU

Athas
Aug 6, 2007

fuck that joker

Bloody posted:

someone tell me a little bit about cuda vs opencl

i think i will soon have a data problem where i think they may be applicable (doing idk what with a lot of time series data) and idk anything about them or differences or w/e

CUDA is much nicer to use in hand-written code. If you can use something like PyOpenCL, then there is less difference.

CUDA is limited to NVIDIA hardware, OpenCL can use many kinds of GPU (also NVIDIA), multicore CPUs, and even exotic things like FPGAs (although I haven't tried it myself).

OpenCL is much nicer as a code generation target.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply