10 ms·
Swift and Go: Building a Fast Future
- Joky 12y agoYes! Two modern languages that are 1) statically typed and 2) statically compiled. At least some people still get it that "modern" and "nice to use" does not implies scripting-like dynamically-fancy typed language "à la" PHP/Python/Javascript/... And the author did not mention Playground for Swift which is just incredibly useful to start experimenting with the language! (Edit: of course Rust is another one as well, but I was in the context of the article)
- derengel 12y agoyou know what they say about Go being modern right?
- Joky 12y agoplease, enlighten me :)
- jakevn 12y agoFor better or worse, Go's design is anything but modern. It lacks things such as immutability and generics. It also perpetuates the mistake of including a run-time type error, null (nil).
- tomp 12y agoMore precisely, Go has generics (along with overloading), they are just not available to users of the language.
- Joky 12y agoNote that modern does not mean perfect. I'm not sure you answer could not fall into the "this-language-lacks-my-favorite-cool-fancy-feature-so-it-is-necessarily-an-old-fashioned-crappy-piece-of-s*" syndrome?
- jakevn 12y agoWere they actually fancy or cool, maybe. They're rather basic features among statically typed languages. Also, I'm not trying to say Go is bad or that I dislike it. It's simply not a modern language as far as design goes.
- masklinn 12y agoThat it might have deserved the moniker if it had been released around the same time as java.
- coldtea 12y agoMake that a few decades before actually: http://cowlark.com/2009-11-15-go/ http://cowlark.com/2009-11-15-go/
- masklinn 12y agoWell it does have a structural type system (one of the few other languages with one being OCaml, '96), a GC (popularised/made acceptable by Java '95) and provides language-level support for CSP (Occam '83)
- Joky 12y agoThanks for the link, that was very interesting to read! I didn't know Algol (I knew the name and how "historical" it is but not the details).
- twic 12y agoHadn't seen this before. This is brilliant. Thanks. So, who's up for an Algol-15 project?
- Dewie 12y ago> Go compiles very quickly, but that actually didn't impact us very much since we have largely been using interpreted languages on the backend. I'll betcha those poor Java programmers get pretty excited about this, though! Oh?
- twic 12y agoSomeone should probably mention to the author that us poor Java programmers have had incremental compilers for over a decade, so compilation speed hasn't been an issue for a long time. Best not to mention that we've also had generics for over a decade, though, wouldn't want to upset him.
- dete 12y agoWell, you can consider it mentioned to the author... that would be me! I shouldn't have tweaked Java so mercilessly since I did love the language for so long (lo, these many years ago). However, I do think you really underestimate the compile speed of Go. Even if 99% of your builds are incremental, you can't entirely discount the occasional clean build. While it has been many years since I hacked Java, even incremental builds could take more than a few seconds. Even a clean build on our 50 kloc Go codebase clocks in under 2 seconds (0.1s when the disk caches are pre-warmed). As for generics, I do like them, and seeing them on iOS (with Swift) is a pretty big win. I'm not entirely convinced that Go is much poorer without them, however. The type system in Go is really unique; if you tried to program Go using Java-style paradigms, there's no question that you'd find it pretty disappointing. However, Go does allow some new ways of thinking about types that allow a degree of flexibility that simply can't be expressed with formal class hierarchies. If what you're doing works for you, just keep on truckin'. But if you give some of these new languages a chance, you might find the areas where they really shine. We did!
- pjmlp 12y ago> However, I do think you really underestimate the compile speed of Go. You mean like Turbo Pascal 4.0 back in MS-DOS?
- notduncansmith 12y agoHow does a language without generics claim to "do more with less code"? Don't get me wrong, I like Go, but it's hard to get behind any language with that low of an abstraction ceiling. Then again, I work in a web shop, building CRUD apps for a living, so maybe it doesn't matter for people who only have to build one version of something.
- gtaylor 12y agoAs a web developer, my tinkerings with Go haven't ever left me wanting for generics. I can't say that this would be the case for every usage case, but it was never an issue for me personally. It's not really my place to argue for or against them, just figured I'd share an anecdote.
- Roboprog 12y agoWe survived getting things into and out of Lists in Java 1.2 to 1.4 somehow. The typecasting on the .get(...) calls is a nuisance, but a minor one.
- pjmlp 12y agoBack in 2002. 12 years ago!
- Roboprog 12y agoIt was a dark age, and void stars filled the console. Many a core were dumped. An age where boys became men! :-)
- threeseed 12y agoSure. And that era of Java was responsible for much of the crap, duplicated code that many of us enterprise developers have had to maintain for a living. To ask developers to go through that again is a bit rich.
- coldtea 12y ago>We survived getting things into and out of Lists in Java 1.2 to 1.4 somehow Being able to survive something is a pretty low bar.
- Roboprog 12y agoAs much as I dislike that most of the "language shootout" benchmarks are mostly numeric wanking, the binary tree benchmark actually makes, uses and disposes of quite a few data structures, and seems more like a real application program to me. Go isn't yet faster than Java, but it is closing the gap, at least on multi-core: http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?test=binarytrees&lang=all&data=u32q http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?t... Single core doesn't fare so well (Go vs Java), though: http://benchmarksgame.alioth.debian.org/u32/benchmark.php?test=binarytrees&lang=all&data=u32 http://benchmarksgame.alioth.debian.org/u32/benchmark.php?te... Perhaps the authors should have used Rust, or Ada, rather than Go? Hell, on a single CPU machine, FreePascal seems to do better than Go :-) Actually, from a "performance, w/out turning off all the safeties" standpoint, it really looks like Rust is owning that space. Now I gotta learn Rust... :-)
- melling 12y agoRust looks great but hasn't shipped yet. Go is production quality and it's being used in some large projects at Google and elsewhere. http://blog.golang.org/4years http://blog.golang.org/4years - From Nov 2013 No, the Go optimizing isn't great. This will be addressed after the compiler is completely rewritten from C to Go. The Go community is growing too, which is probably more important than how well you do on a micro benchmark.
- cromwellian 12y agoI don't understand how writing the Go compiler from scratch in Go is going to make it better than super-mature compilers. Wouldn't it better to leverage Clang/LLVM? Redoing all the optimizations by rewriting the whole compiler in Go seems like it will significantly delay performance parity.
- chadzawistowski 12y agoI don't think being written in Go will make the compiler produce intrinsically fast code. Rather, it will be easier for them to iterate. It is much faster to develop in Go than in C.
- twic 12y ago> I'm pretty darned sure that Rob Pike (creator of Go) and Chris Lattner (creator of Swift) know a few things about computer languages that the rest of us haven't sussed out yet. If these guys think the world needs a new language, it's worth finding out why. (And if you do know more about programming languages than these two? Well, it's honor to have you reading my article, Mr. Wall!) Larry Wall is the ne plus ultra of programming language design. This is satire, right? Please tell me this is satire.
- pdabbadabba 12y agoIs that not the point of his remark? As I understand him, he's implying that Larry Wall is the only one who knows more about language design than Rob Pike and Chris Lattner. Therefore, we should listen to Rob and Chris. Or maybe it's your comment I'm misunderstanding? Edit: Ah. It's been pointed out that perhaps your own remark about Larry Wall was intended as sarcasm (or, equivalently, was intended as a paraphrasing of the quote above it). So it's probably the latter.
- dminor 12y agoHe's disagreeing about Larry Wall.
- dete 12y agoI believe Twic was paraphrasing me, and then asking if my statement (and thus his paraphrase) were satirical. It was a joke, and I intended it to work regardless of your opinion of Perl and Larry Wall himself. With that said, my own opinion is that Larry Wall did a bunch of interesting things in Perl (some of them merely out of ignorance!), that continue to shape modern languages. The Perl community continues this tradition today experimenting with lots of different programming paradigms, to the benefit of the wider development world.
- seanmcdirmid 12y agoMost people who design PLs know little about PL design before they do it besides being passionate programmers. Of course, after you design your first PL, you know a lot more.
- yvsong 12y agoWhich database do you Go for? Is the driver production ready?
- julien_c 12y agomgo, from Gustavo Niemeyer, is great.
- chris0987 12y agoWe are using https://github.com/go-pg/pg https://github.com/go-pg/pg for Postgres with some luck, but I think the standard is https://github.com/lib/pq https://github.com/lib/pq. We are also developing a driver for Orient DB with the goal of it being production ready.
- gnufied 12y agoI have been playing a lot with QML lately and I am loving what I see there. Their approach of animations or graphics seems simple and very approachable - http://qmlbook.org/ch05/index.html http://qmlbook.org/ch05/index.html . The reason I bring this up is, while I like swift (and own more than one macbook pro), I can't bring myself to code for a platform which ties myself further with Apple eco system. If you are looking to build a cross platform 2D game for Android/iOS/OSX/Linux - QML seems like a very good choice.
- coldtea 12y ago>By now, you may be asking yourself why we would choose to use such nascent languages in a production environment. No, we realy are not. If anything, both are quite safe bets. Swift had been in secret development for years and came out almost fully formed (as far as languages go), with a full API, tooling, documentation, etc. Besides it's the Apple blessed way to do things on iOS going forward. As for Go, everybody and its dog are using it for production, left and right. Including very big names. It's pretty much a given that the language is already production-proven, and will do well in the future.
- rgovind 12y ago>>Full API, tooling, documentation, etc. Besides it's the Apple blessed way to do things on iOS going forward. Full API? I believe apart from xcode, there are no developer tools or no examples of parser API. Am I missing something?
- coldtea 12y agoBy "full API" I mean the Cocoa libraries it ties to, not some API for messing with the language (AST stuff etc). As for developer tools, they have an IDE, a compiler, a debugger, a UI designer, the "code playground" thing, etc. That most of those are (also) embedded in XCode doesn't change much.
- bsaul 12y agoJust trying go for some real project, and frankly i wouldn't use it for anything else but network-related middleware ( or low level services), which is what i'm using it for, and almost every tutorial i've read about this language mentions. As long as you're building something very technical, everything's fine. But once you go out of this path, you can see the walls getting dangerously closer. For example, i was surprised to see how many runtime errors i got while coding, for a statically typed language. Surprised as well to see that error checking made me wish for a goto statement again ( what's the pattern for handlings all errors in a block with the same code ? Please tell me..) Then i started to code against a sql db, and boy did it bring me old memories back. Manual transaction scope handling ( annotation where are thou ?), manually counting bound variables in a statement, finding mismatched types between nullable ones and regular ones.... What a mess... Now it may only be a matter of waiting for advanced librairies to mature, but somehow i doubt it.
- andrewchambers 12y agoGo is good at two things. Simple portable command line utilities with no dependencies - and network services.
- howeman 12y agoGo does have a goto statement, and one of its good uses is to transfer to an error handling block (from what I've seen). There are also type annotations (tags), though I don't know how/if they relate to sql
- nathan_f77 12y agoHi @rohamg, I was wondering if you could please share the libraries and frameworks you are using? I'm also building a mobile app in Swift with a web backend in Go. I've done a bit of research, and I think I'm going to use the following: iOS: * MagicalRecord - CoreData abstraction (https://github.com/magicalpanda/MagicalRecord https://github.com/magicalpanda/MagicalRecord) * mogenerator - better CoreData class management (https://github.com/rentzsch/mogenerator https://github.com/rentzsch/mogenerator) * RestKit - with REST API endpoint (http://restkit.org/ http://restkit.org/) Go: * Gin - Web framework. I really like the focus on performance, and that it seems to include all the features you need for an API (authorization, route grouping, etc.) (https://gin-gonic.github.io/gin/ https://gin-gonic.github.io/gin/) * gorm - for most CRUD operations / queries (https://github.com/jinzhu/gorm https://github.com/jinzhu/gorm) * sqlx - for more complex queries (https://github.com/jmoiron/sqlx https://github.com/jmoiron/sqlx) * apns - push notifications (https://github.com/anachronistic/apns https://github.com/anachronistic/apns) * gingorelic - New Relic integration (https://github.com/q1t/gingorelic https://github.com/q1t/gingorelic) * APIBlueprint - API documentation (http://apiblueprint.org/ http://apiblueprint.org/)
- nathan_f77 12y agoArgh, formatting. And now I can't edit or delete it.