Name: Anonymous 2014-11-18 17:53
assembly. Is it just trollin' for /prog/, or do you actually perform your general-purpose programming in assembly? Is it really feasible to be a productive programmer by using just ASM?
Is it just trollin'No, serious business.
do you actually perform your general-purpose programming in assembly?No, that wouldn't make any sense. However, this should not prevent from discussing about assembly.
Is it really feasible to be a productive programmer by using just ASM?No.
module Foo where
foo :: [Int] -> Double
foo xs = loop xs 0.0
where
loop [] a = a
loop (x : xs) a = loop xs (a + fromIntegral x)
22 kBAre you kidding me? Cudder could do it in less than 500 bytes.
define cc 10 void @Foo_foo_info(i64* noalias nocapture %Base_Arg, i64* noalias nocapture %Sp_Arg, i64* noalias nocapture %Hp_Arg, i64 %R1_Arg, i64 %R2_Arg, i64 %R3_Arg, i64 %R4_Arg, i64 %R5_Arg, i64 %R6_Arg, i64 %SpLim_Arg) align 8 nounwind section "X98A__STRIP,__me6"
{
c16u:
%ls15H = alloca i64, i32 1
%Hp_Var = alloca i64*, i32 1
store i64* %Hp_Arg, i64** %Hp_Var
%lc160 = alloca i64, i32 1
%ls15K = alloca i64, i32 1
%ls15J = alloca i64, i32 1
%Sp_Var = alloca i64*, i32 1
store i64* %Sp_Arg, i64** %Sp_Var
%R2_Var = alloca i64, i32 1
store i64 %R2_Arg, i64* %R2_Var
%R1_Var = alloca i64, i32 1
store i64 %R1_Arg, i64* %R1_Var
%ln18y = load i64* %R2_Var
store i64 %ln18y, i64* %ls15H
%ln18z = load i64** %Sp_Var
%ln18A = getelementptr inbounds i64* %ln18z, i32 1
%ln18B = ptrtoint i64* %ln18A to i64
%ln18C = sub i64 %ln18B, 24
%ln18D = icmp ult i64 %ln18C, %SpLim_Arg
br i1 %ln18D, label %c16v, label %c16w
fldz
fooloop:
test esi, esi
jz done
lodsd
fld qword [esi]
faddp
mov esi, eax
jmp fooloop
done:
fldz
fooloop:
test esi, esi
jz done
lodsd
fild dword [esi]
faddp
mov esi, eax
jmp fooloop
done:
Why the fuck you'd want to use a linked list for 4 or 8-byte thingsHaskellers use them even for chars. I.e. Haskell Strings are just linked lists of chars. That's right, 5 words of overhead to store just one byte. Actually, there's even more overhead for lazy Strings (which they are by default), because every char is actually a thunk (a function from () to a char)...
of the nigger machineThe spineless tagless graph machine is better than you, better than sky, better than even Allah.
Data.Text
) which has way better constant-factor and asymptotic performance characteristics. Sadly, it's not the default, and is not even properly part of the standard library. Maybe in a future version that will change. foo (x : xs)
on a Text, people will continue to use Strings for nearly everything. {-# LANGUAGE ViewPatterns #-}
import Data.Text (uncons)
f (uncons -> Nothing) = ...
f (uncons -> Just (x, xs)) = ...