如何评价 Go for android webview 内核或 Swift for web 这种现象

Google may be considering Swift for use on Android
About the time Swift , representatives for three major brands — Google, Facebook and Uber — were at a meeting in London discussing the new language. Sources tell The Next Web that Google is considering making Swift a “first class” language for , while Facebook and Uber are also looking to make Swift more central to their operations.
Google’s Android operating system currently supports Java as its first-class language, and sources say Swift is not meant to replace Java, at least initially. While the ongoing litigation with Oracle is likely cause for concern, sources say Google considers Swift to have a broader “upside” than Java.
Swift is also open source, which means Google could adopt it for Android without changing its own open source mobile structure.
Could Google do it?
as a replacement to Objective C, Swift quickly found favor with developers as an easy-to-write language that shed much of the verbosity and clumsy parameters other languages have. It was introduced at , and has major support from IBM as well as a variety of major apps like Lyft, Pixelmator and
that have all rebuilt
apps with Swift.
Swift can’t be copy-pasted for any platform, though. Specifically, Android would need a runtime for Swift — and that’s just for starters.
Google would also have to make its entire standard library Swift-ready, and support the language in APIs and SDKs. Some low-level Android APIs are C++, which Swift can not currently bridge to. Those would have to be re-written.
Swift would also not be useful in bridging higher level APIs in J they’d have to be re-written as well.
Using Swift for Android is not impossible, though. Late last year,
toyed with Swift for Android — and had some success. While that project was completed well ahead of Swift being open source, it nonetheless proved that it can be done.
That project used the Android NDK, which allows other languages to be loosely implemented into Android. With an open source Swift and support from Google, Android apps wouldn’t require that toolkit.
All told, Google would have to effectively recreate its efforts with Java — for Swift. If the company is motivated enough, it’s very possible to do so without compromising on its open source values or ruffling any developer feathers along the way.
Just , sources also claim Kotlin is being discussed as a first class language for Android.
Like Swift, Kotlin is object oriented with a focus on safety. Unlike Swift, Kotlin works with Android Studio, Google’s IDE for Android development.
Unfortunately, sources tell The Next Web that Google’s current mindset is that Kotlin is a bit too slow when compiling.
But, Kotlin is billed as a language that “works everywhere Java works,” and has “seamless” support for projects that mix it and Java.
It would be much less work on Google’s end to get Kotlin up and running for Android, but could be a tedious transition for developers.
Facebook and Uber
Facebook’s interest in Swift appears to be completely founded in technological advancement.
A benefit of Swift is that it can serve as both a forward-facing language as well as a server-side one. For a product like Facebook, that’ apps and servers can speak to one another seamlessly, and it potentially gives the company a wider scope to write APIs for services.
And work may have already begun. A Github pull request in the Swift repository named ‘’ was made by a Facebook employee. It’s not clear if his work was official Facebook business or not, though we have confirmed Facebook is already working with Swift internally — it’s just not known how thoroughly.
Uber’s road to Swift is probably a bit cleaner than either Google or Facebook. Though there are many moving parts to Uber’s service (app, server and API), it can use Lyft’s transition to Swift as an example.
to Swift, it was a ground-up remodel that took a lot of time and effort — but resulted in an app that’s lighter, leaner and easier to maintain. It’s not known how much (if any) of Lyft’s back-end uses Swift, but the company has been highly complimentary of Swift in its existing application.
When could a move to Swift happen?
The short answer: not anytime soon. The reason? Android.
But Swift is . Several studies suggest it’s , and has
since going open source (GitHub tells The Next Web the language is currently its 11th most popular).
who know Swift is also exploding, which could be all the indication these three companies need to at least explore using Swift more thoroughly.
Google’s onboarding for S it essentially has to rewrite every Android service, app and API. Google would also have to spearhead Swift support for Android — which is still only being poked and prodded at by clever developers in the Swift community.
In a way, Google has already begun moving away from bits of Oracle-flavored Java. It’s
for Android rather than the proprietary Java API, and may be considering a post-Java life altogether. Talks in London were sa Google is not yet pushing to move on from Java. While it would be a big undertaking, Swift is meant for speed and safety, and Swift’s roadmap suggests it won’t be quite as difficult to use it for other platforms in the future, .
Though Kotlin is an alternative, it’s a very nascent language without the eager community Swift has.
Facebook and Uber face similarly daunting tasks when it comes to using Swift throughout, but can –and should — wait for Google to shoulder the load with Android. If the use of Swift is going to be as deep as our sources indicate (that is, all companies want to be using it for server side and forward-facing use cases), Android support is integral.
Moving to Swift for any of the companies also makes little sense unless it’s a thorough re-do, but it’s probably not quite as hard as it sounds.
prove that server-side Swift is ready, and it’s worth considering that Facebook’s engineers () may already be working on this.
to make Swift ready for server-side functions.
But don’t expect Google, Facebook or Uber to announce Swift-y plans anytime soon. Facebook and Google both have developer conferences on the horizon, and there’s no indication that Swift will play a major part at either.
We reached out to all three companies for comment on the information our sources brought forward. All three declined to comment. Google specifically pointed to its
as reason not to participate in this article. Make of that what you will.
Read next:
Prefer to get the news as it happens? Follow us on social media.
1.76M followers在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
点击阅读原文
用SwiftWeb(Perfect)开发一个SwiftChina实践
日 发布,来源:
对于Swift开发者来说也许大家也听说过SwiftWeb服务开发,我自己也是个爱折腾的人下面记录了我折腾SwiftWeb最终弄出来的东西(Demo)。
域名在申报
首页图.png
总所周知,在swiftWeb服务器框架比较出名的是Perfect,Vapor,Kitura,我花了2天对比最终选择了主(http)框架选择了perfecr原因如下:
1.首先忽略了Kitura,原因是虽然IMB是一个很出名的公司,但他的SwiftWeb框架组件并不丰富,没有slack。
2.在vapor和perfect中,vapor最大的优势是社区活跃度非常高,slack加入人数也是最多的,开发人员也是对外的,而且经常文档写的非常好,而他出的项目也非常的人性化如:他有一个vapor cli可以非常轻松的在linux下安装swift环境,leaf模板也是非常强大。不足的地方我感觉就是功能没perfect强大了。当然这个项目也集成了他的几个子package
3.perfect据我了解主开发人员比较少(可以到github上看到)而且他的团队是公司性质的,全部项目几个人一手包办,羡慕他们这些技术牛人。perfect的优势是他家出的产品非常强大如:用swift玩转tensorflow,swift版kafka,swift版ZooKeeper,而且perfect公司还弄了个用swift开发android的,具体可以自己谷歌。
web功能也是比较丰富的例如:
1.session的处理 perfect 分别集成了 mysql,postgressql,redis,
2.可以自己添加过滤器
3.后面文章也会提及
不足的地方就是虽然有中文文档但文档并不人性化,有点乱,几个模板项目运行都有问题
ps:这里不讨论性能那个快那个慢,在框架不成熟的情况比这些没意义。
这个项目用到的模块要有 数据库连接,网页模板,日志,加密,session,redis,json...
下面列举用到的相应package 顺带吐槽一下。
1.数据库用的是mysql,这里本来是应该用perfect家提供的mysql链接库的和orm的,但是在实践中发现该框架并没有支持连接池技术。而且没有时间的认证,我没有选择ORM框架。无可厚非这东西并不成熟,这并不是rails, hibernat。最终选择mysql-swift
2.日志功能直接使用perfect提供的,perfect提供了比较全面的日志方案
3.session 处理的perfect是提供比较好的方案,像上面提及的 它家提供了mysql,postgressql,redis解决方案,便于以后做集群方案处理。但是因为mysql-session与mysql-swiftpackage会冲突的原因,最后选择用redis作为session存储方案
4.模板的话,本来是用Perfect-Mustache的,但考虑到Mustache模板逻辑处理能力太弱了也不便于开发,最后对比leaf和stencil,最后选择stencil,这里介绍一下模板,stencil非常强大,start数也很多,支持继承,支持自定义语法,大家可以了解一下。
5.加密技术用到 package由vapor提供
6.OAuth2 这里用perfect提供的
7.模型转-&JSON处理 因为是swift3的关系(swift4官方会提供方法)这里选择了阿里的handyjson,但是handyjson并不能在linux下运行,所以要修改他的源码,可以用handyjson的好处是支持自定添加转换类型,可以将Date和各种自定义类型进行转换处理
在linux上运行
直接使用vapor 提供的 vapor cli 然后使用它安装swift配置环境 下载本项目他会提示你所需要的包你只需要 按照其提示即可,如果报了 #&uuid/uuid&的错误 需要安装uuid相关库.
代码分析:
创建一个filter 用于验证用户
configuration/Filter.swift
filters.append(["type":"request","priority":"high","name":CheckLogin])
filter/CheckLogin
//检查有没登录
public func CheckLogin(data: [String:Any]) throws -& HTTPRequestFilter {
return checklogin()
struct checklogin:HTTPRequestFilter {
func is_login(req:HTTPRequest) -& [String:Any]? {
guard req.session != nil else {
return nil
guard let user:[String:Any] = req.session!.data["user"] as? [String : Any] else{
return nil
return user
func filter(request: HTTPRequest, response: HTTPResponse, callback: (HTTPRequestFilterResult) -& ()) {
guard let st = request.header(HTTPRequestHeader.Name.accept) else{
callback(.execute(request, response))
guard st.components(separatedBy: "text/html").count & 1 else {
callback(.execute(request, response))
let requestPath = request.path
var in_white_list = false
var islogin = false //已经登录
if requestPath == "//" {
in_white_list = true
for address in whitelist{
if address.components(separatedBy: requestPath).count & 1
in_white_list = true
//判断是否登录
let user = is_login(req: request)
if (user != nil) {
if user?["username"] != nil && user?["userid"] != nil && (user!["username"] as? String != "") && (user!["userid"] as? Int != 0){
islogin = true
//域对象 PageHandlers处理
let dic:[String:Any] = [ "login":islogin
,"username":user?["username"] ?? ""
,"userid":user?["userid"] ?? 0
,"create_time":user?["create_time"] ?? ""]
if in_white_list {
request.scratchPad["locals"] = dic
callback(.continue(request, response))
if islogin {
request.scratchPad["locals"] = dic
request.session!.data.updateValue(true, forKey: "login")
callback(.continue(request, response))
if let st = request.header(HTTPRequestHeader.Name.accept){
//如果是接口请求
if st.components(separatedBy: "application/json").count & 1 {
callback(.execute(request, response))
try response.setBody(json: ["success":false,"msg":"该操作需要先登录"])
response.completed()
Log.error(message: "\(error)")
response.redirect(path: "/login")
使用sctencil 作为模板
原理 使用responet.setbody 输出http
extension HTTPResponse {
public func render(template: String, context: [String: Any] = [String: Any]()) {
//设置路径
let fsLoader = FileSystemLoader(paths: ["webroot/views"])
let environment = Environment(loader: fsLoader)
let stencil = try environment.renderTemplate(name: "\(template)"+".html", context: context)
self.setBody(string: stencil)
self.completed()
Log.error(message: "\(error)")
因为是.html 文件 所以在xcode上编辑有颜色,强烈推荐sctencil
static func avatar(data:[String:Any]) throws -& RequestHandler{
req,res in
let fileDir = Dir(Dir.workingDir.path + "webroot/avatar")
try fileDir.create()
Log.error(message: "\(error)")
let upload = uploads[0]
let thisFile = File(upload.tmpFileName)
let date = NSDate()
let timeInterval = date.timeIntervalSince1970
let hashName = "\(timeInterval.hashValue)"
var type:String?
let typeArray = upload.contentType.components(separatedBy: "/")
guard typeArray.count &= 2 else {
try res.setBody(json: ["success":false,"msg":"获取类型出错"])
res.completed()
type = typeArray[1]
let picName = hashName + "." + type!
let _ = try thisFile.moveTo(path: fileDir.path + picName, overWrite: true)
let judge = try UserServer.update_avatar(avatar: picName, userid: user_id)
guard judge != false else {
try res.setBody(json: ["success":false,"msg":"上传失败"])
res.completed()
try res.setBody(json: ["success":true,"originFilename":upload.tmpFileName,"filename":picName])
res.completed()
Log.error(message: "\(error)")
对swiftWeb有兴趣的小伙伴们可以加入qq群:
我要该,理由是:
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)据说,谷歌考虑将 Swift 作为安卓的“一类”语言
正在这&&的时候,三大品牌巨头—— 谷歌,Facebook和Uber——正在伦敦召开关于讨论新语言的会议。据& 的消息说,谷歌正在考虑将 Swift作为Android的一个“一类”语言,而Facebook和Uber也正在努力使Swift更加适用于自己的核心业务。谷歌的Android操作系统目前支持Java作为其一类语言,据消息来源说,Swift并不是要取代Java,至少在最初阶段。大概与长期进行的诉讼是导致谷歌做出这一决定的可能原因,据说谷歌考虑Swift是认为其可能有比Java更广阔的发展空间。Swift也是开源的,这意味着谷歌可以采用它作为Android的语言,而无需改变自己的开源手机结构。这件事的可能性有多大?什么时候才能发生?答案很简单,不会很快。为什么?因为安卓系统。了解更多,请查看
Swift 的详细介绍:
Swift 的下载地址:
转载请注明:文章转载自 开源中国社区
本文标题:据说,谷歌考虑将 Swift 作为安卓的“一类”语言
本文地址:
要就事论事!不要这里错了,就扯别的,只为维护自己的面子。
“如果你只是跟着人家的尾巴学,认为它会对你有好处,而不是自己尝试去创造,那就是“水平低”,双引号,没有任何贬义面向对象那是高级语言但是真正学编程的人应该更要用低级语言”这绝不能一概而论,做什么事情用什么工具,如果你做的项目是偏底层的当然要用低级的语言,而不是“学编程就要用低级语言”。以下是针对我们做产品角度来看:现实生产不是炫技平台,相信绝大部分做项目都是选择成熟的技术,因为生产需要效率和可靠性,需要尽量将开发人员的经历集中在业务逻辑本身,而不是与业务无关的一些底层技术。当然,有专门负责底层的团队,底层技术是他们必备的技能,但从全局来讲,底层只占了很小一部分,大部分研发投入还是偏上层的业务部分。创造一门语言并不难,我以前也在工作中创造过语言。但是,自己创造的和巨人的作品比起来:
- 首先,语言特性真的各方面的确很难考虑周全,我也经常看其他的创新创造,包括和Swift长得90%相似度的Kotlin,但仔细研究下来还是和Swift差距比较大。
- 其次,自己创造的没有生态,你不能复用社区的成果。
- 再次,费神费力,最后没有好果子。如果语言层面能提高产品质量,减小团队里面人工作量,提高工作的舒适度,何乐而不为? 我们可以在别人debug和时候听着音乐喝着咖啡了。。。
我没有要和你争辩哪个语言好与不好,没有意义。我说这些只是为了指出你的观点里面的明显错误。还是那句话,没了解之前不要下结论,贬低。“你从学校学来的“编译器,脚本”这种定义在现实生产中,其实并不很适用”我从来没觉得学校学的知识在现实生产中不适用,而是很受用。--因为我在学校从来不是死学,而是活学,觉得不适用多半是学习方法不对。1.易学,语法简单--这个不用说了吧,语法少所以简单
-- 这是相对哪些前辈老旧语言来讲的,比如Java。2.安全,提示--用脚本,你写错一个标点符号就知道错了
-- Swift提供的比这个多得多,真正用过才会理解。3.面向脚本--那还用说么,大部分确实是优于OOB,如果你认为程序只是单一的脚本,或者swift,或者单一的面向对象,其实iOS系统里面怎么也会有OBJ的,JS是脚本了吧?人家也支持面向对象的
-- 天生支持好的编程模式不需要付出额外工作量这正是Swift的改进(是面向协议,不是面向对象)。4.无缝调用--这个我就不说了,PYTHON和PHP的无缝调用,你不了解
-- 不如Swift无缝,我们也在用Python,Python2的官方实现源码我有通看一遍,各种配套工具也使用过。5.高性能--给台法拉利估计你也只开40公里,因为是学堂里面教的,技术是练出来的,你开80觉得是极限么?人家骑单车也骑60
-- 基本每种语言的实现都在想方设法提高自身性能,还觉得语言自身的性能没有意义?
没有了解这门语言之前,不要妄下结论。你觉得只是包装了一下Objective-C?苹果是为Swift做了一个Objective-C的桥接层,但它不是必须的,目前官方的Swift实现完全可以脱离Objective-C runtime编译,是一门全新的语言。我们评价一门语言的价值并不在于它是怎么实现的,而是给程序员和产品带来了什么好处。Swift作为一门现代语言,设计时参考了很多语言,因此在它身上随处可见其它语言的影子。从我使用看来,他的关键优点有:1. 易学,语法简洁优美。2. 安全,大部分容易出问题的地方语法上就提示了。3. 面向协议的编程模式,大部分情况下优于面向对象。4. 无缝调用Objective-C和C的代码。5. 高性能。其它语言很难有集齐这些优点的。
引用来自“loongwong”的评论swift不是脚本引用来自“sidney9111”的评论你水平太低,在我看来java也是脚本,或者说我现在正准备把java做成脚本,基本原理就是通过反射,让脚本JAVA运行在现在的android上,现在的android native明显也是java,想在手机上直接编译运行,手机编译,也就是linux编译是个麻烦事,如果将java做成一脚本,就不需要编译了,但如果java是脚本,这个脚本也可以是python,lua,或者javascript,也不需要像我一开始设想的java 脚本我确实水平不高。按你的定义,所有编程语言都是脚本,因为我们都可以做一个解释型的实现。
引用来自“loongwong”的评论swift不是脚本你水平太低,在我看来java也是脚本,或者说我现在正准备把java做成脚本,基本原理就是通过反射,让脚本JAVA运行在现在的android上,现在的android native明显也是java,想在手机上直接编译运行,手机编译,也就是linux编译是个麻烦事,如果将java做成一脚本,就不需要编译了,但如果java是脚本,这个脚本也可以是python,lua,或者javascript,也不需要像我一开始设想的java 脚本
swift不是脚本
引用来自“大头s”的评论谷歌的编译器和语言之类的研究可能比不上苹果微软,谷歌也无心深入这类研究,直接拿来用就好了。 V8 JS引擎足以证明谷歌在编译器和虚拟机方面的造诣!我也听说了,开源中国决定用 Swift 替换 Java 重写整个网站,对于这种新闻,呵呵呵呵呵
引用来自“nothingkill”的评论你说android抄袭symbian才是瞎扯引用来自“海淀游民”的评论自己回去看看安卓的事件处理API,到现在那些处理实体键盘的API还在呢引用来自“nothingkill”的评论你看过symbian的代码,开发过symbian程序吗?信口开河,你去看一下symbian系统源码和Android对照一下,有哪些地方是抄的,我劝你去看明白两个系统的按键事件分发机制再来回 引用来自“海淀游民”的评论真TMD服了,安卓Linux内核,iOS是Mach+BSD的混合内核,我说抄袭是说抄袭界面风格和使用方式,非要死扣字眼到了这种地步,我下次说模仿好了,安卓最早模仿的塞班,后来看到iPhone,改为模仿iOS了,这样你满意了吗?你干脆说历史上所有手机的界面风格都是抄袭的水果不行了???!!!!
C#也是越来越不错如何评价 Go for android 或 Swift for web 这种现象? - 知乎有问题,上知乎。知乎作为中文互联网最大的知识分享平台,以「知识连接一切」为愿景,致力于构建一个人人都可以便捷接入的知识分享网络,让人们便捷地与世界分享知识、经验和见解,发现更大的世界。109被浏览<strong class="NumberBoard-itemValue" title="1分享邀请回答587 条评论分享收藏感谢收起126 条评论分享收藏感谢收起

我要回帖

更多关于 android webview js 的文章

 

随机推荐