• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:59
CET 17:59
KST 01:59
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win0Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down23ISSL (IntoTheTV x SOOP SC2 League): Premier7Weekly Cups (October 12-18): 5.0.17 era begins1
StarCraft 2
General
Liquibets sc2 season 30 Evil Geniuses - shutting down Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win No more SC2 streamers on team liquid? How do you feel about the mass reverts in the 5.0.17 PTR?
Tourneys
WardiTV Mondays ISSL (IntoTheTV x SOOP SC2 League): Premier Stellar Fest TWO the Moon (Dec 16-20) Sparkling Tuna Cup - Weekly Open Tournament RSL goes to London! 2026 Offline Finals Nov 21-22
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[D] the control group Simple Questions/Answers [G] How to playtest arcade maps [A] Nemrods 1/4 players
External Content
Mutation # 550 Graveyard Shift The PondCast: SC2 News & Results Mutation # 549 Endless Sparkles Mutation # 548 Shining Bright
Brood War
General
The End Of An Era Rollback Netcode in Brood War How SKT1 S-Tiers Felt To Be Swept By Flash BW General Discussion Top Players of October 2026 (EBPD Rankings)
Tourneys
2v2v2v2 Tournament Stage 1: Community Poll [Megathread] Daily Proleagues [$1250] International ShieldBattery League New Worlds Star League
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Deus Ex 3!? Mobile Legends: Bang Bang Armies of Exigo - YesYes?
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Chess Thread
Fan Clubs
Fan Club Resource Thread Reynor Fan Club The Flash Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 10556 users

John Carmack Programming Haskell - Page 2

Blogs > CardinalAllin
Post a Reply
Prev 1 2 All
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
August 28 2013 11:27 GMT
#21
On August 28 2013 19:39 3FFA wrote:
I'm wondering if anyone could provide a brief comparison of something done in Haskel vs another language like C or Java so I could actually see the difference?

There's a multitude of sources online for haskel code if you want to see how it looks, the Haskell wikipedia page for example: http://en.wikipedia.org/wiki/Haskell_(programming_language)

Unless you have some experience with functional languages though, it will probably look like some black magic spell though, functional code usually looks very different from what you might be used to.
rabidch
Profile Joined January 2010
United States20289 Posts
Last Edited: 2013-08-28 11:50:13
August 28 2013 11:40 GMT
#22
On August 28 2013 18:19 artynko wrote:
Show nested quote +
On August 28 2013 17:32 rabidch wrote:
On August 28 2013 16:34 artynko wrote:
For me the problem with functional languages is that you can't do "proper" architecture using it (or we don't know how to do it yet)
For example I did a fairly decent sized production software that was written in Erlang (another functional language) it was awesome for what it did, it had probably 10 times less lines of code that if I have written it in anything conventional, but at the end when I was trying to juggle 30 different actors I was starting to feel that a miss the nice architecture I would had had in OO language.
I still love the concepts that a functional language brings mainly immutability and the way concurrency is handled there. When Java 8 comes I will jam that one down my teams throats faster then light (oh closures & functional collection manipulation) but still if anyone asked me if they should learn something like Haskell I would say hell no, learn Scala


what do you mean by architecture?


The standard approach that everyone uses to separate stuff in oo, services, daos, domain object, facades having all the oo patters at yours disposal, when I was doing Erlang I had problems with how do I want to connect all the different parts of the application together, when I coded it in similar fashion as I was used from OO it usually did create either circular references or some horrible unclear dependencies. In the end I ended up with a tree like structure that resembled something you would create using OO and the standard tiered architecture but the "levels" of the tree didn't always contain processes that belonged together and the tree had way more levels .
Then when I returned back to this code after couple of months I was completely lost and had no idea where the different processes belong and how deep in the tree they are. If you compare this to OO even when I look at my old code and want to add new stuff there I know where to start, you just look for the service in question and go on from there.
It just feels like there is no knowledge how to do stuff in functional languages the "right" way compared to OO where we already know how to create something that is manageable and every developer will understand it when he sees it for the first time

interesting, i've never had that problem, but i dont know anything about erlang, most of my experience is in ocaml and haskell. ocaml/F# has a number of object features while haskell isnt oo but is pretty clear about structure through modules and its type system, but its very expressive type system can be an absolute pain to learn... its compiler error messages are almost never helpful.

personally i feel that if the code feels more natural to be imperative or OOP or functional then it should probably be in such a language...

On August 28 2013 19:39 3FFA wrote:
I'm wondering if anyone could provide a brief comparison of something done in Haskel vs another language like C or Java so I could actually see the difference?

http://en.literateprograms.org/LiteratePrograms:Welcome

what the above poster says too
LiquidDota StaffOnly a true king can play the King.
artynko
Profile Joined November 2010
Slovakia86 Posts
August 28 2013 12:05 GMT
#23
On August 28 2013 19:39 3FFA wrote:
I'm wondering if anyone could provide a brief comparison of something done in Haskel vs another language like C or Java so I could actually see the difference?


From what I remember when I was looking at it yesterday
Java -> "astring".substring(1);
Haskell -> tail "astring" or drop 1 "astring"

Mainly what is cool about functional languages is the way you can do cycles with pattern matching so this java code
private void output(String a) {
while (a.lenght > 0) {
sysout(a);
a = a.substring(1);
}
}

can be rewritten like this, you suddenly don't mess up with the 'a' object and it is very clear when the end of the "cycle" is
output([]) -> ok
output(a) -> prinnt(a), output(tail(a));

then when you type somwthere ouput("keke"), it will look at the various heads for the output function and patter match the value so the first one (outuput([])) is only matched when there is blank array as argument so it skips that one and uses the other one to print the first character, and then recursively calls itself again with the remaining characters


CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
September 02 2013 20:53 GMT
#24
Ha, funny that you focused much on object to object messaging, which I just moments ago finished posting some slides for a lecture I gave at my university. http://www.randygaul.net/2013/09/02/powerful-c-messaging/

Really it sounds to me like Haskell is just enforcing some good programming practices, which can be achieved by good programmers in C++ (as seen by my link). To me the solution to a lot of problems is to just have good programmers use C++, instead of forcing bad programmers to write better code. But of course good programmers are rare and hard to come by.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
September 03 2013 06:35 GMT
#25
I read up on some haskell after reading the OP and it's quite a fascinating language, definitely my favorite functional language so far (tried F# and scheme in the past). It's the first language where writing recursive functions makes perfect sense to me (because the syntax is beautiful), and it blew my mind when I realized haskell compiles to machine code and can, in theory at least, be faster than C++ if you write it really well.

It's a downright shame that side-effect handling takes such a weird form... pure programming is cool, but the syntax for IO and such things in haskell just becomes really confusing and uncomfortable.
rabidch
Profile Joined January 2010
United States20289 Posts
September 03 2013 08:34 GMT
#26
On September 03 2013 05:53 CecilSunkure wrote:
Ha, funny that you focused much on object to object messaging, which I just moments ago finished posting some slides for a lecture I gave at my university. http://www.randygaul.net/2013/09/02/powerful-c-messaging/

Really it sounds to me like Haskell is just enforcing some good programming practices, which can be achieved by good programmers in C++ (as seen by my link). To me the solution to a lot of problems is to just have good programmers use C++, instead of forcing bad programmers to write better code. But of course good programmers are rare and hard to come by.

its not fair to either language to talk about it simply like that, i recommend at least dabbling in some haskell to understand the viewpoint where carmack is talking from. hes not saying haskell is all that and everything, but looking at certain problems and code from a different viewpoint can be enlightening

On September 03 2013 15:35 Tobberoth wrote:
I read up on some haskell after reading the OP and it's quite a fascinating language, definitely my favorite functional language so far (tried F# and scheme in the past). It's the first language where writing recursive functions makes perfect sense to me (because the syntax is beautiful), and it blew my mind when I realized haskell compiles to machine code and can, in theory at least, be faster than C++ if you write it really well.

It's a downright shame that side-effect handling takes such a weird form... pure programming is cool, but the syntax for IO and such things in haskell just becomes really confusing and uncomfortable.

it is a really cool and fascinating language, but for the same reasons impractical for the all but a fraction of the industry. sure is interesting to write things in it though. also the IO is weird yes, but if u get used to monads its quite natural, plus there are ways you can cheat around it

i thought F# can compile to machine code? i've used ocaml quite a bit, haskell isnt optimized that well with respect to overhead (theory can only go so far by itself), so ocaml is still generally faster, and F# is also very fast (maybe even faster?), since currently F# is still very close to ocaml
LiquidDota StaffOnly a true king can play the King.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
September 03 2013 09:01 GMT
#27
Hmm, I can find no resource on compiling F# to native, Visual F# obviously compiles to CIL. Not that it's such a huge deal, compiling to native isn't the massive speedgain it used to be since everything does just-in-time compilation nowadays.
Kambing
Profile Joined May 2010
United States1176 Posts
September 03 2013 17:12 GMT
#28
That's correct. There are no F#-to-native code compilers out there. All of them target the .NET framework/CIL.

Haskell can actually be surprisingly speedy in certain situations, e.g.,

http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=all

This is especially true if you know how to exploit strict evaluation and various Haskell quirks about optimization. Where Haskell definitely falters is space usage simply because lazy evaluation means that a lot of computation is left "suspended", waiting to be executed at a yet-to-be-determined time.

The way that side-effects are handled in Haskell is necessary insofar as side-effects destroy referential transparency which is where Haskell gains much of its properties. Its purity guarantees are even stronger than OCaml/F# (which allow "un-scoped" mutation via ref cells and/or objects) which allows for even greater allowance to rely on types to guide development.

One example of how you can rely on types more in Haskell than traditional languages is the encoding of domain-specific languages whose own type properties are checked by Haskell at compile-time. For example, here is a definition of a small calculator language with integers, booleans, addition, greater-than-or-equal comparison, and conditionals (*1):


{-# LANGUAGE KindSignatures, GADTs #-}

data Exp :: * -> * where
IConst :: Int -> Exp Int
BConst :: Bool -> Exp Bool
Add :: Exp Int -> Exp Int -> Exp Int
GTE :: Exp Int -> Exp Int -> Exp Bool
If :: Exp Bool -> Exp a -> Exp a -> Exp a


The type Exp a denotes expressions whose underlying Haskell value are a (i.e., it is a polymorphic type). Examples of terms constructed in this little language are:


IConst 0 -- 0
BConst True -- True
Add (IConst 1) (IConst 1) -- 1 + 1
If (GTE (Add (IConst 1) (IConst 1)) (IConst 2)) (IConst 42) (IConst 6)
-- if (1 + 1 >= 2) then 42 else 6


Notably, the definition of Exp above prevents from writing ill-typed terms in this sub-language. For example:


*Main> Add (IConst 0) (BConst False)

<interactive>:8:17:
Couldn't match type `Bool' with `Int'
Expected type: Exp Int
Actual type: Exp Bool
In the return type of a call of `BConst'
In the second argument of `Add', namely `(BConst False)'
In the expression: Add (IConst 0) (BConst False)


That is, the definition of the Add term requires two Exps that evaluate to Haskell Ints. Similarly


If (BConst True) (IConst 0) (BConst False)


is also ill-typed because If requires that the two branches produce the same type of value.

Note that if you tried to implement this in Java naively (*2), e.g.,:


public class Exp { }
public class IConst extends Exp { public int i; }
public class BConst extends Exp { public boolean b; }
public class Add extends Exp { public Exp e1; public Exp e2; }
public class GTE extends Exp { public Exp e1; public Exp e2; public boolean b; }
public class If extends Exp { public Exp b; public Exp e1; public Exp e2; }


There is nothing stopping you from having an instance of an Add term whose two sub-expressions are booleans rather than integers. You would need to check either at construction or when the expression that the expressions are indeed of the correct type.

Finally, to close here's an example of how you'd use this little language in Haskell. The eval function takes a built-up up Exp, evaluates it, and returns the corresponding Haskell value:


eval :: Exp a -> a
eval (IConst i) = i
eval (BConst b) = b
eval (Add e1 e2) = eval e1 + eval e2
eval (GTE e1 e2) = eval e1 + eval e2
eval (If b e1 e2) = if eval b then eval e1 else eval e2


Running this function on each of the (good) examples above produces the proper Haskell value:


*Main> eval $ IConst 0
0
*Main> eval $ Add (IConst 1) (IConst 1)
2
*Main> eval $ If (GTE (Add (IConst 1) (IConst 1)) (IConst 2)) (IConst 42) (IConst 6)
42


(*1): This example uses an advanced feature of Haskell called Generalized Algebraic Datatypes or GADTs. A GADT is a datatype whose constructors' return types can be freely chosen.

(*2): This example can be encoded using Java generics and C++ templates. However, more complicated examples of GADTs are not possible using Java generics and C++ templates as-is. Both languages require additional features, i.e., type parameter constructors, to emulate the full functionality of GADTs.
MatteDaemon
Profile Joined October 2015
8 Posts
Last Edited: 2017-04-22 10:42:38
April 22 2017 10:40 GMT
#29
Most programmers are too lazy or stupid to see the benefits in using good programming languages. Until then, Java, C++, PHP, etc. will continue to reign supreme. The non-remedial will look into Standard ML, Haskell, OCaml and Scheme, to some extent. The three former-most in that order. The latter-most is just fun and has a lot of good documentation, but I've fallen out of favor with weakly typed languages.
A serious programmer's aspiration, though, is to write faultless programs. [...] There are programmers in abundance whom I would gladly trade for teams of trained fanatical terrorists; at least the police would be looking for the terrorists. - Bob W Floyd
Prev 1 2 All
Please log in or register to reply.
Live Events Refresh
3D!Clan Event
01:30
Autumn Series | Group C
Nicoract vs GgMaChine
3DClanTV 78
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Serral 1954
BRAT_OK 51
MindelVK 18
StarCraft: Brood War
Calm 4197
Shuttle 833
Horang2 546
Stork 217
Rush 157
Mind 93
Zeus 58
Pusan 41
scan(afreeca) 20
Rock 19
[ Show more ]
Bishop 16
soO 15
JYJ 14
Hm[arnc] 12
910 12
yabsab 12
ajuk12(nOOB) 11
Sacsri 11
Noble 10
ggaemo 1
Dota 2
qojqva3329
syndereN458
BananaSlamJamma167
420jenkins106
LuMiX0
Heroes of the Storm
Trikslyr79
Other Games
singsing2805
Liquid`RaSZi1475
hiko939
Beastyqt595
ceh9583
Mlord419
mouzStarbuck303
XaKoH 296
Liquid`VortiX157
TKL 116
ArmadaUGS114
PiGStarcraft54
FrodaN36
KnowMe11
ROOTIllusion7
Organizations
Counter-Strike
PGL275
StarCraft: Brood War
lovetv 7
[ Show 15 non-featured ]
StarCraft 2
• StrangeGG 15
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Laughngamez YouTube
• Migwel
StarCraft: Brood War
• FirePhoenix15
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV642
League of Legends
• Nemesis1227
• TFBlade750
Other Games
• Shiphtur586
Upcoming Events
Replay Cast
6h 1m
The PondCast
17h 1m
KCM Race Survival
17h 1m
OSC
21h 1m
IntoTheTV X SOOP
2 days
Reynor vs Solar
ByuN vs SHIN
Clem vs MaxPax
herO vs Rogue
IPSL
3 days
WorsT vs nOmaD
Dewalt vs andersOn
AI Arena Tournament
3 days
IntoTheTV X SOOP
3 days
IPSL
4 days
Azhi_Dahaki vs ggnore13
Double vs WIZARD
Replay Cast
4 days
[ Show More ]
Replay Cast
5 days
Sparkling Tuna Cup
5 days
WardiTV Invitational
5 days
YoungYakov vs Lambo
SHIN vs TBD
Percival vs Shameless
Solar vs TBD
PiGosaur Cup
6 days
Liquipedia Results

Completed

Proleague 2026-11-03
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
Calamity Cup Div. A Season 8
IEM Beijing 2026
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

1xBet Invitational
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Underdog Cup 2026 Div 2-3
PGL Bucharest 2027
BLAST Bounty Winter 2027
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.