没有合适的资源?快使用搜索试试~ 我知道了~
首页探索Ruby黑客手册:解析内核与语言处理
探索Ruby黑客手册:解析内核与语言处理
需积分: 10 8 下载量 118 浏览量
更新于2024-07-16
1
收藏 22.79MB PDF 举报
《Ruby黑客指南》(Minero Aoki)是一本深入剖析Ruby语言及其官方C实现——ruby的书籍。作者以丰富的C和Ruby知识为基础,目标旨在帮助读者全面掌握Ruby语言的结构,并理解语言处理系统的原理。该书的首要任务是揭示ruby解释器的内部工作机制,让读者能够洞察整个语言的运作机制。 书中内容涵盖了广泛的主题,包括但不限于:理解Ruby对象导向的核心特性、剖析核心数据结构如哈希表(hashtable)、解析器和扫描器的工作原理、以及语言的评估过程。由于并非一本传统的教科书,作者并未详尽地探讨每个领域的细节,而是侧重于关键语言实现结构的解释。此外,书中还包含了一个简要的Ruby语言概述,以便那些对语言本身不太熟悉但希望理解其内部机制的读者能够快速入门。 通过阅读这本书,读者不仅能掌握Ruby的底层构造,还能将这些知识应用于其他语言处理系统的学习和开发中。这对于想要成为Ruby开发者或者深入理解程序执行流程的专业人士来说,是一本不可多得的参考资料。阅读这本书,你不仅会成为一名Ruby黑客,也可能因此洞悉所有编程语言设计和实现的精髓。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/11941047/bg10.jpg)
Asapreparationsteptoinvestigatingintoit,let’sstartbythinking
aboutthedifferencebetweenaninterpreterandacompiler.Ifthe
matteristoattemptatheoreticalcomparisonintheprocesshowa
programisexecuted,there’snodifferencebetweenaninterpreter
languageandacompilelanguage.BecauseitworksbylettingCPU
interpretthecodecompiledtothemachinelanguage,itmaybe
possibletosayitworksasaninterpretor.Thenwhereistheplace
thatactuallymakesadifference?Itisamorepracticalplace,inthe
processofdevelopment.
Iknowsomebody,assoonashearing“intheprocessof
development”,wouldclaimusingastereotypicalphrase,thatan
interpreterreduceseffortofcompilationthatmakesthe
developmentprocedureeasier.ButIdon’tthinkit’saccurate.A
languagecouldpossiblybeplannedsothatitwon’tshowthe
processofcompilation.Actually,Delphicancompileaprojectby
hittingjustF5.Aclaimaboutalongtimeforcompilationisderived
fromthesizeoftheprojectoroptimizationofthecodes.
Compilationitselfdoesn’toweanegativeside.
Well,whypeopleperceiveaninterpreterandcompilersomuch
differentlikethis?Ithinkthatitisbecausethelanguage
developerssofarhavechoseneitherimplementationbasedonthe
traitofeachlanguage.Inotherwords,ifitisalanguagefora
comparativelysmallpurposesuchasadailyroutine,itwouldbean
interpretor.Ifitisforalargeprojectwhereanumberofpeopleare
involvedinthedevelopmentandaccuracyisrequired,itwouldbea
compiler.Thatmaybebecauseofthespeed,aswellastheeaseof
![](https://csdnimg.cn/release/download_crawler_static/11941047/bg11.jpg)
creatingalanguage.
Therefore,Ithink“it’shandybecauseit’saninterpreter”isan
outsizedmyth.Beinganinterpreterdoesn’tnecessarilycontribute
thereadinessinusage;seekingreadinessinusagenaturallymakes
yourpathtowardbuildinganinterpreterlanguage.
Anyway,rubyisaninterpreter;ithasanimportantfactaboutwhere
thisbookisfacing,soIemphasizeithereagain.ThoughIdon’t
knowabout“it’shandybecauseitisaninterpreter”,anywayrubyis
implementedasaninterpreter.
Highportability
EvenwithaproblemthatfundamentallytheinterfacesareUnix-
centered,Iwouldinsistrubypossessesahighportability.Itdoesn’t
requireanyextremelyunfamiliarlibrary.Ithasonlyafewparts
writteninassembler.Thereforeportingtoanewplatformis
comparativelyeasy.Namely,itworksonthefollowingplatforms
currently.
Linux
Win32(Windows95,98,Me,NT,2000,XP)
Cygwin
djgpp
FreeBSD
NetBSD
OpenBSD
![](https://csdnimg.cn/release/download_crawler_static/11941047/bg12.jpg)
BSD/OS
MacOSX
Solaris
Tru64UNIX
HP-UX
AIX
VMS
UX/4800
BeOS
OS/2(emx)
Psion
IheardthatthemainmachineoftheauthorMatsumotoisLinux.
ThuswhenusingLinux,youwillnotfailtocompileanytime.
Furthermore,youcanexpectastablefunctionalityona(typical)
Unixenvironment.Consideringthereleasecycleofpackages,the
primaryoptionfortheenvironmenttohitaroundrubyshouldfall
onabranchofPCUNIX,currently.
Ontheotherhand,theWin32environmenttendstocause
problemsdefinitely.ThelargegapsinthetargetingOSmodeltend
tocauseproblemsaroundthemachinestackandthelinker.Yet,
recentlyWindowshackershavecontributedtomakebetter
support.IuseanativerubyonWindows2000andMe.Onceitgets
successfullyrun,itdoesn’tseemtoshowspecialconcernslike
frequentcrashing.ThemainproblemsonWindowsmaybethe
gapsinthespecifications.
![](https://csdnimg.cn/release/download_crawler_static/11941047/bg13.jpg)
AnothertypeofOSthatmanypeoplemaybeinterestedinshould
probablybeMacOS(priortov9)andhandheldOSlikePalm.
Aroundruby1.2andbefore,itsupportedlegacyMacOS,butthe
developmentseemstobeinsuspension.Evenacompilingcan’tget
through.Thebiggestcauseisthatthecompilerenvironmentof
legacyMacOSandthedecreaseofdevelopers.TalkingaboutMac
OSX,there’snoworriesbecausethebodyisUNIX.
ThereseemtobediscussionstheportabilitytoPalmseveral
branches,butIhaveneverheardofasuccessfulproject.Iguessthe
difficultyliesinthenecessityofsettlingdownthespecification-
levelstandardssuchasstdioonthePalmplatform,ratherthanthe
processesofactualimplementation.WellIsawaportingtoPsion
hasbeendone.([ruby-list:36028]).
HowabouthotstoriesaboutVMseeninJavaand.NET?Because
I’dliketotalkaboutthemcombiningtogetherwiththe
implementation,thistopicwillbeinthefinalchapter.
Automaticmemorycontrol
Functionallyit’scalledGC,orGarbageCollection.SayingitinC-
language,thisfeatureallowsyoutoskipfree()aftermalloc().
Unusedmemoryisdetectedbythesystemautomatically,andwill
bereleased.It’ssoconvenientthatonceyougetusedtoGCyou
won’tbewillingtodosuchmanualmemorycontrolagain.
ThetopicsaboutGChavebeencommonbecauseofitspopularity
![](https://csdnimg.cn/release/download_crawler_static/11941047/bg14.jpg)
inrecentlanguageswithGCasastandardset,anditisfunthatits
algorithmscanstillbeimprovedfurther.
Typelessvariables
ThevariablesinRubydon’thavetypes.Thereasonisprobably
typelessvariablesconformsmorewithpolymorphism,whichisone
ofthestrongestadvantagesofanobject-orientedlanguage.Of
coursealanguagewithvariabletypehasawaytodealwith
polymorphism.WhatImeanhereisatypelessvariableshave
betterconformance.
Thelevelof“betterconformance”inthiscasereferstosynonyms
like“handy”.It’ssometimescorrespondstocrucialimportance,
sometimesitdoesn’tmatterpractically.Yet,thisiscertainlyan
appealingpointifalanguageseeksfor“handyandeasy”,andRuby
does.
Mostofsyntacticelementsare
expressions
Thistopicisprobablydifficulttounderstandinstantlywithouta
littlesupplementalexplanation.Forexample,thefollowingC-
languageprogramresultsinasyntacticerror.
result=if(cond){process(val);}else{0;}
BecausetheC-languagesyntaxdefinesifasastatement.Butyou
剩余884页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_38744153
- 粉丝: 346
- 资源: 2万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 多模态联合稀疏表示在视频目标跟踪中的应用
- Kubernetes资源管控与Gardener开源软件实践解析
- MPI集群监控与负载平衡策略
- 自动化PHP安全漏洞检测:静态代码分析与数据流方法
- 青苔数据CEO程永:技术生态与阿里云开放创新
- 制造业转型: HyperX引领企业上云策略
- 赵维五分享:航空工业电子采购上云实战与运维策略
- 单片机控制的LED点阵显示屏设计及其实现
- 驻云科技李俊涛:AI驱动的云上服务新趋势与挑战
- 6LoWPAN物联网边界路由器:设计与实现
- 猩便利工程师仲小玉:Terraform云资源管理最佳实践与团队协作
- 类差分度改进的互信息特征选择提升文本分类性能
- VERITAS与阿里云合作的混合云转型与数据保护方案
- 云制造中的生产线仿真模型设计与虚拟化研究
- 汪洋在PostgresChina2018分享:高可用 PostgreSQL 工具与架构设计
- 2018 PostgresChina大会:阿里云时空引擎Ganos在PostgreSQL中的创新应用与多模型存储
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)