• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:13
CEST 14:13
KST 21:13
  • 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
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
Weekly Cups (July 27-Aug 2): SHIN's big week0SC4ALL II: Brood War - $2500 - Dec 5-66SC4ALL II announced - $10,000 prize pool, Dec 5-64PIG STY FESTIVAL 8.0! (13 - 23 August)11Neeb returns to progaming; rejoins ONSYDE17
StarCraft 2
General
Neeb returns to progaming; rejoins ONSYDE SC4ALL II: StarCraft 2 Player Announcement 2/8 Balance hotfix patch 5.0.16b (July 16) August World Ranking: Clem climbs to #2 Daily SC2 Player Grid - feedback wanted
Tourneys
Tasteless Time Warp: SC Evo Showmatch (May 25) SC4ALL II announced - $10,000 prize pool, Dec 5-6 Sparkling Tuna Cup - Weekly Open Tournament PIG STY FESTIVAL 8.0! (13 - 23 August) RSL Revival: Season 6 - Qualifiers and Main Event
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
The PondCast: SC2 News & Results Mutation # 537 Hostile Territory Mutation # 536 Railroad Switch Mutation # 535 Assembly of Vengeance
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion ASL22 General Discussion [Personal Project Share] Terran Defense v0.60 BW Drama: Terror's Debt Incident + C9 disbanding
Tourneys
2v2v2v2 Tournament [Megathread] Daily Proleagues SC4ALL II: Brood War - $2500 - Dec 5-6 Escore Tournament - Season 3
Strategy
Any training maps people recommend? Fighting Spirit mining rates Simple Questions, Simple Answers Odyssey Mineral Stack Saturation
Other Games
General Games
ZeroSpace Early Access is Now Live! Stormgate/Frost Giant Megathread General RTS Discussion Thread Nintendo Switch Thread Beyond All Reason
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread Things Aren’t Peaceful in Palestine
Fan Clubs
The Clem Fan Club INnoVation Fan Club The Scarlett Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! Series you have seen recently... [Req][Books] Good Fantasy/SciFi books
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Please support my new stand…
Peanutsc
What is a Gamer?
TrAiDoS
Hello guys!
LIN1s
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3091 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
Kung Fu Cup
11:00
2026 Week 18
IntoTheiNu 1138
WardiTV547
RotterdaM295
TKL 172
SteadfastSC103
IndyStarCraft 98
Rex80
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 295
TKL 172
SteadfastSC 103
IndyStarCraft 98
Ryung 82
Rex 80
StarCraft: Brood War
Britney 39048
Shuttle 1057
Horang2 955
Jaedong 853
Mini 563
EffOrt 401
Soulkey 335
BeSt 285
Light 244
Snow 201
[ Show more ]
Larva 198
Zeus 193
Last 173
ZerO 162
Dewaltoss 148
JYJ 106
ggaemo 102
Pusan 90
hero 81
Hyun 70
Killer 68
ToSsGirL 66
JulyZerg 52
Hm[arnc] 52
PianO 37
Barracks 36
Sexy 33
sorry 32
Icarus 24
Bale 23
yabsab 19
Shine 18
[sc1f]eonzerg 17
soO 13
NotJumperer 12
Sacsri 11
Noble 10
Terrorterran 1
Dota 2
Gorgc17304
Dendi454
XcaliburYe47
League of Legends
Grubby1242
Counter-Strike
shoxiejesuss1850
ScreaM1625
olofmeister1548
byalli900
markeloff78
zeus73
kRYSTAL_31
edward21
Other Games
B2W.Neo640
crisheroes236
Liquid`LucifroN133
Livibee71
hiko68
ZerO(Twitch)5
Pyrionflax2
Organizations
Other Games
gamesdonequick460
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 12 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV399
League of Legends
• Jankos1171
Upcoming Events
Replay Cast
11h 47m
The PondCast
21h 47m
OSC
21h 47m
INu's Battles
22h 47m
Percival vs Cure
Classic vs Clem
Replay Cast
1d 11h
Escore
1d 21h
IntoTheTV X SOOP
1d 22h
RSL Revival
2 days
herO vs SHIN
Clem vs Solar
Serral vs Rogue
RSL Revival
3 days
WardiTV Weekly
4 days
[ Show More ]
The Patches Monday
5 days
Sparkling Tuna Cup
5 days
PiG Sty Festival
5 days
PiGosaur Cup
6 days
Replay Cast
6 days
Kung Fu Cup
6 days
Liquipedia Results

Completed

Proleague 2026-08-04
CranK Gathers Season 4: BW vs SC2 Team League
Eternal Conflict S2 Finale

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
Acropolis #5
RSL Revival: Season 6
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026

Upcoming

Escore Tournament S3: W6
Escore Tournament S3: W7
CSLAN 4
ASL Season 22
Escore Tournament S3: W8
Acropolis #5 - TRS
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
PiG Sty Festival 8.0
Big Dog Cup 2026 Div 1
Thunderpick World Champ.
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 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.