• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:38
CEST 11:38
KST 18:38
  • 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
Code S Season 1 - RO8 Preview3[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Maestros of The Game 2 announcement and schedule !7Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
Maestros of The Game 2 announcement and schedule ! GSL Code S Season 1 (2026) Sea Duckling Open (Global, Bronze-Diamond) RSL Revival: Season 5 - Qualifiers and Main Event Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
Do we have a pimpest plays list? BGH Auto Balance -> http://bghmmr.eu/ (Spoiler) Asl ro8 D winner interview BW General Discussion AI Question
Tourneys
[ASL21] Ro8 Day 4 Escore Tournament StarCraft Season 2 Small VOD Thread 2.0 [BSL22] RO16 Group Stage - 02 - 10 May
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread OutLive 25 (RTS Game) Dawn of War IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread The Letting Off Steam Thread Russo-Ukrainian War Thread 3D technology/software discussion
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1451 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
Next event in 22m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech128
StarCraft: Brood War
Killer 264
Zeus 152
Light 136
Hyuk 134
Calm 130
BeSt 91
Mong 90
ToSsGirL 63
Soulkey 60
Dewaltoss 53
[ Show more ]
ggaemo 51
910 43
Sharp 41
Hm[arnc] 40
ZerO 32
Liquid`Ret 31
Backho 29
Rush 24
Shinee 19
soO 19
sorry 18
Bale 17
NotJumperer 17
hero 10
Sacsri 9
Terrorterran 8
Free 7
GoRush 5
Dota 2
monkeys_forever189
NeuroSwarm89
Counter-Strike
zeus593
allub246
edward58
Other Games
gofns25559
singsing1330
ceh9639
WinterStarcraft361
DeMusliM154
KnowMe117
Mew2King90
ZerO(Twitch)9
Organizations
Other Games
gamesdonequick1105
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 16 non-featured ]
StarCraft 2
• LUISG 36
• Adnapsc2 6
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• TFBlade1022
• Stunt595
Other Games
• WagamamaTV0
Upcoming Events
Escore
22m
The PondCast
22m
WardiTV Invitational
1h 22m
Zoun vs Ryung
Lambo vs ShoWTimE
Big Brain Bouts
6h 22m
Fjant vs Bly
Serral vs Shameless
OSC
12h 22m
The PiG Daily
13h 22m
Maru vs Rogue
TBD vs Classic
herO vs Solar
ByuN vs Solar
Replay Cast
14h 22m
CranKy Ducklings
1d
RSL Revival
1d
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
1d 1h
Krystianer vs TriGGeR
Cure vs Rogue
[ Show More ]
SC Evo League
1d 3h
uThermal 2v2 Circuit
1d 5h
BSL
1d 9h
Artosis vs TerrOr
spx vs StRyKeR
Replay Cast
1d 14h
Sparkling Tuna Cup
2 days
RSL Revival
2 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
2 days
BSL
2 days
Dewalt vs DragOn
Aether vs Jimin
GSL
2 days
Afreeca Starleague
3 days
Soma vs Leta
Wardi Open
3 days
Monday Night Weeklies
3 days
OSC
3 days
CranKy Ducklings
4 days
Afreeca Starleague
4 days
Light vs Flash
Replay Cast
4 days
Replay Cast
5 days
The PondCast
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-05-05
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
Escore Tournament S2: W6
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2

Upcoming

KK 2v2 League Season 1
BSL 22 Non-Korean Championship
YSL S3
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
BLAST Bounty Summer 2026: Closed Qualifier
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 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.