W
WW 635
Guest
kiwifarms.net
Wtf is all this hipster garbage coding talk? F# and Haskell are trash that no one cares about. Real men use C
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
The syntax objection I have with Haskell is that it's got significant whitespace.
quicksort :: (Ord a) => [a] -> [a]
I hate Python for that and I hate Haskell for it too.
In Ocaml, you might see a function like:The main syntax problem I have with Haskell is its weird declarations at the top of functions. For example, the top of a custom quicksort function might read as:
I think that it's not strictly necessary, but it still fucks with my head. Why can't it have sane headers like Java or C?Code:quicksort :: (Ord a) => [a] -> [a]
let format_name first_name last_name =
first_name ^ " " ^ second_name
val format_name : string -> string -> string
utop # format_name "Marvin" "GotShotInTheFace";;
- : string = "Marvin GotShotInTheFace"
function format_name(first_name) {
return function(last_name) {
return first_name + " " + last_name;
};
}
> format_name("Marvin")("GotShotInTheFace");
'Marvin GotShotInTheFace'
> map(function(name) { return name + " is fat and I wouldn't have sex with them"; },
["Kengle", "cwc", "pixyteri"])
[ 'Kengle is fat and I wouldn\'t have sex with them',
'cwc is fat and I wouldn\'t have sex with them',
'pixyteri is fat and I wouldn\'t have sex with them' ]
(* a function to fetch a user from a database handle: *)
let get_lolcow_by_name db_handle name =
... (* omitted *)
(* main script code: *)
let lolcow_names = ["Kengle"; "cwc"; "pixyteri"]
let my_database_handle = open_db()
(* we can fetch our lolcows a few ways...
we can override the db_handle and assign the
resulting function to a var: *)
let db_fetch_lolcow = get_lolcow_by_name my_database_handle
let lolcows = List.map db_fetch_lolcow lolcow_names
(* or we don't even need to assign it to a variable,
we can use parentheses and fill in the db_handle on the fly: *)
let lolcows =
List.map
(get_lolcow_by_name my_database_handle)
lolcow_names
val get_lolcow_by_name : db_handle -> string -> lolcow_obj
val lolcow_names : string list
val my_database_handle : db_handle
val db_fetch_lolcow : string -> lolcow_obj
(* see above, we filled in the first arg, the db_handle, and all
that's left is the string -> lolcow_obj part *)
val lolcows : lolcow_obj list
Heh, Jane Street, per chance? They've got fantastic technology for an investment company.@Marvin, this doesn't follow directly from your post, but I find it interesting that you use Ocaml as your example language. I only know one person IRL who uses it, and he needed to learn it recently for an internship with some investment company.
Forgot to comment on this. You explained that infinitely better than the /g/ recommended learning resources for Haskell. I was attracted to learning Haskell because of its "lazy" evaluation and how easy it makes creating and manipulating sets, but those function headers, man...Something that trips up newcomers to certain functional languages, is that technically speaking, a function has strictly one input and one output.
So "string -> string -> string" isn't a function that takes two arguments. It's really a function that takes a string, and it returns "string -> string". Which is a function that takes a string, which returns a string.
Yep, right on the money. Is that something you just knew or did you look it up?Heh, Jane Street, per chance? They've got fantastic technology for an investment company.
Wow, you're not kidding. I thought my distro had a package for every language. I was wrong.if we want to get extra esoteric, Mythryl
Can you speak to speed and resource use of Scheme compared to Python? Just because Python fills the niche of dynamic and flexible in the public consciousness.Scheme for...dynamic and flexible
then again, with complicated system setups, garbage collection can mean some horrible bugs, like when you are using different standard librairies/virtual machines at once (quite common with real applications)
They're a well known user of Ocaml.Yep, right on the money. Is that something you just knew or did you look it up?
The story behind Mythryl's kinda sad because this brilliant guy had been programming for years, and he's seen basically everything. So he decides to make his own language, using the best parts of everything he's worked on.Wow, you're not kidding. I thought my distro had a package for every language. I was wrong.
Depends on the implementation. Schemes can be very fast with a good compiler.Can you speak to speed and resource use of Scheme compared to Python? Just because Python fills the niche of dynamic and flexible in the public consciousness.
Like bugs involving things getting GC'd inappropriately? Or just GC pauses coming at the wrong times?then again, with complicated system setups, garbage collection can mean some horrible bugs, like when you are using different standard librairies/virtual machines at once (quite common with real applications)
GC is usually on a language level. Thus all libraries would use the same GC. (Or no GC for the C libraries.)I think the most common error would be an object getting freed when it's in use by an external library. Some language allow to explicitly prevent an object and what he references to be freed and sometimes you have to use work-around that leads to heisenbugs.
The worst case is an object spawned by one (standard) library and collected by the garbage collector of another.
I meant complicated on a system level, not algorithmic: multiple librairies compiled by different teams, using different compilers, different processes exchanging custom types, etc...
Firstly you should try to "make your code the comments", meaning it's written in a way that makes it's intent clear, which is obvious and vague advice. If you're doing something for a non-obvious reason, put a comment in there. eg. non-obvious if comparison, non-obvious math. I also like to use block quotes to break up sections inside a single scope.I'm embarrassed to be posting here because I'm a total amateur but I'm doing some programming stuff (It's all Python, which should tell you all you need to know) and I want to know how to comment code effectively
At the moment I have 100+ line functions and classes which have absolutely no commenting and I need to add some but I'm too lazy and don't quite know what to write
This.Firstly you should try to "make your code the comments", meaning it's written in a way that makes it's intent clear, which is obvious and vague advice. If you're doing something for a non-obvious reason, put a comment in there. eg. non-obvious if comparison, non-obvious math.
int a = b + 10; // Add ten to b
/// <summary>
/// Get the index of <paramref name="item"/>
/// </summary>
/// <param name="item">The item to search for</param>
/// <returns>the index of the item, or -1 if the item was not found</returns>
/// <remarks>this will also search for gaps if <paramref name="item"/> is equal to <see cref="defaultValue"/></remarks>
public int IndexOf(T item)
{
int i = -1;
if (tailIndex_ > 0) // skip if no values are in the array
{
foreach (var pair in ValidValues)
{
if (valueComparer_.Equals(pair.value, item)) // check all valid values for item
{
i = pair.i;
break;
}
}
}
if (valueComparer_.Equals(defaultValue_, item)) // if item is the default value
{
if (tailIndex_ > 0) // skip if there are no items in the array
{
var prev = inner_[0].i;
if (i > -1) // if there is a result from checking valid values pick the minimum
{
int dI = -1;
foreach (var pair in ValidValues.Skip(1)) // check for gaps between valid values
{
if (pair.i > i) // don't bother looking past the best result for the previous search
break;
if (pair.i - prev > 1)
{
dI = prev;
break;
}
prev = pair.i;
}
if (dI > -1 && dI < i)
i = dI;
}
else
{
foreach (var pair in ValidValues.Skip(1)) // check for gaps between valid values
{
if (pair.i - prev > 1)
{
i = prev; // return the first index in the gap
break;
}
prev = pair.i;
}
}
}
else if (count > 0) // if there are no items, and the array is not empty, return the first index
i = 0;
}
return i;
}
I have come to the conclusion that software is not designed to satisfy all consumer expectations for the product. It is designed to satisfy minimum consumer expectations, and further amenities are discouraged because they raise consumer expectations.I do not understand why programs like Asterisk hang on to this bullshit concept of limiting things to 80 characters for no reason.
Controversial opinion: It is no longer okay to dislike Java because it is slow, since it has gotten faster. However, it is completely okay to dislike Java because of the resource overhead associated with the JVM and the relatively long program start-up times when the JVM isn't already running.
I have come to the conclusion that software is not designed to satisfy all consumer expectations for the product. It is designed to satisfy minimum consumer expectations, and further amenities are discouraged because they raise consumer expectations.