论坛首页 Java企业应用论坛

为什么选择Scala

浏览 28077 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2009-08-05  
怎么语法那么像as
0 请登录后投票
   发表时间:2009-08-05  
如果你对 scala 这种后 JVM 语言有兴趣,不妨去比较一下另一种类似但更加极端简洁的的语言:Clojure

http://clojure.org
0 请登录后投票
   发表时间:2009-08-06  
有Java+Groovy一切足矣
0 请登录后投票
   发表时间:2009-08-06  
javascript 也不错啊,3d方面很多都用javascript做脚本.
0 请登录后投票
   发表时间:2009-08-06  
飘过~~,
0 请登录后投票
   发表时间:2009-08-06   最后修改:2009-08-06
楼主举那些好处都不重要,这些好处java带来的是语法和代码更难理解,只怕不是什么好现象。
况且这些语法糖的实际功能,java也可能完成,不过是代码数量的差别——这种差别并不是数量级的,但是可读性差别就大了。

actor应该是最大的好处。

所以,多数场合还是java的好。

scala我已经学几个星期了,仔细考虑过合适的应用场景,并没看起来那么美。groovy好处还是多一点(如同robin说的,并不纯粹,异常等很难理解),groovy适合做脚本和黏合剂,测试等方便而不重要的地方。
0 请登录后投票
   发表时间:2009-08-06   最后修改:2009-08-06
和groovy相比又好在哪?
0 请登录后投票
   发表时间:2009-08-06   最后修改:2009-08-06
文章花了很大的篇幅说明静态类型的好处,但是静态类型的好处并不是scala独有的,效率、可检验属性、安全重构等等特性,哪家静态类型语言没有啊?都21世纪了,还把这些当成自己的特色。至于类型推理、匿名函数,新版的C#、C++都有这些特性,又不是scala的专利。

有人对scala的评价如下,我觉的很有道理:
C# 3.0 has a lot of the features that Scala has and they are much more palatable than the way Scala implements them. Why come up with a non-mainstream syntax for existing feature?

简单的说,这些语法糖大家都能想到,干嘛故意搞的和主流语法不一样?

7 请登录后投票
   发表时间:2009-08-06  
代码虽然还不如 ruby 那么简洁易读,但已经比 java 好上一些数量级了。

Nown-Oriented Thinking 写道

For the lack of a nail,
    throw new HorseshoeNailNotFoundException("no nails!");

For the lack of a horseshoe,
    EquestrianDoctor.getLocalInstance().getHorseDispatcher().shoot();

For the lack of a horse,
    RidersGuild.getRiderNotificationSubscriberList().getBroadcaster().run(
      new BroadcastMessage(StableFactory.getNullHorseInstance()));

For the lack of a rider,
    MessageDeliverySubsystem.getLogger().logDeliveryFailure(
      MessageFactory.getAbstractMessageInstance(
        new MessageMedium(MessageType.VERBAL),
        new MessageTransport(MessageTransportType.MOUNTED_RIDER),
        new MessageSessionDestination(BattleManager.getRoutingInfo(
                                        BattleLocation.NEAREST))),
      MessageFailureReasonCode.UNKNOWN_RIDER_FAILURE);

For the lack of a message,
    ((BattleNotificationSender)
      BattleResourceMediator.getMediatorInstance().getResource(
        BattleParticipant.PROXY_PARTICIPANT,
        BattleResource.BATTLE_NOTIFICATION_SENDER)).sendNotification(
          ((BattleNotificationBuilder)
            (BattleResourceMediator.getMediatorInstance().getResource(
            BattleOrganizer.getBattleParticipant(Battle.Participant.GOOD_GUYS),
            BattleResource.BATTLE_NOTIFICATION_BUILDER))).buildNotification(
              BattleOrganizer.getBattleState(BattleResult.BATTLE_LOST),
              BattleManager.getChainOfCommand().getCommandChainNotifier()));

For the lack of a battle,
    try {
        synchronized(BattleInformationRouterLock.getLockInstance()) {
          BattleInformationRouterLock.getLockInstance().wait();
        }
    } catch (InterruptedException ix) {
      if (BattleSessionManager.getBattleStatus(
           BattleResource.getLocalizedBattleResource(Locale.getDefault()),
           BattleContext.createContext(
             Kingdom.getMasterBattleCoordinatorInstance(
               new TweedleBeetlePuddlePaddleBattle()).populate(
                 RegionManager.getArmpitProvince(Armpit.LEFTMOST)))) ==
          BattleStatus.LOST) {
        if (LOGGER.isLoggable(Level.TOTALLY_SCREWED)) {
          LOGGER.logScrewage(BattleLogger.createBattleLogMessage(
            BattleStatusFormatter.format(BattleStatus.LOST_WAR,
                                         Locale.getDefault())));
        }
      }
    }

For the lack of a war,
    new ServiceExecutionJoinPoint(
      DistributedQueryAnalyzer.forwardQueryResult(
        NotificationSchemaManager.getAbstractSchemaMapper(
          new PublishSubscribeNotificationSchema()).getSchemaProxy().
            executePublishSubscribeQueryPlan(
              NotificationSchema.ALERT,
              new NotificationSchemaPriority(SchemaPriority.MAX_PRIORITY),
              new PublisherMessage(MessageFactory.getAbstractMessage(
                MessageType.WRITTEN,
                new MessageTransport(MessageTransportType.WOUNDED_SURVIVOR),
                new MessageSessionDestination(
                  DestinationManager.getNullDestinationForQueryPlan()))),
              DistributedWarMachine.getPartyRoleManager().getRegisteredParties(
                PartyRoleManager.PARTY_KING ||
                PartyRoleManager.PARTY_GENERAL ||
                PartyRoleManager.PARTY_AMBASSADOR)).getQueryResult(),
        PriorityMessageDispatcher.getPriorityDispatchInstance())).
      waitForService();

All for the lack of a horseshoe nail.
0 请登录后投票
   发表时间:2009-08-06  
学学scala,拓宽一下自己的技术视野
程序原来还可以这样写。
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics